@toclocoinc/lattice-grid 1.86.4 → 1.86.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -1
  3. package/angular/package.json +1 -1
  4. package/docs/API.html +4 -4
  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/gantt.html +1 -1
  14. package/docs/api/geometry.html +1 -1
  15. package/docs/api/grid.html +2 -2
  16. package/docs/api/index.html +1 -1
  17. package/docs/api/kanban.html +1 -1
  18. package/docs/api/kpi.html +1 -1
  19. package/docs/api/layout.html +1 -1
  20. package/docs/api/leaflet.html +1 -1
  21. package/docs/api/list.html +1 -1
  22. package/docs/api/mapview.html +1 -1
  23. package/docs/api/mock-socket.html +1 -1
  24. package/docs/api/presets.html +1 -1
  25. package/docs/api/tabs.html +1 -1
  26. package/docs/api/types.html +1 -1
  27. package/docs/api-detail.html +4 -4
  28. package/docs/warnings.json +1 -1
  29. package/lattice-grid.d.ts +1 -1
  30. package/lattice-grid.esm.min.js +3 -3
  31. package/lattice-grid.min.cjs +3 -3
  32. package/lattice-grid.min.css +1 -1
  33. package/lattice-grid.min.js +3 -3
  34. package/modules/ai.d.ts +1 -1
  35. package/modules/ai.esm.min.js +2 -2
  36. package/modules/ai.min.cjs +2 -2
  37. package/modules/ai.min.js +2 -2
  38. package/modules/alarms.d.ts +1 -1
  39. package/modules/alarms.esm.min.js +2 -2
  40. package/modules/alarms.min.cjs +2 -2
  41. package/modules/alarms.min.js +2 -2
  42. package/modules/angular.d.ts +1 -1
  43. package/modules/angular.esm.min.js +2 -2
  44. package/modules/angular.min.cjs +2 -2
  45. package/modules/angular.min.js +2 -2
  46. package/modules/calendar.d.ts +1 -1
  47. package/modules/calendar.esm.min.js +2 -2
  48. package/modules/calendar.min.cjs +2 -2
  49. package/modules/calendar.min.js +2 -2
  50. package/modules/chart-alluvial.d.ts +1 -1
  51. package/modules/chart-alluvial.esm.min.js +1 -1
  52. package/modules/chart-alluvial.min.cjs +1 -1
  53. package/modules/chart-alluvial.min.js +1 -1
  54. package/modules/chart-arc.d.ts +1 -1
  55. package/modules/chart-arc.esm.min.js +1 -1
  56. package/modules/chart-arc.min.cjs +1 -1
  57. package/modules/chart-arc.min.js +1 -1
  58. package/modules/chart-barrace.d.ts +1 -1
  59. package/modules/chart-barrace.esm.min.js +1 -1
  60. package/modules/chart-barrace.min.cjs +1 -1
  61. package/modules/chart-barrace.min.js +1 -1
  62. package/modules/chart-bubblemap.d.ts +1 -1
  63. package/modules/chart-bubblemap.esm.min.js +1 -1
  64. package/modules/chart-bubblemap.min.cjs +1 -1
  65. package/modules/chart-bubblemap.min.js +1 -1
  66. package/modules/chart-bump.d.ts +1 -1
  67. package/modules/chart-bump.esm.min.js +1 -1
  68. package/modules/chart-bump.min.cjs +1 -1
  69. package/modules/chart-bump.min.js +1 -1
  70. package/modules/chart-calendar.d.ts +1 -1
  71. package/modules/chart-calendar.esm.min.js +1 -1
  72. package/modules/chart-calendar.min.cjs +1 -1
  73. package/modules/chart-calendar.min.js +1 -1
  74. package/modules/chart-choropleth.d.ts +1 -1
  75. package/modules/chart-choropleth.esm.min.js +1 -1
  76. package/modules/chart-choropleth.min.cjs +1 -1
  77. package/modules/chart-choropleth.min.js +1 -1
  78. package/modules/chart-decomposition.d.ts +1 -1
  79. package/modules/chart-decomposition.esm.min.js +1 -1
  80. package/modules/chart-decomposition.min.cjs +1 -1
  81. package/modules/chart-decomposition.min.js +1 -1
  82. package/modules/chart-diverging.d.ts +1 -1
  83. package/modules/chart-diverging.esm.min.js +1 -1
  84. package/modules/chart-diverging.min.cjs +1 -1
  85. package/modules/chart-diverging.min.js +1 -1
  86. package/modules/chart-dumbbell.d.ts +1 -1
  87. package/modules/chart-dumbbell.esm.min.js +1 -1
  88. package/modules/chart-dumbbell.min.cjs +1 -1
  89. package/modules/chart-dumbbell.min.js +1 -1
  90. package/modules/chart-fan.d.ts +1 -1
  91. package/modules/chart-fan.esm.min.js +1 -1
  92. package/modules/chart-fan.min.cjs +1 -1
  93. package/modules/chart-fan.min.js +1 -1
  94. package/modules/chart-forcetree.d.ts +1 -1
  95. package/modules/chart-forcetree.esm.min.js +2 -2
  96. package/modules/chart-forcetree.esm.min.js.map +2 -2
  97. package/modules/chart-forcetree.min.cjs +2 -2
  98. package/modules/chart-forcetree.min.js +2 -2
  99. package/modules/chart-forcetree.min.js.map +2 -2
  100. package/modules/chart-hexbin.d.ts +1 -1
  101. package/modules/chart-hexbin.esm.min.js +2 -2
  102. package/modules/chart-hexbin.esm.min.js.map +1 -1
  103. package/modules/chart-hexbin.min.cjs +2 -2
  104. package/modules/chart-hexbin.min.js +2 -2
  105. package/modules/chart-hexbin.min.js.map +1 -1
  106. package/modules/chart-hexmap.d.ts +1 -1
  107. package/modules/chart-hexmap.esm.min.js +1 -1
  108. package/modules/chart-hexmap.min.cjs +1 -1
  109. package/modules/chart-hexmap.min.js +1 -1
  110. package/modules/chart-icicle.d.ts +1 -1
  111. package/modules/chart-icicle.esm.min.js +1 -1
  112. package/modules/chart-icicle.min.cjs +1 -1
  113. package/modules/chart-icicle.min.js +1 -1
  114. package/modules/chart-markermap.d.ts +1 -1
  115. package/modules/chart-markermap.esm.min.js +1 -1
  116. package/modules/chart-markermap.min.cjs +1 -1
  117. package/modules/chart-markermap.min.js +1 -1
  118. package/modules/chart-motion.d.ts +1 -1
  119. package/modules/chart-motion.esm.min.js +1 -1
  120. package/modules/chart-motion.min.cjs +1 -1
  121. package/modules/chart-motion.min.js +1 -1
  122. package/modules/chart-pack.d.ts +1 -1
  123. package/modules/chart-pack.esm.min.js +1 -1
  124. package/modules/chart-pack.min.cjs +1 -1
  125. package/modules/chart-pack.min.js +1 -1
  126. package/modules/chart-parallel.d.ts +1 -1
  127. package/modules/chart-parallel.esm.min.js +1 -1
  128. package/modules/chart-parallel.min.cjs +1 -1
  129. package/modules/chart-parallel.min.js +1 -1
  130. package/modules/chart-pictorial.d.ts +1 -1
  131. package/modules/chart-pictorial.esm.min.js +1 -1
  132. package/modules/chart-pictorial.min.cjs +1 -1
  133. package/modules/chart-pictorial.min.js +1 -1
  134. package/modules/chart-polararea.d.ts +1 -1
  135. package/modules/chart-polararea.esm.min.js +1 -1
  136. package/modules/chart-polararea.min.cjs +1 -1
  137. package/modules/chart-polararea.min.js +1 -1
  138. package/modules/chart-polarscatter.d.ts +1 -1
  139. package/modules/chart-polarscatter.esm.min.js +1 -1
  140. package/modules/chart-polarscatter.min.cjs +1 -1
  141. package/modules/chart-polarscatter.min.js +1 -1
  142. package/modules/chart-pyramid.d.ts +1 -1
  143. package/modules/chart-pyramid.esm.min.js +1 -1
  144. package/modules/chart-pyramid.min.cjs +1 -1
  145. package/modules/chart-pyramid.min.js +1 -1
  146. package/modules/chart-radialbar.d.ts +1 -1
  147. package/modules/chart-radialbar.esm.min.js +1 -1
  148. package/modules/chart-radialbar.min.cjs +1 -1
  149. package/modules/chart-radialbar.min.js +1 -1
  150. package/modules/chart-ridgeline.d.ts +1 -1
  151. package/modules/chart-ridgeline.esm.min.js +1 -1
  152. package/modules/chart-ridgeline.min.cjs +1 -1
  153. package/modules/chart-ridgeline.min.js +1 -1
  154. package/modules/chart-roc.d.ts +1 -1
  155. package/modules/chart-roc.esm.min.js +1 -1
  156. package/modules/chart-roc.min.cjs +1 -1
  157. package/modules/chart-roc.min.js +1 -1
  158. package/modules/chart-serpentine.d.ts +1 -1
  159. package/modules/chart-serpentine.esm.min.js +1 -1
  160. package/modules/chart-serpentine.min.cjs +1 -1
  161. package/modules/chart-serpentine.min.js +1 -1
  162. package/modules/chart-slope.d.ts +1 -1
  163. package/modules/chart-slope.esm.min.js +1 -1
  164. package/modules/chart-slope.min.cjs +1 -1
  165. package/modules/chart-slope.min.js +1 -1
  166. package/modules/chart-spiral.d.ts +1 -1
  167. package/modules/chart-spiral.esm.min.js +1 -1
  168. package/modules/chart-spiral.min.cjs +1 -1
  169. package/modules/chart-spiral.min.js +1 -1
  170. package/modules/chart-splom.d.ts +1 -1
  171. package/modules/chart-splom.esm.min.js +1 -1
  172. package/modules/chart-splom.min.cjs +1 -1
  173. package/modules/chart-splom.min.js +1 -1
  174. package/modules/chart-tree.d.ts +1 -1
  175. package/modules/chart-tree.esm.min.js +2 -2
  176. package/modules/chart-tree.esm.min.js.map +2 -2
  177. package/modules/chart-tree.min.cjs +2 -2
  178. package/modules/chart-tree.min.js +2 -2
  179. package/modules/chart-tree.min.js.map +2 -2
  180. package/modules/chart-venn.d.ts +1 -1
  181. package/modules/chart-venn.esm.min.js +1 -1
  182. package/modules/chart-venn.min.cjs +1 -1
  183. package/modules/chart-venn.min.js +1 -1
  184. package/modules/chart-voronoi.d.ts +1 -1
  185. package/modules/chart-voronoi.esm.min.js +1 -1
  186. package/modules/chart-voronoi.min.cjs +1 -1
  187. package/modules/chart-voronoi.min.js +1 -1
  188. package/modules/chart-waffle.d.ts +1 -1
  189. package/modules/chart-waffle.esm.min.js +1 -1
  190. package/modules/chart-waffle.min.cjs +1 -1
  191. package/modules/chart-waffle.min.js +1 -1
  192. package/modules/chart-wordcloud.d.ts +1 -1
  193. package/modules/chart-wordcloud.esm.min.js +1 -1
  194. package/modules/chart-wordcloud.min.cjs +1 -1
  195. package/modules/chart-wordcloud.min.js +1 -1
  196. package/modules/charts.d.ts +1 -1
  197. package/modules/charts.esm.min.js +235 -235
  198. package/modules/charts.esm.min.js.map +2 -2
  199. package/modules/charts.min.cjs +235 -235
  200. package/modules/charts.min.js +235 -235
  201. package/modules/charts.min.js.map +2 -2
  202. package/modules/dashboard.d.ts +1 -1
  203. package/modules/dashboard.esm.min.js +2 -2
  204. package/modules/dashboard.min.cjs +2 -2
  205. package/modules/dashboard.min.js +2 -2
  206. package/modules/data-router.d.ts +1 -1
  207. package/modules/data-router.esm.min.js +2 -2
  208. package/modules/data-router.min.cjs +2 -2
  209. package/modules/data-router.min.js +2 -2
  210. package/modules/deckgl.d.ts +1 -1
  211. package/modules/deckgl.esm.min.js +2 -2
  212. package/modules/deckgl.min.cjs +2 -2
  213. package/modules/deckgl.min.js +2 -2
  214. package/modules/devtools.d.ts +1 -1
  215. package/modules/devtools.esm.min.js +1 -1
  216. package/modules/devtools.min.cjs +1 -1
  217. package/modules/devtools.min.js +1 -1
  218. package/modules/dhtmlx-compat.d.ts +1 -1
  219. package/modules/dhtmlx-compat.esm.min.js +2 -2
  220. package/modules/dhtmlx-compat.min.cjs +2 -2
  221. package/modules/dhtmlx-compat.min.js +2 -2
  222. package/modules/gantt.d.ts +1 -1
  223. package/modules/gantt.esm.min.js +2 -2
  224. package/modules/gantt.min.cjs +2 -2
  225. package/modules/gantt.min.js +2 -2
  226. package/modules/geo-europe-nuts.d.ts +1 -1
  227. package/modules/geo-europe-nuts.esm.min.js +1 -1
  228. package/modules/geo-europe-nuts.min.cjs +1 -1
  229. package/modules/geo-europe-nuts.min.js +1 -1
  230. package/modules/geo-uk.d.ts +1 -1
  231. package/modules/geo-uk.esm.min.js +1 -1
  232. package/modules/geo-uk.min.cjs +1 -1
  233. package/modules/geo-uk.min.js +1 -1
  234. package/modules/geo-us-states.d.ts +1 -1
  235. package/modules/geo-us-states.esm.min.js +1 -1
  236. package/modules/geo-us-states.min.cjs +1 -1
  237. package/modules/geo-us-states.min.js +1 -1
  238. package/modules/geo-world-110m.d.ts +1 -1
  239. package/modules/geo-world-110m.esm.min.js +1 -1
  240. package/modules/geo-world-110m.min.cjs +1 -1
  241. package/modules/geo-world-110m.min.js +1 -1
  242. package/modules/geo-world-50m.d.ts +1 -1
  243. package/modules/geo-world-50m.esm.min.js +1 -1
  244. package/modules/geo-world-50m.min.cjs +1 -1
  245. package/modules/geo-world-50m.min.js +1 -1
  246. package/modules/geometry.d.ts +1 -1
  247. package/modules/geometry.esm.min.js +2 -2
  248. package/modules/geometry.min.cjs +2 -2
  249. package/modules/geometry.min.js +2 -2
  250. package/modules/htmx.d.ts +1 -1
  251. package/modules/htmx.esm.min.js +3 -3
  252. package/modules/htmx.min.cjs +3 -3
  253. package/modules/htmx.min.js +3 -3
  254. package/modules/kanban.d.ts +1 -1
  255. package/modules/kanban.esm.min.js +2 -2
  256. package/modules/kanban.min.cjs +2 -2
  257. package/modules/kanban.min.js +2 -2
  258. package/modules/kpi.d.ts +1 -1
  259. package/modules/kpi.esm.min.js +2 -2
  260. package/modules/kpi.min.cjs +2 -2
  261. package/modules/kpi.min.js +2 -2
  262. package/modules/layout.d.ts +1 -1
  263. package/modules/layout.esm.min.js +2 -2
  264. package/modules/layout.min.cjs +2 -2
  265. package/modules/layout.min.js +2 -2
  266. package/modules/leaflet.d.ts +1 -1
  267. package/modules/leaflet.esm.min.js +2 -2
  268. package/modules/leaflet.min.cjs +2 -2
  269. package/modules/leaflet.min.js +2 -2
  270. package/modules/list.d.ts +1 -1
  271. package/modules/list.esm.min.js +2 -2
  272. package/modules/list.min.cjs +2 -2
  273. package/modules/list.min.js +2 -2
  274. package/modules/mapview.d.ts +1 -1
  275. package/modules/mapview.esm.min.js +2 -2
  276. package/modules/mapview.min.cjs +2 -2
  277. package/modules/mapview.min.js +2 -2
  278. package/modules/mock-socket.d.ts +1 -1
  279. package/modules/mock-socket.esm.min.js +1 -1
  280. package/modules/mock-socket.min.cjs +1 -1
  281. package/modules/mock-socket.min.js +1 -1
  282. package/modules/presets.d.ts +1 -1
  283. package/modules/presets.esm.min.js +2 -2
  284. package/modules/presets.min.cjs +2 -2
  285. package/modules/presets.min.js +2 -2
  286. package/modules/react.d.ts +1 -1
  287. package/modules/react.esm.min.js +2 -2
  288. package/modules/react.min.cjs +2 -2
  289. package/modules/react.min.js +2 -2
  290. package/modules/svelte.d.ts +1 -1
  291. package/modules/svelte.esm.min.js +2 -2
  292. package/modules/svelte.min.cjs +2 -2
  293. package/modules/svelte.min.js +2 -2
  294. package/modules/tabs.d.ts +1 -1
  295. package/modules/tabs.esm.min.js +2 -2
  296. package/modules/tabs.min.cjs +2 -2
  297. package/modules/tabs.min.js +2 -2
  298. package/modules/vue.d.ts +1 -1
  299. package/modules/vue.esm.min.js +2 -2
  300. package/modules/vue.min.cjs +2 -2
  301. package/modules/vue.min.js +2 -2
  302. package/modules/webcomponent.d.ts +1 -1
  303. package/modules/webcomponent.esm.min.js +3 -3
  304. package/modules/webcomponent.min.cjs +3 -3
  305. package/modules/webcomponent.min.js +3 -3
  306. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Lattice Grid 1.86.4, webcomponent module
2
+ * Lattice Grid 1.86.5, webcomponent module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- var dr=Object.create(null),fr=Object.create(null);function Fe(e,K){dr[e]=K}function Kn(e){var K=fr[e];if(K)return K;var Q=Object.create(null);fr[e]=Q;var $=dr[e];if(!$)throw new Error("[lattice] missing module: "+e);return $(Q,Kn),Q}Fe("packages/core/src/internal/util.js",function(e,K){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return ne}});const Q="1.86.4";async function $(){return Q}const B="1.86.4",I=new Set,_=2e3;function X(oe){if(I.add(oe),I.size>_){const le=I.values().next().value;le!==void 0&&I.delete(le)}}const W=[],H=500;function U(oe,le,ae){W.push({key:oe,level:le,message:ae.map(se=>typeof se=="string"?se:z(se)).join(" "),at:Date.now()}),W.length>H&&W.shift()}function z(oe){if(oe instanceof Error)return oe.message;try{return JSON.stringify(oe)}catch{return String(oe)}}function w(){return W.map(oe=>({...oe}))}function k(oe){if(oe.length===0||typeof oe[0]!="string")return oe;const le=oe[0].replace(/^\[lattice\]\s*/,"");return le===oe[0]?oe:[le,...oe.slice(1)]}function g(oe,...le){if(I.has(oe))return;X(oe);const ae=k(le);U(oe,"warn",ae),console.warn("[lattice]",...ae)}function l(oe,...le){if(I.has(oe))return;X(oe);const ae=k(le);U(oe,"info",ae),console.info("[lattice]",...ae)}function c(){I.clear(),W.length=0}function s(oe,le){const ae=new Error(`[lattice] ${oe}`);throw le!==void 0&&(ae.cause=le),ae}function n(oe,le){oe||s(le)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(oe){return oe!==null&&typeof oe=="object"&&!Array.isArray(oe)}function o(oe){return typeof oe=="function"}function f(oe){return oe==null}function u(oe){return oe==null||oe===""}function i(oe){return typeof oe!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(oe))?!0:!!(oe.prototype&&Object.getOwnPropertyNames(oe.prototype).length>1)}const m=new Map;function d(oe){let le=m.get(oe);if(le)return le;if(!oe.includes("."))le=ae=>ae?.[oe];else{const ae=oe.split("."),se=ae.length;le=ee=>{let ie=ee;for(let ce=0;ce<se;ce++){if(ie==null)return;ie=ie[ae[ce]]}return ie}}return m.set(oe,le),le}const h=new Map;function a(oe){let le=h.get(oe);if(le)return le;if(!oe.includes("."))le=(ae,se)=>{ae!=null&&(ae[oe]=se)};else{const ae=oe.split("."),se=ae.length-1;le=(ee,ie)=>{let ce=ee;for(let he=0;he<se;he++){if(ce==null)return;const me=ae[he];ce[me]==null&&(ce[me]={}),ce=ce[me]}ce!=null&&(ce[ae[se]]=ie)}}return h.set(oe,le),le}function p(oe,le){return d(le)(oe)}function b(oe,le,ae){a(le)(oe,ae)}function j(oe){return oe?(oe.includes(".")?oe.slice(oe.lastIndexOf(".")+1):oe).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(/^./,ae=>ae.toUpperCase()):""}const S={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function y(oe){const le=oe==null?"":String(oe);return/[&<>"']/.test(le)?le.replace(/[&<>"']/g,ae=>S[ae]):le}function v(oe){return String(oe).replace(/\w\S*/g,le=>le[0].toUpperCase()+le.slice(1).toLowerCase())}function R(oe,le,ae){if(oe!==void 0)return oe===!0?{enabled:!0,...ae}:oe===!1?{enabled:!1}:r(oe)?oe:{[le]:oe,enabled:!0}}function O(oe){return oe==null?[]:Array.isArray(oe)?oe:[oe]}const x=Object.freeze(new Set(["__proto__","constructor","prototype"]));function C(oe,le){if(!r(oe))return r(le)?{...le}:le;if(!r(le))return le===void 0?oe:le;const ae={...oe};for(const se of Object.keys(le)){if(x.has(se))continue;const ee=le[se];ee!==void 0&&(ae[se]=r(ee)&&r(ae[se])?C(ae[se],ee):ee)}return ae}function P(oe,le){if(!r(oe)||!r(le)||oe===le)return le;const ae=Object.create(Object.getPrototypeOf(oe));return Object.assign(ae,oe,le),ae}class F{#e;#t=new Map;#n;constructor(le=256,ae=null){this.#e=le,this.#n=ae}get size(){return this.#t.size}get max(){return this.#e}set max(le){this.#e=le,this.#r()}has(le){return this.#t.has(le)}get(le){const ae=this.#t;if(!ae.has(le))return;const se=ae.get(le);return ae.delete(le),ae.set(le,se),se}peek(le){return this.#t.get(le)}set(le,ae){const se=this.#t;return se.has(le)&&se.delete(le),se.set(le,ae),this.#r(),ae}delete(le){const ae=this.#t.get(le);return this.#t.delete(le)&&this.#n&&this.#n(ae,le),ae}clear(){if(this.#n)for(const[le,ae]of this.#t)this.#n(ae,le);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const le=this.#t;for(;le.size>this.#e;){const ae=le.keys().next().value,se=le.get(ae);le.delete(ae),this.#n&&this.#n(se,ae)}}}const E=new Map;function D(oe,le){const ae=`${oe||""}|${le?JSON.stringify(le):""}`;let se=E.get(ae);return se||(se=new Intl.Collator(oe||void 0,{numeric:!0,sensitivity:"variant",...le}),E.set(ae,se)),se}function N(oe,le){if(oe===le)return 0;if(oe==null)return 1;if(le==null)return-1;if(typeof oe=="number"&&typeof le=="number")return Number.isNaN(oe)?Number.isNaN(le)?0:1:Number.isNaN(le)||oe<le?-1:oe>le?1:0;const ae=String(oe),se=String(le);return ae<se?-1:ae>se?1:0}function M(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const A=typeof requestAnimationFrame=="function";function L(oe){return A?requestAnimationFrame(oe):setTimeout(()=>oe(M()),16)}function G(oe){oe!=null&&(A?cancelAnimationFrame(oe):clearTimeout(oe))}function q(oe){let le=null,ae=null;const se=()=>{le=null;const ie=ae;ae=null,oe(...ie||[])},ee=(...ie)=>{ae=ie,le===null&&(le=L(se))};return ee.cancel=()=>{G(le),le=null,ae=null},ee.flush=()=>{le!==null&&(G(le),se())},ee}function Y(oe,le){let ae=null,se=null;const ee=()=>{if(ae=null,se===null)return;const he=se;se=null,oe(...he),ie()},ie=()=>{ae=setTimeout(ee,le),typeof ae?.unref=="function"&&ae.unref()},ce=(...he)=>{ae===null?(oe(...he),ie()):(se=he,clearTimeout(ae),ie())};return ce.flush=()=>{if(ae!==null&&clearTimeout(ae),ae=null,se===null)return;const he=se;se=null,oe(...he)},ce.cancel=()=>{ae!==null&&clearTimeout(ae),ae=null,se=null},ce.pending=()=>ae!==null||se!==null,ce}function J(oe,le=50){return typeof requestIdleCallback=="function"?requestIdleCallback(oe,{timeout:le}):setTimeout(()=>oe({timeRemaining:()=>0,didTimeout:!0}),1)}let te=0;function ne(oe="l"){return`${oe}${(++te).toString(36)}`}}),Fe("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return v}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),_=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=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 W(R,O){const x=Number(R),C=Number(O);if(R!==null&&R!==""&&O!==null&&O!==""&&Number.isFinite(x)&&Number.isFinite(C))return x<C?-1:x>C?1:0;const F=String(R??"").toLowerCase(),E=String(O??"").toLowerCase();return F<E?-1:F>E?1:0}function H(R){return R==null||R===""}function U(R,O){if(!O||typeof O!="object")return!1;const{op:x}=O,C=O.value,P=O.value2;switch(x){case"blank":return H(R);case"notBlank":return!H(R);case"true":return R===!0;case"false":return R===!1;default:break}if(H(R))return!1;switch(x){case"eq":return W(R,C)===0;case"ne":return W(R,C)!==0;case"gt":return W(R,C)>0;case"gte":return W(R,C)>=0;case"lt":return W(R,C)<0;case"lte":return W(R,C)<=0;case"between":return W(R,C)>=0&&W(R,P)<=0;case"outside":return W(R,C)<0||W(R,P)>0;case"contains":return String(R).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(R).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(R).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(R).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function z(R,O,x){const C=G=>{const q=String(G).replace("#",""),Y=q.length===3?q.split("").map(J=>J+J).join(""):q;return[0,2,4].map(J=>parseInt(Y.slice(J,J+2),16)||0)},[P,F,E]=C(R),[D,N,M]=C(O),A=Math.max(0,Math.min(1,x)),L=(G,q)=>Math.round(G+(q-G)*A);return`#${[L(P,D),L(F,N),L(E,M)].map(G=>G.toString(16).padStart(2,"0")).join("")}`}function w(R){const O=[];for(const D of R||[]){if(D==null||D==="")continue;const N=D instanceof Date?D.getTime():Number(D);Number.isFinite(N)&&O.push(N)}if(!O.length)return null;O.sort((D,N)=>D-N);let x=0,C=0,P=0;for(const D of O){x++;const N=D-C;C+=N/x,P+=N*(D-C)}const F=k(O,.25),E=k(O,.75);return{n:O.length,min:O[0],max:O[O.length-1],mean:C,stddev:O.length>1?Math.sqrt(P/(O.length-1)):0,median:k(O,.5),q1:F,q3:E,iqr:E-F,sorted:O}}function k(R,O){if(!R.length)return 0;const x=(R.length-1)*Math.max(0,Math.min(1,O)),C=Math.floor(x),P=Math.ceil(x);return C===P?R[C]:R[C]+(x-C)*(R[P]-R[C])}function g(R){for(const O of Array.isArray(R)?R:[])if(!(!O||typeof O!="object")&&(O.when&&_.includes(O.when.op)||O.scale&&O.scale.from||O.dataBar&&!(Number.isFinite(Number(O.dataBar.min))&&Number.isFinite(Number(O.dataBar.max)))||O.iconSet&&!Array.isArray(O.iconSet.thresholds)))return!0;return!1}function l(R,O){const x=Number(R.value),C=P=>k(O.sorted,P);switch(R.op){case"topPercent":{const P=c(x,10);return{op:"gte",value:C(1-P)}}case"bottomPercent":{const P=c(x,10);return{op:"lte",value:C(P)}}case"topN":{const P=Math.max(1,Math.floor(x)||1),F=Math.max(0,O.sorted.length-P);return{op:"gte",value:O.sorted[F]}}case"bottomN":{const P=Math.max(1,Math.floor(x)||1),F=Math.min(O.sorted.length-1,P-1);return{op:"lte",value:O.sorted[F]}}case"aboveMean":return{op:"gt",value:O.mean};case"belowMean":return{op:"lt",value:O.mean};case"aboveMedian":return{op:"gt",value:O.median};case"belowMedian":return{op:"lt",value:O.median};case"zAbove":return O.stddev?{op:"gte",value:O.mean+(Number.isFinite(x)?x:2)*O.stddev}:null;case"zBelow":return O.stddev?{op:"lte",value:O.mean-(Number.isFinite(x)?x:2)*O.stddev}:null;case"outlier":{const P=(Number.isFinite(x)&&x>0?x:1.5)*O.iqr;return O.iqr?{op:"outside",value:O.q1-P,value2:O.q3+P}:null}default:return null}}function c(R,O){const x=Number.isFinite(R)?R:O,C=x>1?x/100:x;return Math.max(0,Math.min(1,C))}function s(R,O){if(R.from==="minmax")return{...R,min:O.min,max:O.max};if(R.from==="quantile")return{...R,min:k(O.sorted,c(Number(R.low),5)),max:k(O.sorted,c(Number(R.high),95))};if(R.from==="stddev"){const x=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:O.mean-x*O.stddev,max:O.mean+x*O.stddev}}return R}function n(R,O){const x=Array.isArray(R)?R:[];return!O||!O.n?x.map(C=>C&&g([C])?{...C,enabled:!1}:C):x.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:s(C.scale,O)};if(C.dataBar)return{...C,dataBar:t(C.dataBar,O)};if(C.iconSet)return{...C,iconSet:r(C.iconSet,O)};if(!C.when||!_.includes(C.when.op))return C;const P=l(C.when,O);return P?{...C,when:P}:{...C,enabled:!1}})}function t(R,O){const x=Number.isFinite(Number(R.min))?Number(R.min):void 0,C=Number.isFinite(Number(R.max))?Number(R.max):void 0;if(x!==void 0&&C!==void 0)return{...R,min:x,max:C};if(R.from==="quantile")return{...R,min:x??k(O.sorted,c(Number(R.low),5)),max:C??k(O.sorted,c(Number(R.high),95))};if(R.from==="stddev"){const P=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:x??O.mean-P*O.stddev,max:C??O.mean+P*O.stddev}}return{...R,min:x??O.min,max:C??O.max}}function r(R,O){if(Array.isArray(R.thresholds))return R;const x=o(R),C=[];for(let P=1;P<x;P++)C.push(k(O.sorted,P/x));return{...R,thresholds:C}}function o(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.length;if(Number.isFinite(Number(R.count))&&Number(R.count)>=2)return Math.floor(Number(R.count));const O=a[R.set];return O?O.length:3}function f(R){return`url("data:image/svg+xml,${encodeURIComponent(R)}")`}function u(R){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${R}"/></svg>`}function i(R,O){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${O==="up"?"8,2 14,13 2,13":O==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${R}"/></svg>`}function m(R,O){const x="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 C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${O*16} 16">`;for(let P=0;P<O;P++){const F=P<R?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${P*16},0)" d="${x}" fill="${F}"/>`}return`${C}</svg>`}const d=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),h=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),a=Object.freeze({arrows:d,trafficLights:h,ratings:Object.freeze([1,2,3,4,5].map(R=>m(R,5)))}),p=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function b(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?f(String(C)):String(C));const O=R.set||"arrows";if(O==="ratings"){const C=o(R),P=[];for(let F=1;F<=C;F++)P.push(f(m(F,C)));return P}const x=a[O];return x?x.map(f):(B(`iconSet:${O}`,`unknown icon set '${O}'; falling back to arrows.`),d.map(f))}function j(R){const O=Number(R.min),C=Number(R.max)-O,P=R.colour||R.color||"#5b9bd5",F=R.negativeColour||R.negativeColor||"#d13438",E=R.direction==="rtl"?"left":"right",D=M=>Math.max(0,Math.min(1,(M-O)/C))*100,N=C?Math.max(0,Math.min(100,(0-O)/C*100)):0;return M=>{if(H(M))return null;const A=Number(M);if(!Number.isFinite(A)||!C)return null;const L=D(A),G=Math.min(L,N),q=Math.max(L,N),Y=A>=0?P:F;return{backgroundImage:`linear-gradient(to ${E}, transparent ${G}%, ${Y} ${G}%, ${Y} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function S(R){const O=b(R),x=R.reverse?[...O].reverse():O,C=(Array.isArray(R.thresholds)?R.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(R.size))?Number(R.size):16,F=R.set==="ratings"?P*o(R):P;return E=>{if(H(E))return null;const D=Number(E);if(!Number.isFinite(D))return null;let N=0;for(const A of C)D>=A&&N++;const M=x[Math.min(N,x.length-1)];return M?{backgroundImage:M,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${F}px ${P}px`,paddingLeft:`${F+4}px`}:null}}function y(R){const O=Array.isArray(R.colours)&&R.colours.length>=2?R.colours:["#f8f9fa","#1a6bc7"],x=Number(R.min),C=Number(R.max),P=C-x,F=O.length-1,E=[];for(let N=0;N<=F;N++)E.push(F?N/F:0);const D=Number(R.mid);if(R.mid!==void 0&&R.mid!==null)if(O.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${O.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&P&&D>Math.min(x,C)&&D<Math.max(x,C)){const N=F/2,M=Math.max(0,Math.min(1,(D-x)/P));for(let A=0;A<=F;A++)E[A]=A<=N?N?A/N*M:M:M+(A-N)/(F-N)*(1-M)}else Number.isFinite(D)&&B("formatting.scale.mid.range",`a scale's "mid" (${D}) is outside its min..max range, so it was ignored.`);return N=>{const M=Number(N);if(!Number.isFinite(M)||!P)return null;const A=Math.max(0,Math.min(1,(M-x)/P));let L=0;for(;L<F-1&&A>E[L+1];)L++;const G=E[L+1]-E[L],q=G>0?(A-E[L])/G:0;return{background:z(O[L],O[L+1],Math.max(0,Math.min(1,q)))}}}function v(R,O=null){const x=g(R)?n(R,O):R,C=(Array.isArray(x)?x:[]).filter(F=>F&&typeof F=="object");if(!C.length)return()=>null;const P=C.map(F=>F.scale?{scale:y(F.scale),enabled:F.enabled!==!1}:F.dataBar?{scale:j(F.dataBar),enabled:F.enabled!==!1}:F.iconSet?{scale:S(F.iconSet),enabled:F.enabled!==!1}:{when:F.when,style:F.style,stop:F.stopIfTrue!==!1,enabled:F.enabled!==!1});return F=>{const E=F?F.value:void 0;let D=null;for(const N of P){if(!N.enabled)continue;if(N.scale){const A=N.scale(E);A&&(D={...D||{},...A});continue}if(!U(E,N.when))continue;const M=$(N.style)?N.style(F):N.style;if(M&&(D={...D||{},...M}),N.stop)break}return D}}}),Fe("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",$="str",B="ref",I="name",_="op",X="end",W=["<=",">=","<>","!="],H="+-*/^%(),<>=";class U extends Error{constructor(o,f){super(o),this.name="FormulaError",this.at=f}}function z(r){const o=[];let f=0;for(;f<r.length;){const u=r[f];if(u===" "||u===" "||u===`
6
+ var dr=Object.create(null),fr=Object.create(null);function Fe(e,K){dr[e]=K}function Kn(e){var K=fr[e];if(K)return K;var Q=Object.create(null);fr[e]=Q;var $=dr[e];if(!$)throw new Error("[lattice] missing module: "+e);return $(Q,Kn),Q}Fe("packages/core/src/internal/util.js",function(e,K){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return ne}});const Q="1.86.5";async function $(){return Q}const B="1.86.5",I=new Set,_=2e3;function X(oe){if(I.add(oe),I.size>_){const le=I.values().next().value;le!==void 0&&I.delete(le)}}const W=[],H=500;function U(oe,le,ae){W.push({key:oe,level:le,message:ae.map(se=>typeof se=="string"?se:z(se)).join(" "),at:Date.now()}),W.length>H&&W.shift()}function z(oe){if(oe instanceof Error)return oe.message;try{return JSON.stringify(oe)}catch{return String(oe)}}function w(){return W.map(oe=>({...oe}))}function k(oe){if(oe.length===0||typeof oe[0]!="string")return oe;const le=oe[0].replace(/^\[lattice\]\s*/,"");return le===oe[0]?oe:[le,...oe.slice(1)]}function g(oe,...le){if(I.has(oe))return;X(oe);const ae=k(le);U(oe,"warn",ae),console.warn("[lattice]",...ae)}function l(oe,...le){if(I.has(oe))return;X(oe);const ae=k(le);U(oe,"info",ae),console.info("[lattice]",...ae)}function c(){I.clear(),W.length=0}function s(oe,le){const ae=new Error(`[lattice] ${oe}`);throw le!==void 0&&(ae.cause=le),ae}function n(oe,le){oe||s(le)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(oe){return oe!==null&&typeof oe=="object"&&!Array.isArray(oe)}function o(oe){return typeof oe=="function"}function f(oe){return oe==null}function u(oe){return oe==null||oe===""}function i(oe){return typeof oe!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(oe))?!0:!!(oe.prototype&&Object.getOwnPropertyNames(oe.prototype).length>1)}const m=new Map;function d(oe){let le=m.get(oe);if(le)return le;if(!oe.includes("."))le=ae=>ae?.[oe];else{const ae=oe.split("."),se=ae.length;le=ee=>{let ie=ee;for(let ce=0;ce<se;ce++){if(ie==null)return;ie=ie[ae[ce]]}return ie}}return m.set(oe,le),le}const h=new Map;function a(oe){let le=h.get(oe);if(le)return le;if(!oe.includes("."))le=(ae,se)=>{ae!=null&&(ae[oe]=se)};else{const ae=oe.split("."),se=ae.length-1;le=(ee,ie)=>{let ce=ee;for(let he=0;he<se;he++){if(ce==null)return;const me=ae[he];ce[me]==null&&(ce[me]={}),ce=ce[me]}ce!=null&&(ce[ae[se]]=ie)}}return h.set(oe,le),le}function p(oe,le){return d(le)(oe)}function b(oe,le,ae){a(le)(oe,ae)}function j(oe){return oe?(oe.includes(".")?oe.slice(oe.lastIndexOf(".")+1):oe).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(/^./,ae=>ae.toUpperCase()):""}const S={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function y(oe){const le=oe==null?"":String(oe);return/[&<>"']/.test(le)?le.replace(/[&<>"']/g,ae=>S[ae]):le}function v(oe){return String(oe).replace(/\w\S*/g,le=>le[0].toUpperCase()+le.slice(1).toLowerCase())}function R(oe,le,ae){if(oe!==void 0)return oe===!0?{enabled:!0,...ae}:oe===!1?{enabled:!1}:r(oe)?oe:{[le]:oe,enabled:!0}}function O(oe){return oe==null?[]:Array.isArray(oe)?oe:[oe]}const x=Object.freeze(new Set(["__proto__","constructor","prototype"]));function C(oe,le){if(!r(oe))return r(le)?{...le}:le;if(!r(le))return le===void 0?oe:le;const ae={...oe};for(const se of Object.keys(le)){if(x.has(se))continue;const ee=le[se];ee!==void 0&&(ae[se]=r(ee)&&r(ae[se])?C(ae[se],ee):ee)}return ae}function P(oe,le){if(!r(oe)||!r(le)||oe===le)return le;const ae=Object.create(Object.getPrototypeOf(oe));return Object.assign(ae,oe,le),ae}class F{#e;#t=new Map;#n;constructor(le=256,ae=null){this.#e=le,this.#n=ae}get size(){return this.#t.size}get max(){return this.#e}set max(le){this.#e=le,this.#r()}has(le){return this.#t.has(le)}get(le){const ae=this.#t;if(!ae.has(le))return;const se=ae.get(le);return ae.delete(le),ae.set(le,se),se}peek(le){return this.#t.get(le)}set(le,ae){const se=this.#t;return se.has(le)&&se.delete(le),se.set(le,ae),this.#r(),ae}delete(le){const ae=this.#t.get(le);return this.#t.delete(le)&&this.#n&&this.#n(ae,le),ae}clear(){if(this.#n)for(const[le,ae]of this.#t)this.#n(ae,le);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const le=this.#t;for(;le.size>this.#e;){const ae=le.keys().next().value,se=le.get(ae);le.delete(ae),this.#n&&this.#n(se,ae)}}}const E=new Map;function D(oe,le){const ae=`${oe||""}|${le?JSON.stringify(le):""}`;let se=E.get(ae);return se||(se=new Intl.Collator(oe||void 0,{numeric:!0,sensitivity:"variant",...le}),E.set(ae,se)),se}function N(oe,le){if(oe===le)return 0;if(oe==null)return 1;if(le==null)return-1;if(typeof oe=="number"&&typeof le=="number")return Number.isNaN(oe)?Number.isNaN(le)?0:1:Number.isNaN(le)||oe<le?-1:oe>le?1:0;const ae=String(oe),se=String(le);return ae<se?-1:ae>se?1:0}function M(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const A=typeof requestAnimationFrame=="function";function L(oe){return A?requestAnimationFrame(oe):setTimeout(()=>oe(M()),16)}function G(oe){oe!=null&&(A?cancelAnimationFrame(oe):clearTimeout(oe))}function q(oe){let le=null,ae=null;const se=()=>{le=null;const ie=ae;ae=null,oe(...ie||[])},ee=(...ie)=>{ae=ie,le===null&&(le=L(se))};return ee.cancel=()=>{G(le),le=null,ae=null},ee.flush=()=>{le!==null&&(G(le),se())},ee}function Y(oe,le){let ae=null,se=null;const ee=()=>{if(ae=null,se===null)return;const he=se;se=null,oe(...he),ie()},ie=()=>{ae=setTimeout(ee,le),typeof ae?.unref=="function"&&ae.unref()},ce=(...he)=>{ae===null?(oe(...he),ie()):(se=he,clearTimeout(ae),ie())};return ce.flush=()=>{if(ae!==null&&clearTimeout(ae),ae=null,se===null)return;const he=se;se=null,oe(...he)},ce.cancel=()=>{ae!==null&&clearTimeout(ae),ae=null,se=null},ce.pending=()=>ae!==null||se!==null,ce}function J(oe,le=50){return typeof requestIdleCallback=="function"?requestIdleCallback(oe,{timeout:le}):setTimeout(()=>oe({timeRemaining:()=>0,didTimeout:!0}),1)}let te=0;function ne(oe="l"){return`${oe}${(++te).toString(36)}`}}),Fe("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return v}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),_=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=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 W(R,O){const x=Number(R),C=Number(O);if(R!==null&&R!==""&&O!==null&&O!==""&&Number.isFinite(x)&&Number.isFinite(C))return x<C?-1:x>C?1:0;const F=String(R??"").toLowerCase(),E=String(O??"").toLowerCase();return F<E?-1:F>E?1:0}function H(R){return R==null||R===""}function U(R,O){if(!O||typeof O!="object")return!1;const{op:x}=O,C=O.value,P=O.value2;switch(x){case"blank":return H(R);case"notBlank":return!H(R);case"true":return R===!0;case"false":return R===!1;default:break}if(H(R))return!1;switch(x){case"eq":return W(R,C)===0;case"ne":return W(R,C)!==0;case"gt":return W(R,C)>0;case"gte":return W(R,C)>=0;case"lt":return W(R,C)<0;case"lte":return W(R,C)<=0;case"between":return W(R,C)>=0&&W(R,P)<=0;case"outside":return W(R,C)<0||W(R,P)>0;case"contains":return String(R).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(R).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(R).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(R).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function z(R,O,x){const C=G=>{const q=String(G).replace("#",""),Y=q.length===3?q.split("").map(J=>J+J).join(""):q;return[0,2,4].map(J=>parseInt(Y.slice(J,J+2),16)||0)},[P,F,E]=C(R),[D,N,M]=C(O),A=Math.max(0,Math.min(1,x)),L=(G,q)=>Math.round(G+(q-G)*A);return`#${[L(P,D),L(F,N),L(E,M)].map(G=>G.toString(16).padStart(2,"0")).join("")}`}function w(R){const O=[];for(const D of R||[]){if(D==null||D==="")continue;const N=D instanceof Date?D.getTime():Number(D);Number.isFinite(N)&&O.push(N)}if(!O.length)return null;O.sort((D,N)=>D-N);let x=0,C=0,P=0;for(const D of O){x++;const N=D-C;C+=N/x,P+=N*(D-C)}const F=k(O,.25),E=k(O,.75);return{n:O.length,min:O[0],max:O[O.length-1],mean:C,stddev:O.length>1?Math.sqrt(P/(O.length-1)):0,median:k(O,.5),q1:F,q3:E,iqr:E-F,sorted:O}}function k(R,O){if(!R.length)return 0;const x=(R.length-1)*Math.max(0,Math.min(1,O)),C=Math.floor(x),P=Math.ceil(x);return C===P?R[C]:R[C]+(x-C)*(R[P]-R[C])}function g(R){for(const O of Array.isArray(R)?R:[])if(!(!O||typeof O!="object")&&(O.when&&_.includes(O.when.op)||O.scale&&O.scale.from||O.dataBar&&!(Number.isFinite(Number(O.dataBar.min))&&Number.isFinite(Number(O.dataBar.max)))||O.iconSet&&!Array.isArray(O.iconSet.thresholds)))return!0;return!1}function l(R,O){const x=Number(R.value),C=P=>k(O.sorted,P);switch(R.op){case"topPercent":{const P=c(x,10);return{op:"gte",value:C(1-P)}}case"bottomPercent":{const P=c(x,10);return{op:"lte",value:C(P)}}case"topN":{const P=Math.max(1,Math.floor(x)||1),F=Math.max(0,O.sorted.length-P);return{op:"gte",value:O.sorted[F]}}case"bottomN":{const P=Math.max(1,Math.floor(x)||1),F=Math.min(O.sorted.length-1,P-1);return{op:"lte",value:O.sorted[F]}}case"aboveMean":return{op:"gt",value:O.mean};case"belowMean":return{op:"lt",value:O.mean};case"aboveMedian":return{op:"gt",value:O.median};case"belowMedian":return{op:"lt",value:O.median};case"zAbove":return O.stddev?{op:"gte",value:O.mean+(Number.isFinite(x)?x:2)*O.stddev}:null;case"zBelow":return O.stddev?{op:"lte",value:O.mean-(Number.isFinite(x)?x:2)*O.stddev}:null;case"outlier":{const P=(Number.isFinite(x)&&x>0?x:1.5)*O.iqr;return O.iqr?{op:"outside",value:O.q1-P,value2:O.q3+P}:null}default:return null}}function c(R,O){const x=Number.isFinite(R)?R:O,C=x>1?x/100:x;return Math.max(0,Math.min(1,C))}function s(R,O){if(R.from==="minmax")return{...R,min:O.min,max:O.max};if(R.from==="quantile")return{...R,min:k(O.sorted,c(Number(R.low),5)),max:k(O.sorted,c(Number(R.high),95))};if(R.from==="stddev"){const x=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:O.mean-x*O.stddev,max:O.mean+x*O.stddev}}return R}function n(R,O){const x=Array.isArray(R)?R:[];return!O||!O.n?x.map(C=>C&&g([C])?{...C,enabled:!1}:C):x.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:s(C.scale,O)};if(C.dataBar)return{...C,dataBar:t(C.dataBar,O)};if(C.iconSet)return{...C,iconSet:r(C.iconSet,O)};if(!C.when||!_.includes(C.when.op))return C;const P=l(C.when,O);return P?{...C,when:P}:{...C,enabled:!1}})}function t(R,O){const x=Number.isFinite(Number(R.min))?Number(R.min):void 0,C=Number.isFinite(Number(R.max))?Number(R.max):void 0;if(x!==void 0&&C!==void 0)return{...R,min:x,max:C};if(R.from==="quantile")return{...R,min:x??k(O.sorted,c(Number(R.low),5)),max:C??k(O.sorted,c(Number(R.high),95))};if(R.from==="stddev"){const P=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:x??O.mean-P*O.stddev,max:C??O.mean+P*O.stddev}}return{...R,min:x??O.min,max:C??O.max}}function r(R,O){if(Array.isArray(R.thresholds))return R;const x=o(R),C=[];for(let P=1;P<x;P++)C.push(k(O.sorted,P/x));return{...R,thresholds:C}}function o(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.length;if(Number.isFinite(Number(R.count))&&Number(R.count)>=2)return Math.floor(Number(R.count));const O=a[R.set];return O?O.length:3}function f(R){return`url("data:image/svg+xml,${encodeURIComponent(R)}")`}function u(R){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${R}"/></svg>`}function i(R,O){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${O==="up"?"8,2 14,13 2,13":O==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${R}"/></svg>`}function m(R,O){const x="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 C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${O*16} 16">`;for(let P=0;P<O;P++){const F=P<R?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${P*16},0)" d="${x}" fill="${F}"/>`}return`${C}</svg>`}const d=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),h=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),a=Object.freeze({arrows:d,trafficLights:h,ratings:Object.freeze([1,2,3,4,5].map(R=>m(R,5)))}),p=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function b(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?f(String(C)):String(C));const O=R.set||"arrows";if(O==="ratings"){const C=o(R),P=[];for(let F=1;F<=C;F++)P.push(f(m(F,C)));return P}const x=a[O];return x?x.map(f):(B(`iconSet:${O}`,`unknown icon set '${O}'; falling back to arrows.`),d.map(f))}function j(R){const O=Number(R.min),C=Number(R.max)-O,P=R.colour||R.color||"#5b9bd5",F=R.negativeColour||R.negativeColor||"#d13438",E=R.direction==="rtl"?"left":"right",D=M=>Math.max(0,Math.min(1,(M-O)/C))*100,N=C?Math.max(0,Math.min(100,(0-O)/C*100)):0;return M=>{if(H(M))return null;const A=Number(M);if(!Number.isFinite(A)||!C)return null;const L=D(A),G=Math.min(L,N),q=Math.max(L,N),Y=A>=0?P:F;return{backgroundImage:`linear-gradient(to ${E}, transparent ${G}%, ${Y} ${G}%, ${Y} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function S(R){const O=b(R),x=R.reverse?[...O].reverse():O,C=(Array.isArray(R.thresholds)?R.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(R.size))?Number(R.size):16,F=R.set==="ratings"?P*o(R):P;return E=>{if(H(E))return null;const D=Number(E);if(!Number.isFinite(D))return null;let N=0;for(const A of C)D>=A&&N++;const M=x[Math.min(N,x.length-1)];return M?{backgroundImage:M,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${F}px ${P}px`,paddingLeft:`${F+4}px`}:null}}function y(R){const O=Array.isArray(R.colours)&&R.colours.length>=2?R.colours:["#f8f9fa","#1a6bc7"],x=Number(R.min),C=Number(R.max),P=C-x,F=O.length-1,E=[];for(let N=0;N<=F;N++)E.push(F?N/F:0);const D=Number(R.mid);if(R.mid!==void 0&&R.mid!==null)if(O.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${O.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&P&&D>Math.min(x,C)&&D<Math.max(x,C)){const N=F/2,M=Math.max(0,Math.min(1,(D-x)/P));for(let A=0;A<=F;A++)E[A]=A<=N?N?A/N*M:M:M+(A-N)/(F-N)*(1-M)}else Number.isFinite(D)&&B("formatting.scale.mid.range",`a scale's "mid" (${D}) is outside its min..max range, so it was ignored.`);return N=>{const M=Number(N);if(!Number.isFinite(M)||!P)return null;const A=Math.max(0,Math.min(1,(M-x)/P));let L=0;for(;L<F-1&&A>E[L+1];)L++;const G=E[L+1]-E[L],q=G>0?(A-E[L])/G:0;return{background:z(O[L],O[L+1],Math.max(0,Math.min(1,q)))}}}function v(R,O=null){const x=g(R)?n(R,O):R,C=(Array.isArray(x)?x:[]).filter(F=>F&&typeof F=="object");if(!C.length)return()=>null;const P=C.map(F=>F.scale?{scale:y(F.scale),enabled:F.enabled!==!1}:F.dataBar?{scale:j(F.dataBar),enabled:F.enabled!==!1}:F.iconSet?{scale:S(F.iconSet),enabled:F.enabled!==!1}:{when:F.when,style:F.style,stop:F.stopIfTrue!==!1,enabled:F.enabled!==!1});return F=>{const E=F?F.value:void 0;let D=null;for(const N of P){if(!N.enabled)continue;if(N.scale){const A=N.scale(E);A&&(D={...D||{},...A});continue}if(!U(E,N.when))continue;const M=$(N.style)?N.style(F):N.style;if(M&&(D={...D||{},...M}),N.stop)break}return D}}}),Fe("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",$="str",B="ref",I="name",_="op",X="end",W=["<=",">=","<>","!="],H="+-*/^%(),<>=";class U extends Error{constructor(o,f){super(o),this.name="FormulaError",this.at=f}}function z(r){const o=[];let f=0;for(;f<r.length;){const u=r[f];if(u===" "||u===" "||u===`
7
7
  `||u==="\r"){f++;continue}if(u>="0"&&u<="9"){f=k(r,f,o);continue}if(u==="."&&r[f+1]>="0"&&r[f+1]<="9"){f=k(r,f,o);continue}if(u==='"'||u==="'"){f=g(r,f,o);continue}if(u==="["){const m=r.indexOf("]",f+1);if(m<0)throw new U("a [column reference] was opened and never closed",f);o.push({kind:B,value:r.slice(f+1,m).trim(),at:f}),f=m+1;continue}if(w(u)){f=l(r,f,o);continue}const i=r.slice(f,f+2);if(W.includes(i)){o.push({kind:_,value:i==="!="?"<>":i,at:f}),f+=2;continue}if(H.includes(u)){o.push({kind:_,value:u,at:f}),f++;continue}throw new U(`unexpected character ${JSON.stringify(u)}`,f)}return o.push({kind:X,value:null,at:r.length}),o}function w(r){return/[A-Za-z_À-￿]/.test(r)}function k(r,o,f){let u=o,i=!1;for(;u<r.length;){const m=r[u];if(m>="0"&&m<="9"){u++;continue}if(m==="."&&!i){i=!0,u++;continue}if((m==="e"||m==="E")&&/[0-9+-]/.test(r[u+1]||"")){for(u+=2;u<r.length&&r[u]>="0"&&r[u]<="9";)u++;break}break}return f.push({kind:Q,value:Number(r.slice(o,u)),at:o}),u}function g(r,o,f){const u=r[o];let i=o+1,m="";for(;i<r.length;){if(r[i]===u){if(r[i+1]===u){m+=u,i+=2;continue}return f.push({kind:$,value:m,at:o}),i+1}m+=r[i],i++}throw new U("a string was opened and never closed",o)}function l(r,o,f){let u=o;for(;u<r.length&&/[A-Za-z0-9_.À-￿]/.test(r[u]);)u++;const i=r.slice(o,u);let m=u;for(;m<r.length&&r[m]===" ";)m++;return f.push({kind:r[m]==="("?I:B,value:i,at:o}),u}const c={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function s(r){const o=String(r??"").replace(/^\s*=/,"");if(!o.trim())throw new U("the formula is empty");const f=z(o);let u=0;const i=()=>f[u],m=()=>f[u++],d=y=>{const v=i();if(v.kind!==_||v.value!==y)throw new U(`expected ${JSON.stringify(y)}`,v.at);u++},h=y=>{let v=a();for(;;){const R=i();if(R.kind!==_)break;const O=c[R.value];if(!O||O<y)break;u++;const x=h(R.value==="^"?O:O+1);v={kind:"bin",op:R.value,left:v,right:x}}return v},a=()=>{const y=i();return y.kind===_&&(y.value==="-"||y.value==="+")?(u++,{kind:"unary",op:y.value,arg:a()}):p()},p=()=>{let y=b();for(;i().kind===_&&i().value==="%";)u++,y={kind:"unary",op:"%",arg:y};return y},b=()=>{const y=m();if(y.kind===Q)return{kind:"num",value:y.value};if(y.kind===$)return{kind:"str",value:y.value};if(y.kind===B)return{kind:"ref",name:y.value};if(y.kind===I){d("(");const v=[];if(!(i().kind===_&&i().value===")"))for(;;){if(v.push(h(1)),i().kind===_&&i().value===","){u++;continue}break}return d(")"),{kind:"call",name:String(y.value).toUpperCase(),args:v}}if(y.kind===_&&y.value==="("){const v=h(1);return d(")"),v}throw y.kind===X?new U("the formula ends unexpectedly",y.at):new U(`unexpected ${JSON.stringify(y.value)}`,y.at)},j=h(1),S=i();if(S.kind!==X)throw new U(`unexpected ${JSON.stringify(S.value)}: is an operator missing?`,S.at);return j}function n(r){const o=new Set,f=u=>{if(!(!u||typeof u!="object")){if(u.kind==="ref"){o.add(String(u.name));return}if(u.kind==="bin"){f(u.left),f(u.right);return}if(u.kind==="unary"){f(u.arg);return}if(u.kind==="call")for(const i of u.args)f(i)}};return f(r),[...o]}function t(r){return typeof r=="string"&&/^\s*=/.test(r)&&r.trim()!=="="}}),Fe("packages/core/src/formula/evaluate.js",function(e,K){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return k}});const $=K("packages/core/src/formula/parse.js").FormulaError;function B(g){if(g==null||g==="")return 0;if(typeof g=="boolean")return g?1:0;if(g instanceof Date)return g.getTime();const l=typeof g=="number"?g:Number(String(g).replace(/[,\s]/g,""));if(!Number.isFinite(l))throw new $(`${JSON.stringify(g)} is not a number`);return l}function I(g){return g==null?"":String(g)}function _(g){if(typeof g=="boolean")return g;if(g==null||g==="")return!1;if(typeof g=="number")return g!==0;const l=String(g).trim().toLowerCase();return l==="false"||l==="no"||l==="0"?!1:l!==""}function X(g){const l=[];for(const c of g){if(Array.isArray(c)){for(const s of c)s!=null&&s!==""&&l.push(B(s));continue}c==null||c===""||l.push(B(c))}return l}function W(g,l){const c=10**l,s=g*c;return Math.sign(s)*Math.round(Math.abs(s)+Number.EPSILON*Math.abs(s))/c}function H(g,l){if(!g.length)return 0;const c=g.slice().sort((r,o)=>r-o),s=(c.length-1)*Math.min(1,Math.max(0,l)),n=Math.floor(s),t=Math.ceil(s);return n===t?c[n]:c[n]+(s-n)*(c[t]-c[n])}function U(g,l){let c=0,s=0,n=0;for(const r of g){c++;const o=r-s;s+=o/c,n+=o*(r-s)}const t=l?c-1:c;return t>0?Math.sqrt(n/t):0}const z={SUM:g=>X(g).reduce((l,c)=>l+c,0),AVERAGE:g=>{const l=X(g);return l.length?l.reduce((c,s)=>c+s,0)/l.length:0},MIN:g=>{const l=X(g);return l.length?Math.min(...l):0},MAX:g=>{const l=X(g);return l.length?Math.max(...l):0},COUNT:g=>X(g).length,PRODUCT:g=>X(g).reduce((l,c)=>l*c,1),ROUND:g=>W(B(g[0]),g.length>1?B(g[1]):0),ROUNDDOWN:g=>{const l=10**(g.length>1?B(g[1]):0),c=B(g[0])*l;return(c<0?Math.ceil(c):Math.floor(c))/l},ROUNDUP:g=>{const l=10**(g.length>1?B(g[1]):0),c=B(g[0])*l;return(c<0?Math.floor(c):Math.ceil(c))/l},ABS:g=>Math.abs(B(g[0])),FLOOR:g=>Math.floor(B(g[0])),CEILING:g=>Math.ceil(B(g[0])),SQRT:g=>Math.sqrt(B(g[0])),POWER:g=>B(g[0])**B(g[1]),MOD:g=>{const l=B(g[1]);if(l===0)throw new $("MOD by zero");return(B(g[0])%l+l)%l},IF:g=>_(g[0])?g[1]:g.length>2?g[2]:!1,AND:g=>g.every(_),OR:g=>g.some(_),NOT:g=>!_(g[0]),COALESCE:g=>g.find(l=>l!=null&&l!=="")??null,CONCAT:g=>g.map(I).join(""),LEN:g=>I(g[0]).length,UPPER:g=>I(g[0]).toUpperCase(),LOWER:g=>I(g[0]).toLowerCase(),TRIM:g=>I(g[0]).trim(),LEFT:g=>I(g[0]).slice(0,g.length>1?B(g[1]):1),RIGHT:g=>{const l=g.length>1?B(g[1]):1;return l<=0?"":I(g[0]).slice(-l)},MEDIAN:g=>H(X(g),.5),PERCENTILE:g=>{const l=B(g[g.length-1]);return H(X(g.slice(0,-1)),l>1?l/100:l)},QUARTILE1:g=>H(X(g),.25),QUARTILE3:g=>H(X(g),.75),STDEV:g=>U(X(g),!0),STDEVP:g=>U(X(g),!1),VAR:g=>{const l=U(X(g),!0);return l*l},VARP:g=>{const l=U(X(g),!1);return l*l},COUNTDISTINCT:g=>{const l=new Set;for(const c of g){const s=Array.isArray(c)?c:[c];for(const n of s)n!=null&&n!==""&&l.add(n)}return l.size},IQR:g=>{const l=X(g);return H(l,.75)-H(l,.25)}};z.AVG=z.AVERAGE,z.CEIL=z.CEILING,z.POW=z.POWER,z.STDEVS=z.STDEV,z.PERCENTILEINC=z.PERCENTILE;function w(g,l){const c=Number(g),s=Number(l);if(g!==null&&g!==""&&l!==null&&l!==""&&Number.isFinite(c)&&Number.isFinite(s))return c<s?-1:c>s?1:0;const t=I(g).toLowerCase(),r=I(l).toLowerCase();return t<r?-1:t>r?1:0}function k(g,l={}){const c=typeof l.lookup=="function"?l.lookup:null,s=l.functions?{...z,...l.functions}:z,n=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!c)throw new $(`there is no column called ${JSON.stringify(t.name)} here`);const r=c(String(t.name));if(r===void 0)throw new $(`there is no column called ${JSON.stringify(t.name)}`);return r}case"unary":{if(t.op==="%")return B(n(t.arg))/100;const r=B(n(t.arg));return t.op==="-"?-r:r}case"bin":{const r=t.op;if(r==="=")return w(n(t.left),n(t.right))===0;if(r==="<>")return w(n(t.left),n(t.right))!==0;if(r==="<")return w(n(t.left),n(t.right))<0;if(r==="<=")return w(n(t.left),n(t.right))<=0;if(r===">")return w(n(t.left),n(t.right))>0;if(r===">=")return w(n(t.left),n(t.right))>=0;const o=B(n(t.left)),f=B(n(t.right));if(r==="+")return o+f;if(r==="-")return o-f;if(r==="*")return o*f;if(r==="^")return o**f;if(r==="/"){if(f===0)throw new $("division by zero");return o/f}throw new $(`unknown operator ${JSON.stringify(r)}`)}case"call":{const r=s[t.name];if(typeof r!="function")throw new $(`there is no function called ${t.name}`);return r(t.args.map(n),l)}default:throw new $("the formula could not be read")}};return n(g)}}),Fe("packages/core/src/formula/index.js",function(e,K){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/formula/parse.js"),$=Q.parseFormula,B=Q.referencesOf,I=Q.looksLikeFormula,_=Q.FormulaError,X=Q.tokenise,W=K("packages/core/src/formula/evaluate.js"),H=W.evaluateAst,U=W.FUNCTIONS;function z(k){const{grid:g,row:l,data:c}=k||{},s=f=>String(f).toLowerCase().replace(/[\s_-]/g,""),n=g&&g.columns&&typeof g.columns.all=="function"?g.columns.all():[],t=g&&g.permissions,r=t&&typeof t.isReadable=="function"?f=>t.isReadable(f):()=>!0,o=new Set;for(const f of n)r(f)||(o.add(s(f.id)),f.field&&o.add(s(f.field)),f.title&&o.add(s(f.title)));return f=>{const u=s(f);if(o.has(u))throw new _(`"${f}" cannot be read`);for(const i of n)if(s(i.id)===u||i.field&&s(i.field)===u||i.title&&s(i.title)===u)return l&&g.rows&&typeof g.rows.value=="function"?g.rows.value(l.key,i.id):c?c[i.field||i.id]:void 0;if(c&&typeof c=="object"){for(const i of Object.keys(c))if(s(i)===u){if(!r(i))throw new _(`"${f}" cannot be read`);return c[i]}}}}function w(k,g={}){try{const l=$(k);return{ok:!0,value:H(l,{lookup:z(g),functions:g.formulaFunctions}),references:B(l)}}catch(l){return{ok:!1,error:l instanceof _?l.message:"the formula could not be read",at:l instanceof _?l.at:void 0}}}}),Fe("packages/core/src/defaults.js",function(e,K){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return U}});const Q=K("packages/core/src/internal/util.js"),$=Q.isObject,B=Q.merge,I=Q.warnOnce;let _=null;class X extends Error{}function W(z,w=new Set){if(Array.isArray(z)){if(w.has(z))throw new X;w.add(z);const g=z.map(l=>W(l,w));return w.delete(z),g}if(!$(z)||Object.getPrototypeOf(z)!==Object.prototype&&Object.getPrototypeOf(z)!==null)return z;if(w.has(z))throw new X;w.add(z);const k={};for(const[g,l]of Object.entries(z))k[g]=W(l,w);return w.delete(z),k}function H(z){if(z===void 0)return W(_??{});if(z===null)return _=null,{};if(!$(z))return I("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(z)?"an array":typeof z}. The call was ignored and the defaults are unchanged.`),W(_??{});try{_=W(z)}catch(w){if(!(w instanceof X))throw w;return I("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."),W(_??{})}return W(_)}function U(z){return _===null?z:B(W(_),z)}}),Fe("packages/core/src/events/names.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return B}});const Q=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"]),$=new Set(Q);function B(I){return I==="*"||$.has(I)}}),Fe("packages/core/src/events/bus.js",function(e,K){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.uid,I=Q.DEV,X=K("packages/core/src/events/names.js").isKnownEvent,W="*";function H(c,s){!I||X(s)||$(`bus.unknown:${s}`,`${c}('${s}') 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 U=new Set(["api","user","init","ai"]),z=new WeakMap;function w(c){let s=z.get(c);return s||(s=B("h"),z.set(c,s)),s}function k(){return typeof performance=="object"&&performance?performance.now():Date.now()}function g(c){if(!c||typeof c!="object")return{};const s={};for(const[n,t]of Object.entries(c))n!=="grid"&&(t==null?s[n]=String(t):Array.isArray(t)?s[n]=`[${t.length}]`:typeof t=="object"?s[n]=t.key?`row ${t.key}`:"{…}":typeof t=="function"?s[n]="[function]":s[n]=String(t).slice(0,60));return s}class l{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#s=!1;#l=0;constructor(s=null){this.#i=s}attach(s){this.#i=s}get grid(){return this.#i}get destroyed(){return this.#s}on(s,n){if(typeof n!="function")return $(`bus.handler:${s}`,`on('${s}') needs a function; ignored.`),()=>{};H("on",s);let t=this.#e.get(s);return t||(t=[],this.#e.set(s,t)),t.push(n),()=>this.off(s,n)}once(s,n){if(typeof n!="function")return $(`bus.handler:${s}`,`once('${s}') needs a function; ignored.`),()=>{};H("once",s);const t=r=>{this.off(s,n),n(r)};return this.#o.set(n,t),this.on(s,t)}off(s,n){if(n===void 0){this.#e.delete(s);return}const t=this.#e.get(s);if(!t)return;const r=this.#o.get(n),o=r&&t.includes(r)?r:n,f=t.indexOf(o);f>=0&&t.splice(f,1),r&&o===r&&this.#o.delete(n),t.length===0&&this.#e.delete(s)}count(s){const n=this.#e.get(s),t=s===W?null:this.#e.get(W);return(n?n.length:0)+(t?t.length:0)}#a(s,n,t,r,o){this.#n.push({type:s,origin:n,listeners:(r?r.length:0)+(o?o.length:0),payload:g(t),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(s,n){this.#t=!!s,Number.isFinite(n)&&n>0&&(this.#r=Math.floor(n)),s||(this.#n=[])}eventLog(){return this.#n.map(s=>({...s}))}clearEventLog(){this.#n=[]}counts(){const s={};for(const[n,t]of this.#e)s[n]=t.length;return s}emit(s,n,t){const r=t??(n&&n.origin),o=U.has(r)?r:"api",f={...n||null,type:s,origin:o,grid:this.#i};if(this.#s)return f;const u=this.#e.get(s),i=s===W?void 0:this.#e.get(W);if(this.#t&&this.#a(s,o,n,u,i),!u&&!i)return f;const m=this.#t?k():0;this.#l++;try{u&&this.#u(u.slice(),f,s),i&&this.#u(i.slice(),f,W)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=k()-m)}return f}emitBefore(s,n,t){const r=t??(n&&n.origin),o=U.has(r)?r:"user";let f=!1,u=null;const i=b=>{f=!0,b!=null&&u===null&&(u=String(b))},m={...n||null,type:s,origin:o,grid:this.#i,get defaultPrevented(){return f},get reason(){return u},preventDefault(b){i(b)}};if(this.#s)return!0;const d=this.#e.get(s);this.#t&&this.#a(s,o,n,d,void 0);const h=d?d.slice():[];if(h.length===0)return!0;const a=()=>(f&&u===null&&(u="prevented"),f&&n&&typeof n=="object"&&(n.reason=u),!f),p=[];for(const b of h)try{const j=b(m);j&&typeof j.then=="function"?p.push(j):j===!1&&i("prevented")}catch(j){i("error"),$(`bus.beforeThrow:${s}:${w(b)}`,`a '${s}' before-handler threw; the action was cancelled.`,j)}return p.length===0?a():Promise.allSettled(p).then(b=>{for(const j of b)j.status==="rejected"?(i("error"),$(`bus.beforeReject:${s}`,`a '${s}' before-handler rejected; the action was cancelled.`,j.reason)):j.value===!1&&i("prevented");return a()})}#u(s,n,t){for(let r=0;r<s.length;r++)try{s[r](n)}catch(o){$(`bus.throw:${t}:${w(s[r])}`,`a '${t}' handler threw; other handlers were unaffected.`,o)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#s=!0,this.#i=null}}}),Fe("packages/core/src/registry/free-tier-notice.js",function(e,K){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return Q}});const Q="Free for non-commercial use: latticegrid.dev/free"}),Fe("packages/core/src/registry/licence.js",function(e,K){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return x}});const $=K("packages/core/src/internal/util.js").warnOnce,B=K("packages/core/src/registry/free-tier-notice.js"),I=B.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return B.FREE_TIER_NOTICE}});const _="lattice-grid",X=1,W="LG1",H=64,U="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",w=(()=>{const C=new Int16Array(128).fill(-1);for(let P=0;P<z.length;P++)C[z.charCodeAt(P)]=P;return C[43]=62,C[47]=63,C})();function k(C){if(typeof C!="string")return null;let P="";for(let A=0;A<C.length;A++){const L=C.charCodeAt(A);if(L!==61){if(L>127||w[L]<0)return null;P+=C[A]}}const F=P.length;if(F%4===1)return null;const E=new Uint8Array(Math.floor(F*3/4));let D=0,N=0,M=0;for(let A=0;A<F;A++)D=D<<6|w[P.charCodeAt(A)],N+=6,N>=8&&(N-=8,E[M++]=D>>N&255);return M===E.length?E:E.subarray(0,M)}function g(C){let P="",F=0;for(;F+2<C.length;F+=3){const D=C[F]<<16|C[F+1]<<8|C[F+2];P+=z[D>>18&63]+z[D>>12&63]+z[D>>6&63]+z[D&63]}const E=C.length-F;if(E===1){const D=C[F]<<16;P+=z[D>>18&63]+z[D>>12&63]}else if(E===2){const D=C[F]<<16|C[F+1]<<8;P+=z[D>>18&63]+z[D>>12&63]+z[D>>6&63]}return P}function l(C){const P=new Uint8Array(C.length);for(let F=0;F<C.length;F++)P[F]=C.charCodeAt(F)&127;return P}function c(C){if(typeof TextDecoder=="function")return new TextDecoder().decode(C);let P="";for(let F=0;F<C.length;F++)P+=String.fromCharCode(C[F]);return P}function s(C){const P={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof C=="string"?C:""};if(typeof C!="string"||C.length===0)return{...P,reason:"missing"};const F=C.trim(),E=F.split(".");if(E.length!==3)return P;const[D,N,M]=E;if(D!==W)return{...P,reason:"prefix"};const A=k(N),L=k(M);if(!A||!L)return P;let G;try{G=JSON.parse(c(A))}catch{return P}return G===null||typeof G!="object"?P:{ok:!0,reason:null,product:typeof G.p=="string"?G.p:null,issuedTo:typeof G.t=="string"?G.t:null,expires:typeof G.e=="string"?G.e:null,terms:typeof G.terms=="string"?G.terms:null,features:Array.isArray(G.f)?G.f.slice():[],deployments:Array.isArray(G.d)?G.d.slice():[],version:typeof G.v=="number"?G.v:0,message:l(N),signature:L,raw:F}}function n(C,P){if(!C)return!1;const F=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(C)?`${C}T23:59:59.999Z`:C);return Number.isNaN(F)?!0:P>F}function t(C){return C==="non-commercial"?"non-commercial":"commercial"}let r=null,o=null,f=null;function u(){const C=globalThis.crypto;return C&&C.subtle?C.subtle:null}async function i(C){if(r&&o===C)return r;const P=u();if(!P)return null;const F=k(C);if(!F)return null;try{const E=await P.importKey("raw",F,{name:"Ed25519"},!1,["verify"]);return r=E,o=C,E}catch{return null}}async function m(){return f!==null||(f=await i(U)!==null),f}async function d(C,P={}){const F=P.warn!==!1,E=P.product||_,D=P.publicKey||U,N=P.now??Date.now(),M=P.host??a(),A=h(M)?"":` ${I}`,L=s(C);if(!L.ok){const te=L.reason==="missing"?"missing":"malformed";return F&&$(`licence.${te}`,te==="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.${A}`:`licence key could not be read. The grid will render with a watermark.${A}`),{valid:!1,reason:te,terms:"commercial"}}const G={product:L.product||void 0,issuedTo:L.issuedTo||void 0,expires:L.expires||void 0,terms:t(L.terms)};if(L.product!==E)return F&&$("licence.product",`licence key is for '${L.product}', not '${E}'. The grid will render with a watermark.`),{valid:!1,...G,reason:"product"};if(n(L.expires,N))return F&&$("licence.expired",`licence expired on ${L.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...G,reason:"expired"};const q=L.deployments||[];if(q.length&&M&&!h(M)&&!p(M,q))return F&&$("licence.domain",`licence key is not valid for ${M}; it covers ${q.join(", ")}. The grid will render with a watermark.`),{valid:!1,...G,reason:"domain"};const Y=await i(D);if(!Y){const te=!!L.signature&&L.signature.length===H;return F&&$("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),te?{valid:!0,...G,reason:"unverified"}:{valid:!1,...G,reason:"signature"}}let J=!1;try{J=await u().verify({name:"Ed25519"},Y,L.signature,L.message)}catch{J=!1}return J?{valid:!0,...G}:(F&&$("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...G,reason:"signature"})}function h(C){const P=String(C??a()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!P||P==="localhost"||P.endsWith(".localhost")||P==="::1"||P==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(P)}function a(){const C=globalThis.location;return C&&typeof C.hostname=="string"?C.hostname:null}function p(C,P){const F=b(C);return!F||!Array.isArray(P)?!1:P.some(E=>{const D=b(E);if(!D)return!1;if(D==="*")return!0;if(D.startsWith("*.")){const N=D.slice(2);return F===N||F.endsWith(`.${N}`)}return F===D})}function b(C){return String(C??"").trim().toLowerCase().replace(/\.$/,"")}class j{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#o;#i=new Set;constructor(P={}){this.#o=P}set(P){this.#e=typeof P=="string"?P.trim():"";const F=s(this.#e);return this.#t=F.ok?{valid:!n(F.expires,Date.now())&&F.product===(this.#o.product||_),product:F.product||void 0,issuedTo:F.issuedTo||void 0,expires:F.expires||void 0,terms:t(F.terms),reason:"pending"}:{valid:!1,reason:F.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const P=this.#e;return this.#n=d(P,this.#o).then(F=>{if(this.#e===P){this.#t=F;for(const E of this.#i)E(F)}return F}),this.#n}onSettled(P){return this.#i.add(P),()=>this.#i.delete(P)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!h(this.#r)}setHost(P){this.#r=P}state(){return this.#t.valid?"licensed":h(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#i.clear()}}const S=new j;function y(C){return S.set(C)}function v(){return S.info()}function R(){return S.watermark()}function O(){return S.state()}function x(){return S}}),Fe("packages/core/src/registry/registry.js",function(e,K){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return t}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.isFunction,I=Q.DEV,_=K("packages/core/src/registry/licence.js"),X=_.LicenceHolder,W=_.sharedLicence,H=["renderer","editor","filter","dataType","totalFn","pipe","component"],U=["all","header","body","totals","panels"];class z{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#o;#i=null;#s=null;#l=new Set;#a=new Map;constructor(o={}){for(const f of H)this.#t.set(f,new Map);this.#o=o.holder||W(),this.#s=o.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),o.licence&&this.setLicence(o.licence)}registerModules(o,f={}){f.licence&&this.setLicence(f.licence),f.grid!==void 0&&(this.#s=f.grid);const u=Array.isArray(o)?o:[o],i=[];for(const m of u){if(!m||typeof m!="object"||typeof m.name!="string"||!m.name){$("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(m.name)){I&&this.#c(this.#e.get(m.name),m);continue}if(!B(m.install)){$(`registry.module.install:${m.name}`,`module '${m.name}' has no install() and was ignored.`);continue}const d={registry:this,grid:this.#s};try{m.install(d)}catch(h){$(`registry.module.throw:${m.name}`,`module '${m.name}' threw during install; it was not registered.`,h);continue}this.#e.set(m.name,m);for(const h of w(m))this.#n.add(h);i.push(m.name),this.#d({reason:"module",name:m.name,capabilities:this.capabilities(),regions:l(m)})}return i}unregisterModule(o){const f=this.#e.get(o);if(!f)return!1;if(B(f.uninstall))try{f.uninstall({registry:this,grid:this.#s})}catch(u){$(`registry.module.uninstall:${o}`,`module '${o}' threw during uninstall.`,u)}return this.#e.delete(o),this.#u(),this.#d({reason:"unmodule",name:o,capabilities:this.capabilities(),regions:l(f)}),!0}modules(){return[...this.#e.values()]}has(o){return this.#e.has(o)}#u(){this.#n.clear();for(const o of this.#e.values())for(const f of w(o))this.#n.add(f)}#c(o,f){!o||o===f||k(o,f)||$(`registry.module.reconfigure:${f.name}`,`module '${f.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(o){return this.#n.has(o)}onChange(o){return B(o)?(this.#r.add(o),this.#a.set(o,this.#s),()=>{this.#r.delete(o),this.#a.delete(o)}):()=>{}}#d(o){for(const f of[...this.#r])try{f(o)}catch(u){$("registry.onChange.throw","a registry change handler threw.",u)}}register(o,f,u){const i=this.#t.get(o);if(!i){$(`registry.kind:${o}`,`unknown registry kind '${o}'; expected one of ${H.join(", ")}.`);return}if(!f||typeof f!="string"){$(`registry.name:${o}`,`register('${o}', ...) needs a name.`);return}i.has(f)&&i.get(f)!==u&&$(`registry.replace:${o}:${f}`,`'${f}' was already registered as a ${o} and has been replaced.`),i.set(f,u),this.#d({reason:"register",name:f,kind:o,capabilities:this.capabilities(),regions:c(o)})}registerAll(o,f){if(f)for(const u of Object.keys(f))this.register(o,u,f[u])}get(o,f){const u=this.#t.get(o);return u?u.get(f):void 0}names(o){const f=this.#t.get(o);return f?[...f.keys()]:[]}#f(o,f){const u=this.#t.get(o).get(f);return u!==void 0?u:this.#t.get("component").get(f)}renderer(o){return this.#f("renderer",o)}editor(o){return this.#f("editor",o)}filter(o){return this.#f("filter",o)}dataType(o){return this.get("dataType",o)}totalFn(o){return this.get("totalFn",o)}pipe(o){return this.get("pipe",o)}setLicence(o){return this.#o.set(o)}licence(){return this.#o.info()}licenceVerified(){return this.#o.verify()}watermark(){return this.#o.watermark()}attach(o){o!=null&&(this.#l.add(o),this.#s=o)}detach(o){if(o!=null){this.#l.delete(o);for(const[f,u]of[...this.#a])u===o&&(this.#r.delete(f),this.#a.delete(f));if(this.#s===o){const f=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#s=f}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(o){if(o!=null){this.detach(o);return}for(const f of[...this.#e.keys()])this.unregisterModule(f);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#s=null}}function w(r){const o=r.capabilities,f=Array.isArray(o)?o.filter(u=>typeof u=="string"):[];return[r.name,...f]}function k(r,o){return r.install!==o.install||r.uninstall!==o.uninstall||(r.version||"")!==(o.version||"")?!1:g(w(r),w(o))&&g(l(r),l(o))}function g(r,o){const f=new Set(r),u=new Set(o);if(f.size!==u.size)return!1;for(const i of f)if(!u.has(i))return!1;return!0}function l(r){const o=r.regions;return!Array.isArray(o)||o.length===0?["all"]:o.filter(f=>U.includes(f))}function c(r){switch(r){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const s=new z;function n(){return s}function t(r,o={}){return s.registerModules(r,o)}}),Fe("packages/core/src/format/number.js",function(e,K){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return B}});const $=K("packages/core/src/internal/util.js").isNil;function B(I,_){const X=I||{},W=X.locale||_||void 0,H=X.style||"decimal",U=typeof X.scale=="number"?X.scale:1,z=X.nullDisplay??"",w=X.zeroDisplay,k=X.prefix||"",g=X.suffix||"",l=X.negative||"minus",c=X.signed===!0,s={style:H,notation:X.notation||"standard"};H==="currency"&&(s.currency=X.currency||"USD",X.currencyDisplay&&(s.currencyDisplay=X.currencyDisplay)),typeof X.decimals=="number"?(s.minimumFractionDigits=X.decimals,s.maximumFractionDigits=X.decimals):(typeof X.minDecimals=="number"&&(s.minimumFractionDigits=X.minDecimals),typeof X.maxDecimals=="number"&&(s.maximumFractionDigits=X.maxDecimals),s.minimumFractionDigits>(s.maximumFractionDigits??20)&&(s.maximumFractionDigits=s.minimumFractionDigits)),X.thousandsSeparator===!1&&(s.useGrouping=!1),s.notation==="compact"&&(s.compactDisplay=X.compactDisplay||"short");const n=new Intl.NumberFormat(W,s),t=typeof X.thousandsSeparator=="string"?X.thousandsSeparator:null,r=typeof X.decimalSeparator=="string"?X.decimalSeparator:null;let o=",",f=".";if(t||r)for(const a of n.formatToParts(12345.6))a.type==="group"?o=a.value:a.type==="decimal"&&(f=a.value);const u=a=>{let p=a;return t&&(p=p.split(o).join("")),r&&(p=p.split(f).join("")),t&&(p=p.split("").join(t)),r&&(p=p.split("").join(r)),p},i=!!(t||r),m=k!==""&&H==="currency",d=a=>{let p;if(m){const b=n.formatToParts(a);let j=!1;p="";for(const S of b)p+=S.value,!j&&S.type==="currency"&&(p+=k,j=!0);j||(p=k+p)}else p=k+n.format(a);return i&&(p=u(p)),p+g},h=a=>{if($(a)||a==="")return z;const p=typeof a=="number"?a:Number(a);if(Number.isNaN(p))return z;const b=U===1?p:p*U;return b===0&&w!==void 0?w:b<0?l==="parentheses"?`(${d(-b)})`:l==="suffix"?`${d(-b)}-`:d(b):c&&b>0?`+${d(b)}`:d(b)};return h.negativeClass=X.negativeClass||null,h.spec=X,h}}),Fe("packages/core/src/format/date.js",function(e,K){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return n}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.warnOnce,I=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(t){const r=[];let o=0,f="";const u=()=>{f&&(r.push({token:null,text:f}),f="")};for(;o<t.length;){const i=t[o];if(i==="'"){if(t[o+1]==="'"){f+="'",o+=2;continue}const d=t.indexOf("'",o+1);if(d===-1){f+=t.slice(o+1),o=t.length;continue}f+=t.slice(o+1,d),o=d+1;continue}const m=I.find(d=>t.startsWith(d,o));if(m){u(),r.push({token:m,text:m}),o+=m.length;continue}/[A-Za-z]/.test(i)&&B(`date.pattern.token:${i}`,`the date pattern "${t}" contains '${i}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${I.join(" ")}.`),f+=i,o+=1}return u(),r}const X=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function W(t){if($(t)||t==="")return null;if(t instanceof Date)return Number.isNaN(t.getTime())?null:t;if(typeof t=="number")return Number.isNaN(t)?null:new Date(t);if(typeof t=="string"){const r=X.exec(t.trim());if(r){const[,f,u,i,m="0",d="0",h="0"]=r;return new Date(+f,+u-1,+i,+m,+d,+h)}const o=new Date(t);return Number.isNaN(o.getTime())?null:o}return null}function H(t,r){return String(t).padStart(r,"0")}function U(t){if(!t)return f=>({year:f.getFullYear(),month:f.getMonth()+1,day:f.getDate(),hour:f.getHours(),minute:f.getMinutes(),second:f.getSeconds(),ms:f.getMilliseconds(),weekday:f.getDay()});const r=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),o={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return f=>{const u={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:f.getMilliseconds(),weekday:0};for(const i of r.formatToParts(f))switch(i.type){case"year":u.year=Number(i.value);break;case"month":u.month=Number(i.value);break;case"day":u.day=Number(i.value);break;case"hour":u.hour=Number(i.value)%24;break;case"minute":u.minute=Number(i.value);break;case"second":u.second=Number(i.value);break;case"weekday":u.weekday=o[i.value]??0;break;default:break}return u}}function z(t,r,o){const f=_(t),u=U(o),i=new Set(f.filter(p=>p.token).map(p=>p.token)),m=i.has("MMM")?new Intl.DateTimeFormat(r,{month:"short",timeZone:o}):null,d=i.has("MMMM")?new Intl.DateTimeFormat(r,{month:"long",timeZone:o}):null,h=i.has("EEE")?new Intl.DateTimeFormat(r,{weekday:"short",timeZone:o}):null,a=i.has("EEEE")?new Intl.DateTimeFormat(r,{weekday:"long",timeZone:o}):null;return p=>{const b=u(p);let j="";for(const S of f){if(!S.token){j+=S.text;continue}switch(S.token){case"yyyy":j+=H(b.year,4);break;case"yy":j+=H(b.year%100,2);break;case"MMMM":j+=d.format(p);break;case"MMM":j+=m.format(p);break;case"MM":j+=H(b.month,2);break;case"M":j+=String(b.month);break;case"dd":j+=H(b.day,2);break;case"d":j+=String(b.day);break;case"EEEE":j+=a.format(p);break;case"EEE":j+=h.format(p);break;case"HH":j+=H(b.hour,2);break;case"H":j+=String(b.hour);break;case"hh":j+=H(b.hour%12===0?12:b.hour%12,2);break;case"h":j+=String(b.hour%12===0?12:b.hour%12);break;case"mm":j+=H(b.minute,2);break;case"m":j+=String(b.minute);break;case"ss":j+=H(b.second,2);break;case"s":j+=String(b.second);break;case"SSS":j+=H(b.ms,3);break;case"a":j+=b.hour<12?"AM":"PM";break;default:j+=S.text;break}}return j}}const w=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function k(t,r){const o=t||{},f=o.locale||r||void 0,u=o.nullDisplay??"",i=o.timeZone;let m;if(o.pattern)m=z(o.pattern,f,i);else if(o.dateStyle||o.timeStyle){const b={timeZone:i};o.dateStyle&&(b.dateStyle=o.dateStyle),o.timeStyle&&(b.timeStyle=o.timeStyle);const j=new Intl.DateTimeFormat(f,b);m=S=>j.format(S)}else{const b=new Intl.DateTimeFormat(f,{dateStyle:"medium",timeZone:i});m=j=>b.format(j)}const d=o.relative?new Intl.RelativeTimeFormat(f,{numeric:"auto"}):null,a=(typeof o.relative=="object"&&o.relative?o.relative.threshold??7:7)*24*36e5,p=(b,j)=>{const S=W(b);if(!S)return u;if(d){const y=j&&typeof j.now=="number"?j.now:Date.now(),v=S.getTime()-y;if(Math.abs(v)<a){for(const[R,O]of w)if(Math.abs(v)>=O||R==="second")return d.format(Math.round(v/O),R)}}return m(S)};return p.spec=o,p}function g(t){if($(t)||t==="")return null;if(typeof t=="string"){const f=/^(\d{4}-\d{2}-\d{2})/.exec(t.trim());if(f)return f[1];const u=W(t);return u?g(u):null}const r=W(t);if(!r)return null;const o=f=>String(f).padStart(2,"0");return`${r.getFullYear()}-${o(r.getMonth()+1)}-${o(r.getDate())}`}function l(t,r){if($(t)||t==="")return null;if(typeof t=="string"){const f=t.trim();if(c.test(f)){const m=W(f);return m?s(m,r):null}const u=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(f);if(u){const[,m,d,h,a]=u;return`${m}T${d}:${h}${a&&a!=="00"?`:${a}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(f))return`${f}T00:00`;const i=W(f);return i?l(i):null}const o=W(t);return o?s(o,r):null}const c=/(?:Z|[+-]\d{2}:?\d{2})$/i;function s(t,r){const o=m=>String(m).padStart(2,"0");if(r)try{const m=new Intl.DateTimeFormat("en-CA",{timeZone:r,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(t).reduce((a,p)=>(p.type!=="literal"&&(a[p.type]=p.value),a),{}),d=m.hour==="24"?"00":m.hour,h=Number(m.second);return`${m.year}-${m.month}-${m.day}T${d}:${m.minute}`+(h?`:${m.second}`:"")}catch{}const f=`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`,u=t.getSeconds(),i=`${o(t.getHours())}:${o(t.getMinutes())}${u?`:${o(u)}`:""}`;return`${f}T${i}`}function n(t,r){const o=$(t)||t===""?null:String(t),f=$(r)||r===""?null:String(r);return o===null?f===null?0:1:f===null||o<f?-1:o>f?1:0}}),Fe("packages/core/src/format/boolean.js",function(e,K){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isNil,B={true:"☑",false:"☐",null:""},I={true:"◉",false:"◯",null:""};function _(W){if($(W)||W==="")return null;if(typeof W=="boolean")return W;if(typeof W=="number")return W!==0;const H=String(W).trim().toLowerCase();return H==="true"||H==="yes"||H==="y"||H==="1"?!0:H==="false"||H==="no"||H==="n"||H==="0"?!1:null}function X(W,H){const U=W||{},z=U.display||"text",w=U.trueLabel??"Yes",k=U.falseLabel??"No",g=U.nullLabel??"";let l=w,c=k;const s=g;z==="checkbox"?(l=B.true,c=B.false):z==="switch"?(l=I.true,c=I.false):z==="icon"&&(l=U.trueIcon??w,c=U.falseIcon??k);const n=t=>{const r=_(t);return r===null?s:r?l:c};return n.display=z,n.labels={true:w,false:k,null:g},n.locale=H,n.spec=U,n}}),Fe("packages/core/src/format/text.js",function(e,K){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return I}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.titleCase;function I(_,X){const W=_||{},H=W.locale||X||void 0,U=W.nullDisplay??"",z=W.emptyDisplay??"",w=W.transform||"none",k=typeof W.truncate=="number"?{chars:W.truncate}:W.truncate||null,g=k?k.chars:0,l=k?k.ellipsis??"…":"",c=n=>{switch(w){case"upper":return H?n.toLocaleUpperCase(H):n.toUpperCase();case"lower":return H?n.toLocaleLowerCase(H):n.toLowerCase();case"title":return B(n);default:return n}},s=n=>{if($(n))return U;let t=typeof n=="string"?n:String(n);return t===""?z:(w!=="none"&&(t=c(t)),g>0&&t.length>g&&(t=t.slice(0,g)+l),t)};return s.spec=W,s}}),Fe("packages/core/src/format/mask.js",function(e,K){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return X}});const Q=new Set(["0","#","?",",","."]),$="\0";function B(H){const U=[];let z="",w=!1;for(let k=0;k<H.length;k++){const g=H[k];if(g==="\\"){z+=g+(H[k+1]??""),k+=1;continue}if(g==='"'){w=!w,z+=g;continue}if(g===";"&&!w){U.push(z),z="";continue}z+=g}return U.push(z),U}function I(H){let U="",z="",w="",k=1,g=!1,l=!1;const c=m=>{l?z+=m:U+=m};for(let m=0;m<H.length;m++){const d=H[m];if(d==="\\"){c(H[m+1]??""),m+=1;continue}if(d==='"'){const h=H.indexOf('"',m+1);c(h===-1?H.slice(m+1):H.slice(m+1,h)),m=h===-1?H.length:h;continue}if(d==="%"){k*=100,c("%");continue}if(d==="@"){g=!0,c("\0");continue}if(Q.has(d)){w+=d,l=!0;continue}c(d)}let s=-1;for(let m=w.length-1;m>=0;m--){const d=w[m];if(d==="0"||d==="#"||d==="?"){s=m;break}}let n=!1,t="";for(let m=0;m<w.length;m++){const d=w[m];if(d===","){m>s?k/=1e3:n=!0;continue}t+=d}const r=t.indexOf("."),o=r===-1?t:t.slice(0,r),f=r===-1?"":t.slice(r+1);let u=0;for(const m of o)m==="0"&&(u+=1);let i=0;for(const m of f)m==="0"&&(i+=1);return{prefix:U,suffix:z,minInt:u,minDec:i,maxDec:f.length,grouping:n,scale:k,hasNumber:s!==-1,isText:g}}function _(H,U){const z=new Intl.NumberFormat(U,{minimumIntegerDigits:Math.max(H.minInt,1),minimumFractionDigits:H.minDec,maximumFractionDigits:Math.max(H.maxDec,H.minDec),useGrouping:H.grouping}),{prefix:w,suffix:k,scale:g,hasNumber:l}=H;return c=>{if(!l)return w+k;const s=g===1?c:c*g;return w+z.format(s)+k}}function X(H,U){const w=B(String(H)).map(I),k=w.map(t=>_(t,U)),g=0,l=w.length>1?1:-1,c=w.length>2?2:-1,s=w.length>3?3:-1,n=t=>{if(t==null||t==="")return"";if(typeof t!="number"||Number.isNaN(t)){const r=Number(t);if(Number.isNaN(r))return s===-1?String(t):(w[s].prefix+w[s].suffix).split("\0").join(String(t));t=r}return t===0&&c!==-1?k[c](0):t<0&&l!==-1?k[l](-t):k[g](t)};return n.spec={mask:H},{format:n,ooxml:W(String(H))}}function W(H){return H.trim()}}),Fe("packages/core/src/format/shorthand.js",function(e,K){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return W}});const Q=["currency","number","percent","date","boolean","text","relative"],$=/[#0?@;"\\]/,B=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function I(H){return typeof H!="string"||H===""||X(H)?!1:$.test(H)}function _(H){return typeof H!="string"||H===""||X(H)?!1:B.test(H)}function X(H){const U=H.indexOf(":"),z=U===-1?H:H.slice(0,U);return Q.includes(z)?z:null}function W(H){const U=X(H);if(!U)return null;const z=H.indexOf(":"),w=z===-1?"":H.slice(z+1),k=w===""?[]:w.split(":");switch(U){case"currency":{const g={type:"number",style:"currency",currency:k[0]||"USD"};return k[1]!==void 0&&k[1]!==""&&(g.decimals=Number(k[1])),g}case"number":{const g={type:"number",style:"decimal"};return k[0]!==void 0&&k[0]!==""&&(g.decimals=Number(k[0])),g}case"percent":{const g={type:"number",style:"percent"};return k[0]!==void 0&&k[0]!==""&&(g.decimals=Number(k[0])),g}case"date":return{type:"date",pattern:w||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const g=w.split("/"),l={type:"boolean",display:"text"};return g[0]!==void 0&&g[0]!==""&&(l.trueLabel=g[0]),g[1]!==void 0&&g[1]!==""&&(l.falseLabel=g[1]),g[2]!==void 0&&(l.nullLabel=g[2]),l}case"text":{const g={type:"text"};return k[0]&&(g.transform=k[0]),k[1]!==void 0&&k[1]!==""&&(g.truncate=Number(k[1])),g}default:return null}}}),Fe("packages/core/src/format/index.js",function(e,K){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return j}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.isObject,I=Q.warnOnce,_=K("packages/core/src/format/number.js"),X=_.compileNumber,W=K("packages/core/src/format/date.js"),H=W.compileDate,U=W.scanPattern,z=K("packages/core/src/format/boolean.js"),w=z.compileBoolean,k=K("packages/core/src/format/text.js"),g=k.compileText,l=K("packages/core/src/format/mask.js"),c=l.compileMask,s=K("packages/core/src/format/shorthand.js"),n=s.parseShorthand,t=s.looksLikeMask,r=s.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return _.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return W.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return W.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return W.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return W.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return z.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return z.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return k.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return l.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return l.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return l.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return s.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return s.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return s.looksLikeDatePattern}});const o=new Set(["decimal","currency","percent","unit"]),f=new Set(["type","locale"]),u={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"])},i=new Set(["number","date","boolean","text"]);function m(R,O){const x=R.type;if(x===void 0||i.has(x)||!o.has(String(x)))return;const C=O?`"${O}"`:"with no id";I(`format:unknown-style-key:${O||""}:${x}`,`column ${C} has format: { type: "${x}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${x}" instead?`)}function d(R,O,x){const C=u[O],P=x?`"${x}"`:"with no id";for(const F of R){if(f.has(F)||C.has(F))continue;const E=Object.keys(u).find(D=>D!==O&&u[D].has(F));E?I(`format:inapplicable:${x||""}:${F}`,`column ${P} has format key "${F}", which applies to a ${E} column, not the ${O} column it was applied to; it is ignored.`):I(`format:unknown:${x||""}:${F}`,`column ${P} has an unrecognised format key "${F}" for its ${O} format; it is ignored.`)}}function h(R){if(R.type==="number"||R.type==="date"||R.type==="boolean"||R.type==="text")return!0;const O=o.has(String(R.style));return!!(R.pattern||R.dateStyle||R.timeStyle||R.relative||R.timeZone||R.trueLabel||R.falseLabel||R.display||R.trueIcon||R.falseIcon||R.transform||R.truncate||R.emptyDisplay||O||R.currency||R.decimals!==void 0||R.minDecimals!==void 0||R.maxDecimals!==void 0||R.notation||R.negative||R.scale!==void 0||R.prefix||R.suffix||R.zeroDisplay!==void 0)}function a(R,O){if(R.type==="number"||R.type==="date"||R.type==="boolean"||R.type==="text")return R.type;if(R.pattern||R.dateStyle||R.timeStyle||R.relative||R.timeZone)return"date";if(R.trueLabel||R.falseLabel||R.display||R.trueIcon||R.falseIcon)return"boolean";if(R.transform||R.truncate||R.emptyDisplay)return"text";if(R.style||R.currency||R.decimals!==void 0||R.minDecimals!==void 0||R.maxDecimals!==void 0||R.notation||R.negative||R.scale!==void 0||R.prefix||R.suffix||R.zeroDisplay!==void 0)return"number";const x=O&&O.base;return x==="number"?"number":x==="date"||x==="dateString"?"date":x==="boolean"?"boolean":"text"}function p(R,O=null,x=void 0,C=void 0,P=void 0){if(R==null||R==="")return null;const F=B(R)?Object.keys(R):null;if(typeof R=="function"){const N=(M,A)=>String(R({...A||{},value:M,locale:x})??"");return N.ooxml=O&&O.excel||"General",N}if(typeof R=="string"){if(t(R)){const{format:M,ooxml:A}=c(R,x);return M.ooxml=A,M}const N=n(R)||(r(R)?{type:"date",pattern:R}:null);return N?p(N,O,x,C,P):(I(`format:${R}`,`unrecognised format string "${R}"; the value will be stringified`),null)}if(!B(R))return I("format:shape","format must be a spec object or a string; ignoring",R),null;if(O&&$(O.format)&&!h(R)||O&&$(O.format)&&Array.isArray(O.formatPatterns)&&R.type===void 0)return null;const E=a(R,O);E==="date"&&C&&R.timeZone===void 0&&(R={...R,timeZone:C}),m(R,P),d(F||Object.keys(R),E,P);let D;switch(E){case"number":D=X(R,x);break;case"date":D=H(R,x);break;case"boolean":D=w(R,x);break;default:D=g(R,x);break}return D.ooxml=j(R,E,x,O),D.kind=E,D}const b={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 j(R,O,x=void 0,C=null){if(O==="date"){if(R.pattern){let N="";for(const M of U(R.pattern))N+=M.token?b[M.token]??M.text:M.text;return N}return C&&C.excel||"yyyy-mm-dd"}if(O==="boolean")return"General";if(O==="text")return"@";if(R.notation==="compact"||R.notation==="scientific")return"General";const P=typeof R.decimals=="number"?R.decimals:typeof R.minDecimals=="number"?R.minDecimals:R.style==="currency"?2:0;let E=`${R.thousandsSeparator===!1?"":"#,#"}#0${P>0?`.${"0".repeat(P)}`:""}`,D="";return R.style==="currency"&&(D+=S(v(R.currency||"USD",x))),R.prefix&&(D+=S(R.prefix)),E=D+E,R.style==="percent"&&(E=`${E}%`),R.suffix&&(E+=S(R.suffix)),R.negative==="parentheses"?`${E};(${E})`:R.negative==="suffix"?`${E};${E}-`:E}function S(R){return`"${String(R).split('"').join("")}"`}const y=new Map;function v(R,O){const x=`${R}|${O||""}`;let C=y.get(x);if(C!==void 0)return C;C=R;try{const F=new Intl.NumberFormat(O,{style:"currency",currency:R}).formatToParts(0).find(E=>E.type==="currency");F&&(C=F.value)}catch{}return y.set(x,C),C}}),Fe("packages/core/src/columns/types/temporal.js",function(e,K){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return qe}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.isFunction,I=K("packages/core/src/format/date.js"),_=I.toDate,X=I.compilePattern,W=I.compileDate,H=I.toIsoDateTime,U=I.compareIso,z=864e5,w=Object.freeze({}),k=1e3,g=60*k,l=60*g,c=24*l,s=7*c,n=new WeakMap;function t(Ae,Ge){const Ze=Ae&&Ae.locale||"",tt=Ae&&Ae.column;if(!tt)return Ze?{locale:Ze}:w;const at=n.get(tt);if(at&&at.locale===Ze)return at.bag;const ft=tt.typeOptions||tt[Ge]||(r(tt.format)?tt.format:null),mt={...ft||w,locale:ft&&ft.locale||Ze||void 0};return n.set(tt,{locale:Ze,bag:mt}),mt}function r(Ae){return Ae!==null&&typeof Ae=="object"&&!Array.isArray(Ae)&&!(Ae instanceof Date)}function o(Ae,Ge){const Ze=Ae===null||Number.isNaN(Ae)?null:Ae,tt=Ge===null||Number.isNaN(Ge)?null:Ge;return Ze===null?tt===null?0:1:tt===null||Ze<tt?-1:Ze>tt?1:0}const f=/^(\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 i(Ae,Ge,Ze,tt){return!(Ae>=0&&Ae<=23)||!(Ge>=0&&Ge<=59)||!(Ze>=0&&Ze<=59)||!(tt>=0&&tt<=999)?null:Ae*l+Ge*g+Ze*k+tt}function m(Ae){if($(Ae))return null;const Ge=String(Ae).trim();if(Ge==="")return null;const Ze=u.exec(Ge);if(Ze){const Pt=Ze[1];if(Pt.length===5)return null;const Tt=Pt.length===3?1:2;return i(Number(Pt.slice(0,Tt)),Number(Pt.slice(Tt,Tt+2)),Number(Pt.slice(Tt+2,Tt+4)||0),0)}const tt=f.exec(Ge);if(!tt)return null;let at=Number(tt[1]);const ft=Number(tt[2]||0),mt=Number(tt[3]||0),Ot=tt[4]?Number(tt[4].padEnd(3,"0")):0,At=tt[5]?tt[5][0].toLowerCase():null;if(At){if(at<1||at>12)return null;at=at%12,At==="p"&&(at+=12)}return i(at,ft,mt,Ot)}function d(Ae){return $(Ae)||Ae===""?null:typeof Ae=="number"?Number.isFinite(Ae)?(Ae%c+c)%c:null:Ae instanceof Date?Number.isNaN(Ae.getTime())?null:Ae.getHours()*l+Ae.getMinutes()*g+Ae.getSeconds()*k+Ae.getMilliseconds():m(Ae)}const h=new Map;function a(Ae){const Ge=Ae.pattern||"",Ze=Ae.timeStyle||(Ae.seconds?"medium":"short"),tt=`${Ae.locale||""}|${Ge}|${Ze}`;let at=h.get(tt);if(at)return at;if(Ge)at=X(Ge,Ae.locale||void 0,"UTC");else{const ft=new Intl.DateTimeFormat(Ae.locale||void 0,{timeStyle:Ze,timeZone:"UTC"});at=mt=>ft.format(mt)}return h.set(tt,at),at}function p(Ae,Ge){const Ze=Ge||w;if(Ae==null||typeof Ae!="number"||!Number.isFinite(Ae))return Ze.nullDisplay??"";const tt=(Ae%c+c)%c;return a(Ze)(new Date(tt))}function b(Ae){return Ae instanceof Date?!Number.isNaN(Ae.getTime()):typeof Ae=="number"?Number.isFinite(Ae)&&Ae>=0&&Ae<c:typeof Ae!="string"||!Ae.includes(":")?!1:m(Ae)!==null}function j(Ae){const Ge=d(Ae);return Ge==null?"":p(Ge,{pattern:Ge%k===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const S=new Map;function y(Ae){const Ge=Ae||"";let Ze=S.get(Ge);return Ze||(Ze=new Intl.DateTimeFormat("en-GB",{timeZone:Ae||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),S.set(Ge,Ze)),Ze}function v(Ae,Ge){const Ze={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const tt of y(Ge).formatToParts(new Date(Ae)))tt.type==="year"?Ze.year=Number(tt.value):tt.type==="month"?Ze.month=Number(tt.value):tt.type==="day"?Ze.day=Number(tt.value):tt.type==="hour"?Ze.hour=Number(tt.value)%24:tt.type==="minute"?Ze.minute=Number(tt.value):tt.type==="second"&&(Ze.second=Number(tt.value));return Ze}function R(Ae,Ge){const Ze=v(Ae,Ge);return Date.UTC(Ze.year,Ze.month-1,Ze.day,Ze.hour,Ze.minute,Ze.second,0)-Math.floor(Ae/1e3)*1e3}function O(Ae,Ge){const Ze=Ae.hour||0,tt=Ae.minute||0,at=Ae.second||0,ft=Ae.ms||0;if(!Ge)return new Date(Ae.year,Ae.month-1,Ae.day,Ze,tt,at,ft).getTime();const mt=Date.UTC(Ae.year,Ae.month-1,Ae.day,Ze,tt,at,ft);let Ot=mt-R(mt,Ge);return Ot=mt-R(Ot,Ge),Ot}const x=/(?:Z|[+-]\d{2}:?\d{2})$/i,C=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function P(Ae,Ge){if($(Ae))return null;const Ze=String(Ae).trim();if(Ze==="")return null;const tt=Ge&&Ge.timeZone||void 0;if(!x.test(Ze)){const at=C.exec(Ze);if(at){const ft=(at[4]||"").trim(),mt=ft===""?0:m(ft);if(mt===null)return null;const Ot=O({year:Number(at[1]),month:Number(at[2]),day:Number(at[3]),hour:Math.floor(mt/l),minute:Math.floor(mt/g)%60,second:Math.floor(mt/k)%60,ms:mt%k},tt);return Number.isNaN(Ot)?null:new Date(Ot)}}return _(Ze)}function F(Ae){if(typeof Ae=="number")return Number.isFinite(Ae)?Ae:null;const Ge=_(Ae);return Ge?Ge.getTime():null}const E=new Map;function D(Ae){const Ge=[Ae.locale||"",Ae.pattern||"",Ae.dateStyle||"",Ae.timeStyle||"",Ae.timeZone||"",Ae.seconds?"1":""].join("|");let Ze=E.get(Ge);if(Ze)return Ze;const tt=Ae.pattern?{type:"date",pattern:Ae.pattern,timeZone:Ae.timeZone}:{type:"date",dateStyle:Ae.dateStyle||"medium",timeStyle:Ae.timeStyle||(Ae.seconds?"medium":"short"),timeZone:Ae.timeZone};return Ze=W(tt,Ae.locale||void 0),E.set(Ge,Ze),Ze}function N(Ae,Ge){const Ze=Ge||w,tt=F(Ae);return tt==null?Ze.nullDisplay??"":D(Ze)(tt)}function M(Ae){return Ae instanceof Date?!Number.isNaN(Ae.getTime()):typeof Ae!="string"||!C.test(Ae.trim())?!1:P(Ae)!==null}const A=Object.freeze([{key:"w",ms:s,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:c,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:l,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:g,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:k,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"]}]),L=new Map;for(const Ae of A)for(const Ge of Ae.names)L.set(Ge,Ae);const G=Object.freeze(A.filter(Ae=>Ae.key!=="w")),q=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,Y=/^\d+(?:\.\d+)?$/,J=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function te(Ae){const Ge=Ae&&Ae.defaultUnit?L.get(String(Ae.defaultUnit).toLowerCase()):null;return Ge?Ge.ms:g}function ne(Ae){return(Ae&&Ae.defaultUnit?L.get(String(Ae.defaultUnit).toLowerCase()):null)||L.get("m")}function oe(Ae,Ge){if($(Ae))return null;let Ze=String(Ae).trim().toLowerCase();if(Ze==="")return null;let tt=1;if(Ze[0]==="-"?(tt=-1,Ze=Ze.slice(1).trim()):Ze[0]==="+"&&(Ze=Ze.slice(1).trim()),Ze==="")return null;const at=J.exec(Ze);if(at){const At=at[3]!==void 0,Pt=Number(at[1])*l+Number(at[2])*g+(At?Number(at[3])*k:0)+(at[4]?Number(at[4].padEnd(3,"0")):0);return tt*Pt}if(Y.test(Ze))return Math.round(tt*Number(Ze)*te(Ge||w));let ft=Ze,mt=0,Ot=0;for(;ft!=="";){const At=q.exec(ft);if(!At)return null;const Pt=L.get(At[2]);if(!Pt)return null;mt+=Number(At[1])*Pt.ms,ft=ft.slice(At[0].length),Ot++}return Ot===0?null:Math.round(tt*mt)}function le(Ae){return $(Ae)||Ae===""?null:typeof Ae=="number"?Number.isFinite(Ae)?Ae:null:oe(Ae)}const ae=new Map;function se(Ae,Ge,Ze){const tt=`${Ze||""}|${Ge.intl}`;let at=ae.get(tt);if(at===void 0){try{at=new Intl.NumberFormat(Ze||void 0,{style:"unit",unit:Ge.intl,unitDisplay:"long"})}catch{at=null}ae.set(tt,at)}return at?at.format(Ae):`${Ae} ${Ae===1?Ge.long[0]:Ge.long[1]}`}function ee(Ae,Ge){return String(Ae).padStart(Ge,"0")}function ie(Ae,Ge){const Ze=Ge||w;if(Ae==null||typeof Ae!="number"||!Number.isFinite(Ae))return Ze.nullDisplay??"";const tt=Ze.style||"short",at=Ae<0;let ft=Math.round(Math.abs(Ae));const mt=at?"-":"";if(ft===0&&Ze.zeroDisplay!=null)return Ze.zeroDisplay;if(tt==="clock"){const Tt=Math.floor(ft/l),It=Math.floor(ft/g)%60,Bt=Math.floor(ft/k)%60;return`${mt}${ee(Tt,2)}:${ee(It,2)}:${ee(Bt,2)}`}if(ft===0){const Tt=ne(Ze);return tt==="long"?se(0,Tt,Ze.locale):`0${Tt.key}`}const Ot=Ze.weeks===!0?A:G,At=typeof Ze.maxUnits=="number"&&Ze.maxUnits>0?Ze.maxUnits:Ze.maxUnits===void 0?2:1/0,Pt=[];for(const Tt of Ot){if(Pt.length>=At)break;const It=Math.floor(ft/Tt.ms);It!==0&&(ft-=It*Tt.ms,Pt.push(tt==="long"?se(It,Tt,Ze.locale):`${It}${Tt.key}`))}return mt+Pt.join(" ")}function ce(Ae){if(typeof Ae!="string")return!1;const Ge=Ae.trim();return Ge===""||J.test(Ge)||!/[a-z]/i.test(Ge)?!1:oe(Ge)!==null}const he=Date.UTC(1899,11,30),me=new Map;function Ee(Ae,Ge){const Ze=Ae||"";let tt=me.get(Ze);tt||(tt=new Intl.DateTimeFormat("en-GB",{timeZone:Ae||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),me.set(Ze,tt));const at=typeof Ge=="number"?Ge:Date.now();for(const ft of tt.formatToParts(new Date(at)))if(ft.type==="timeZoneName")return ft.value;return""}function ge(Ae){if(Ae)return Ae;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function je(Ae,Ge){const Ze=ge(Ae),tt=Ee(Ae,Ge);return tt?`${Ze} (${tt})`:Ze}function pe(Ae,Ge){if(Ae&&Ae.timeZone)return Ae.timeZone;const Ze=Ge&&Ge.grid;return(Ze&&B(Ze.get)?Ze.get("timeZone"):void 0)||void 0}function we(Ae,Ge){const Ze=Ge||w,tt=F(Ae);if(tt==null)return Ze.nullDisplay??"";const at=D(Ze)(tt);if(!Ze.showOrigin)return at;const ft=Ze.originZone;return ft?ft===(Ze.timeZone||ge(Ze.timeZone))?at:`${at} (${je(ft,tt)})`:`${at} (no origin recorded)`}function ye(Ae,Ge,Ze,tt){if(Ge==="instant"||!Ge)return Ae;const at=v(Ae,Ze);if(Ge==="month")return O({year:at.year,month:at.month,day:1},Ze);if(Ge==="week"){const ft=tt>=1&&tt<=7?tt:1,Ot=((new Date(Date.UTC(at.year,at.month-1,at.day)).getUTCDay()+6)%7+1-ft+7)%7,At=new Date(Date.UTC(at.year,at.month-1,at.day-Ot));return O({year:At.getUTCFullYear(),month:At.getUTCMonth()+1,day:At.getUTCDate()},Ze)}return O({year:at.year,month:at.month,day:at.day},Ze)}function Ne(Ae,Ge){const Ze=Ae&&Ae.group,tt=Ze&&Ze.granularity||"day";if(tt==="instant")return null;const at=Ze&&Ze.weekStart;return ft=>typeof ft=="number"?ye(ft,tt,Ge,at):ft}const $e={time:{base:"number",storage:"float64",matches:b,format:Ae=>p(d(Ae.value),t(Ae,"time")),parse:Ae=>m(Ae.text),compare:(Ae,Ge)=>o(d(Ae),d(Ge)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Ae=>{const Ge=d(Ae);return Ge===null?null:Ge/z},toStorage:Ae=>d(Ae),toClipboard:j,fromClipboard:m},datetime:{base:"dateString",storage:"dictionary",matches:M,format:Ae=>N(Ae.value,t(Ae,"datetime")),parse:Ae=>H(P(Ae.text,t(Ae,"datetime"))??Ae.text),compare:U,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Ae,Ge)=>H(Ae,Ge&&Ge.timeZone),toClipboard:Ae=>$(Ae)?"":String(Ae),fromClipboard:Ae=>H(Ae)},duration:{base:"number",storage:"float64",matches:ce,format:Ae=>ie(le(Ae.value),t(Ae,"duration")),parse:Ae=>oe(Ae.text,t(Ae,"duration")),compare:(Ae,Ge)=>o(le(Ae),le(Ge)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Ae=>{const Ge=le(Ae);return Ge===null?null:Ge/z},toStorage:Ae=>le(Ae),toClipboard:Ae=>ie(le(Ae),{style:"short",maxUnits:-1}),fromClipboard:Ae=>oe(Ae)},timestamp:{base:"number",storage:"float64",format:Ae=>{const Ge=t(Ae,"timestamp");return we(Ae.value,{...Ge,timeZone:pe(Ge,Ae)})},parse:Ae=>{const Ge=t(Ae,"timestamp"),Ze=P(Ae.text,{timeZone:pe(Ge,Ae)});return Ze?Ze.getTime():null},compare:(Ae,Ge)=>o(F(Ae),F(Ge)),groupProjector:(Ae,Ge)=>Ne(Ae,Ge),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Ae,Ge)=>{const Ze=F(Ae);if(Ze==null)return null;const tt=v(Ze,Ge&&Ge.timeZone||void 0);return(Date.UTC(tt.year,tt.month-1,tt.day,tt.hour,tt.minute,tt.second)-he)/z},toStorage:Ae=>F(Ae),toClipboard:Ae=>{const Ge=F(Ae);return Ge==null?"":new Date(Ge).toISOString()},fromClipboard:Ae=>F(Ae)}},Ve=["datetime","time","duration"],qe=$e}),Fe("packages/core/src/columns/types/network.js",function(e,K){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return P}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.Lru,I=4294967295,_=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function X(F){if($(F))return null;if(typeof F=="string")return W(F);const E=Number(F);return Number.isFinite(E)?E<0?E<-2147483648?null:E>>>0:E>I?null:Math.trunc(E)>>>0:null}function W(F){if($(F))return null;const E=String(F).trim();if(E==="")return null;const D=_.exec(E);if(!D)return null;let N=0;for(let M=1;M<=4;M++){const A=D[M];if(A.length>1&&A.charCodeAt(0)===48)return null;const L=Number(A);if(L>255)return null;N=N*256+L}return N}function H(F){const E=X(F);return E===null?"":`${E>>>24&255}.${E>>>16&255}.${E>>>8&255}.${E&255}`}function U(F){return typeof F=="string"&&W(F)!==null}function z(F,E){const D=X(F),N=X(E);return D===null?N===null?0:1:N===null||D<N?-1:D>N?1:0}const w=64,k=I*w+32,g=/^(?:0|[1-9]\d?)$/;function l(F,E){return F*w+E}function c(F){if($(F))return null;if(typeof F=="string"){const N=s(F);return N===null?null:c(N)}if(typeof F=="object"){const N=X(F.address),M=Number(F.prefix);return N===null||!Number.isInteger(M)||M<0||M>32?null:{address:N,prefix:M}}const E=Number(F);if(!Number.isInteger(E)||E<0||E>k)return null;const D=E%w;return D>32?null:{address:(E-D)/w,prefix:D}}function s(F){if($(F))return null;const E=String(F).trim();if(E==="")return null;const D=E.indexOf("/");if(D<0)return null;const N=W(E.slice(0,D));if(N===null)return null;const M=E.slice(D+1).trim();if(!g.test(M))return null;const A=Number(M);return A>32?null:l(N,A)}function n(F){const E=c(F);return E?`${H(E.address)}/${E.prefix}`:""}function t(F){return typeof F=="string"&&s(F)!==null}function r(F,E){const D=c(F),N=c(E);return D?N?D.address!==N.address?D.address<N.address?-1:1:D.prefix-N.prefix:-1:N?1:0}function o(F){return F===0?0:4294967295<<32-F>>>0}function f(F){const E=c(F);return E?(E.address&o(E.prefix))>>>0:null}function u(F){const E=c(F);return E?(E.address&o(E.prefix)|~o(E.prefix)>>>0)>>>0:null}function i(F){const E=c(F);return E?2**(32-E.prefix):null}function m(F){const E=c(F);return E?E.prefix===32?1:E.prefix===31?2:2**(32-E.prefix)-2:null}function d(F,E){const D=c(F);if(!D)return!1;const N=X(E);if(N===null)return!1;const M=o(D.prefix);return(N&M)>>>0===(D.address&M)>>>0}function h(F,E){const D=f(F),N=f(E);return D===null||N===null?!1:D<=u(E)&&N<=u(F)}const a=/^[0-9a-fA-F]{1,4}$/,p=new B(512);function b(F){if($(F))return null;let E=String(F).trim();if(E==="")return null;const D=E.indexOf("%");if(D>=0&&(E=E.slice(0,D)),E==="")return null;if(E.indexOf(".")>=0){const q=E.lastIndexOf(":");if(q<0)return null;const Y=W(E.slice(q+1));if(Y===null)return null;E=`${E.slice(0,q+1)}${(Y>>>16&65535).toString(16)}:${(Y&65535).toString(16)}`}const N=E.split("::");if(N.length>2)return null;const M=j(N[0]);if(M===null)return null;if(N.length===1)return M.length===8?M:null;const A=j(N[1]);if(A===null)return null;const L=8-M.length-A.length;if(L<1)return null;const G=M.slice();for(let q=0;q<L;q++)G.push(0);for(const q of A)G.push(q);return G}function j(F){if(F==="")return[];const E=[];for(const D of F.split(":")){if(!a.test(D))return null;E.push(parseInt(D,16))}return E}function S(F){if(typeof F!="string")return b(F);if(p.has(F))return p.get(F);const E=b(F);return p.set(F,E),E}function y(F){if(F[0]===0&&F[1]===0&&F[2]===0&&F[3]===0&&F[4]===0&&F[5]===65535)return`::ffff:${H((F[6]<<16|F[7])>>>0)}`;let E=-1,D=0,N=-1,M=0;for(let G=0;G<8;G++)F[G]===0?(N<0?(N=G,M=1):M++,M>D&&(D=M,E=N)):(N=-1,M=0);if(D<2)return F.map(G=>G.toString(16)).join(":");const A=F.slice(0,E).map(G=>G.toString(16)).join(":"),L=F.slice(E+D).map(G=>G.toString(16)).join(":");return`${A}::${L}`}function v(F){const E=b(F);return E===null?null:y(E)}function R(F){return v(F)??""}function O(F){return typeof F=="string"&&F.indexOf(":")>=0&&b(F)!==null}function x(F,E){const D=S(F),N=S(E);if(!D)return N?1:0;if(!N)return-1;for(let M=0;M<8;M++)if(D[M]!==N[M])return D[M]<N[M]?-1:1;return 0}const C=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:U,parse:F=>W(F.text),compare:z,format:F=>H(F.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:F=>X(F),toClipboard:F=>H(F),fromClipboard:F=>W(F)},cidr:{base:"number",storage:"float64",matches:t,parse:F=>s(F.text),compare:r,format:F=>n(F.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:F=>{const E=c(F);return E===null?null:l(E.address,E.prefix)},toClipboard:F=>n(F),fromClipboard:F=>s(F)},ipv6:{base:"text",storage:"dictionary",matches:O,parse:F=>v(F.text),compare:x,format:F=>R(F.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:F=>v(F),toClipboard:F=>R(F),fromClipboard:F=>v(F)}}),P=C}),Fe("packages/core/src/i18n/catalogue.js",function(e,K){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return I}});const $=K("packages/core/src/registry/free-tier-notice.js").FREE_TIER_NOTICE,B=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","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.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.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"},"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.workload.title":"Resource workload","gantt.workload.resource":"Resource","gantt.workload.total":"Total","gantt.workload.unassigned":"Unassigned","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.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.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","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":$,"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.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","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"}),I=Object.freeze(Object.keys(B))}),Fe("packages/core/src/i18n/format.js",function(e,K){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return k}});const $=K("packages/core/src/internal/util.js").isFunction,B=/\{(\w+)\}/g,I=new Map,_=new Map;function X(g){const l=g||"";if(I.has(l))return I.get(l);let c=null;try{c=new Intl.PluralRules(g||void 0)}catch{c=null}return I.set(l,c),c}function W(g,l,c="conjunction"){const s=Array.isArray(g)?g.filter(r=>r!=null&&r!==""):[];if(s.length===0)return"";if(s.length===1)return String(s[0]);const n=`${l||""}|${c}`;let t=_.get(n);if(t===void 0){try{t=new Intl.ListFormat(l||void 0,{style:"long",type:c})}catch{t=null}_.set(n,t)}return t?t.format(s.map(String)):s.map(String).join(", ")}function H(g,l){return g==null?"":typeof g=="number"?Number.isFinite(g)?g.toLocaleString(l||void 0,{maximumFractionDigits:20}):"":String(g)}function U(g,l,c){if(typeof g=="string")return g;if(!g||typeof g!="object")return"";const s=l&&typeof l.count=="number"?l.count:null;if(s===null)return g.other??"";const n=X(c),t=n?n.select(s):s===1?"one":"other";return g[t]??g.other??""}function z(g,l={},c){const s=U(g,l,c);return s?s.replace(B,(n,t)=>Object.prototype.hasOwnProperty.call(l,t)?H(l[t],c):n):""}function w(g,l,c="en-GB"){return typeof g=="string"&&g?g:typeof l=="string"&&l?l:c}function k(g,l){const c=g?g[l]:void 0;return c==null||$(c)?l:c}}),Fe("packages/core/src/i18n/index.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return s}});const Q=K("packages/core/src/i18n/catalogue.js"),$=Q.EN_GB,B=Q.MESSAGE_KEYS,I=K("packages/core/src/i18n/format.js"),_=I.formatMessage,X=I.formatList,W=I.lookup,H=I.resolveLocale,U=K("packages/core/src/internal/util.js"),z=U.isFunction,w=U.warnOnce;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return Q.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return Q.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return I.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return I.resolveLocale}});const k="en-GB";class g{#e=k;#t=$;constructor(t={}){this.configure(t)}configure(t={}){this.#e=H(t.locale,t.declared,k);const r=t.messages;if(!r||typeof r!="object"){this.#t=$;return}const o=Object.keys(r).filter(f=>!(f in $));o.length&&w(`i18n:unknown:${o[0]}`,`message keys not in the catalogue and so ignored: ${o.slice(0,5).join(", ")}${o.length>5?`, and ${o.length-5} more`:""}`),this.#t={...$,...r}}get locale(){return this.#e}t(t,r){return _(W(this.#t,t),r||{},this.#e)}list(t,r){return X(t,this.#e,r)}number(t,r){const o=Number(t);return Number.isFinite(o)?o.toLocaleString(this.#e,r||{maximumFractionDigits:20}):""}}const l=new g;function c(n){return n instanceof g?n:new g(n||{})}function s(n){const t=n&&typeof n=="object"?n:{},r=B.filter(f=>{const u=t[f];return u==null||u===""||z(u)}),o=Object.keys(t).filter(f=>!(f in $));return{missing:r,unknown:o}}}),Fe("packages/core/src/columns/types/structured.js",function(e,K){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.isObject,_=K("packages/core/src/i18n/index.js").defaultMessages,X=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function W(n,t){const r=t||{},o=r.emptyDisplay??X.emptyDisplay;if($(n)||n==="")return o;const u=[...typeof r.char=="string"&&r.char!==""?r.char:X.char][0]||X.char,i=r.fixedLength??X.fixedLength,m=Number.isFinite(r.length)&&Number(r.length)>0?Math.floor(Number(r.length)):X.length,d=typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"||typeof n=="bigint"?String(n):null;let h=0;if(d!==null){const a=Number.isFinite(r.lastVisible)?Math.floor(Number(r.lastVisible)):X.lastVisible,p=[...d];if(h=a>0&&a<p.length?a:0,h>0){const b=p.slice(p.length-h).join(""),j=Math.max(1,(i?m:p.length)-h);return u.repeat(j)+b}return u.repeat(i?m:Math.max(1,p.length))}return u.repeat(m)}const H=48;function U(n){try{const t=JSON.stringify(n);return t===void 0?null:t}catch{return null}}function z(n,t){if($(n))return"";const r=Number.isFinite(t&&t.inlineLimit)?Number(t.inlineLimit):H;if(typeof n=="string")return n.length>r?`${n.slice(0,r-1)}…`:n;if(typeof n!="object")return String(n);const o=U(n);if(o!==null&&o.length<=r)return o;if(Array.isArray(n)){const u=n.length;return`[${_.t("count.items",{count:u})}]`}const f=Object.keys(n).length;return`{${_.t("count.keys",{count:f})}}`}function w(n,t){if(n==null)return"null";const r=typeof n;if(r==="number"||r==="boolean"||r==="bigint")return String(n);if(r==="string")return JSON.stringify(n);if(r!=="object")return JSON.stringify(String(n));const o=t||new WeakSet;return o.has(n)?'"[circular]"':(o.add(n),n instanceof Date?JSON.stringify(n.toISOString()):Array.isArray(n)?`[${n.map(i=>w(i,o)).join(",")}]`:`{${Object.keys(n).sort().map(i=>`${JSON.stringify(i)}:${w(n[i],o)}`).join(",")}}`)}function k(n,t){if($(n))return $(t)?0:1;if($(t))return-1;const r=w(n),o=w(t);return r<o?-1:r>o?1:0}function g(n){if($(n))return null;const t=String(n);if(t.trim()==="")return null;try{return JSON.parse(t)}catch{return t}}function l(n){const t=n&&n.cell&&n.cell.props;return B(t)?t:{}}const c=Object.freeze({json:{base:"object",storage:"object",format:n=>z(n&&n.value,l(n&&n.column)),parse:n=>g(n&&n.text),compare:k,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:n=>{if($(n))return"";if(typeof n=="string")return n;try{const t=JSON.stringify(n,null,2);return t===void 0?String(n):t}catch{return String(n)}},fromClipboard:n=>g(n)},secret:{base:"text",storage:"object",format:n=>W(n&&n.value,l(n&&n.column)),parse:n=>{const t=n&&n.text;return $(t)||String(t)===""?null:String(t)},compare:(n,t)=>{const r=$(n)||n==="",o=$(t)||t==="";return r===o?0:r?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:n=>W(n),fromClipboard:n=>$(n)||String(n)===""?null:String(n)}}),s=c}),Fe("packages/core/src/columns/types/unit.js",function(e,K){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return N}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.warnOnce;function I(M,A,L,G){return Object.freeze({symbol:M,factor:A,aliases:Object.freeze(L||[]),binary:!!(G&&G.binary),prefix:G&&G.prefix||null,auto:!(G&&G.auto===!1)})}function _(M,A,L,G){return I(M,A,L,G)}const X=Object.freeze({data:Object.freeze([I("B",1,["byte","bytes"]),I("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),I("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),I("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),I("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),I("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),I("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),I("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),I("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),I("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([I("bps",1,["bit","bits","bit/s","b/s"]),I("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),I("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),I("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),I("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([I("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),I("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),I("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),I("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),I("in",.0254,["inch","inches"],{auto:!1}),I("ft",.3048,["foot","feet"],{auto:!1}),I("yd",.9144,["yard","yards"],{auto:!1}),I("m",1,["metre","metres","meter","meters"]),I("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),I("mi",1609.344,["mile","miles"],{auto:!1}),I("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([I("mg",.001,["milligram","milligrams"]),I("g",1,["gram","grams"]),I("oz",28.349523125,["ounce","ounces"],{auto:!1}),I("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),I("kg",1e3,["kilogram","kilograms"]),I("st",6350.29318,["stone"],{auto:!1}),I("t",1e6,["tonne","tonnes","ton"],{auto:!1}),I("ton (US)",907184.74,["ton","shortton"],{auto:!1}),I("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([I("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),I("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),I("ms",.001,["msec","msecs","millisecond","milliseconds"]),I("s",1,["sec","secs","second","seconds"]),I("m",60,["min","mins","minute","minutes"]),I("h",3600,["hr","hrs","hour","hours"]),I("d",86400,["day","days"])]),speed:Object.freeze([I("mm/s",.001,["millimetre/s","millimeter/s"]),I("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),I("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),I("mph",.44704,["mile/h","miles/h"],{auto:!1}),I("kn",1852/3600,["knot","knots"],{auto:!1}),I("m/s",1,["metre/s","meter/s","mps"]),I("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([I("mm/s²",.001,["mm/s2"]),I("ft/s²",.3048,["ft/s2"],{auto:!1}),I("m/s²",1,["m/s2","metre/s2","meter/s2"]),I("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([I("mm²",1e-6,["mm2"]),I("cm²",1e-4,["cm2"]),I("in²",64516e-8,["in2","sqin"],{auto:!1}),I("ft²",.09290304,["ft2","sqft"],{auto:!1}),I("yd²",.83612736,["yd2","sqyd"],{auto:!1}),I("m²",1,["m2","sqm"]),I("ha",1e4,["hectare","hectares"],{auto:!1}),I("ac",4046.8564224,["acre","acres"],{auto:!1}),I("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([I("µL",1e-6,["ul","microlitre","microliter"]),I("mL",.001,["millilitre","milliliter"]),I("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),I("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),I("L",1,["litre","litres","liter","liters"]),I("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),I("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),I("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),I("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([I("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),I("J",1,["joule","joules"]),I("cal",4.184,["calorie","calories"],{auto:!1}),I("kJ",1e3,["kilojoule","kilojoules"]),I("BTU",1055.05585262,["btu"],{auto:!1}),I("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),I("MJ",1e6,["megajoule","megajoules"]),I("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),I("GJ",1e9,["gigajoule","gigajoules"]),I("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([I("mW",.001,["milliwatt","milliwatts"]),I("W",1,["watt","watts"]),I("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),I("kW",1e3,["kilowatt","kilowatts"]),I("hp",745.6998715822702,["horsepower"],{auto:!1}),I("MW",1e6,["megawatt","megawatts"]),I("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([I("mN",.001,["millinewton","millinewtons"]),I("N",1,["newton","newtons"]),I("lbf",4.4482216152605,["poundforce"],{auto:!1}),I("kgf",9.80665,["kilogramforce"],{auto:!1}),I("kN",1e3,["kilonewton","kilonewtons"]),I("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([I("Pa",1,["pascal","pascals"]),I("mbar",100,["millibar"],{auto:!1}),I("inH₂O",249.0889,["inh2o"],{auto:!1}),I("mmHg",133.322387415,["torr"],{auto:!1}),I("kPa",1e3,["kilopascal","kilopascals"]),I("inHg",3386.388640341,["inhg"],{auto:!1}),I("psi",6894.757293168361,["lbf/in2"],{auto:!1}),I("bar",1e5,[],{auto:!1}),I("atm",101325,["atmosphere","atmospheres"],{auto:!1}),I("MPa",1e6,["megapascal","megapascals"]),I("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([I("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),I("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),I("kN·m",1e3,["knm","kn.m"],{auto:!1}),I("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([I("kg/m³",1,["kg/m3"]),I("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),I("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),I("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([I("L/min",1/6e4,["lpm","l/min"],{auto:!1}),I("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),I("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),I("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),I("cfm",.0004719474432,["ft3/min"],{auto:!1}),I("L/s",.001,["lps","l/s"],{auto:!1}),I("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([I("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),I("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),I("mrad",.001,["milliradian","milliradians"],{auto:!1}),I("mil",Math.PI/3200,["nato-mil"],{auto:!1}),I("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),I("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),I("rad",1,["radian","radians"]),I("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([I("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),I("rad/s",1,["radps","radians/s"]),I("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),I("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([I("ppt",1e-12,["partspertrillion"],{auto:!1}),I("ppb",1e-9,["partsperbillion"]),I("ppm",1e-6,["partspermillion"]),I("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),I("‰",.001,["permille","permil"],{auto:!1}),I("%",.01,["pct","percent"]),I("×",1,["x","ratio","times"])]),molarity:Object.freeze([I("pM",1e-12,["picomolar","picomolarity"]),I("nM",1e-9,["nanomolar","nanomolarity"]),I("µM",1e-6,["um-molar","micromolar","micromolarity"]),I("mM",.001,["millimolar","millimolarity"]),I("M",1,["molar","mol/l","mol/L","molarity"]),I("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([I("mg/s",1e-6,["milligrams/s"]),I("g/s",.001,["grams/s"]),I("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),I("kg/s",1,["kilograms/s","kgps"]),I("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),I("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),I("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([I("µPa·s",1e-6,["upas","micropascalsecond"]),I("cP",.001,["centipoise"],{auto:!1}),I("mPa·s",.001,["mpas","millipascalsecond"]),I("P",.1,["poise"],{auto:!1}),I("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([I("cSt",1e-6,["centistokes","centistoke"]),I("mm²/s",1e-6,["mm2/s"],{auto:!1}),I("St",1e-4,["stokes","stoke"],{auto:!1}),I("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([I("mW/(m·K)",.001,["mw/mk"]),I("W/(m·K)",1,["w/mk","wmk"]),I("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),I("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([I("J/(kg·K)",1,["j/kgk","jkgk"]),I("kJ/(kg·K)",1e3,["kj/kgk"]),I("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([I("nSv/h",1e-9,["nsvh"]),I("µSv/h",1e-6,["usv/h","usvh"]),I("mSv/h",.001,["msvh"]),I("Sv/h",1,["svh"]),I("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),W=Symbol("ambiguous"),H=new Map,U=new Map;function z(M,A){const L=String(M||"").trim();if(!L)throw new Error("[lattice] a unit system needs a name");if(X[L]||U.has(L))throw new Error(`[lattice] unit system "${L}" already exists`);const G=[...A||[]];if(!G.length)throw new Error(`[lattice] unit system "${L}" has no units`);if(!G.some(Y=>Y.factor===1))throw new Error(`[lattice] unit system "${L}" has no base unit (none with factor 1)`);const q=new Set;for(const Y of G){if(q.has(Y.symbol))throw new Error(`[lattice] unit system "${L}" declares "${Y.symbol}" twice`);q.add(Y.symbol)}return U.set(L,Object.freeze(G)),H.delete(L),L}function w(){return[...Object.keys(X),...U.keys()]}function k(M){const A=g(M);return A?A.units:[]}function g(M){const A=String(M||""),L=H.get(A);if(L!==void 0)return L;const G=X[A]||U.get(A);if(!G)return H.set(A,null),null;const q=Object.freeze([...G].sort((oe,le)=>oe.factor-le.factor)),Y=new Map,J=new Map,te=(oe,le)=>{const ae=Y.get(oe);ae===void 0?Y.set(oe,le):ae!==le&&Y.set(oe,W)};for(const oe of q){te(oe.symbol.toLowerCase(),oe);for(const le of oe.aliases)te(le.toLowerCase(),oe);if(oe.prefix){const le=J.get(oe.prefix)||[];le.push(oe),J.set(oe.prefix,le)}}const ne={units:q,byToken:Y,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 H.set(A,ne),ne}function l(M,A){return A&&M.binary||M.decimal}function c(M,A){const L=g(M);if(!L||$(A))return null;const G=L.units.find(Y=>Y.symbol===String(A));if(G)return G;const q=L.byToken.get(String(A).trim().toLowerCase());return q&&q!==W?q:null}const s=new WeakMap;function n(M){const A=M||{};if(typeof A=="object"&&A!==null){const Y=s.get(A);if(Y!==void 0)return Y}const L=A.system||"data",G=g(L);let q=null;if(!G)B(`unit:system:${L}`,`unknown unit system "${L}"; known systems are ${w().join(", ")}`);else{let Y=A.unit?c(L,A.unit):null;Y||(A.unit&&B(`unit:unit:${L}:${A.unit}`,`unknown unit "${A.unit}" in system "${L}"; falling back to ${G.units[0].symbol}`),Y=G.units.find(J=>J.factor===1)||G.units[0]),q={index:G,base:Y,binary:A.binary===!0}}return typeof A=="object"&&A!==null&&s.set(A,q),q}const t=new WeakMap;function r(M,A){if(!M||!A||!Array.isArray(M.compound)||M.compound.length===0)return null;const L=t.get(M);if(L!==void 0)return L;const G=new Set,q=[];for(const J of M.compound){const te=c(M.system||"data",J);if(!te){B(`unit:compound:${M.system}:${J}`,`unknown compound unit "${J}" in system "${M.system||"data"}"; ignoring it`);continue}G.has(te.symbol)||(G.add(te.symbol),q.push(te))}q.sort((J,te)=>te.factor-J.factor);const Y=q.length>=2?q:null;return t.set(M,Y),Y}function o(M,A,L){return A===L||A.factor===L.factor?M:M*A.factor/L.factor}const f=new Map;function u(M){const A=M||"",L=f.get(A);if(L)return L;const G={group:",",decimal:"."};try{for(const q of new Intl.NumberFormat(M||void 0).formatToParts(12345.6))q.type==="group"?G.group=q.value:q.type==="decimal"&&(G.decimal=q.value)}catch{}return f.set(A,G),G}const i=/[\s   ]/g,m=/^[+-]?[\d   '’ .,]*(?:[eE][+-]?\d+)?/,d=/^[^\d+\-(.,\s]+\s*/,h=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function a(M,A){const{group:L,decimal:G}=u(A);let q=String(M).replace(i,"");if(q==="")return null;const Y=G?q.indexOf(G):-1;if(L&&L!==G){if(Y>=0&&q.indexOf(L,Y+G.length)>=0)return null;q=q.split(L).join("")}if(G&&G!=="."&&(q=q.split(G).join(".")),!h.test(q))return null;const J=Number(q);return Number.isFinite(J)?J:null}function p(M,A,L){const G=String(M).trim().replace(/\.$/,"");if(G==="")return null;const q=A.units.find(le=>le.symbol===G);if(q)return q;const Y=G.toLowerCase(),J=A.byToken.get(Y);if(J===W)return null;if(J)return J;const te=A.byPrefix.get(Y);if(!te||!te.length)return null;const ne=l(A,L),oe=te.filter(le=>ne.includes(le));return oe.length===1?oe[0]:null}function b(M,A,L,G){let q=M,Y=0,J=!1,te=!1;for(;q!=="";){const ne=m.exec(q)[0];if(ne==="")return null;const oe=a(ne,G&&G.locale);if(oe===null)return null;q=q.slice(ne.length).trim();const le=q.search(/[+-]?[\d]/),ae=(le>=0?q.slice(0,le):q).trim();if(q=le>=0?q.slice(le).trim():"",ae===""){if(J)return null;te=!0,Y+=o(oe,L[0],A.base)}else{const se=p(ae,A.index,A.binary);if(!se)return null;Y+=o(oe,se,A.base)}if(J=!0,te&&q!=="")return null}return J?Y:null}function j(M,A){if($(M))return null;if(typeof M=="number")return Number.isFinite(M)?M:null;const L=n(A);if(!L)return null;let G=String(M).trim();if(G==="")return null;let q=!1;G.startsWith("(")&&G.endsWith(")")&&(q=!0,G=G.slice(1,-1).trim());const Y=r(A,L);if(Y){G.startsWith("-")&&(q=!0,G=G.slice(1).trim());const ee=b(G,L,Y,A);return ee===null?null:q?-ee:ee}let J=null;const te=d.exec(G);if(te&&te[0]){const ee=p(te[0].trim(),L.index,L.binary);ee&&(J=ee,G=G.slice(te[0].length).trim())}const ne=m.exec(G)[0],oe=a(ne,A&&A.locale);if(oe===null)return null;const le=G.slice(ne.length).trim();if(J&&le!=="")return null;const ae=J||(le===""?L.base:p(le,L.index,L.binary));if(!ae)return null;const se=o(oe,ae,L.base);return q?-se:se}const S=new Map;function y(M,A,L,G){const q=`${M||""}|${A}|${L}|${G?1:0}`;let Y=S.get(q);return Y||(Y=new Intl.NumberFormat(M||void 0,{minimumFractionDigits:A,maximumFractionDigits:L,useGrouping:G}),S.set(q,Y)),Y}function v(M,A){if(!Number.isFinite(M)||M===0)return Math.max(0,A-1);const L=Math.floor(Math.log10(Math.abs(M)));return Math.min(20,Math.max(0,A-1-L))}function R(M,A){if(!Number.isFinite(M)||M===0)return M;const L=Math.ceil(Math.log10(Math.abs(M))),G=10**(A-L);return Math.round(M*G)/G}function O(M,A,L){if(!L||L===A.base.symbol)return A.base;if(L!=="auto")return x(A,L);if(M===0||!Number.isFinite(M))return A.base;const G=Math.abs(M)*A.base.factor,q=l(A.index,A.binary);let Y=q[0];for(const ne of q)G>=ne.factor&&(Y=ne);if(G>=Y.factor)return Y;let J=Y;for(const ne of A.index.units)ne.binary!==A.binary&&ne.factor!==1||ne.factor<=G&&ne.factor>(J===Y?0:J.factor)&&(J=ne);if(J!==Y)return J;let te=Y;for(const ne of A.index.units)ne.binary!==A.binary&&ne.factor!==1||ne.factor<te.factor&&(te=ne);return te.factor<A.base.factor?te:A.base}function x(M,A){const L=M.index.units.find(q=>q.symbol===A);if(L)return L;const G=M.index.byToken.get(String(A).toLowerCase());return G&&G!==W?G:(B(`unit:display:${A}`,`unknown display unit "${A}"; rendering in ${M.base.symbol}`),M.base)}function C(M,A,L,G){const q=M<0;let Y=Math.abs(M)*A.base.factor;const J=typeof G.decimals=="number"?G.decimals:G.minDecimals??0,te=typeof G.decimals=="number"?G.decimals:G.maxDecimals??Math.max(J,2),ne=G.space??" ",oe=[];for(let ae=0;ae<L.length;ae++){const se=L[ae],ee=ae===L.length-1;let ie=ee?Y/se.factor:Math.floor(Y/se.factor);if(Y-=ie*se.factor,ee){const he=10**te;ie=Math.round(ie*he)/he+0}const ce=ee?y(G.locale,J,te,G.group!==!1):y(G.locale,0,0,G.group!==!1);oe.push(`${ce.format(ie)}${ne}${se.symbol}`)}const le=oe.join(" ");return q?`-${le}`:le}function P(M,A){const L=A||{},G=L.nullDisplay??"";if($(M)||M==="")return G;const q=typeof M=="number"?M:Number(M);if(!Number.isFinite(q))return G;const Y=n(L);if(!Y)return String(q);const J=r(L,Y);if(J)return C(q,Y,J,L);const te=typeof L.significantFigures=="number"&&L.significantFigures>0?L.significantFigures:0,ne=te?R(q,te):q,oe=O(ne,Y,L.display),le=o(ne,Y.base,oe);let ae=typeof L.decimals=="number"?L.decimals:L.minDecimals??0,se=typeof L.decimals=="number"?L.decimals:L.maxDecimals??Math.max(ae,2);te&&(ae=v(le,te),se=ae);const ee=y(L.locale,ae,se,L.group!==!1).format(le),ie=L.space??" ";return L.placement==="prefix"?`${oe.symbol}${L.space??""}${ee}`:`${ee}${ie}${oe.symbol}`}function F(M,A){const L=$(M)||Number.isNaN(M)?null:Number(M),G=$(A)||Number.isNaN(A)?null:Number(A);return L===null||Number.isNaN(L)?G===null||Number.isNaN(G)?0:1:G===null||Number.isNaN(G)||L<G?-1:L>G?1:0}function E(M){const A=typeof M.decimals=="number"&&M.decimals>0?`.${"0".repeat(M.decimals)}`:"";return`${typeof M.decimals=="number"?`#,##0${A}`:"#,##0.##"}" ${M.symbol}"`}function D(M){const A={system:"data",...M||{}},L=n(A),G=L?L.base.symbol:String(A.unit||""),q=Object.freeze({...A,unit:G}),Y=Object.freeze({...q,display:G,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[q.locale||"",q]]),te=ne=>{const oe=ne||"";let le=J.get(oe);return le||(le=Object.freeze({...q,locale:ne||void 0}),J.set(oe,le)),le};return{base:"number",extends:"number",storage:"float64",unitConfig:q,format:ne=>P(ne.value,ne.locale?te(ne.locale):q),parse:ne=>j(ne.text,ne.locale?te(ne.locale):q),compare:F,defaults:{filter:"number",editor:"unit",align:"end",total:A.total||"sum"},...A.totals?{totals:A.totals}:{},excel:A.excel||E({decimals:A.decimals,symbol:G}),toStorage:ne=>typeof ne=="number"?Number.isFinite(ne)?ne:null:typeof ne=="string"?j(ne,q):$(ne)?null:j(String(ne),q),toClipboard:ne=>P(ne,Y),fromClipboard:ne=>j(ne,q)}}const N=D}),Fe("packages/core/src/columns/types/engineering.js",function(e,K){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return _}});const $=K("packages/core/src/internal/util.js").isNil,I=K("packages/core/src/columns/types/unit.js").createUnitType;function _(H){const U=2*Math.PI/H;return z=>{let w=0,k=0,g=0;for(const c of z||[]){if($(c))continue;const s=Number(c);Number.isFinite(s)&&(w+=Math.cos(s*U),k+=Math.sin(s*U),g+=1)}return!g||Math.hypot(w,k)/g<1e-12?null:(Math.atan2(k,w)/U%H+H)%H}}function X(H){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:_(H)}}}const W=Object.freeze({metres:I({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:I({system:"length",unit:"mm",maxDecimals:2}),kilometres:I({system:"length",unit:"km",maxDecimals:3}),grams:I({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:I({system:"mass",unit:"kg",maxDecimals:3}),tonnes:I({system:"mass",unit:"t",maxDecimals:3}),seconds:I({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:I({system:"duration",unit:"ms",maxDecimals:3}),hours:I({system:"duration",unit:"h",maxDecimals:2}),speed:I({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:I({system:"speed",unit:"km/h",maxDecimals:1}),mph:I({system:"speed",unit:"mph",maxDecimals:1}),knots:I({system:"speed",unit:"kn",maxDecimals:1}),acceleration:I({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:I({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:I({system:"area",unit:"ha",maxDecimals:4}),volume:I({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:I({system:"volume",unit:"m³",maxDecimals:3}),energy:I({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:I({system:"energy",unit:"kWh",maxDecimals:2}),power:I({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:I({system:"power",unit:"kW",maxDecimals:2}),force:I({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:I({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:I({system:"pressure",unit:"bar",maxDecimals:3}),psi:I({system:"pressure",unit:"psi",maxDecimals:1}),torque:I({system:"torque",unit:"N·m",maxDecimals:2}),density:I({system:"density",unit:"kg/m³",maxDecimals:2}),flow:I({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:I({system:"flow",unit:"L/min",maxDecimals:1}),radians:I({system:"angle",unit:"rad",maxDecimals:4,totals:X(2*Math.PI)}),degrees:I({system:"angle",unit:"°",maxDecimals:2,totals:X(360)}),rpm:I({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:I({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:I({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:I({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:I({system:"fraction",unit:"bp",maxDecimals:1}),molarity:I({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:I({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:I({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:I({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:I({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:I({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:I({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:I({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Fe("packages/core/src/columns/types/si.js",function(e,K){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/columns/types/unit.js"),$=Q.defineUnit,B=Q.registerUnitSystem,I=Q.createUnitType,_=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})]),X=Object.freeze(["p","n","µ","m","","k","M","G"]);function W(k){const g=String(k.base),l=new Set([...k.prefixes||X,""]),c=[];for(const s of _){if(!l.has(s.symbol))continue;const n=`${s.symbol}${g}`,t=[];if(k.name){t.push(`${s.name}${k.name}`,`${s.name}${k.name}s`);const r=s.name.slice(-1);if(r&&k.name.startsWith(r)){const o=`${s.name.slice(0,-1)}${k.name}`;t.push(o,`${o}s`)}}s.symbol==="µ"&&t.push(`u${g}`),s.factor===1&&k.aliases&&t.push(...k.aliases),c.push($(n,s.factor,t))}for(const s of k.extra||[])c.push(s);return c}function H(k,g){const l=W(g);return B(k,l)}function U(k,g,l){return H(k,g),I({system:k,unit:g.base,display:"auto",maxDecimals:3,...l||{}})}const z=Object.freeze({voltage:U("voltage",{base:"V",name:"volt"}),current:U("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:U("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:U("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:U("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:U("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[$("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),$("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:U("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:U("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[$("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:U("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:U("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:U("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:U("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:U("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:U("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:U("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[$("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:U("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),w=U}),Fe("packages/core/src/columns/types/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const $=K("packages/core/src/internal/util.js").isNil,B=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:c=>c+273.15,fromKelvin:c=>c-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:c=>(c+459.67)*(5/9),fromKelvin:c=>c*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:c=>c,fromKelvin:c=>c}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:c=>c*(5/9),fromKelvin:c=>c*(9/5)})});function I(c){if($(c))return null;const s=String(c).trim();if(s==="")return null;for(const[t,r]of Object.entries(B))if(s===t||s===r.symbol)return{key:t,scale:r};const n=s.toLowerCase();for(const[t,r]of Object.entries(B))if(r.aliases.includes(n))return{key:t,scale:r};return null}function _(c,s,n){const t=I(s),r=I(n);return!t||!r||!Number.isFinite(Number(c))?null:t.key===r.key?Number(c):r.scale.fromKelvin(t.scale.toKelvin(Number(c)))}const X=new Map;function W(c,s,n){const t=`${c||""}|${s}|${n}`;let r=X.get(t);return r||(r=new Intl.NumberFormat(c||void 0,{minimumFractionDigits:s,maximumFractionDigits:n}),X.set(t,r)),r}function H(c,s){const n=s||{},t=n.nullDisplay??"";if($(c)||c==="")return t;const r=Number(c);if(!Number.isFinite(r))return t;const o=I(n.scale||"C");if(!o)return String(r);const f=I(n.display||n.scale||"C")||o,u=f.key===o.key?r:f.scale.fromKelvin(o.scale.toKelvin(r)),i=typeof n.decimals=="number"?n.decimals:null,m=i??n.minDecimals??0,d=i??n.maxDecimals??1;return`${W(n.locale,m,d).format(u)}${n.space??" "}${f.scale.symbol}`}const U=/^[+-]?[\d\s.,  ]*\d/;function z(c,s){const n=String(c).trim();if(n==="")return null;const t=new Intl.NumberFormat(s||void 0).formatToParts(1.1).find(u=>u.type==="decimal")?.value||".",r=t===","?".":",",o=n.split(r).join("").split(/[\s  ]/).join("").replace(t,"."),f=Number(o);return Number.isFinite(f)?f:null}function w(c,s){if($(c))return null;const n=s||{},t=I(n.scale||"C");if(!t)return null;if(typeof c=="number")return Number.isFinite(c)?c:null;let r=String(c).trim();if(r==="")return null;let o=!1;r.startsWith("(")&&r.endsWith(")")&&(o=!0,r=r.slice(1,-1).trim());const f=U.exec(r);if(!f)return null;const u=z(f[0],n.locale);if(u===null)return null;const i=r.slice(f[0].length).trim();if(i==="")return o?-u:u;const m=I(i);if(!m)return null;const d=m.key===t.key?u:t.scale.fromKelvin(m.scale.toKelvin(u));return o?-d:d}function k(c){const s=Object.freeze({scale:"C",...c||{}}),t=(I(s.scale)||I("C")).scale.symbol,r=Object.freeze({...s,display:s.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),o=new Map([[s.locale||"",s]]),f=u=>{const i=u||"";let m=o.get(i);return m||(m=Object.freeze({...s,locale:u||void 0}),o.set(i,m)),m};return{base:"number",extends:"number",storage:"float64",temperatureConfig:s,format:u=>H(u.value,u.locale?f(u.locale):s),parse:u=>w(u.text,u.locale?f(u.locale):s),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:s.excel||`#,##0${typeof s.decimals=="number"&&s.decimals>0?`.${"0".repeat(s.decimals)}`:".#"}" ${t}"`,toStorage:u=>typeof u=="number"?Number.isFinite(u)?u:null:typeof u=="string"?w(u,s):$(u)?null:w(String(u),s),toClipboard:u=>H(u,r),fromClipboard:u=>w(u,s)}}const g=Object.freeze({celsius:k({scale:"C"}),fahrenheit:k({scale:"F"}),kelvin:k({scale:"K"})}),l=k}),Fe("packages/core/src/columns/types/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return C}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.warnOnce,I=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}),_=Object.freeze({2:1,8:3,16:4}),X=Object.freeze({2:"0b",8:"0o",16:"0x"}),W=Object.freeze({2:4,8:3,16:2}),H=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),U=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),z=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),w=/[\s\u00a0\u202f_,']/g,k=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,g=Object.freeze([8,16,32,53]),l=new WeakSet,c=new WeakMap,s=new Map,n=new WeakMap,t=new WeakMap,r=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 o(P){if(P==null)return 16;const F=typeof P=="string"?P.toLowerCase():P,E=I[F];return E||(B(`radix:base:${String(P)}`,`unsupported radix ${String(P)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function f(P,F){return Math.ceil(P/_[F])}function u(P,F){if(!P)return F?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!F)return{min:0,max:2**P-1};const E=2**(P-1);return{min:-E,max:E-1}}function i(P){return U[P]||"hexadecimal"}function m(P){if(typeof P=="string"){const F=r[P];return F||B(`radix:preset:${P}`,`unknown radix preset "${P}"; known presets are ${Object.keys(r).join(", ")}`),{...F||{}}}if(P&&typeof P.preset=="string"){const F=r[P.preset];return F||B(`radix:preset:${P.preset}`,`unknown radix preset "${P.preset}"; known presets are ${Object.keys(r).join(", ")}`),{...F||{},...P}}return P||{}}function d(P){const F=m(P),E=o(F.radix),D=_[E];let N=null;if(F.bitWidth!==void 0&&F.bitWidth!==null&&F.bitWidth!==!1){const ne=Number(F.bitWidth);g.includes(ne)?N=ne:B(`radix:width:${String(F.bitWidth)}`,`unsupported bitWidth ${String(F.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let M=F.signed!==!1;!M&&N===null&&(B("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),N=32);const A=F.prefix===void 0||F.prefix===!0?X[E]:F.prefix===!1?"":String(F.prefix);let L=0;F.pad===!0?L=N?f(N,E):0:typeof F.pad=="number"&&F.pad>0&&(L=Math.floor(F.pad));let G=0;F.group===!0?G=W[E]:typeof F.group=="number"&&F.group>0&&(G=Math.floor(F.group));const q=u(N,M),Y=typeof F.min=="number"?Math.max(q.min,F.min):q.min,J=typeof F.max=="number"?Math.min(q.max,F.max):q.max,te=Object.freeze({radix:E,bits:D,prefix:A,uppercase:F.uppercase!==!1,pad:L,group:G,groupSeparator:typeof F.groupSeparator=="string"?F.groupSeparator:" ",bitWidth:N,signed:M,min:Y,max:J<Y?Y:J,nullDisplay:typeof F.nullDisplay=="string"?F.nullDisplay:"",name:i(E)});return l.add(te),te}function h(P){if(P&&l.has(P))return P;if(typeof P=="string"){let F=s.get(P);return F||(F=d(P),s.set(P,F)),F}if(P&&typeof P=="object"){let F=c.get(P);return F||(F=d(P),c.set(P,F)),F}return h("hex")}function a(P){return P<0?-Math.round(-P):Math.round(P)}function p(P,F,E){if(F<=0||P.length<=F)return P;const D=P.length%F||F,N=[P.slice(0,D)];for(let M=D;M<P.length;M+=F)N.push(P.slice(M,M+F));return N.join(E)}function b(P){const F=h(P),{radix:E,prefix:D,uppercase:N,pad:M,group:A,groupSeparator:L,signed:G,bitWidth:q,nullDisplay:Y}=F,J=q?2**q:0,te=ne=>{if($(ne)||ne==="")return Y;const oe=typeof ne=="number"?ne:Number(ne);if(!Number.isFinite(oe))return Y;const le=a(oe);let ae="",se=le;le<0&&(G?(ae="-",se=-le):se=(le%J+J)%J);let ee=se.toString(E);return ee=N?ee.toUpperCase():ee.toLowerCase(),M>0&&ee.length<M&&(ee=ee.padStart(M,"0")),A>0&&(ee=p(ee,A,L)),ae+D+ee};return te.options=F,te}function j(P,F){const E=h(F);let D=n.get(E);return D||(D=b(E),n.set(E,D)),D(P)}function S(P){const F=h(P),{radix:E,groupSeparator:D,signed:N,min:M,max:A}=F,L=H[E],G=q=>{if($(q))return{ok:!0,value:null,reason:"blank"};let Y=String(q);if(D&&D!==""&&(Y=Y.split(D).join("")),Y=Y.replace(w,""),Y==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((Y[0]==="-"||Y[0]==="+")&&(J=Y[0]==="-",Y=Y.slice(1)),Y==="")return{ok:!1,value:null,reason:"digits"};let te=null;for(const[oe,le]of z){const ae=oe.exec(Y);if(!ae)continue;const se=Y.slice(ae[0].length);if(se==="")break;if(!H[le].test(se))return{ok:!1,value:null,reason:"digits"};te=parseInt(se,le);break}if(te===null)if(L.test(Y))te=parseInt(Y,E);else if(k.test(Y))te=Number(Y);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(te))return{ok:!1,value:null,reason:"digits"};const ne=a(J?-te:te);return!N&&ne<0?{ok:!1,value:ne,reason:"negative"}:ne<M||ne>A?{ok:!1,value:ne,reason:"range"}:{ok:!0,value:ne,reason:"ok"}};return G.options=F,G}function y(P,F){const E=h(F);let D=t.get(E);return D||(D=S(E),t.set(E,D)),D(P)}function v(P,F){const E=y(P,F);return E.ok?E.value:null}function R(P,F){const E=$(P)||Number.isNaN(P)?null:Number(P),D=$(F)||Number.isNaN(F)?null:Number(F);return E===null?D===null?0:1:D===null||E<D?-1:E>D?1:0}function O(P){const F=P.min>=-2147483648&&P.max<=2147483647;return P.bitWidth&&F?"int32":"float64"}function x(P){const F=d(P),E=b(F),D=S(F);return{base:"number",extends:"number",storage:O(F),matches:null,format:N=>E(N.value),parse:N=>{const M=D(N.text);return M.ok?M.value:null},compare:R,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:N=>E(N),fromClipboard:N=>{const M=D(N);return M.ok?M.value:null},radix:F,formatValue:E,parseText:D}}const C=x}),Fe("packages/core/src/columns/types/aggregable.js",function(e,K){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return _}});const $=K("packages/core/src/internal/util.js").isNil;function B(z){const w=[];for(const k of z||[]){if($(k))continue;const g=Number(k);Number.isFinite(g)&&w.push(g)}return w}function I(z){return w=>{const k=B(w);if(!k.length)return null;let g=0;for(const l of k)g+=10**(l/z);return z*Math.log10(g)}}function _(z){return w=>{const k=B(w);if(!k.length)return null;let g=0;for(const l of k)g+=10**(l/z);return z*Math.log10(g/k.length)}}function X(z,w){const k=w&&w.column,l=(k&&k.typeOptions||{}).weight,c=w&&w.valueAt;if(!l||typeof c!="function")return null;let s=0,n=0;for(let t=0;t<z.length;t++){if($(z[t]))continue;const r=Number(z[t]);if(!Number.isFinite(r))continue;const o=c(l,t);if($(o))continue;const f=Number(o);!Number.isFinite(f)||f<=0||(s+=r*f,n+=f)}return n===0?null:s/n}function W(z={}){const w=z.factor===20?20:10,k=typeof z.suffix=="string"?z.suffix:"",g=Number.isInteger(z.decimals)?z.decimals:1;return{base:"number",storage:"float64",name:z.name||"logarithmic",format:l=>{const c=l&&l.value;return $(c)||!Number.isFinite(Number(c))?"":`${Number(c).toFixed(g)}${k}`},parse:l=>{const c=String((l&&l.text)??"").replace(k,"").trim();if(!c)return null;const s=Number(c);return Number.isFinite(s)?s:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:I(w),avg:_(w)}}}}function H(z={}){const w=Number.isInteger(z.decimals)?z.decimals:1,k=z.percent===!0;return{base:"number",storage:"float64",name:z.name||"ratio",format:g=>{const l=g&&g.value;return $(l)||!Number.isFinite(Number(l))?"":k?`${Number(l).toFixed(w)}%`:Number(l).toFixed(w)},parse:g=>{const l=String((g&&g.text)??"").replace("%","").trim();if(!l)return null;const c=Number(l);return Number.isFinite(c)?c:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:X}}}}const U=Object.freeze({decibel:W({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:W({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:H({name:"ratio"}),percentRate:H({name:"percentRate",percent:!0})})}),Fe("packages/core/src/columns/types/currency.js",function(e,K){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const $=K("packages/core/src/internal/util.js").isNil,B="⚠ no rate";function I(u){if($(u))return null;const i=String(u).trim().toUpperCase();return i===""?null:i}function _(u){if($(u))return null;if(typeof u=="object"&&!Array.isArray(u)){const i=Number(u.amount),m=I(u.code);return!m||!Number.isFinite(i)?null:{amount:i,code:m}}if(Array.isArray(u)&&u.length===2){const i=Number(u[0]),m=I(u[1]);return!m||!Number.isFinite(i)?null:{amount:i,code:m}}return null}const X=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),W=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),H=/[+-]?[\d\s., ]*\d/;function U(u,i){const m=String(u).trim();if(m==="")return null;const d=new Intl.NumberFormat(i||void 0).formatToParts(1.1).find(b=>b.type==="decimal")?.value||".",h=d===","?".":",",a=m.split(h).join("").split(/[\s ]/).join("").replace(d,"."),p=Number(a);return Number.isFinite(p)?p:null}function z(u,i){const m=i||{},d=I(m.code);if($(u))return null;const h=_(u);if(h)return h;if(typeof u=="number")return Number.isFinite(u)&&d?{amount:u,code:d}:null;let a=String(u).trim();if(a==="")return null;let p=!1;a.startsWith("(")&&a.endsWith(")")&&(p=!0,a=a.slice(1,-1).trim());let b=null;for(const[O,x]of Object.entries(X)){if(a.startsWith(O)){b=x,a=a.slice(O.length).trim();break}if(a.endsWith(O)){b=x,a=a.slice(0,-O.length).trim();break}}const j=H.exec(a);if(!j)return null;const S=U(j[0],m.locale);if(S===null)return null;const y=(a.slice(0,j.index)+" "+a.slice(j.index+j[0].length)).trim();!b&&y!==""&&(b=I(y));const v=b||d;return v?{amount:p?-S:S,code:v}:null}function w(u,i){if(typeof u=="function")return(m,d)=>{if(m===d)return 1;const h=u(m,d);return typeof h=="number"&&Number.isFinite(h)&&h>0?h:null};if(u&&typeof u=="object"){const m=u;return(d,h)=>{if(d===h)return 1;const a=Number(m[d]),p=Number(m[h]);return!Number.isFinite(a)||!Number.isFinite(p)||a<=0||p<=0?null:p/a}}return(m,d)=>m===d?1:null}function k(u,i,m){if(!u)return null;if(u.code===i)return u.amount;const d=m(u.code,i);return d===null?null:u.amount*d}const g=new Map;function l(u,i,m){const d=`${u||""}|${i}|${m??""}`;let h=g.get(d);if(!h){const a={style:"currency",currency:i};typeof m=="number"&&(a.minimumFractionDigits=m,a.maximumFractionDigits=m);try{h={fmt:new Intl.NumberFormat(u||void 0,a),currency:!0}}catch{h={fmt:new Intl.NumberFormat(u||void 0,typeof m=="number"?{minimumFractionDigits:m,maximumFractionDigits:m}:{}),currency:!1}}g.set(d,h)}return h}function c(u,i){const m=i||{},d=m.nullDisplay??"",h=_(u);if(!h)return d;const a=I(m.display)||h.code;let p=h.amount,b=h.code;if(a!==h.code){const y=m.rateFn||w(m.rates,m.rateBase),v=k(h,a,y);if(v===null)return`${m.missingRate??B} ${h.code}→${a}`;p=v,b=a}const{fmt:j,currency:S}=l(m.locale,b,m.decimals);return S?j.format(p):`${j.format(p)} ${b}`}function s(u){const i=_(u);return i?`${i.amount} ${i.code}`:""}function n(u){const i=u||{},m=I(i.display),d=i.rateFn||w(i.rates,i.rateBase);return(h,a)=>{const p=_(h),b=_(a);if(!p&&!b)return 0;if(!p)return 1;if(!b)return-1;if(m){const j=k(p,m,d),S=k(b,m,d);if(j!==null&&S!==null)return j===S?0:j<S?-1:1}return p.code===b.code?p.amount===b.amount?0:p.amount<b.amount?-1:1:p.code<b.code?-1:1}}function t(u){const i=u||{},m=(h,a)=>{const p=[];for(const v of h||[]){const R=_(v);R&&p.push(R)}if(!p.length)return null;if(new Set(p.map(v=>v.code)).size===1){const v=p[0].code;return{amount:a(p.map(R=>R.amount)),code:v}}const j=I(i.display);if(!j)return`${i.missingRate??B}: mixed currencies, no display currency set`;const S=i.rateFn||w(i.rates,i.rateBase),y=[];for(const v of p){const R=k(v,j,S);if(R===null)return`${i.missingRate??B}: ${v.code}→${j}`;y.push(R)}return{amount:a(y),code:j}},d=h=>h.reduce((a,p)=>a+p,0);return{sum:h=>m(h,d),avg:h=>m(h,a=>d(a)/a.length),min:h=>m(h,a=>Math.min(...a)),max:h=>m(h,a=>Math.max(...a))}}function r(u){const i=Object.freeze({code:"USD",...u||{}}),m=w(i.rates,i.rateBase),d=Object.freeze({...i,rateFn:m}),h=t(d),a=n(d),p=new Map([[i.locale||"",d]]),b=y=>{const v=y||"";let R=p.get(v);return R||(R=Object.freeze({...d,locale:y||void 0}),p.set(v,R)),R},j=W[I(i.display||i.code)]||"",S=typeof i.decimals=="number"&&i.decimals>0?`.${"0".repeat(i.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:d,format:y=>c(y.value,y.locale?b(y.locale):d),parse:y=>z(y.text,y.locale?b(y.locale):d),compare:a,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:h},excel:i.excel||(j?`"${j}"#,##0${S}`:`#,##0${S}`),toStorage:y=>{const v=_(y);return v||(typeof y=="string"||typeof y=="number"?z(y,d):null)},toClipboard:y=>s(y),fromClipboard:y=>z(y,d)}}const o=Object.freeze({currency:r({code:"USD"}),usd:r({code:"USD"}),eur:r({code:"EUR"}),gbp:r({code:"GBP"}),jpy:r({code:"JPY",decimals:0})}),f=r}),Fe("packages/core/src/columns/types/index.js",function(e,K){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return O}});const Q=K("packages/core/src/columns/types/temporal.js"),$=Q.TEMPORAL_TYPES,B=K("packages/core/src/columns/types/network.js"),I=B.NETWORK_TYPES,_=K("packages/core/src/columns/types/structured.js"),X=_.STRUCTURED_TYPES,W=K("packages/core/src/columns/types/unit.js"),H=W.createUnitType,U=W.UNIT_SYSTEMS,z=W.parseUnit,w=W.formatUnit,k=W.registerUnitSystem,g=W.unitSystemNames,l=W.unitsOf,c=W.defineUnit,s=K("packages/core/src/columns/types/engineering.js"),n=s.ENGINEERING_TYPES,t=K("packages/core/src/columns/types/si.js"),r=t.SI_TYPES,o=t.createSiType,f=t.createSiSystem,u=t.siUnits,i=t.SI_PREFIXES,m=K("packages/core/src/columns/types/temperature.js"),d=m.TEMPERATURE_TYPES,h=m.createTemperatureType,a=m.convertTemperature,p=m.formatTemperature,b=m.parseTemperature,j=m.TEMPERATURE_SCALES,S=K("packages/core/src/columns/types/radix.js"),y=S.createRadixType,v=S.RADIX_PRESETS,R=S.parseRadix,O=S.formatRadix,x=K("packages/core/src/columns/types/aggregable.js"),C=x.AGGREGABLE_TYPES,P=K("packages/core/src/columns/types/currency.js"),F=P.CURRENCY_TYPES,E=P.createCurrencyType,D=P.parseMoney,N=P.formatMoney,M=P.convertMoney,A=P.toMoney,L=P.rateFunction,G=P.moneyComparator,q=P.normaliseCode,Y=P.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return W.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return s.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return s.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return m.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return m.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return m.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return m.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return m.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return m.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return m.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return P.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return P.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return P.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return P.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return P.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return P.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return P.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return P.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return P.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return P.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Q.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return B.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return _.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return x.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return x.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return x.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return Q.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return Q.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return Q.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return Q.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return Q.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return Q.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return B.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return B.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return B.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return B.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return B.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return B.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return B.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return B.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return B.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return B.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return B.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return _.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return _.summariseJson}});const J=Object.freeze({...$,...I,...X,...C,hex:y(v.hex),hex8:y(v.hex8),hex16:y(v.hex16),hex32:y(v.hex32),binary:y(v.binary),binary8:y(v.binary8),octal:y(v.octal),bytes:H({system:"data",unit:"B",display:"auto"}),megabytes:H({system:"data",unit:"MB"}),gigabytes:H({system:"data",unit:"GB"}),bitrate:H({system:"bitrate",unit:"Mbps"}),gigabits:H({system:"bitrate",unit:"Gbps"}),...n,...r,...d,...F});{const te=new Set;for(const ne of[$,I,X,C,n,r,d,F])for(const oe of Object.keys(ne)){if(te.has(oe))throw new Error(`[lattice] data type "${oe}" is declared twice`);te.add(oe)}}}),Fe("packages/core/src/compute/handle.js",function(e,K){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return t}});const Q=K("packages/core/src/internal/util.js"),$=Q.collator,B=Q.defaultCompare,I=Q.warnOnce;function _(r){const o=new Uint32Array(r);for(let f=0;f<r;f++)o[f]=f;return o}function X(r,o){if(o&&typeof o.count=="number")return o.count;if(!r)return 0;if(typeof r.count=="number")return r.count;if(typeof r.length=="number")return r.length;const f=r.values;return r.kind==="multi"&&r.offsets?Math.max(0,r.offsets.length-1):f?r.kind==="bitset"?typeof f.size=="number"?f.size:r.presence&&typeof r.presence.size=="number"?r.presence.size:(I(`count:${r.id}`,`column "${r.id}" is bitset-backed with no declared row count; assuming ${f.length*8}`),f.length*8):f.length:r.presence&&typeof r.presence.size=="number"?r.presence.size:0}const W=new WeakMap;function H(r){const o=r.constructor;if(!o)return"unknown";const f=W.get(o);if(f)return f;let u="unknown";try{let i=null;typeof o.from=="function"?i=o.from([!1,!0]):(i=new o(8),i.set(1));const m=i&&i.words;m&&m.length&&(m[0]===2?u="lsb":m[0]===64&&(u="msb"))}catch{u="unknown"}return W.set(o,u),u}function U(r){if(!r)return()=>0;const o=r instanceof Uint8Array?r:r.words;if(o instanceof Uint8Array){const f=r instanceof Uint8Array?"lsb":H(r);if(f==="lsb")return u=>o[u>>>3]>>>(u&7)&1;if(f==="msb")return u=>o[u>>>3]>>>7-(u&7)&1}return typeof r.get=="function"?f=>r.get(f)?1:0:()=>0}function z(r){return!r||!r.presence?null:U(r.presence)}function w(r){return r?typeof r.size=="number"?r.size:typeof r.values=="function"?r.values().length:0:0}function k(r,o){return r?typeof r.valueOf=="function"?r.valueOf(o):typeof r.values=="function"?r.values()[o]:null:null}function g(r,o){const f=r.offsets,u=r.values;if(!f||!u)return[];const i=f[o],m=f[o+1];if(!(m>i))return[];const d=r.dict,h=new Array(m-i);for(let a=i;a<m;a++)h[a-i]=d?k(d,u[a]):u[a];return h}function l(r){if(!r)return()=>{};const o=r.values,f=z(r),u=r.kind;if(u==="dictionary"){const i=r.dict;return f?m=>f(m)?k(i,o[m]):null:m=>k(i,o[m])}if(u==="bitset"){const i=U(o);return f?m=>f(m)?i(m)===1:null:m=>i(m)===1}if(u==="multi")return f?i=>f(i)?g(r,i):null:i=>g(r,i);if(!o&&typeof r.get=="function"){const i=r.get.bind(r);return m=>{const d=i(m);return d===void 0?null:d}}return f?i=>{if(!f(i))return null;const m=o[i];return m===void 0?null:m}:i=>{const m=o[i];return m===void 0?null:m}}function c(r,o){if(r<o)return-1;if(r>o)return 1;if(r===o){const i=Object.is(r,-0),m=Object.is(o,-0);return i===m?0:i?-1:1}const f=Number.isNaN(r),u=Number.isNaN(o);return f&&u?0:f?1:-1}function s(r){const o=$(r);return(f,u)=>{if(f===u)return 0;const i=typeof f,m=typeof u;if(i==="string"&&m==="string")return o.compare(f,u);if(i==="number"&&m==="number")return c(f,u);if(i==="boolean"&&m==="boolean")return f===u?0:f?1:-1;if(f instanceof Date||u instanceof Date){const d=f instanceof Date?f.getTime():Number(f),h=u instanceof Date?u.getTime():Number(u);return c(d,h)}return B(f,u)}}function n(r,o){if(r&&typeof r.ranks=="function")return r.ranks(o);const f=r&&typeof r.values=="function"?r.values():[],u=f.length,i=s(o),m=new Array(u);for(let h=0;h<u;h++)m[h]=h;m.sort((h,a)=>i(f[h],f[a])||h-a);const d=new Uint32Array(u);for(let h=0;h<u;h++)d[m[h]]=h;return d}function t(r){return r==null||typeof r=="number"&&Number.isNaN(r)}}),Fe("packages/core/src/compute/filter.js",function(e,K){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return ae}});const Q=K("packages/core/src/internal/util.js"),$=Q.isBlank,B=Q.toArray,I=Q.warnOnce,_=K("packages/core/src/format/date.js"),X=_.toDate,W=_.toIsoDate,H=K("packages/core/src/compute/handle.js"),U=H.bitReader,z=H.dictSize,w=H.dictValue,k=H.presenceReader,g=H.valueComparator,l=H.valueReader,c=/^\d{4}-\d{2}-\d{2}$/,s="\0null\0";function n(se,ee){const ie=se&&se.pool;if(ie){const ce=ie.mask||ie.acquireMask||ie.acquire||ie.take;if(typeof ce=="function"){const he=ce.call(ie,ee);if(he&&he.length>=ee)return he}}return new Uint8Array(ee)}function t(se,ee){const ie=se&&se.pool;if(!ie||!ee)return;const ce=ie.release||ie.releaseMask||ie.free||ie.recycle;typeof ce=="function"&&ce.call(ie,ee)}function r(se,ee,ie){return se.fill(ie,0,ee),se}function o(se){return se==null||typeof se=="number"&&Number.isNaN(se)}function f(se,ee){if(se==null)return se;if(ee==="number")return typeof se=="number"?se:Number(se);if(ee==="date"||ee==="dateString"){const ie=W(se);return ie===null?u(se):ie}return ee==="boolean"?typeof se=="boolean"?se:se==="true"||se===1?!0:se==="false"||se===0?!1:!!se:se}function u(se){return se instanceof Date?se.getTime():typeof se=="number"?se:Date.parse(String(se))}function i(se){return typeof se=="number"?se:se instanceof Date?se.getTime():se==null||se===""?NaN:Number(se)}function m(se,ee){const ie=typeof se=="string"?se:String(se);return ee?ie:ie.toLowerCase()}function d(se,ee){return se==null?s:typeof se=="string"?ee?se:se.toLowerCase():se instanceof Date?se.getTime():se}function h(se,ee,ie){const ce=new Set;for(const he of B(se)){const me=f(he,ie);ce.add(d(me,ee)),typeof me=="string"&&me!==""&&Number.isFinite(Number(me))?ce.add(Number(me)):typeof me=="number"&&Number.isFinite(me)&&ce.add(d(String(me),ee))}return ce}function a(se,ee,ie){if(se==null||ee===null||ee===void 0)return se==null&&ee==null;const ce=typeof se,he=typeof ee;return ce==="string"&&he==="string"?ie?se===ee:se.toLowerCase()===ee.toLowerCase():se instanceof Date||ee instanceof Date?u(se)===u(ee):ce==="number"&&he==="number"?se===ee||Number.isNaN(se)&&Number.isNaN(ee):ce==="number"&&he==="string"?se===Number(ee):ce==="string"&&he==="number"?Number(se)===ee:ce==="boolean"||he==="boolean"?se===ee:Array.isArray(se)&&Array.isArray(ee)?se.length===ee.length&&se.every((me,Ee)=>a(me,ee[Ee],ie)):se===ee}function p(se,ee){try{if(se instanceof RegExp){const ie=se.flags.replace(/[gy]/g,"");return new RegExp(se.source,ee||ie.includes("i")?ie:`${ie}i`)}return new RegExp(String(se),ee?"":"i")}catch(ie){return I(`regex:${String(se)}`,`filter operator "matches" received an invalid pattern: ${String(se)}`,ie),null}}function b(se,ee){if(se&&se.type==="datetime"&&j.has(se.op))return O(se,ee);const ie=x(se,ee),ce=se&&se.type;return ce!=="date"&&ce!=="dateString"?ie:he=>ie(typeof he=="string"&&c.test(he)?he:W(he)??he)}const j=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),S=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,y=new Map;function v(se,ee){let ie=y.get(ee);if(ie===void 0){try{ie=new Intl.DateTimeFormat("en-CA",{timeZone:ee,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{ie=null}y.set(ee,ie)}if(!ie)return null;const ce={};for(const he of ie.formatToParts(se))he.type!=="literal"&&(ce[he.type]=he.value);return ce}function R(se,ee){if(se==null||se==="")return null;if(typeof se=="string"){const me=S.exec(se.trim());if(me)return Date.UTC(+me[1],+me[2]-1,+me[3],+(me[4]||0),+(me[5]||0),+(me[6]||0),+(me[7]||"0").padEnd(3,"0"))}const ie=X(se);if(!ie)return null;const ce=ie.getUTCMilliseconds(),he=ee?v(ie,ee):null;return he?Date.UTC(+he.year,+he.month-1,+he.day,he.hour==="24"?0:+he.hour,+he.minute,+he.second,ce):Date.UTC(ie.getFullYear(),ie.getMonth(),ie.getDate(),ie.getHours(),ie.getMinutes(),ie.getSeconds(),ce)}function O(se,ee){const ie=typeof se.timeZone=="string"&&se.timeZone?se.timeZone:void 0,ce=Ee=>R(Ee,ie),he=Array.isArray(se.value)?se.value.map(ce):ce(se.value),me=x({...se,type:"number",value:he},ee);return Ee=>me(R(Ee))}function x(se,ee){const ie=se&&se.op,ce=!!(se&&se.caseSensitive),he=se&&se.type,me=g(ee),Ee=ge=>je=>!ge(je);switch(ie){case"eq":{const ge=f(se.value,he);return je=>a(je,ge,ce)}case"ne":{const ge=f(se.value,he);return je=>!a(je,ge,ce)}case"lt":case"lte":case"gt":case"gte":{const ge=f(se.value,he);if(o(ge))return()=>!1;const je=ie==="lt"?-1:ie==="lte"?0:ie==="gt"?1:2;return pe=>{if(o(pe))return!1;const we=me(pe,ge);return je===-1?we<0:je===0?we<=0:je===1?we>0:we>=0}}case"between":case"notBetween":{const ge=B(se.value),je=f(ge[0],he),pe=f(ge[1],he),we=se.bounds||"[]",ye=we.charAt(0)!=="(",Ne=we.charAt(1)!==")";if(o(je)||o(pe))return ie==="between"?()=>!1:()=>!0;const $e=Ve=>{if(o(Ve))return!1;const qe=me(Ve,je),Ae=me(Ve,pe);return(ye?qe>=0:qe>0)&&(Ne?Ae<=0:Ae<0)};return ie==="between"?$e:Ee($e)}case"in":case"notIn":{const ge=h(se.value,ce,he),je=pe=>ge.has(d(pe,ce));return ie==="in"?je:Ee(je)}case"contains":case"notContains":{const ge=m(f(se.value,he),ce),je=pe=>pe==null?!1:m(pe,ce).includes(ge);return ie==="contains"?je:Ee(je)}case"startsWith":{const ge=m(f(se.value,he),ce);return je=>je==null?!1:m(je,ce).startsWith(ge)}case"endsWith":{const ge=m(f(se.value,he),ce);return je=>je==null?!1:m(je,ce).endsWith(ge)}case"matches":{const ge=p(se.value,ce);return ge?je=>je==null?!1:ge.test(String(je)):()=>!1}case"blank":return ge=>$(ge)||Array.isArray(ge)&&ge.length===0;case"notBlank":return ge=>!($(ge)||Array.isArray(ge)&&ge.length===0);case"containsAny":case"containsNone":{const ge=h(se.value,ce,he),je=pe=>{const we=pe==null?[]:B(pe);for(let ye=0;ye<we.length;ye++)if(ge.has(d(we[ye],ce)))return!0;return!1};return ie==="containsAny"?je:Ee(je)}case"containsAll":{const ge=B(se.value).map(je=>d(f(je,he),ce));return je=>{const pe=je==null?[]:B(je);if(ge.length===0)return!0;const we=new Set(pe.map(ye=>d(ye,ce)));for(let ye=0;ye<ge.length;ye++)if(!we.has(ge[ye]))return!1;return!0}}default:{const ge=ae(ie);return ge?ge.compile(se.value):(I(`op:${String(ie)}`,`unknown filter operator "${String(ie)}"; the condition is refused rather than matching every row`),()=>!1)}}}function C(se,ee,ie){return b(ee,ie)(se)}const P=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),F=new Set(["containsAny","containsAll","containsNone"]);function E(se,ee,ie){const ce=se&&se.op,he=P[ce]||ce,me=b({...se,op:he,type:ee.type},ie),Ee=ee.items,ge=je=>{const pe=Ee(je);if(!pe)return!1;for(let we=0;we<pe.length;we++)if(me(pe[we]))return!0;return!1};return P[ce]?je=>!ge(je):ge}function D(se,ee,ie,ce){const he=k(se);if(he){const ge=ee?1:0;for(let je=0;je<ce;je++)ie[je]=he(je)===ge?1:0;return ie}const me=se.kind;if(me==="float64"||me==="int32"||me==="bitset")return r(ie,ce,ee?1:0);const Ee=l(se);for(let ge=0;ge<ce;ge++){const je=Ee(ge),pe=$(je)||Array.isArray(je)&&je.length===0;ie[ge]=pe===ee?0:1}return ie}function N(se,ee,ie,ce){const he=se.dict,me=z(he),Ee=new Uint8Array(me);for(let we=0;we<me;we++)Ee[we]=ee(w(he,we))?1:0;const ge=se.values,je=k(se);if(!je){for(let we=0;we<ce;we++)ie[we]=Ee[ge[we]];return ie}const pe=ee(null)?1:0;for(let we=0;we<ce;we++)ie[we]=je(we)===1?Ee[ge[we]]:pe;return ie}function M(se,ee,ie,ce){const he=U(se.values),me=ee(!0)?1:0,Ee=ee(!1)?1:0,ge=k(se);if(!ge){for(let pe=0;pe<ce;pe++)ie[pe]=he(pe)===1?me:Ee;return ie}const je=ee(null)?1:0;for(let pe=0;pe<ce;pe++)ie[pe]=ge(pe)===0?je:he(pe)===1?me:Ee;return ie}function A(se,ee,ie,ce,he){const me=se.values,Ee=ee.type,ge=ee.op;let je=!0;switch(ge){case"eq":case"ne":{const we=i(f(ee.value,Ee)),ye=typeof ee.value=="number"&&Number.isNaN(ee.value),Ne=ge==="ne"?1:0;if(ye)for(let $e=0;$e<he;$e++)ce[$e]=(Number.isNaN(me[$e])?1:0)^Ne;else for(let $e=0;$e<he;$e++)ce[$e]=(me[$e]===we?1:0)^Ne;break}case"lt":{const we=i(f(ee.value,Ee));for(let ye=0;ye<he;ye++)ce[ye]=me[ye]<we?1:0;break}case"lte":{const we=i(f(ee.value,Ee));for(let ye=0;ye<he;ye++)ce[ye]=me[ye]<=we?1:0;break}case"gt":{const we=i(f(ee.value,Ee));for(let ye=0;ye<he;ye++)ce[ye]=me[ye]>we?1:0;break}case"gte":{const we=i(f(ee.value,Ee));for(let ye=0;ye<he;ye++)ce[ye]=me[ye]>=we?1:0;break}case"between":case"notBetween":{const we=B(ee.value),ye=i(f(we[0],Ee)),Ne=i(f(we[1],Ee)),$e=ee.bounds||"[]",Ve=$e.charAt(0)!=="(",qe=$e.charAt(1)!==")",Ae=ge==="notBetween"?1:0;if(Ve&&qe)for(let Ge=0;Ge<he;Ge++)ce[Ge]=(me[Ge]>=ye&me[Ge]<=Ne?1:0)^Ae;else if(Ve)for(let Ge=0;Ge<he;Ge++)ce[Ge]=(me[Ge]>=ye&me[Ge]<Ne?1:0)^Ae;else if(qe)for(let Ge=0;Ge<he;Ge++)ce[Ge]=(me[Ge]>ye&me[Ge]<=Ne?1:0)^Ae;else for(let Ge=0;Ge<he;Ge++)ce[Ge]=(me[Ge]>ye&me[Ge]<Ne?1:0)^Ae;break}case"in":case"notIn":{const we=new Set;for(const Ne of B(ee.value)){const $e=i(f(Ne,Ee));Number.isNaN($e)||we.add($e)}const ye=ge==="notIn"?1:0;for(let Ne=0;Ne<he;Ne++)ce[Ne]=(we.has(me[Ne])?1:0)^ye;break}default:je=!1;break}if(!je)return!1;const pe=k(se);if(pe){const we=ie(null)?1:0;for(let ye=0;ye<he;ye++)pe(ye)===0&&(ce[ye]=we)}return!0}function L(se,ee,ie,ce){const he=l(se);for(let me=0;me<ce;me++)ie[me]=ee(he(me))?1:0;return ie}function G(se,ee,ie){const ce=ee.count|0,he=ie||n(ee,ce);if(!se)return r(he,ce,1);const me=typeof ee.handle=="function"?ee.handle(se.col):void 0,Ee=typeof ee.custom=="function"?ee.custom:null;if(!me){if(Ee){for(let we=0;we<ce;we++)he[we]=Ee(se,we)?1:0;return he}return I(`filter:col:${String(se.col)}`,`filter references unknown column "${String(se.col)}"; the condition is refused rather than matching every row`),r(he,ce,0)}const ge=se.op;if(ge==="blank"||ge==="notBlank")return D(me,ge==="notBlank",he,ce);const je=typeof ee.itemwise=="function"?ee.itemwise(se.col):null;if(je&&!ae(ge)&&!F.has(ge))return L(me,E(se,je,ee.locale),he,ce);const pe=b(se,ee.locale);switch(me.kind){case"dictionary":return N(me,pe,he,ce);case"bitset":return M(me,pe,he,ce);case"float64":case"int32":return A(me,se,pe,he,ce)?he:L(me,pe,he,ce);default:return L(me,pe,he,ce)}}function q(se,ee,ie){if(!se)return r(n(ee,ie),ie,1);if(Array.isArray(se.conditions)){const ce=se.conditions.filter(Ee=>Ee!=null),he=se.op==="or"?"or":se.op==="not"?"not":"and";if(ce.length===0)return r(n(ee,ie),ie,1);const me=q(ce[0],ee,ie);for(let Ee=1;Ee<ce.length;Ee++){const ge=q(ce[Ee],ee,ie);if(he==="or")for(let je=0;je<ie;je++)me[je]|=ge[je];else for(let je=0;je<ie;je++)me[je]&=ge[je];t(ee,ge)}if(he==="not")for(let Ee=0;Ee<ie;Ee++)me[Ee]^=1;return me}return G(se,ee,n(ee,ie))}function Y(se,ee){return q(se,ee,ee.count|0)}function J(se,ee){if(!se||!ee)return se||null;const ie=se;if(Array.isArray(ie.conditions)){if((ie.op==="or"?"or":ie.op==="not"?"not":"and")!=="and")return te(ie,ee)?null:se;const he=[];for(const me of ie.conditions){const Ee=J(me,ee);Ee&&he.push(Ee)}return he.length?{...ie,op:"and",conditions:he}:null}return ie.col===ee?null:se}function te(se,ee){if(!se||typeof se!="object")return!1;const ie=se;if(ie.col===ee)return!0;if(Array.isArray(ie.conditions)){for(const ce of ie.conditions)if(te(ce,ee))return!0}return!1}function ne(se,ee,ie){if(ie&&ie.length>=ee){let Ee=0;for(let ge=0;ge<ee;ge++)se[ge]&&(ie[Ee++]=ge);return ie.subarray(0,Ee)}let ce=0;for(let Ee=0;Ee<ee;Ee++)ce+=se[Ee]?1:0;const he=new Uint32Array(ce);let me=0;for(let Ee=0;Ee<ee;Ee++)se[Ee]&&(he[me++]=Ee);return he}const oe=new Map;function le(se){if(!(!se||typeof se!="object"))for(const[ee,ie]of Object.entries(se))ie&&typeof ie.compile=="function"&&oe.set(ee,ie)}function ae(se){return typeof se=="string"?oe.get(se):void 0}}),Fe("packages/core/src/columns/datatypes.js",function(e,K){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return F}});const Q=K("packages/core/src/internal/util.js"),$=Q.collator,B=Q.defaultCompare,I=Q.isNil,_=Q.isObject,X=Q.isFunction,W=Q.fail,H=Q.titleCase,U=K("packages/core/src/format/date.js"),z=U.toDate,w=U.toIsoDate,k=U.compareIso,l=K("packages/core/src/format/boolean.js").toTriState,s=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,n=K("packages/core/src/formula/index.js"),t=n.evaluateFormula,r=n.looksLikeFormula,f=K("packages/core/src/compute/filter.js").declareOperators,u=/^\d{4}-\d{2}-\d{2}$/;function i(E){return E.getHours()===0&&E.getMinutes()===0&&E.getSeconds()===0&&E.getMilliseconds()===0}const m=new Map;function d(E){const D=E||"",N=m.get(D);if(N)return N;const M={group:",",decimal:"."};try{for(const A of new Intl.NumberFormat(E||void 0).formatToParts(12345.6))A.type==="group"?M.group=A.value:A.type==="decimal"&&(M.decimal=A.value)}catch{}return m.set(D,M),M}const h=/\d\s*[*/^]\s*[\d.(]/;function a(E,D){if(I(E))return null;let N=String(E).trim();if(N===""||N.startsWith("=")||h.test(N))return null;let M=1;N.startsWith("(")&&N.endsWith(")")&&(M=-1,N=N.slice(1,-1));const A=N.endsWith("%"),{group:L,decimal:G}=d(D);if(N=N.replace(/[\s\u00a0\u202f\u2009']/g,""),L&&L!=="."&&L!==","&&(N=N.split(L).join("")),N=N.replace(/[^0-9eE+\-.,]/g,""),G===","?N=N.split(".").join("").replace(",","."):N=N.split(",").join(""),N===""||N==="-"||N==="+")return null;const q=Number(N);return Number.isNaN(q)?null:M*(A?q/100:q)}function p(E,D){const N=I(E)||Number.isNaN(E)?null:Number(E),M=I(D)||Number.isNaN(D)?null:Number(D);return N===null?M===null?0:1:M===null||N<M?-1:N>M?1:0}function b(E,D){const N=l(E),M=l(D);return N===null?M===null?0:1:M===null?-1:N===M?0:N?1:-1}function j(E,D){const N=z(E),M=z(D);if(!N)return M?1:0;if(!M)return-1;const A=N.getTime(),L=M.getTime();return A<L?-1:A>L?1:0}const S=new Map;function y(E){const D=z(E.value);if(!D)return"";const N=E.locale||"";let M=S.get(N);return M||(M=new Intl.DateTimeFormat(E.locale||void 0,{dateStyle:"medium"}),S.set(N,M)),M.format(D)}const v={boolean:{base:"boolean",storage:"bitset",matches:E=>typeof E=="boolean",parse:E=>l(E.text),compare:b,format:E=>l(E.value)===null?"":l(E.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:E=>l(E)===null?"":String(l(E)),fromClipboard:E=>l(E)},number:{base:"number",storage:"float64",matches:E=>typeof E=="number"&&!Number.isNaN(E),parse:E=>{if(r(E.text)){const D=t(E.text,E);if(!D.ok)return null;const N=Number(D.value);return Number.isFinite(N)?N:null}return a(E.text,E.locale)},compare:p,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:E=>I(E)?"":String(E),fromClipboard:(E,D)=>a(E,D&&D.locale)},date:{base:"dateString",storage:"dictionary",matches:E=>typeof E=="string"&&u.test(E)&&!Number.isNaN(Date.parse(E))||E instanceof Date&&!Number.isNaN(E.getTime())&&i(E),parse:E=>w(E.text),compare:k,format:y,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:E=>w(E),toClipboard:E=>I(E)?"":String(E),fromClipboard:E=>w(E)},dateString:{base:"dateString",storage:"dictionary",matches:E=>typeof E=="string"&&u.test(E)&&!Number.isNaN(Date.parse(E)),parse:E=>w(E.text),compare:k,format:y,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:E=>w(E),toClipboard:E=>I(E)?"":String(E),fromClipboard:E=>w(E)},text:{base:"text",storage:"dictionary",matches:E=>typeof E=="string",parse:E=>E.text===""?null:String(E.text),compare:(E,D)=>I(E)?I(D)?0:1:I(D)?-1:$().compare(String(E),String(D)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:E=>I(E)?"":String(E),fromClipboard:E=>E},image:{base:"text",storage:"dictionary",parse:E=>E.text===""||E.text==null?null:String(E.text).trim(),compare:(E,D)=>I(E)?I(D)?0:1:I(D)?-1:$().compare(String(E),String(D)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:E=>I(E)?"":String(E),fromClipboard:E=>E},lookup:{base:"text",storage:"dictionary",parse:E=>{if(E.text===""||E.text==null)return null;const D=E.column&&E.column.lookup,N=D&&X(D.options)?D.options():null;if(!N)return E.text;const M=String(E.text),A=N.find(q=>String(q.id)===M);if(A)return A.id;const L=M.trim().toLowerCase(),G=N.find(q=>String(q.label).toLowerCase()===L);return G?G.id:E.text},compare:B,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:E=>I(E)?"":String(E),fromClipboard:E=>E},object:{base:"object",storage:"object",matches:E=>E!==null&&typeof E=="object"&&!(E instanceof Date),parse:E=>{try{return E.text===""?null:JSON.parse(E.text)}catch{return E.text}},compare:(E,D)=>B(E,D),format:E=>{const D=E.value;if(I(D))return"";if(typeof D=="string")return D;try{return JSON.stringify(D)}catch{return String(D)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:E=>I(E)?"":typeof E=="string"?E:JSON.stringify(E),fromClipboard:E=>E}},R=["boolean","number","date","dateString","datetime","text","object"];function O(E,D,N,M){const A=N.get(E);if(A)return A;M.includes(E)&&W(`circular data type extends chain: ${[...M,E].join(" → ")}`);const L=D[E];L||W(`unknown data type "${E}"`);let G=null;L.extends&&(G=O(L.extends,D,N,[...M,E]));const q={...G||{},...L,name:E,defaults:{...G&&G.defaults||{},...L.defaults||{}}};return q.base||(q.base=G&&G.base||"text"),q.storage||(q.storage=G&&G.storage||"object"),N.set(E,q),q}function x(E,D){const N={...v,...s};if(D&&typeof D.dataType=="function"&&typeof D.names=="function")for(const A of D.names("dataType")){const L=D.dataType(A);L&&(N[A]=L)}if(_(E))for(const[A,L]of Object.entries(E))N[A]=L;const M=new Map;for(const A of R)O(A,N,M,[]);O("lookup",N,M,[]);for(const A of Object.keys(N))O(A,N,M,[]);for(const A of M.values())f(A.operators);return M}function C(E,D){if(E.base==="text"&&(!E.compare||E.compare===v.text.compare)){const N=$(D);return(M,A)=>I(M)?I(A)?0:1:I(A)?-1:N.compare(String(M),String(A))}return E.compare||B}function P(E,D){return D?E.multiStorage||"multi":E.storage||"object"}function F(E){return H(String(E).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Fe("packages/core/src/columns/infer.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return X}});const Q=K("packages/core/src/internal/util.js"),$=Q.infoOnce,B=Q.isNil,I=100;function _(W,H,U={}){const z=U.sampleSize??I,w=[];for(let k=0;k<W.length&&w.length<z;k++){const g=W[k];B(g)||typeof g=="number"&&Number.isNaN(g)||w.push(g)}if(w.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[k,g]of H){if(typeof g.matches!="function")continue;let l=!0;for(let c=0;c<w.length;c++)if(!g.matches(w[c])){l=!1;break}if(l)return{type:k,unanimous:!0,sampled:w.length}}return U.quiet||$(`infer:${U.colId||"?"}`,`column "${U.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:w.length}}function X(W,H,U,z,w={}){const k=w.sampleSize??I,g=[];for(let l=0;l<H.length&&g.length<k;l++){const c=U(H[l]);B(c)||typeof c=="number"&&Number.isNaN(c)||g.push(c)}return _(g,z,{...w,colId:W}).type}}),Fe("packages/core/src/columns/graph.js",function(e,K){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return z}});const Q=K("packages/core/src/internal/util.js"),$=Q.DEV,B=Q.fail,I=Q.isFunction,_=Q.warnOnce,X="*";function W(w){const k=w.value||{};if(!I(k.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const l=k.pure!==!1;return k.deps===X?{computed:!0,wholeRow:!0,deps:[],pure:l}:Array.isArray(k.deps)?{computed:!0,wholeRow:!1,deps:k.deps.slice(),pure:l}:(_(`deps:missing:${w.id}`,`computed column "${w.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:l})}function H(w){const k=new Map;for(const m of w)k.set(m.id,m);const g=new Map,l=new Map,c=new Set,s=new Set,n=new Set,t=new Set;for(const m of w){const d=W(m);if(!d.computed){g.set(m.id,[]);continue}s.add(m.id),(d.pure?n:t).add(m.id),d.wholeRow&&c.add(m.id);const h=[],a=[];for(const p of d.deps)(k.has(p)?h:a).push(p);g.set(m.id,h),a.length&&l.set(m.id,a)}for(const m of n)for(const d of g.get(m))t.has(d)&&B(`pure computed column "${m}" depends on impure column "${d}". Mark it \`value.pure: false\` or make the dependency pure.`);const r=[],o=new Map,f=[],u=m=>{const d=o.get(m);if(d!=="done"){if(d==="open"){const h=f.indexOf(m);B(`circular column dependency: ${[...f.slice(h),m].join(" → ")}`)}o.set(m,"open"),f.push(m);for(const h of g.get(m)||[])k.has(h)&&u(h);f.pop(),o.set(m,"done"),r.push(m)}};for(const m of w)u(m.id);const i=new Map;for(const m of w)i.set(m.id,[]);for(const m of w)for(const d of g.get(m.id)||[]){const h=i.get(d);h&&!h.includes(m.id)&&h.push(m.id)}if(c.size)for(const m of w){if(s.has(m.id))continue;const d=i.get(m.id);for(const h of c)d.includes(h)||d.push(h)}return{order:r,dependents:i,pure:n,impure:t,computed:s,deps:g,wholeRow:c,external:l,index:k}}function U(w,k){const g=Array.isArray(k)?k:[k],l=new Set,c=[...g];for(;c.length;){const s=c.shift();for(const n of w.dependents.get(s)||[])l.has(n)||(l.add(n),c.push(n))}for(const s of g)l.delete(s);return w.order.filter(s=>l.has(s))}function z(w,k,g){if(!$)return w;const l=k instanceof Set?k:new Set(k);return new Proxy(w,{get(c,s){return typeof s=="string"&&!l.has(s)&&!Object.hasOwn(c,s)&&_(`undeclared:${g}:${s}`,`computed column "${g}" read undeclared dependency "${s}". Add it to \`value.deps\` or the value will go stale.`),c[s]}})}}),Fe("packages/core/src/model/rowkey.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return c}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.pathGetter,I=Q.isFunction,_=Q.isBlank,X=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],W="";function H(s){if(s===null)return"\0n";if(s===void 0)return"\0u";const n=typeof s;if(n==="string")return s;if(n==="number"||n==="bigint"||n==="boolean")return String(s);if(s instanceof Date)return`\0d${s.getTime()}`;try{return`\0o${JSON.stringify(s)}`}catch{return"\0o?"}}function U(s){if(s.length===1)return H(s[0]);let n="";for(let t=0;t<s.length;t++)t&&(n+=W),n+=H(s[t]);return n}function z(s,n={}){const t=n.warn!==!1;if(I(s)){const r=s;return{stable:!0,fields:[],disabled:[],key(o,f){try{const u=r(o);return Array.isArray(u)?U(u):H(u)}catch(u){return $("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",u),`#${f??-1}`}},keyEmpty(o){try{const f=r(o);return Array.isArray(f)?f.length===0||f.some(_):_(f)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(s)&&s.length>0){const r=s.filter(u=>typeof u=="string"),o=r.map(u=>B(u)),f=o.length;return{stable:!0,fields:r,disabled:[],key(u){const i=new Array(f);for(let m=0;m<f;m++)i[m]=o[m](u);return U(i)},keyEmpty(u){for(let i=0;i<f;i++)if(_(o[i](u)))return!0;return!1},missingFields(u){const i=[];for(let m=0;m<f;m++)_(o[m](u))&&i.push(r[m]);return i}}}if(typeof s=="string"&&s.length>0){const r=B(s);return{stable:!0,fields:[s],disabled:[],key(o){return H(r(o))},keyEmpty(o){return _(r(o))},missingFields(o){return _(r(o))?[s]:[]}}}return t&&$("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${X.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:X.slice(),key(r,o){if(r===null||typeof r!="object")return`#${o??0}:${String(r)}`;let f=w.get(r);return f===void 0&&(f=`#${k++}`,w.set(r,f)),f}}}const w=new WeakMap;let k=0;function g(s,n){if(!s||s.stable===!1||!I(s.keyEmpty)||!Array.isArray(n)||n.length===0)return;let t=0,r=null,o;for(let m=0;m<n.length;m++){const d=n[m];s.keyEmpty(d)&&(t++,r===null&&(r=I(s.missingFields)?s.missingFields(d):[],o=d))}if(t===0)return;const f=s.fields.length?s.fields.join(","):"(function)",u=r&&r.length?r.join(", "):s.fields.length?s.fields.join(", "):"the rowKey function",i=o!==null&&typeof o=="object"?Object.keys(o).join(", ")||"(no fields)":String(o);$(`rowKey.emptyValue:${f}`,`rowKey ${u} is missing on ${t} of ${n.length} rows; the first such row has: ${i}. 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(s){return U(s)}function c(s){return s.split(W)}}),Fe("packages/core/src/columns/lookup.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return s}});const Q=K("packages/core/src/internal/util.js"),$=Q.collator,B=Q.defaultCompare,I=Q.isFunction,_=Q.isNil,X=Q.warnOnce,H=K("packages/core/src/model/rowkey.js").compositeKey,U=", ",z="";function w(n,t,r,o){if(n===null||typeof n!="object")return{id:n,label:n==null?"":String(n)};const f=n[t],u=n[r],i={id:f,label:u==null?String(f??""):String(u)};n.disabled&&(i.disabled=!0),n.variant&&(i.variant=n.variant),n.icon&&(i.icon=n.icon);const m=o?n[o]:n.group;return m!==void 0&&(i.group=m),i}function k(n,t,r=0,o=[],f=[]){for(const u of n||[]){const i=u&&typeof u=="object"?u[t]:null;if(f.push({raw:u,depth:r,path:o}),Array.isArray(i)&&i.length){const m=String(u&&typeof u=="object"?u.label??u.name??u.id??"":u);k(i,t,r+1,[...o,m],f)}}return f}function g(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&I(n.router&&n.router.subscribe)}class l{#e;#t;#n;#r;#o=[];#i=new Map;#s=new Map;#l=0;#a="idle";#u=null;#c;#d=null;#f=new Map;constructor(t,r={}){this.#e=t||{},this.#t=r.colId||"?",this.#n=r.locale,this.#r=r.onChange||null,this.#c=$(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??U}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#o}setLocale(t){this.#n=t,this.#c=$(t)}#h(t){const r=this.#e,o=r.valueKey||"id",f=r.labelKey||"label",u=r.childrenKey||"children";this.#o=k(t,u).map(i=>{const m=w(i.raw,o,f,r.groupKey);return i.depth&&(m.depth=i.depth,m.path=i.path),m}),this.#i=new Map,this.#s=new Map,this.#o.forEach((i,m)=>{this.#i.set(i.id,i),this.#s.set(i.id,m)}),this.#a="ready",this.#l+=1}load(){if(this.#u)return this.#u;const t=this.#e.options;if(Array.isArray(t)||t===void 0)return this.#u=Promise.resolve(this.#o),this.#u;if(g(t))return this.#u=this.#p(t),this.#u;if(!I(t))return X(`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.#u=Promise.resolve([]),this.#u;this.#a="loading";let r;try{r=t()}catch(o){return this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,o),this.#u=Promise.resolve([]),this.#u}return!r||!I(r.then)?(this.#h(r),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=r.then(o=>(this.#h(o),this.#r&&this.#r(this),this.#o),o=>(this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,o),[])),this.#u)}refresh(){return this.#u=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#o)):this.load()}#p(t){if(this.#d)return Promise.resolve(this.#o);const r=this.#e,o=r.valueKey||"id",f=r.labelKey||"label",u=r.groupKey,i=I(t.map)?t.map:null,m=h=>w(i?i(h):h,o,f,u).id,d=h=>this.#m(h,i,o,f,u);return t.router.subscribe(t.predicate,d,{rowKey:m}),this.#d=()=>{I(t.router.detach)&&t.router.detach(d)},this.#a="ready",Promise.resolve(this.#o)}#m(t,r,o,f,u){const i=t&&t.add||[],m=t&&t.update||[],d=t&&t.remove||[];if(!(!i.length&&!m.length&&!d.length)){for(const h of i)this.#g(h,r,o,f,u);for(const h of m)this.#g(h,r,o,f,u);for(const h of d){if(!this.#f.has(h))continue;const a=this.#f.get(h);this.#f.delete(h),this.#i.delete(a);const p=this.#o.findIndex(b=>b.id===a);p>=0&&this.#o.splice(p,1)}this.#s=new Map(this.#o.map((h,a)=>[h.id,a])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(t,r,o,f,u){const i=w(r?r(t):t,o,f,u);this.#f.set(H([i.id]),i.id);const m=this.#o.findIndex(d=>d.id===i.id);m>=0?this.#o[m]=i:this.#o.push(i),this.#i.set(i.id,i)}destroy(){this.#d&&(this.#d(),this.#d=null)}search(t,r){const o=this.#e;if(!I(o.search)){const i=String(t||"").toLowerCase();return Promise.resolve(i===""?this.#o:this.#o.filter(m=>m.label.toLowerCase().includes(i)))}const f=o.valueKey||"id",u=o.labelKey||"label";return Promise.resolve(o.search(t,r)).then(i=>(i||[]).map(m=>w(m,f,u,o.groupKey)))}option(t){return this.#i.get(t)}has(t){return this.#i.has(t)}label(t){if(_(t)||t==="")return"";const r=this.#i.get(t);if(r)return r.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||X(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(t)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const o=this.#e.unknownLabel;return I(o)?String(o(t)??""):typeof o=="string"?o:String(t)}text(t){if(this.multiple){const r=c(t);return r.length===0?"":r.map(o=>this.label(o)).join(this.separator)}return this.label(t)}dictionary(){return this.#o.map(t=>t.id)}sorted(){const t=this.sortBy;if(t==="optionOrder"||t==="count")return this.#o.slice();if(t==="value")return this.#o.slice().sort((o,f)=>B(o.id,f.id));const r=this.#c;return this.#o.slice().sort((o,f)=>r.compare(o.label,f.label))}comparator(){const t=this.sortBy,r=this.multiple,o=this.#c,f=this.#s;if(r&&t==="count")return(i,m)=>c(i).length-c(m).length;const u=r?i=>c(i)[0]:i=>i;return t==="value"?(i,m)=>B(u(i),u(m)):t==="optionOrder"?(i,m)=>{const d=f.has(u(i))?f.get(u(i)):Number.MAX_SAFE_INTEGER,h=f.has(u(m))?f.get(u(m)):Number.MAX_SAFE_INTEGER;return d-h}:(i,m)=>{const d=u(i),h=u(m);return _(d)?_(h)?0:1:_(h)?-1:o.compare(this.label(d),this.label(h))}}groupKey(t){return this.multiple?c(t).map(o=>String(o)).sort().join(z):_(t)?"":String(t)}countValues(t){return this.multiple?c(t).length:_(t)?0:1}contains(t,r,o){const f=this.multiple?c(t):_(t)?[]:[t],u=Array.isArray(r)?r:[r];switch(o){case"containsAll":return u.every(i=>f.includes(i));case"containsNone":return!u.some(i=>f.includes(i));default:return u.some(i=>f.includes(i))}}exportText(t,r="label"){return r==="value"?this.multiple?c(t).join(this.separator):_(t)?"":String(t):this.text(t)}exportColumns(){const t=this.multiple;return this.#o.map(r=>({id:r.id,label:r.label,has:o=>t?c(o).includes(r.id):o===r.id}))}}function c(n){return Array.isArray(n)?n:_(n)||n===""?[]:[n]}function s(n,t={}){const r=n.lookup;if(!r)return null;const o=new l(r,{colId:n.id,locale:t.locale,onChange:t.onChange});return!Array.isArray(r.options)&&r.options!==void 0&&o.load(),o}}),Fe("packages/core/src/columns/value.js",function(e,K){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),$=Q.getPath,B=Q.isFunction,I=Q.isNil,_=Q.Lru,X=Q.warnOnce,H=K("packages/core/src/columns/graph.js").depsProxy,U="\0";function z(n,t={}){const r=t.locale,o=t.grid??null,f=t.context,u=n.value&&n.value.format,i=n.formatter||null,m=n.dataType&&n.dataType.format,d=n.lookup||null,h=(a,p,b)=>({value:a,data:b,row:p,column:n,colId:n.id,grid:o,context:f,locale:r});if(B(u))return(a,p,b)=>{const j=u(h(a,p,b));return j==null?"":String(j)};if(i){if(d){const a=i.kind==="text";return(p,b,j)=>i(a?d.text(p):p,h(p,b,j))}return(a,p,b)=>i(a,h(a,p,b))}return B(m)?(a,p,b)=>{const j=m(h(a,p,b));return j==null?"":String(j)}:d?a=>d.text(a):a=>I(a)?"":typeof a=="string"?a:String(a)}function w(n,t){!n||!n.value||n.value.pure!==!1||X(`impure:${t}:${n.id}`,`column "${n.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${t}. The result is not stable across passes.`)}class k{#e;#t;#n;#r;#o;#i;#s=new _(4096);constructor(t){this.#e=t.columns instanceof Map?t.columns:new Map((t.columns||[]).map(r=>[r.id,r])),this.#t=t.graph,this.#n=t.grid??null,this.#r=t.context,this.#i=t.stored||null,this.#o=t.rowKey||g}get graph(){return this.#t}setGraph(t){this.#t=t,this.#s.clear()}beginPass(){this.#s.clear()}endPass(){this.#s.clear()}invalidate(t){if(this.#s.size===0)return;const r=t&&t.rows?new Set([...t.rows].map(String)):null,o=t&&t.columns?[...t.columns]:null;if(!r&&!o){this.#s.clear();return}const f=o?this.#l(o):null;for(const u of[...this.#s.keys()]){const i=String(u).split(U);i.length===3&&(r&&!r.has(i[0])||f&&!f.has(i[2])||this.#s.delete(u))}}#l(t){const r=new Set,o=this.#t,f=[...t];for(;f.length;){const u=f.pop();if(!r.has(u)){r.add(u);for(const i of o?o.dependents.get(u)||[]:[])f.push(i)}}return r}value(t,r,o){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return;if(!f.computed)return this.#u(f,r,o);if(f.value.pure!==!1&&this.#i&&o&&o.physical!=null&&this.#i.has(f.id))return this.#i.get(f.id,o.physical);if(f.volatile)return this.compute(f,r,o);if(f.value.pure===!1)return this.compute(f,r,o);const u=`${this.#a(r,o)}${U}${f.id}`;if(this.#s.has(u))return this.#s.get(u);const i=this.compute(f,r,o);return this.#s.set(u,i),i}#a(t,r){return`${this.#o(t,r)}${U}${l(t)}`}#u(t,r,o){if(this.#i&&o&&o.physical!=null&&this.#i.has(t.id))return this.#i.get(t.id,o.physical);if(t.field)return t.read?t.read(r):$(r,t.field)}compute(t,r,o){const f=this.#t,u=f&&f.wholeRow.has(t.id);let i;if(u)i=r??{};else{i={};const d=f&&f.deps.get(t.id)||[];for(const a of d)i[a]=this.value(a,r,o);const h=f&&f.external.get(t.id)||[];for(const a of h)i[a]=$(r,a);i=H(i,[...d,...h],t.id)}const m={data:r,row:o,column:t,grid:this.#n,context:this.#r};return t.value.compute(i,m)}values(t,r){const o={},f=this.#t?this.#t.order:[...this.#e.keys()];for(const u of f)o[u]=this.value(u,t,r);return o}text(t,r,o){const f=typeof t=="string"?this.#e.get(t):t;return f?f.formatValue(this.value(f,r,o),o,r):""}key(t,r,o){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return"";const u=this.value(f,r,o);return B(f.value.key)?String(f.value.key(this.#c(f,u,r,o))):f.lookup?f.lookup.groupKey(u):I(u)?"":String(u)}quickFilterText(t,r,o){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return"";if(B(f.value.quickFilterText)){const u=this.value(f,r,o);return String(f.value.quickFilterText(this.#c(f,u,r,o))??"")}return this.text(f,r,o)}#c(t,r,o,f){return{value:r,data:o,row:f,column:t,colId:t.id,grid:this.#n,context:this.#r}}parse(t,r,o,f){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return r;const i={text:r,value:this.value(u,o,f),data:o,row:f,column:u,grid:this.#n,context:this.#r,locale:this.#n&&B(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&B(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return B(u.value.parse)?u.value.parse(i):u.dataType&&B(u.dataType.parse)?u.dataType.parse(i):r}validate(t,r,o,f,u){const i=typeof t=="string"?this.#e.get(t):t;if(!i||!B(i.edit.validate))return!0;const m=i.edit.validate({value:r,oldValue:o,data:f,row:u,column:i,grid:this.#n,context:this.#r});return m===!0||m===void 0?!0:String(m)}apply(t,r,o,f){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return!1;const i=this.value(u,o,f);if(B(u.value.apply)){const m=u.value.apply({value:r,oldValue:i,data:o,row:f,column:u,grid:this.#n,context:this.#r});return this.#d(u,o,f),m!==!1}return u.field?i===r?!1:(u.write(o,r),this.#d(u,o,f),!0):(X(`apply:${u.id}`,`column "${u.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(t,r,o,f){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const i=this.value(u,o,f),m=this.parse(u,r,o,f),d=this.validate(u,m,i,o,f);if(d!==!0)return{ok:!1,value:m,oldValue:i,changed:!1,error:d};const h=this.apply(u,m,o,f);return{ok:!0,value:m,oldValue:i,changed:h}}#d(t,r,o){if(this.#s.size===0)return;const f=this.#a(r,o);this.#s.delete(`${f}${U}${t.id}`);for(const u of this.#t?this.#t.dependents.get(t.id)||[]:[])this.#s.delete(`${f}${U}${u}`)}}function g(n,t){return t&&t.key!=null?String(t.key):l(n)}function l(n){if(n&&typeof n=="object"){let t=c.get(n);return t===void 0&&(t=`#${s++}`,c.set(n,t)),t}return String(n)}const c=new WeakMap;let s=0}),Fe("packages/core/src/model/shadow.js",function(e,K){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return i}});const $=K("packages/core/src/internal/util.js").warnOnce,B=2e5,I=20,_=1e3,X=50;function W(m){return Math.min(_,Math.max(X,Math.floor(m)))}const H=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"]),U=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),z=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),w=.6745,k=3.5,g=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),l=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),c=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 s(m,d){if(!d)return null;const h=Number.isFinite(Number(d.lower))?Number(d.lower):null,a=Number.isFinite(Number(d.upper))?Number(d.upper):null;if(h===null&&a===null||!Number.isFinite(m))return null;if(h!==null&&m<h||a!==null&&m>a)return g.FAIL;const p=Number.isFinite(Number(d.warnLower))?Number(d.warnLower):null,b=Number.isFinite(Number(d.warnUpper))?Number(d.warnUpper):null;return p!==null&&m<p||b!==null&&m>b?g.WARN:g.PASS}function n(m,d,h){if(!d||typeof d!="object")return null;if(d.kind!=="time")return d.kind!==void 0&&$(`shadow.history.window.kind:${m}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${d.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 a=d.minutes!=null?Number(d.minutes)*6e4:Number(d.span);if(!(a>0))return $(`shadow.history.window.span:${m}`,"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 p=Math.max(2,Math.floor(h)||I);return{span:a,bucketMs:Math.max(1,Math.floor(a/p))}}class t{#e;#t=new Map;#n=new Map;#r=new Map;#o=new Map;#i=new Map;#s=new Map;#l=0;#a;#u;#c;#d;#f=new Map;#h=null;#p=null;#m=null;constructor(d){this.#e=d.colId,this.#a=Math.max(2,d.depth||I),this.#u=Math.max(1,d.max||B),this.#c=d.now||(()=>Date.now()),this.#d=n(this.#e,d.historyWindow,this.#a),this.#d&&(this.#h=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(d,h){const a=u(h);if(a===null)return;if(!this.#n.has(d)){this.#p=null,this.#m=null,this.#g(),this.#t.set(d,a),this.#n.set(d,a),this.#r.set(d,0),this.#o.set(d,this.#c()),this.#i.set(d,[a]),this.#d&&this.#f.set(d,[a]),this.#s.set(d,0);return}const p=this.#n.get(d);if(p===a)return;this.#p=null,this.#m=null,this.#n.set(d,a),this.#r.set(d,(this.#r.get(d)||0)+1),this.#o.set(d,this.#c());const b=this.#i.get(d)||[];b.push(a),b.length>this.#a&&b.splice(0,b.length-this.#a),this.#i.set(d,b);const j=Math.sign(a-p),S=this.#s.get(d)||0;this.#s.set(d,Math.sign(S)===j?S+j:j)}#g(){if(this.#n.size<this.#u)return;const d=this.#n.keys().next().value;d!==void 0&&(this.#t.delete(d),this.#n.delete(d),this.#r.delete(d),this.#o.delete(d),this.#i.delete(d),this.#f.delete(d),this.#s.delete(d),this.#l++)}rebase(){for(const[d,h]of this.#n)this.#t.set(d,h);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#o.clear(),this.#i.clear(),this.#f.clear(),this.#s.clear(),this.#l=0,this.#p=null,this.#m=null,this.#d&&(this.#h=Math.floor(this.#c()/this.#d.bucketMs))}retain(d){const h=d instanceof Set?d:new Set(d);let a=0;for(const p of[...this.#n.keys()])h.has(p)||(this.#t.delete(p),this.#n.delete(p),this.#r.delete(p),this.#o.delete(p),this.#i.delete(p),this.#f.delete(p),this.#s.delete(p),a++);return a&&(this.#p=null,this.#m=null),a}advanceHistoryWindow(d=this.#c()){const h=this.#d;if(!h)return 0;const a=Math.floor(d/h.bucketMs),p=a-this.#h;if(!(p>0))return 0;const b=Math.min(p,this.#a);for(const[j,S]of this.#f){const y=this.#n.get(j);for(let v=0;v<b;v++)S.push(y);S.length>this.#a&&S.splice(0,S.length-this.#a)}return this.#h=a,p}read(d,h,a,p){switch(d){case"updates":return this.#r.has(h)?this.#r.get(h):0;case"updatedAt":{const b=this.#o.get(h);return b===void 0?null:new Date(b)}case"sinceUpdate":{const b=this.#o.get(h);return b===void 0?null:this.#c()-b}case"firstValue":return this.#t.has(h)?this.#t.get(h):null;case"delta":return this.#n.has(h)?this.#n.get(h)-this.#t.get(h):null;case"deltaPercent":{if(!this.#n.has(h))return null;const b=this.#t.get(h);return b?(this.#n.get(h)-b)/Math.abs(b)*100:null}case"rate":{const b=this.#i.get(h),j=this.#o.get(h);if(!b||b.length<2||j===void 0)return null;const S=this.#c()-j,y=b[b.length-1]-b[b.length-2];return S>0?y/S*1e3:y}case"history":return this.#d?this.#f.has(h)?[...this.#f.get(h)]:null:this.#i.has(h)?[...this.#i.get(h)]:null;case"streak":return this.#s.has(h)?this.#s.get(h):0;case"specStatus":return this.#n.has(h)?s(this.#n.get(h),p):null;default:return l.includes(d)?this.#S(d,h,a,p):null}}#b(d){if(d){if(this.#m&&this.#m.only===d)return this.#m.view;const h=this.#w(d);return this.#m={only:d,view:h},h}return this.#p?this.#p:(this.#p=this.#w(null),this.#p)}#w(d){const h=[];for(const[x,C]of this.#n)d&&!d.has(x)||h.push(C);const a=h.sort((x,C)=>x-C);let p=0,b=0,j=0,S=0;for(const x of a){S+=x,p++;const C=x-b;b+=C/p,j+=C*(x-b)}const y=[];for(const[x,C]of this.#t)d&&!d.has(x)||y.push(C);const v=p?r(a):0,R=a.map(x=>Math.abs(x-v)).sort((x,C)=>x-C),O=p?r(R):0;return{sorted:a,baseline:y.sort((x,C)=>x-C),sum:S,mean:p?b:0,sd:p>1?Math.sqrt(j/(p-1)):0,median:v,mad:O}}#S(d,h,a,p){if(!this.#n.has(h)||a&&!a.has(h))return null;const b=this.#n.get(h),j=this.#b(a),S=j.sorted.length;if(!S)return null;switch(d){case"rank":return S-f(j.sorted,b)+1;case"rankAsc":return o(j.sorted,b)+1;case"rankChange":{if(!this.#t.has(h)||!j.baseline.length)return null;const y=j.baseline.length-f(j.baseline,this.#t.get(h))+1,v=S-f(j.sorted,b)+1;return y-v}case"percentile":return f(j.sorted,b)/S*100;case"quartile":{const y=f(j.sorted,b)/S;return Math.min(4,Math.max(1,Math.ceil(y*4)))}case"zScore":return j.sd?(b-j.mean)/j.sd:null;case"anomalyScore":return j.mad?w*(b-j.median)/j.mad:null;case"anomalyFlag":{if(!j.mad)return null;const y=p&&Number.isFinite(Number(p.threshold))?Number(p.threshold):k;return Math.abs(w*(b-j.median)/j.mad)>y}case"shareOfTotal":return j.sum?b/j.sum*100:null;default:return null}}}function r(m){const d=m.length;if(!d)return 0;const h=(d-1)*.5,a=Math.floor(h),p=Math.ceil(h);return a===p?m[a]:m[a]+(h-a)*(m[p]-m[a])}function o(m,d){let h=0,a=m.length;for(;h<a;){const p=h+a>>1;m[p]<d?h=p+1:a=p}return h}function f(m,d){let h=0,a=m.length;for(;h<a;){const p=h+a>>1;m[p]<=d?h=p+1:a=p}return h}function u(m){if(m==null||m==="")return null;if(m instanceof Date){const h=m.getTime();return Number.isFinite(h)?h:null}const d=typeof m=="number"?m:Number(m);return Number.isFinite(d)?d:null}function i(m){const d=[];for(const h of m||[]){const a=h.shadow;if(!a)continue;const p=typeof a=="string"?{kind:a}:a,b=p.kind;H.includes(b)&&(U.includes(b)||z.includes(b)||d.push({colId:h.id||h.field,of:p.of||h.field||h.id,kind:b,depth:p.depth,historyWindow:b==="history"?p.window:void 0}))}return d}}),Fe("packages/core/src/columns/model.js",function(e,K){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return le}});const Q=K("packages/core/src/internal/util.js"),$=Q.expand,B=Q.fail,I=Q.getPath,_=Q.humanise,X=Q.isFunction,W=Q.isObject,H=Q.merge,U=Q.pathGetter,z=Q.pathSetter,w=Q.toArray,k=Q.uid,g=Q.warnOnce,c=K("packages/core/src/format/index.js").compileFormat,s=K("packages/core/src/columns/datatypes.js"),n=s.comparatorFor,t=s.createTypeRegistry,r=s.storageKind,o=K("packages/core/src/columns/infer.js"),f=o.inferColumnType,u=o.DEFAULT_SAMPLE,i=K("packages/core/src/columns/graph.js"),m=i.buildGraph,d=i.affectedBy,a=K("packages/core/src/columns/lookup.js").createLookup,p=K("packages/core/src/columns/value.js"),b=p.compileDisplay,j=p.ValuePipeline,S=p.warnImpureUse,v=K("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,R=Object.freeze({geometry:"geometry",list:"list"}),O={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},x={centre:"center"},C=new Set(["start","center","end","left","right"]);function P(se){if(typeof se!="string")return;const ee=se.toLowerCase();return x[ee]?x[ee]:C.has(ee)?ee:void 0}function F(se){if(typeof se!="string")return;const ee=se.toLowerCase();return ee==="center"||ee==="centre"?"middle":ee==="top"||ee==="middle"||ee==="bottom"?ee:void 0}const E=["cell","layout","header"];function D(se){if(!W(se))return{};const ee={...se},ie=(ce,he)=>{if(se[ce]===void 0)return;const me=$(se[ce],he);me&&E.includes(ce)&&!W(se[ce])&&delete me.enabled,ee[ce]=me};return ie("sort","direction"),ie("filter","type"),ie("cell","render"),ie("edit","editor"),ie("layout","width"),ie("group","index"),ie("pivot","index"),ie("header","render"),ie("facet","strategy"),ee}function N(se,ee){const ie={...se||{}},ce=W(ee)&&W(ee.layout)&&ee.layout.width!==void 0;return ie.fit==="content"&&!ce&&delete ie.width,ie}const M=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"]),A=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function L(se,ee,ie,ce){const he=ie==="columnGroup"?"column group":"column";for(const me of Object.keys(se))if(!ee.has(me)){if(me==="timeZone"&&ie==="column"){g("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${ce}". 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}g(`${ie}.unknown:${me}`,`'${me}' is not a configuration key this grid recognises, so it had no effect on ${he} "${ce}". Check the spelling against the reference.`)}}function G(se){W(se.cell)&&se.cell.autoHeight!==void 0&&g("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${se.id||se.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function q(se,ee){const ie=ee&&X(se.defaultsFor)?se.defaultsFor(ee):null,ce={...se.defaults||{},...W(ie)?ie:{}},he={};return ce.align&&(he.align=ce.align,he.cell={align:ce.align},he.header={align:ce.align}),ce.filter&&(he.filter=ce.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:ce.filter}),ce.editor&&(he.edit=ce.editor==="none"?{editor:null}:{editor:ce.editor}),ce.total&&(he.total=ce.total),ce.render&&(he.cell={...he.cell||{},render:ce.render}),se.export&&(he.export={...se.export}),he}function Y(se){if(typeof se=="string")return se.trim()?[se.trim()]:[];if(!Array.isArray(se))return[];const ee=[];for(const ie of se){if(typeof ie!="string")continue;const ce=ie.trim();ce&&!ee.includes(ce)&&ee.push(ce)}return ee}class J{#e=new Map;#t=[];#n=[];#r=new WeakMap;#o;#i;#s;#l;#a;#u;#c(ee,ie,ce){const he=this.#d(ee,ie,ce);if(typeof he!="string"||!this.#f)return he??null;const me=ie&&ie.totals&&ie.totals.implement;if(me&&X(me[he])){const ge=me[he];return ge.totalName=he,ge}const Ee=this.#f.totalFn?.(he);return X(Ee)?Ee:he}#d(ee,ie,ce){if(typeof ee!="string")return ee;const he=ie&&ie.totals&&ie.totals.supported;if(!Array.isArray(he)||he.includes(ee))return ee;const me=he.length?he.join(", "):"none";return B(`column "${ce}" is typed ${ie.name||"a type"}, for which the total "${ee}" is not meaningful. Supported: ${me}. Aggregating it anyway would produce a confident wrong number.`),ee}#f;#h;#p;#m;#g;#b;#w=!1;#S;#y;constructor(ee={}){this.#i=D(ee.columnDefaults||{}),this.#s=ee.columnPresets||{},this.#a=ee.locale,this.#l=ee.timeZone,this.#u=F(ee.verticalAlign),this.#f=ee.registry||null,this.#h=ee.grid||null,this.#p=ee.context,this.#S=ee.sampleSize??u,this.#y=ee.onChange||null,this.#b=X(ee.rowKey)?ee.rowKey:void 0,this.#o=t(ee.dataTypes,this.#f);const{leaves:ie,groups:ce}=le(ee.columns||[]);this.#n=ce;for(const he of ie){he.facet!==void 0&&this.#r.set(he.def,he.facet);const me=this.#O(he.def,null);if(me.groupPath=he.path,this.#e.has(me.id)){g(`columns.duplicate:${me.id}`,`two columns resolve to the id '${me.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}he.column=me,this.#e.set(me.id,me),this.#t.push(me.id)}this.#T(ee.stored||null)}#O(ee,ie){L(ee,M,"column",ee.id||ee.field||"(unnamed)"),G(ee);const ce=D(ee),he=w(ee.preset),me=he.map(Ae=>{const Ge=this.#s[Ae];return Ge?D(Ge):(g(`preset:${Ae}`,`unknown column preset "${Ae}"; ignoring`),{})}),Ee=this.#j(ce,me,ie),ge=this.#o.get(Ee)||this.#o.get("text");if(!this.#o.has(Ee)&&ee.type){const Ae=R[Ee];g(`type:${Ee}`,`unknown data type "${Ee}"; falling back to "text"`+(Ae?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Ae}'.`:""))}const je=X(ge.items)?this.#A(ce,me,ee.id||ee.field||"(unnamed)"):null;let pe=O;pe=H(pe,this.#i),ee.type!==!1&&(pe=H(pe,q(ge,je)));for(const Ae of me)pe=H(pe,Ae);this.#r.has(ee)&&(pe=H(pe,D({facet:this.#r.get(ee)}))),pe=H(pe,ce);const we=pe.edit;we&&we.editor&&we.enabled!==!0&&!X(we.enabled)&&(ee.edit||{}).editor&&g(`column.editor-not-enabled:${ee.id||ee.field}`,`column '${ee.id||ee.field}' names the editor '${we.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const ye=ee.id||ee.field||k("col");if(ee.shadow&&!X(pe.value&&pe.value.compute)){const Ae=typeof ee.shadow=="string"?{kind:ee.shadow}:ee.shadow,Ge=Ae.of||ee.field||ye,Ze=v.includes(Ae.kind),tt=Ze?Ae.model||Ae:null,at=Ze&&tt?[...Array.isArray(tt.predictors)?tt.predictors:[],tt.response].filter(Boolean):null;pe.value={...pe.value||{},deps:at&&at.length?at:Ae.orderBy&&Ae.orderBy!==Ge?[Ge,Ae.orderBy]:[Ge],pure:!1,compute:(ft,mt)=>{const Ot=mt.grid&&mt.grid.statistics;if(!Ot)return null;const At=mt.row&&mt.row.key||Ot.keyOf(mt.data);if(!At)return null;if(Ze){if(!X(Ot.fitShadow))return null;const Pt=Ae.model?{...Ae.model,threshold:Ae.threshold}:Ae;return Ot.fitShadow(Ae.kind,At,Pt)}return Ot.shadow(Ge,Ae.kind,At,Ae.scope,Ae)}}}if(ee.running&&!X(pe.value&&pe.value.compute)){const Ae=typeof ee.running=="string"?{kind:ee.running}:ee.running,Ge=Ae.of||ee.field||ye;pe.value={...pe.value||{},deps:[Ge],pure:!1,compute:(Ze,tt)=>{const at=tt.grid&&tt.grid.statistics;if(!at||!X(at.running))return null;const ft=tt.row&&tt.row.key||at.keyOf(tt.data);return ft?at.running(Ge,Ae.kind||"total",ft):null}},ee.sort===void 0&&(pe.sort={...pe.sort||{},enabled:!1})}const Ne=ee.field??(X(pe.value&&pe.value.compute)?null:ee.id??null),$e=X(pe.value&&pe.value.compute),Ve={id:ye,field:Ne,shadow:ee.shadow||null,running:ee.running||null,spec:ee.spec||null,validation:ee.validation||null,volatile:!!(ee.shadow||ee.running),title:pe.title??_(Ne||ye),type:ge.name,dataType:ge,itemType:je,nullable:pe.nullable!==!1,align:P(ce.cell&&ce.cell.align||ce.align||pe.cell&&pe.cell.align||pe.align||ge.defaults&&ge.defaults.align)||"start",verticalAlign:F(ce.cell&&ce.cell.verticalAlign||ce.verticalAlign||pe.cell&&pe.cell.verticalAlign||pe.verticalAlign)||this.#u,rowSpan:X(pe.rowSpan)?pe.rowSpan:null,colSpan:X(pe.colSpan)?pe.colSpan:null,value:{pure:!0,...pe.value||{}},cell:{...pe.cell||{}},edit:{...pe.edit||{}},sort:{...pe.sort||{}},filter:{...pe.filter||{}},group:{enabled:!1,index:-1,explode:!1,...pe.group||{}},pivot:{enabled:!1,index:-1,...pe.pivot||{}},total:this.#c(pe.total,ge,ee.id||ee.field||"(unnamed)"),groupTotal:pe.groupTotal===void 0?null:this.#c(pe.groupTotal,ge,ee.id||ee.field||"(unnamed)"),grandTotal:pe.grandTotal===void 0?null:this.#c(pe.grandTotal,ge,ee.id||ee.field||"(unnamed)"),tags:Y(pe.tags),typeOptions:pe.typeOptions??null,...W(pe[Ee])?{[Ee]:pe[Ee]}:{},layout:N(pe.layout,ce),header:{...pe.header||{}},contextMenu:pe.contextMenu===void 0?null:pe.contextMenu,facet:{...pe.facet||{}},export:{...pe.export||{}},allowGroup:pe.allowGroup!==!1,allowPivot:pe.allowPivot!==!1,allowTotal:pe.allowTotal!==!1,quickFilter:pe.quickFilter!==!1,def:ee,format:pe.format,presets:he,inferred:ie!=null&&!ee.type,computed:$e,diff:ee.diff===void 0?void 0:!!ee.diff,read:Ne?U(Ne):null,write:Ne?z(Ne):null};Ve.cell.align=P(ce.cell&&ce.cell.align)||Ve.align,Ve.header.align=P(ce.header&&ce.header.align)||Ve.align;const qe=pe.lookup||null;return Ve.lookup=qe?a({id:ye,lookup:qe},{locale:this.#a,onChange:()=>{this.#y&&this.#y("lookup",{colId:ye})}}):null,Ve.group.explode&&Ve.lookup&&Ve.lookup.multiple&&g(`explode:${ye}`,`column "${ye}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#k(Ve),Ve}#k(ee){ee.formatter=c(ee.format,ee.dataType,this.#a,this.#l,ee.id),ee.formatValue=b(ee,{locale:this.#a,grid:this.#h,context:this.#p}),ee.itemCompare=ee.itemType?n(ee.itemType,this.#a):null,ee.compare=X(ee.value.compare)?ee.value.compare:ee.lookup?ee.lookup.comparator():X(ee.dataType.compareFor)?ee.dataType.compareFor(ee):n(ee.dataType,this.#a),ee.excel=ee.formatter&&ee.formatter.ooxml||ee.dataType&&ee.dataType.excel||"General",ee.storeKind=r(ee.dataType,!!(ee.lookup&&ee.lookup.multiple))}#A(ee,ie,ce){let he=W(ee.typeOptions)?ee.typeOptions:null;for(let je=ie.length-1;!he&&je>=0;je--)W(ie[je].typeOptions)&&(he=ie[je].typeOptions);!he&&W(this.#i.typeOptions)&&(he=this.#i.typeOptions);const me=he&&he.of!==void 0?he.of:"text",Ee=typeof me=="string"?this.#o.get(me):void 0;return Ee&&!X(Ee.items)&&Ee.storage!=="object"?Ee:(g(`type:of:${String(me)}`,`column "${ce}" names "${String(me)}" as its item type (typeOptions.of), which is not ${Ee?"a scalar data type":"a known data type"}; its items are read as text.`),this.#o.get("text"))}#j(ee,ie,ce){if(ee.type===!1)return"text";if(ee.type)return ee.type;for(let he=ie.length-1;he>=0;he--)if(ie[he].type)return ie[he].type;if(this.#i.type)return this.#i.type;if(ee.shadow){const he=typeof ee.shadow=="string"?ee.shadow:ee.shadow.kind;if(he==="fitInfluence")return"boolean";if(he==="fitPredicted"||he==="fitResidual"||he==="fitStdResidual"||he==="fitLeverage"||he==="fitCooksD"||he==="tsTrend"||he==="tsSeasonal"||he==="tsResidual"||he==="tsCoverage"||he==="tsSmoothed"||he==="tsSmoothingAlpha"||he==="tsSmoothingBeta")return"number"}return ce||(ee.lookup?"lookup":"text")}#T(ee){const ie=this.all();this.#m=m(ie),this.#g?this.#g.setGraph(this.#m):this.#g=new j({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:ee||null,rowKey:this.#b});const ce=this.#g;for(const he of ie)he.getValue=(me,Ee)=>ce.value(he,me,Ee)}all(){return this.#t.map(ee=>this.#e.get(ee))}visible(){return this.all().filter(ee=>!ee.layout.hidden)}get(ee){return this.#e.get(ee)}groups(){const ee=ie=>{const ce=[];for(const he of ie)Array.isArray(he.columns)?ce.push({...he,columns:ee(he.columns)}):he.column&&ce.push(he.column);return ce};return ee(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#o}affectedBy(ee){return d(this.#m,ee)}value(ee,ie,ce){return this.#g.value(ee,ie,ce)}text(ee,ie,ce){return this.#g.text(ee,ie,ce)}checkImpure(ee,ie){S(this.#e.get(ee),ie)}setLocale(ee){this.#a=ee;for(const ie of this.all())ie.lookup&&ie.lookup.setLocale(ee),this.#k(ie);this.#y&&this.#y("locale",{locale:ee})}infer(ee){const ie={};if(this.#w||!Array.isArray(ee)||ee.length===0)return ie;this.#w=!0;let ce=!1;for(const he of this.all()){const me=he.def;if(me.type!==void 0||!he.field||he.computed||he.lookup||this.#M(he))continue;const Ee=he.read||(pe=>I(pe,he.field)),ge=f(he.id,ee,Ee,this.#o,{sampleSize:this.#S});if(ge===he.type)continue;ie[he.id]=ge;const je=this.#O(me,ge);je.groupPath=he.groupPath,je.layout={...je.layout,...te(he.layout)},this.#e.set(he.id,je),ae(this.#n,he.id,je),ce=!0}return ce&&this.#T(null),ie}redecorate(ee,ie,ce={}){const he=this.#e.get(ee);if(!he){g(`redecorate:${ee}`,`columns.decorate('${ee}', …): no column with id '${ee}'.`);return}const me=he.def||{},Ee={...W(me.cell)?me.cell:{}};Ee.decoration=ie??void 0,ce&&"variant"in ce&&(Ee.variant=ce.variant);const ge={...me,cell:Ee};this.#r.has(me)&&this.#r.set(ge,this.#r.get(me));const je=this.#O(ge,he.type);return je.groupPath=he.groupPath,je.layout={...je.layout,...te(he.layout)},he.lookup&&he.lookup!==je.lookup&&X(he.lookup.destroy)&&he.lookup.destroy(),this.#e.set(ee,je),ae(this.#n,ee,je),this.#T(null),this.#y&&this.#y("decorate",{colId:ee}),je}destroy(){for(const ee of this.#e.values())ee.lookup&&X(ee.lookup.destroy)&&ee.lookup.destroy()}#M(ee){for(const ie of ee.presets){const ce=this.#s[ie];if(ce&&ce.type)return!0}return!!this.#i.type}#C(ee){return!ee.computed&&X(ee.dataType&&ee.dataType.toStorage)}storeReader(ee){if(ee.computed)return ie=>this.#g.value(ee,ie,null);if(this.#C(ee)){const ie=ee.dataType.toStorage,ce={timeZone:this.#l,colId:ee.id,itemType:ee.itemType||null};return he=>ie(ee.read(he),ce)}return ee.read}storeValue(ee,ie){if(!(!ee||ee.computed)&&X(ee.read))return this.storeReader(ee)(ie)}storeSchema(){const ee=[];for(const ie of this.all()){if(ie.computed&&ie.value.pure===!1||!ie.computed&&!ie.field)continue;const ce=this.storeReader(ie);let he=null;!ie.computed&&!this.#C(ie)&&typeof ie.field=="string"&&!ie.lookup&&(he=ie.field);const me={id:ie.id,kind:ie.storeKind,nullable:ie.nullable,read:ce};he!==null&&(me.field=he),ie.lookup&&(me.dictionary=ie.lookup.dictionary()),ee.push(me)}return ee}state(){return this.all().map(ee=>({id:ee.id,width:ee.layout.width,flex:ee.layout.flex||void 0,hidden:!!ee.layout.hidden,pin:ee.layout.pin??null,sort:ee.sort.direction??null,sortIndex:ee.sort.direction?ee.sort.order??0:null,groupIndex:ee.group.enabled?ee.group.index??0:null,pivotIndex:ee.pivot.enabled?ee.pivot.index??0:null,total:typeof ee.total=="string"?ee.total:null,groupTotal:typeof ee.groupTotal=="string"?ee.groupTotal:void 0,grandTotal:typeof ee.grandTotal=="string"?ee.grandTotal:void 0,decoration:ee.cell&&ee.cell.decoration!=null?ne(ee.cell.decoration):void 0,variant:ee.cell&&ee.cell.variant!=null?ne(ee.cell.variant):void 0}))}applyState(ee,ie={}){const ce={applied:[],skipped:[]},he=Array.isArray(ee)?ee:ee&&ee.columns||[],me=!Array.isArray(ee)&&ee&&ee.columnOrder||null;for(const ge of he){if(!ge||!ge.id){ce.skipped.push({key:"?",reason:"no id"});continue}let je=this.#e.get(ge.id);if(!je){ce.skipped.push({key:ge.id,reason:"unknown column"});continue}if(Object.hasOwn(ge,"decoration")||Object.hasOwn(ge,"variant")){const pe=je.cell?je.cell.decoration:void 0,we=ge.decoration??null,ye=Object.hasOwn(ge,"variant"),Ne=ye&&!oe(je.cell?je.cell.variant:void 0,ge.variant);(!oe(pe,we)||Ne)&&(this.redecorate(ge.id,we,ye?{variant:ge.variant??void 0}:{}),je=this.#e.get(ge.id)||je)}ge.width!=null&&(je.layout.width=ge.width),ge.flex!=null&&(je.layout.flex=ge.flex),ge.hidden!=null&&(je.layout.hidden=!!ge.hidden),ge.pin!==void 0&&(je.layout.pin=ge.pin),ge.sort!==void 0&&(je.sort.direction=ge.sort),ge.sortIndex!=null&&(je.sort.order=ge.sortIndex),ge.groupIndex!=null&&(je.group.enabled=!0,je.group.index=ge.groupIndex),ge.pivotIndex!=null&&(je.pivot.enabled=!0,je.pivot.index=ge.pivotIndex),ge.total!==void 0&&(je.total=ge.total),ge.groupTotal!==void 0&&(je.groupTotal=ge.groupTotal),ge.grandTotal!==void 0&&(je.grandTotal=ge.grandTotal),ce.applied.push(ge.id)}const Ee=me||(ie&&ie.keepOrder?[]:he.map(ge=>ge&&ge.id).filter(Boolean));if(Ee.length){const ge=Ee.filter(pe=>this.#e.has(pe)),je=this.#t.filter(pe=>!ge.includes(pe));this.#t=[...ge,...je]}return this.#y&&this.#y("state",ce),ce}move(ee,ie){this.#E(ee,ie)&&(this.#x(),this.#y&&this.#y("move",{id:ee,to:ie}))}reorder(ee){const ie={applied:[],skipped:[]},ce=[];let he=0;for(const me of Array.isArray(ee)?ee:[]){const Ee=he++;this.#E(me,Ee)&&(ie.applied.push(me),ce.push({id:me,to:Ee}))}if(!ce.length)return ie;if(this.#x(),this.#y)for(const me of ce)this.#y("move",me);return ie}#E(ee,ie){const ce=this.#t.indexOf(ee);if(ce===-1||Math.max(0,Math.min(Number(ie)||0,this.#t.length-1))===ce)return!1;const me=this.#e.get(ee);if(me.layout.movable===!1||me.layout.lockPosition)return g(`move:${ee}`,`column "${ee}" is not movable; the move was ignored`),!1;const Ee=this.#L(ee,ie);return Ee?(g(`move.married:${Ee}`,`band "${Ee}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(ce,1),this.#t.splice(Math.max(0,Math.min(ie,this.#t.length)),0,ee),!0)}#L(ee,ie){if(!this.#n||!this.#n.length)return null;const ce=this.#t.filter(ge=>ge!==ee),he=Math.max(0,Math.min(ie,ce.length)),me=(ge,je)=>{if(Array.isArray(ge.columns)){for(const we of ge.columns)me(we,je);return je}const pe=ge.column?ge.column.id:ge.id;return pe&&je.push(pe),je},Ee=ge=>{for(const je of ge){if(!Array.isArray(je.columns))continue;if(je.marryChildren===!0){const we=me(je,[]),ye=we.includes(ee),Ne=we.map($e=>ce.indexOf($e)).filter($e=>$e>=0);if(Ne.length){const $e=Math.min(...Ne),Ve=Math.max(...Ne);if(ye?he<$e||he>Ve+1:he>$e&&he<=Ve)return je.id}}const pe=Ee(je.columns);if(pe)return pe}return null};return Ee(this.#n)}#x(){const ee=new Map(this.#t.map((he,me)=>[he,me])),ie=he=>{if(!Array.isArray(he.columns)){const Ee=he.column?he.column.id:he.id;return ee.has(Ee)?ee.get(Ee):1/0}let me=1/0;for(const Ee of he.columns)me=Math.min(me,ie(Ee));return me},ce=he=>{he.sort((me,Ee)=>ie(me)-ie(Ee));for(const me of he)Array.isArray(me.columns)&&ce(me.columns)};ce(this.#n)}#B(ee){const ie=ce=>{for(let he=0;he<ce.length;he++){const me=ce[he];if(Array.isArray(me.columns)){const Ee=ie(me.columns);if(Ee)return Ee}else if(me.column&&me.column.id===ee)return ce.splice(he,1)[0]}return null};return ie(this.#n)}#H(ee){const ie=[];for(let ce=ee.length-1;ce>=0;ce--){const he=ee[ce];Array.isArray(he.columns)&&(ie.push(...this.#H(he.columns)),he.columns.length===0&&(ie.push(he.id),ee.splice(ce,1)))}return ie}#U(){const ee=(ie,ce,he)=>{for(const me of ie)Array.isArray(me.columns)?ee(me.columns,[...ce,me.id]):me.column&&(me.column.groupPath=ce)};ee(this.#n,[])}#N(ee){const ie=new Set(ee),ce=this.#t.filter(ge=>ie.has(ge));if(!ce.length)return;const he=Math.min(...ce.map(ge=>this.#t.indexOf(ge))),me=this.#t.slice(0,he).filter(ge=>!ie.has(ge)),Ee=this.#t.slice(he).filter(ge=>!ie.has(ge));this.#t=[...me,...ce,...Ee]}#$(ee){const ie=[],ce=he=>{if(Array.isArray(he.columns))for(const me of he.columns)ce(me);else he.column&&ie.push(he.column.id)};return ce(ee),ie}#z(ee){const ie=ce=>{for(const he of ce){if(!Array.isArray(he.columns))continue;if(he.id===ee)return{node:he,parent:ce};const me=ie(he.columns);if(me)return me}return null};return ie(this.#n)}groupColumns(ee,ie={}){const ce=w(ee).filter(je=>this.#e.has(je));if(!ce.length)return g("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const je of ce)if(this.#e.get(je).layout.lockPosition)return g(`columns.group.locked:${je}`,`column "${je}" is position-locked and cannot be grouped.`),null;const he=ie.groupId?this.#z(ie.groupId):null;if(ie.groupId&&!he)return g(`columns.group.unknown:${ie.groupId}`,`no band "${ie.groupId}" to add to; nothing was grouped.`),null;let me=null;if(!he&&ie.id!=null&&(me=String(ie.id),this.#z(me)||this.#e.has(me)))return g(`columns.group.idtaken:${me}`,`band id "${me}" is already in use; nothing was grouped.`),null;const Ee=ce.map(je=>this.#B(je)).filter(Boolean);if(!Ee.length)return null;let ge;if(he)he.node.columns.push(...Ee),ge=he.node.id;else{const je={id:me||k("grp"),title:ie.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Ee},pe=Number.isInteger(ie.at)?Math.max(0,Math.min(ie.at,this.#n.length)):this.#n.length;this.#n.splice(pe,0,je),ge=je.id}return this.#H(this.#n),this.#N(ce),this.#U(),this.#x(),this.#y&&this.#y("columngroup",{action:"formed",groupId:ge,ids:ce}),ge}ungroupColumn(ee){const ie=this.#e.get(ee);if(!ie){g(`columns.ungroup.unknown:${ee}`,`no column "${ee}" to ungroup.`);return}const ce=ie.groupPath||[];if(!ce.length)return;const he=ce[ce.length-1],me=this.#z(he);if(!me)return;const Ee=this.#B(ee);if(!Ee)return;const ge=me.parent.indexOf(me.node);me.parent.splice(ge+1,0,Ee);const je=this.#H(this.#n),pe=this.#$(me.node);if(pe.length){this.#N(pe);const we=Math.max(...pe.map(Ne=>this.#t.indexOf(Ne))),ye=this.#t.filter(Ne=>Ne!==ee);ye.splice(we+1,0,ee),this.#t=ye}this.#U(),this.#x(),this.#y&&this.#y("columngroup",{action:"removed",id:ee,dissolved:je})}renameGroup(ee,ie){const ce=this.#z(ee);if(!ce){g(`columns.group.rename:${ee}`,`no band "${ee}" to rename.`);return}ce.node.title=String(ie??""),this.#y&&this.#y("columngroup",{action:"renamed",groupId:ee,title:ce.node.title})}dissolveGroup(ee){const ie=this.#z(ee);if(!ie){g(`columns.group.dissolve:${ee}`,`no band "${ee}" to dissolve.`);return}const ce=ie.parent.indexOf(ie.node);ie.parent.splice(ce,1,...ie.node.columns),this.#U(),this.#x(),this.#y&&this.#y("columngroup",{action:"dissolved",groupId:ee})}moveGroup(ee,ie){const ce=this.#z(ee);if(!ce){g(`columns.group.move:${ee}`,`no band "${ee}" to move.`);return}const he=ce.parent,me=he.indexOf(ce.node);me!==-1&&(he.splice(me,1),he.splice(Math.max(0,Math.min(ie,he.length)),0,ce.node),this.#_(),this.#U(),this.#y&&this.#y("columngroup",{action:"moved",groupId:ee,to:ie}))}#_(){const ee=[],ie=he=>{for(const me of he)Array.isArray(me.columns)?ie(me.columns):me.column&&ee.push(me.column.id)};ie(this.#n);const ce=new Set(ee);this.#t=[...ee,...this.#t.filter(he=>!ce.has(he))]}groupTree(){const ee=ce=>ce.map(he=>Array.isArray(he.columns)?{id:he.id,title:he.title||"",collapsible:!!he.collapsible,openByDefault:he.openByDefault!==!1,columns:ee(he.columns)}:he.column?he.column.id:null).filter(he=>he!==null),ie=ee(this.#n);return ie.some(ce=>ce&&typeof ce=="object")?ie:[]}applyGroupTree(ee){if(!Array.isArray(ee))return;const ie=new Set,ce=me=>{const Ee=[];for(const ge of me)if(ge&&typeof ge=="object"&&Array.isArray(ge.columns)){const je=ce(ge.columns);if(!je.length)continue;Ee.push({id:ge.id||k("grp"),title:ge.title||"",collapsible:ge.collapsible===!0,openByDefault:ge.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:je})}else if(typeof ge=="string"){const je=this.#e.get(ge);je&&!ie.has(ge)&&(ie.add(ge),Ee.push({column:je,path:[]}))}return Ee},he=ce(ee);for(const me of this.#t){if(ie.has(me))continue;const Ee=this.#e.get(me);Ee&&he.push({column:Ee,path:[]})}this.#n=he,this.#U(),this.#x(),this.#y&&this.#y("columngroup",{action:"applied"})}show(ee){this.#Y(ee,!1)}hide(ee){this.#Y(ee,!0)}#Y(ee,ie){const ce=[];for(const he of w(ee)){const me=this.#e.get(he);if(me){if(ie&&me.layout.lockVisible){g(`lockVisible:${he}`,`column "${he}" is \`layout.lockVisible\` and cannot be hidden`);continue}me.layout.hidden!==ie&&(me.layout.hidden=ie,ce.push(he))}}ce.length&&this.#y&&this.#y("visible",{ids:ce,hidden:ie})}pin(ee,ie){const ce=this.#e.get(ee);ce&&(ce.layout.pin=ie??null,this.#y&&this.#y("pin",{id:ee,side:ce.layout.pin}))}resize(ee,ie){const ce=this.#e.get(ee);if(!ce)return;if(ce.layout.resizable===!1){g(`resize:${ee}`,`column "${ee}" is not resizable; the resize was ignored`);return}const he=ce.layout.min??0,me=ce.layout.max;let Ee=Math.max(he,ie);me!=null&&(Ee=Math.min(me,Ee)),ce.layout.width=Ee,ce.layout.flex=0,this.#y&&this.#y("resize",{id:ee,width:Ee})}}function te(se){const ee={};return se.width!=null&&(ee.width=se.width),se.hidden!=null&&(ee.hidden=se.hidden),se.pin!==void 0&&(ee.pin=se.pin),ee}function ne(se){if(se===null||typeof se!="object")return se;try{return structuredClone(se)}catch{}try{return JSON.parse(JSON.stringify(se))}catch{return se}}function oe(se,ee){const ie=se??null,ce=ee??null;if(ie===ce)return!0;if(ie===null||ce===null)return!1;if(typeof ie!="object"||typeof ce!="object")return ie===ce;try{return JSON.stringify(ie)===JSON.stringify(ce)}catch{return!1}}function le(se){const ee=[],ie=(he,me,Ee)=>{const ge=[];for(const je of he){if(!W(je)){B("a column definition must be an object");continue}if(Array.isArray(je.columns)){L(je,A,"columnGroup",je.title||je.id||"(unnamed)");const pe={id:je.id||k("grp"),title:je.title||"",collapsible:je.collapsible===!0,openByDefault:je.openByDefault!==!1,showWhen:je.showWhen||"always",marryChildren:je.marryChildren===!0,header:je.header||{},def:je,columns:[]};pe.columns=ie(je.columns,[...me,pe.id],je.facet!==void 0?je.facet:Ee),ge.push(pe)}else{const pe={def:je,path:me,facet:Ee};ee.push(pe),ge.push(pe)}}return ge},ce=ie(se,[],void 0);return{leaves:ee,groups:ce}}function ae(se,ee,ie){for(const ce of se){if(ce.columns){if(ae(ce.columns,ee,ie))return!0;continue}if(ce.column&&ce.column.id===ee)return ce.column=ie,!0}return!1}}),Fe("packages/core/src/columns/autogroup.js",function(e,K){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return W}});const $=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_group",I=240,_=.5;function X(H){const{columns:U,groupBy:z}=H,w=z.map(l=>U.get(l)).filter(Boolean),k=w.length?w.map(l=>l.title||l.id).join(" > "):"Group",g=H.config&&H.config.autoGroupColumnWidth||I;return{id:B,field:null,title:k,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:z.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:g,min:120,pin:H.config&&H.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(l,c){return c&&c.group?c.groupValue:null},formatValue(l,c){if(!c||!c.group)return"";if(c.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";const s=w[Math.min(c.level||0,w.length-1)];return s&&typeof s.formatValue=="function"?s.formatValue(l,c):l==null?"":String(l)}}}function W(H,U,z){!H.length||z<100||U<z*_||$(`grouping.cardinality:${H.join(",")}`,`grouping by ${H.join(", ")} produced ${U} groups for ${z} 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.`)}}),Fe("packages/core/src/columns/selectcolumn.js",function(e,K){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const Q="__lattice_select",$=44;function B(_){const X=_.selection||{},W=_.config&&_.config.selectionColumnWidth||$;return{id:Q,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:W,min:W,max:W,pin:_.config&&_.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:X.headerCheckbox===!0,def:{},getValue(H,U){return U?U.selected:!1},formatValue(){return""}}}const I=B}),Fe("packages/core/src/columns/rownumbercolumn.js",function(e,K){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const $=K("packages/core/src/internal/util.js").isFunction,B="__lattice_rownumber",I=40,_=9,X=22;function W(z){const w=String(Math.max(1,Math.trunc(Math.abs(z))||1)).length;return Math.max(I,w*_+X)}function H(z){const w=z.rowNumbers,k=w&&typeof w=="object"?w:{},g=Number.isFinite(k.start)?k.start:1,l=Number.isFinite(k.width)?k.width:W((z.maxNumber||0)+g),c=$(z.rank)?z.rank:()=>null;return{id:B,field:null,title:typeof k.title=="string"?k.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:l,min:l,max:l,pin:"start",hidden:!1,resizable:k.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(s,n){const t=c(n);return t==null?null:t-1+g},formatValue(s){return s==null?"":String(s)}}}const U=H}),Fe("packages/core/src/model/detail.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=240,_=10;function X(U){if(!U)return null;const z=U===!0?{}:U;return z.enabled===!1?null:!$(z.rows)&&!z.render?(B("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:z.render||null,config:z.config||null,rows:$(z.rows)?z.rows:null,height:z.height??I,cacheLimit:Number.isFinite(z.cacheLimit)?Math.max(0,z.cacheLimit):_,isMaster:$(z.isMaster)?z.isMaster:null,target:z.target||null,onCreate:$(z.onCreate)?z.onCreate:null,path:typeof z.path=="string"?z.path:null}}class W{#e;#t=new Set;#n;#r=0;constructor(z){this.#e=z.config,this.#n=$(z.onChange)?z.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(z){if(!z||z.group||z.detail)return!1;const w=this.#e.isMaster;return w?!!w(z.data,z):!0}isOpen(z){return this.#t.has(z)}keys(){return[...this.#t]}activeKey(){for(const z of this.#t)return z;return null}heightOf(z){const w=this.#e.height;return $(w)?Number(w(z))||I:w==="auto"?I:Number(w)||I}open(z){return this.#t.has(z)?!1:(this.inline||this.#t.clear(),this.#t.add(z),this.#o(),!0)}close(z){return this.#t.delete(z)?(this.#o(),!0):!1}toggle(z){return this.#t.has(z)?(this.close(z),!1):(this.open(z),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#o())}prune(z){if(!this.#t.size||!$(z))return;let w=!1;for(const k of[...this.#t])z(k)||(this.#t.delete(k),w=!0);w&&this.#o()}signature(){return`${this.#r}`}set(z){this.#t.clear();const w=Array.isArray(z)?z:[];for(const k of this.inline?w:w.slice(0,1))this.#t.add(k);this.#o()}#o(){this.#r++,this.#n()}}const H=W}),Fe("packages/core/src/compute/special.js",function(e,K){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return s}});const Q=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),$=3e-12,B=1e-300;function I(n){if(n<.5)return Math.log(Math.PI/Math.sin(Math.PI*n))-I(1-n);const t=n-1;let r=.9999999999998099;const o=t+7.5;for(let f=0;f<Q.length;f++)r+=Q[f]/(t+f+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(o)-o+Math.log(r)}function _(n,t,r){const o=n+t,f=n+1,u=n-1;let i=1,m=1-o*r/f;Math.abs(m)<B&&(m=B),m=1/m;let d=m;for(let h=1;h<=300;h++){const a=2*h;let p=h*(t-h)*r/((u+a)*(n+a));m=1+p*m,Math.abs(m)<B&&(m=B),i=1+p/i,Math.abs(i)<B&&(i=B),m=1/m,d*=m*i,p=-(n+h)*(o+h)*r/((n+a)*(f+a)),m=1+p*m,Math.abs(m)<B&&(m=B),i=1+p/i,Math.abs(i)<B&&(i=B),m=1/m;const b=m*i;if(d*=b,Math.abs(b-1)<$)break}return d}function X(n,t,r){if(!(n>0)||!(t>0)||!Number.isFinite(r))return Number.NaN;if(r<=0)return 0;if(r>=1)return 1;const o=Math.exp(I(n+t)-I(n)-I(t)+n*Math.log(r)+t*Math.log(1-r));return r<(n+1)/(n+t+2)?o*_(n,t,r)/n:1-o*_(t,n,1-r)/t}function W(n){if(!(n>0)||!(n<1))return n===0?-1/0:n===1?1/0:Number.NaN;const t=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],r=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],o=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],f=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],u=.02425;let i,m,d;n<u?(i=Math.sqrt(-2*Math.log(n)),d=(((((o[0]*i+o[1])*i+o[2])*i+o[3])*i+o[4])*i+o[5])/((((f[0]*i+f[1])*i+f[2])*i+f[3])*i+1)):n<=1-u?(i=n-.5,m=i*i,d=(((((t[0]*m+t[1])*m+t[2])*m+t[3])*m+t[4])*m+t[5])*i/(((((r[0]*m+r[1])*m+r[2])*m+r[3])*m+r[4])*m+1)):(i=Math.sqrt(-2*Math.log(1-n)),d=-(((((o[0]*i+o[1])*i+o[2])*i+o[3])*i+o[4])*i+o[5])/((((f[0]*i+f[1])*i+f[2])*i+f[3])*i+1));const a=(.5*H(-d/Math.SQRT2)-n)*Math.sqrt(2*Math.PI)*Math.exp(d*d/2);return d-a/(1+d*a/2)}function H(n){const t=Math.abs(n),r=2/(2+t),o=4*r-2,f=[-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,i=0,m;for(let h=f.length-1;h>0;h--)m=i,i=o*i-u+f[h],u=m;const d=r*Math.exp(-t*t+.5*(f[0]+o*i)-u);return n>=0?d:2-d}function U(n){return .5*H(-n/Math.SQRT2)}function z(n,t){if(!(t>0)||!Number.isFinite(n))return Number.NaN;const r=.5*X(t/2,.5,t/(t+n*n));return n>0?1-r:r}function w(n,t){if(!(n>0)||!(n<1)||!(t>0))return Number.NaN;if(t>1e7)return W(n);let r=-1e4,o=1e4,f=W(n);const u=I(t/2)+I(.5)-I((t+1)/2);for(let i=0;i<60;i++){const m=z(f,t);m<n?r=f:o=f;const d=Math.exp(-((t+1)/2)*Math.log(1+f*f/t)-u)/Math.sqrt(t),h=d>0?(m-n)/d:0;if(Math.abs(h)<1e-12)break;const a=f-h;if(f=a>r&&a<o&&Number.isFinite(a)?a:(r+o)/2,o-r<1e-12)break}return f}function k(n,t){let r=n,o=1/n,f=o;for(let u=0;u<300&&(r+=1,f*=t/r,o+=f,!(Math.abs(f)<Math.abs(o)*$));u++);return o*Math.exp(-t+n*Math.log(t)-I(n))}function g(n,t){let r=t+1-n,o=1/B,f=1/r,u=f;for(let i=1;i<=300;i++){const m=-i*(i-n);r+=2,f=m*f+r,Math.abs(f)<B&&(f=B),o=r+m/o,Math.abs(o)<B&&(o=B),f=1/f;const d=f*o;if(u*=d,Math.abs(d-1)<$)break}return Math.exp(-t+n*Math.log(t)-I(n))*u}function l(n,t){return!(n>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<n+1?k(n,t):1-g(n,t)}function c(n,t){return t>0?l(t/2,n/2):Number.NaN}function s(n,t){const r=c(n,t);return Number.isNaN(r)?Number.NaN:Math.min(1,Math.max(0,1-r))}}),Fe("packages/core/src/compute/linalg.js",function(e,K){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return X}});function Q(W){const H=W.length,U=Array.from({length:H},()=>new Array(H).fill(0));for(let z=0;z<H;z++)for(let w=0;w<=z;w++){let k=W[z][w];for(let g=0;g<w;g++)k-=U[z][g]*U[w][g];if(z===w){if(!(k>0))return null;U[z][w]=Math.sqrt(k)}else U[z][w]=k/U[w][w]}return U}function $(W,H){const U=W.length,z=new Array(U).fill(0);for(let k=0;k<U;k++){let g=H[k];for(let l=0;l<k;l++)g-=W[k][l]*z[l];z[k]=g/W[k][k]}const w=new Array(U).fill(0);for(let k=U-1;k>=0;k--){let g=z[k];for(let l=k+1;l<U;l++)g-=W[l][k]*w[l];w[k]=g/W[k][k]}return w}function B(W){const H=W.length,U=Array.from({length:H},()=>new Array(H).fill(0));for(let z=0;z<H;z++){const w=new Array(H).fill(0);w[z]=1;const k=$(W,w);for(let g=0;g<H;g++)U[g][z]=k[g]}return U}function I(W,H,U){const z=W.length,w=z?W[0].length:0,k=Array.from({length:w},()=>new Array(w).fill(0)),g=new Array(w).fill(0);for(let l=0;l<z;l++){const c=U?U[l]:1,s=W[l];for(let n=0;n<w;n++){const t=c*s[n];g[n]+=t*H[l];for(let r=n;r<w;r++)k[n][r]+=t*s[r]}}for(let l=0;l<w;l++)for(let c=0;c<l;c++)k[l][c]=k[c][l];return{xtwx:k,xtwy:g}}function _(W,H){return W.map(U=>U.reduce((z,w,k)=>z+w*H[k],0))}function X(W,H){let U=0;for(let z=0;z<W.length;z++){let w=0;for(let k=0;k<W.length;k++)w+=H[z][k]*W[k];U+=W[z]*w}return U}}),Fe("packages/core/src/compute/sketch.js",function(e,K){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});class Q{#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(l){if(!Number.isFinite(l))return;this.#e++;const c=l-this.#t;this.#t+=c/this.#e,this.#n+=c*(l-this.#t)}merge(l){if(l.#e===0)return;if(this.#e===0){this.#e=l.#e,this.#t=l.#t,this.#n=l.#n;return}const c=this.#e+l.#e,s=l.#t-this.#t;this.#t+=s*(l.#e/c),this.#n+=l.#n+s*s*(this.#e*l.#e/c),this.#e=c}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 l=this.variance();return l===null?null:Math.sqrt(l)}stddevP(){const l=this.varianceP();return l===null?null:Math.sqrt(l)}}class ${#e=[];#t=0;#n;#r;constructor(l,c=Math.random){if(!(l>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(l),this.#r=c}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(l){if(!Number.isFinite(l))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(l);return}const c=Math.floor(this.#r()*this.#t);c<this.#n&&(this.#e[c]=l)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let l=0;for(const c of this.#e)l+=c;return l/this.#e.length}quantile(l){const c=this.#e.length;if(!c)return null;const s=this.#e.slice().sort((o,f)=>o-f);if(c===1)return s[0];const n=(c-1)*Math.min(1,Math.max(0,l)),t=Math.floor(n),r=Math.ceil(n);return t===r?s[t]:s[t]+(n-t)*(s[r]-s[t])}}function B(g){return g^=g>>>16,g=Math.imul(g,2246822507),g^=g>>>13,g=Math.imul(g,3266489909),g^=g>>>15,g>>>0}function I(g){if(typeof g=="number"){const s=new DataView(new ArrayBuffer(8));return s.setFloat64(0,g===0?0:g),B(s.getUint32(0)^s.getUint32(4))}const l=typeof g=="string"?g:String(g);let c=2166136261;for(let s=0;s<l.length;s++)c^=l.charCodeAt(s),c=Math.imul(c,16777619);return B(c)}class _{#e;#t;#n;constructor(l=14){const c=Math.floor(l);if(c<4||c>16)throw new RangeError("HLL precision must be 4..16");this.#e=c,this.#t=1<<c,this.#n=new Uint8Array(this.#t)}static errorBoundFor(l=14){const c=1<<Math.floor(l),s=1.04/Math.sqrt(c);return Object.freeze({kind:"probabilistic",metric:"relative",value:s,statement:`distinct count within ~${(s*100).toFixed(2)}% relative standard error (m=${c} buckets)`})}errorBound(){return _.errorBoundFor(this.#e)}add(l){const c=I(l),s=c&this.#t-1,n=c>>>this.#e|1<<32-this.#e;let t=1,r=n;for(;(r&1)===0;)t++,r>>>=1;t>this.#n[s]&&(this.#n[s]=t)}count(){const l=this.#t,c=32-this.#e,s=new Float64Array(c+2);for(let r=0;r<l;r++)s[this.#n[r]]++;let n=l*H(1-s[c+1]/l);for(let r=c;r>=1;r--)n=.5*(n+s[r]);n+=l*W(s[0]/l);const t=X*l*l/n;return Math.round(t)}}const X=.5/Math.log(2);function W(g){if(g===1)return 1/0;let l=1,c=g,s;do g*=g,s=c,c+=g*l,l+=l;while(c!==s);return c}function H(g){if(g===0||g===1)return 0;let l=1,c=1-g,s;do g=Math.sqrt(g),s=c,l*=.5,c-=(1-g)**2*l;while(c!==s);return c/3}class U{#e=new Map;#t;#n=0;constructor(l){if(!(l>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(l)}errorBoundFor(l){const c=l/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:c,statement:`each count overestimates the truth by at most N/m = ${c.toFixed(2)} (N=${l}, m=${this.#t})`})}get seen(){return this.#n}add(l){this.#n++;const c=this.#e.get(l);if(c){c.count++;return}if(this.#e.size<this.#t){this.#e.set(l,{count:1,error:0});return}let s,n=1/0;for(const[t,r]of this.#e)r.count<n&&(n=r.count,s=t);this.#e.delete(s),this.#e.set(l,{count:n+1,error:n})}top(l=this.#t){return[...this.#e.entries()].map(([s,n])=>({item:s,count:n.count,error:n.error})).sort((s,n)=>n.count-s.count).slice(0,Math.max(0,Math.floor(l)))}}class z{#e;#t=[[]];#n=0;#r;#o;constructor(l=200,c=Math.random){this.#e=Math.max(8,Math.floor(l)),this.#r=c,this.#o=2/3}static errorBoundFor(l=200){const c=1/Math.max(8,Math.floor(l));return Object.freeze({kind:"probabilistic",metric:"rank",value:c,statement:`queried quantile's true rank within ~${(c*100).toFixed(2)}% of N of the requested rank (k=${l})`})}errorBound(){return z.errorBoundFor(this.#e)}get count(){return this.#n}#i(l){const s=this.#t.length-1-l,n=Math.ceil(this.#e*this.#o**s);return Math.max(2,n)}add(l){Number.isFinite(l)&&(this.#n++,this.#t[0].push(l),this.#t[0].length>=this.#i(0)&&this.#s(0))}#s(l){const c=this.#t[l];c.sort((t,r)=>t-r),l+1>=this.#t.length&&this.#t.push([]);const s=this.#t[l+1],n=this.#r()<.5?0:1;for(let t=n;t<c.length;t+=2)s.push(c[t]);this.#t[l]=[];for(let t=0;t<this.#t.length;t++)if(this.#t[t].length>=this.#i(t)){this.#s(t);return}}#l(){const l=[];for(let c=0;c<this.#t.length;c++){const s=1<<c;for(const n of this.#t[c])l.push({v:n,w:s})}return l}quantile(l){const c=this.#l();if(!c.length)return null;c.sort((r,o)=>r.v-o.v);let s=0;for(const r of c)s+=r.w;const n=Math.min(1,Math.max(0,l))*s;let t=0;for(const r of c)if(t+=r.w,t>=n)return r.v;return c[c.length-1].v}rank(l){let c=0;for(let s=0;s<this.#t.length;s++){const n=1<<s;for(const t of this.#t[s])t<=l&&(c+=n)}return c}}const w=Object.freeze({distinct:_.errorBoundFor(14),median:z.errorBoundFor(200),p25:z.errorBoundFor(200),p75:z.errorBoundFor(200),p90:z.errorBoundFor(200),p95:z.errorBoundFor(200),p99:z.errorBoundFor(200),iqr:z.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"})}),k={Welford:Q,Reservoir:$,HyperLogLog:_,SpaceSaving:U,KLL:z,hash32:I,SKETCH_BOUNDS:w}}),Fe("packages/core/src/compute/statistics.js",function(e,K){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return at}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return It}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return De}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return Xe}});const Q=K("packages/core/src/compute/handle.js"),$=Q.presenceReader,B=Q.valueReader,I=K("packages/core/src/compute/special.js"),_=I.studentTQuantile,X=I.studentT,W=I.normalQuantile,H=I.normalCdf,U=I.chiSquareUpperTail,z=K("packages/core/src/compute/linalg.js"),w=z.cholesky,k=z.choleskySolve,g=z.choleskyInverse,l=z.normalEquations,c=z.quadForm,n=K("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,t=5e3,r=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"}),o=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:n.distinct}),median:Object.freeze({sketch:"KLL",bound:n.median}),p25:Object.freeze({sketch:"KLL",bound:n.p25}),p75:Object.freeze({sketch:"KLL",bound:n.p75}),p90:Object.freeze({sketch:"KLL",bound:n.p90}),p95:Object.freeze({sketch:"KLL",bound:n.p95}),p99:Object.freeze({sketch:"KLL",bound:n.p99}),iqr:Object.freeze({sketch:"KLL",bound:n.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:n.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:n.topK})});function f(ve){const be=ve==="sum"||ve==="avg"||ve==="countValues"||ve==="min"||ve==="max"?"maintained":Object.prototype.hasOwnProperty.call(r,ve)?r[ve]:null,Oe=Object.prototype.hasOwnProperty.call(o,ve)?o[ve]:null;return{stat:ve,exact:be,approximate:Oe}}function u(ve,be){const Oe=be.length,Ce=new Float64Array(Oe);let Re=0;if(ve&&(ve.kind==="float64"||ve.kind==="int32")){const ke=ve.values,Te=$(ve);for(let ze=0;ze<Oe;ze++){const He=be[ze];if(Te&&Te(He)!==1)continue;const Qe=ke[He];Number.isNaN(Qe)||(Ce[Re++]=Qe)}return Ce.subarray(0,Re)}const _e=B(ve);for(let ke=0;ke<Oe;ke++){const Te=_e(be[ke]);if(Te==null||Te==="")continue;const ze=typeof Te=="number"?Te:Number(Te);Number.isFinite(ze)&&(Ce[Re++]=ze)}return Ce.subarray(0,Re)}function i(ve,be){const Oe=new Map,Ce=B(ve);let Re=0;for(let _e=0;_e<be.length;_e++){const ke=Ce(be[_e]);if(ke==null||ke===""||typeof ke=="number"&&Number.isNaN(ke))continue;const Te=typeof ke=="object"?String(ke):ke;Oe.set(Te,(Oe.get(Te)||0)+1),Re++}const Be=[...Oe.values()].sort((_e,ke)=>ke-_e);return{counts:Be,total:Re,distinct:Be.length}}function m(ve){return ve.total>0?ve.counts.map(be=>be/ve.total):[]}function d(ve,be){const Oe=i(ve,be);if(!Oe.total)return null;let Ce=0;for(const Re of m(Oe))Ce+=Re*Re;return Ce}function h(ve,be){const Oe=i(ve,be);if(!Oe.total)return null;let Ce=0;for(const Re of m(Oe))Re>0&&(Ce-=Re*Math.log2(Re));return Ce}function a(ve,be){const Oe=i(ve,be);if(!Oe.total||Oe.distinct<2)return Oe.total?1:null;let Ce=0;for(const Re of m(Oe))Re>0&&(Ce-=Re*Math.log2(Re));return Ce/Math.log2(Oe.distinct)}function p(ve,be,Oe=3){const Ce=i(ve,be);if(!Ce.total)return null;const Re=Math.max(1,Math.floor(Oe));let Be=0;for(let _e=0;_e<Math.min(Re,Ce.counts.length);_e++)Be+=Ce.counts[_e];return Be/Ce.total}function b(ve,be){const Oe=u(ve,be),Ce=Oe.length;if(!Ce)return null;const Re=Oe.slice().sort();if(Re[0]<0)return null;let Be=0,_e=0;for(let ke=0;ke<Ce;ke++)Be+=Re[ke],_e+=(ke+1)*Re[ke];return Be===0?0:2*_e/(Ce*Be)-(Ce+1)/Ce}function j(ve){let be=0,Oe=0,Ce=0;for(let Re=0;Re<ve.length;Re++){const Be=ve[Re];be++;const _e=Be-Oe;Oe+=_e/be,Ce+=_e*(Be-Oe)}return{n:be,mean:Oe,m2:Ce}}function S(ve,be){const Oe=ve.length;if(!Oe)return NaN;if(Oe===1)return ve[0];const Ce=(Oe-1)*Math.min(1,Math.max(0,be)),Re=Math.floor(Ce),Be=Math.ceil(Ce);return Re===Be?ve[Re]:ve[Re]+(Ce-Re)*(ve[Be]-ve[Re])}function y(ve,be){if(!ve.length)return NaN;const Oe=ve.slice().sort();return S(Oe,be)}function v(ve,be){const Oe=B(ve);let Ce=0,Re=0,Be=0;for(let _e=0;_e<be.length;_e++){const ke=Oe(be[_e]);if(ke==null||ke==="")continue;const Te=String(ke).toUpperCase();Te==="PASS"?Ce++:Te==="FAIL"?Re++:Te==="WARN"&&Be++}return{pass:Ce+Be,fail:Re,warn:Be,judged:Ce+Be+Re}}const R=Object.freeze({hhi:(ve,be)=>d(ve,be),entropy:(ve,be)=>h(ve,be),evenness:(ve,be)=>a(ve,be),top3Share:(ve,be)=>p(ve,be,3),top10Share:(ve,be)=>p(ve,be,10),gini:(ve,be)=>b(ve,be),trimmedMean:(ve,be)=>F(u(ve,be),.1),winsorizedMean:(ve,be)=>E(u(ve,be),.1),robustOutliers:(ve,be)=>D(u(ve,be),3.5),jarqueBera:(ve,be)=>N(u(ve,be)),variance:(ve,be)=>{const{n:Oe,m2:Ce}=j(u(ve,be));return Oe>1?Ce/(Oe-1):null},varianceP:(ve,be)=>{const{n:Oe,m2:Ce}=j(u(ve,be));return Oe>0?Ce/Oe:null},stddev:(ve,be)=>{const{n:Oe,m2:Ce}=j(u(ve,be));return Oe>1?Math.sqrt(Ce/(Oe-1)):null},stddevP:(ve,be)=>{const{n:Oe,m2:Ce}=j(u(ve,be));return Oe>0?Math.sqrt(Ce/Oe):null},median:(ve,be)=>{const Oe=u(ve,be);return Oe.length?y(Oe,.5):null},p25:(ve,be)=>{const Oe=u(ve,be);return Oe.length?y(Oe,.25):null},p75:(ve,be)=>{const Oe=u(ve,be);return Oe.length?y(Oe,.75):null},p90:(ve,be)=>{const Oe=u(ve,be);return Oe.length?y(Oe,.9):null},p95:(ve,be)=>{const Oe=u(ve,be);return Oe.length?y(Oe,.95):null},p99:(ve,be)=>{const Oe=u(ve,be);return Oe.length?y(Oe,.99):null},iqr:(ve,be)=>{const Oe=u(ve,be);if(!Oe.length)return null;const Ce=Oe.slice().sort();return S(Ce,.75)-S(Ce,.25)},mad:(ve,be)=>{const Oe=u(ve,be);if(!Oe.length)return null;const Ce=y(Oe,.5),Re=new Float64Array(Oe.length);for(let Be=0;Be<Oe.length;Be++)Re[Be]=Math.abs(Oe[Be]-Ce);return y(Re,.5)},range:(ve,be)=>{const Oe=u(ve,be);if(!Oe.length)return null;let Ce=1/0,Re=-1/0;for(let Be=0;Be<Oe.length;Be++)Oe[Be]<Ce&&(Ce=Oe[Be]),Oe[Be]>Re&&(Re=Oe[Be]);return Re-Ce},distinct:(ve,be)=>{const Oe=B(ve),Ce=new Set;for(let Re=0;Re<be.length;Re++){const Be=Oe(be[Re]);Be==null||Be===""||Ce.add(Be instanceof Date?Be.getTime():Be)}return Ce.size},mode:(ve,be)=>{const Oe=B(ve),Ce=new Map;for(let _e=0;_e<be.length;_e++){const ke=Oe(be[_e]);if(ke==null||ke==="")continue;const Te=ke instanceof Date?ke.getTime():ke;Ce.set(Te,(Ce.get(Te)||0)+1)}let Re=null,Be=1;for(const[_e,ke]of Ce)ke>Be&&(Be=ke,Re=_e);return Re},skewness:(ve,be)=>{const Oe=u(ve,be),{n:Ce,mean:Re,m2:Be}=j(Oe);if(Ce<3||Be<=0)return null;const _e=Math.sqrt(Be/(Ce-1));let ke=0;for(let Te=0;Te<Oe.length;Te++)ke+=((Oe[Te]-Re)/_e)**3;return Ce/((Ce-1)*(Ce-2))*ke},kurtosis:(ve,be)=>{const Oe=u(ve,be),{n:Ce,mean:Re,m2:Be}=j(Oe);if(Ce<4||Be<=0)return null;const _e=Math.sqrt(Be/(Ce-1));let ke=0;for(let He=0;He<Oe.length;He++)ke+=((Oe[He]-Re)/_e)**4;const Te=Ce*(Ce+1)/((Ce-1)*(Ce-2)*(Ce-3)),ze=3*(Ce-1)**2/((Ce-2)*(Ce-3));return Te*ke-ze},geomean:(ve,be)=>{const Oe=u(ve,be);if(!Oe.length)return null;let Ce=0;for(let Re=0;Re<Oe.length;Re++){if(Oe[Re]<=0)return null;Ce+=Math.log(Oe[Re])}return Math.exp(Ce/Oe.length)},harmean:(ve,be)=>{const Oe=u(ve,be);if(!Oe.length)return null;let Ce=0;for(let Re=0;Re<Oe.length;Re++){if(Oe[Re]===0)return null;Ce+=1/Oe[Re]}return Oe.length/Ce},sumSquares:(ve,be)=>{const Oe=u(ve,be);let Ce=0;for(let Re=0;Re<Oe.length;Re++)Ce+=Oe[Re]*Oe[Re];return Ce},passRate:(ve,be)=>{const{pass:Oe,judged:Ce}=v(ve,be);return Ce?Oe/Ce:null},failureCount:(ve,be)=>v(ve,be).fail}),O=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 x(ve,be,Oe){const Ce=B(ve),Re=B(be);let Be=0,_e=0;for(let ke=0;ke<Oe.length;ke++){const Te=Oe[ke],ze=Number(Ce(Te)),He=Number(Re(Te));!Number.isFinite(ze)||!Number.isFinite(He)||(Be+=ze*He,_e+=He)}return _e===0?null:Be/_e}function C(ve,be,Oe){const Ce=B(ve);let Re=null,Be=Oe?-1/0:1/0;for(let _e=0;_e<be.length;_e++){const ke=be[_e],Te=Number(Ce(ke));Number.isFinite(Te)&&(Oe?Te>Be:Te<Be)&&(Be=Te,Re=ke)}return Re}function P(ve,be,Oe){const Ce=B(ve),Re=B(be);let Be=0,_e=0,ke=0,Te=0,ze=0,He=0;for(let ot=0;ot<Oe.length;ot++){const bt=Oe[ot],vt=Number(Ce(bt)),pt=Number(Re(bt));!Number.isFinite(vt)||!Number.isFinite(pt)||(Be++,_e+=vt,ke+=pt,Te+=vt*vt,ze+=pt*pt,He+=vt*pt)}if(Be<2)return null;const Qe=Be*He-_e*ke,it=Math.sqrt((Be*Te-_e*_e)*(Be*ze-ke*ke));if(it===0)return null;const st=Qe/it;return Math.max(-1,Math.min(1,st))}function F(ve,be=.1){const Oe=ve.length;if(!Oe)return null;const Ce=Array.from(ve).sort((ke,Te)=>ke-Te),Re=Math.floor(Oe*Math.min(.49,Math.max(0,be))),Be=Ce.slice(Re,Oe-Re);if(!Be.length)return S(Ce,.5);let _e=0;for(const ke of Be)_e+=ke;return _e/Be.length}function E(ve,be=.1){const Oe=ve.length;if(!Oe)return null;const Ce=Array.from(ve).sort((Te,ze)=>Te-ze),Re=Math.floor(Oe*Math.min(.49,Math.max(0,be))),Be=Ce[Re],_e=Ce[Oe-1-Re];let ke=0;for(const Te of Ce)ke+=Math.min(_e,Math.max(Be,Te));return ke/Oe}function D(ve,be=3.5){if(!ve.length)return null;const Ce=Array.from(ve).sort((Te,ze)=>Te-ze),Re=S(Ce,.5),Be=Ce.map(Te=>Math.abs(Te-Re)).sort((Te,ze)=>Te-ze),_e=S(Be,.5);if(_e===0)return null;let ke=0;for(const Te of Ce)Math.abs(.6745*(Te-Re)/_e)>be&&ke++;return ke}function N(ve){const be=ve.length;if(be<8)return null;let Oe=0;for(const Te of ve)Oe+=Te;Oe/=be;let Ce=0,Re=0,Be=0;for(const Te of ve){const ze=Te-Oe;Ce+=ze*ze,Re+=ze*ze*ze,Be+=ze*ze*ze*ze}if(Ce/=be,Re/=be,Be/=be,Ce===0)return null;const _e=Re/Ce**1.5,ke=Be/(Ce*Ce)-3;return be/6*(_e*_e+ke*ke/4)}function M(ve,be,Oe){const Ce=[];let Re=0;for(let Te=0;Te<ve.length;Te++){const ze=Number(ve[Te]),He=Number(be[Te]);!Number.isFinite(ze)||!Number.isFinite(He)||He<=0||(Ce.push([ze,He]),Re+=He)}if(!Ce.length||Re<=0)return null;if(Ce.sort((Te,ze)=>Te[0]-ze[0]),Ce.length===1)return Ce[0][0];const Be=[];let _e=0;for(const[,Te]of Ce)Be.push((_e+Te/2)/Re),_e+=Te;const ke=Math.max(0,Math.min(1,Oe));if(ke<=Be[0])return Ce[0][0];if(ke>=Be[Be.length-1])return Ce[Ce.length-1][0];for(let Te=1;Te<Be.length;Te++){if(ke>Be[Te])continue;const ze=Be[Te]-Be[Te-1],He=ze>0?(ke-Be[Te-1])/ze:0;return Ce[Te-1][0]+(Ce[Te][0]-Ce[Te-1][0])*He}return Ce[Ce.length-1][0]}function A(ve,be,Oe){const Ce=B(ve),Re=B(be),Be=new Float64Array(Oe.length),_e=new Float64Array(Oe.length);let ke=0;for(let Te=0;Te<Oe.length;Te++){const ze=Oe[Te],He=Number(Ce(ze)),Qe=Number(Re(ze));!Number.isFinite(He)||!Number.isFinite(Qe)||(Be[ke]=He,_e[ke]=Qe,ke++)}return{xs:Be.subarray(0,ke),ys:_e.subarray(0,ke),n:ke}}function L(ve,be,Oe,Ce=!1){const{xs:Re,ys:Be,n:_e}=A(ve,be,Oe);if(_e<2)return null;let ke=0,Te=0;for(let He=0;He<_e;He++)ke+=Re[He],Te+=Be[He];ke/=_e,Te/=_e;let ze=0;for(let He=0;He<_e;He++)ze+=(Re[He]-ke)*(Be[He]-Te);return ze/(Ce?_e:_e-1)}function G(ve,be,Oe){const{xs:Ce,ys:Re,n:Be}=A(ve,be,Oe);if(Be<2)return null;let _e=0,ke=0;for(let vt=0;vt<Be;vt++)_e+=Ce[vt],ke+=Re[vt];_e/=Be,ke/=Be;let Te=0,ze=0,He=0;for(let vt=0;vt<Be;vt++){const pt=Ce[vt]-_e,Ct=Re[vt]-ke;Te+=pt*pt,ze+=pt*Ct,He+=Ct*Ct}if(Te===0)return null;const Qe=ze/Te,it=ke-Qe*_e,st=He===0?1:Math.max(0,Math.min(1,ze*ze/(Te*He))),ot=Math.max(0,He-Qe*ze),bt=Be>2?Math.sqrt(ot/(Be-2)/Te):0;return{slope:Qe,intercept:it,r2:st,stdError:bt,n:Be}}const q=new Set(["ols","wls","robust"]),Y=new Set(["quantile"]),J=new Set(["ridge","lasso","elasticnet","mixed","gls"]),te=1.345;function ne(ve,be,Oe){const{xtwx:Ce,xtwy:Re}=l(ve,be,Oe),Be=w(Ce);if(!Be)return null;const _e=k(Be,Re),ke=g(Be),Te=oe(ve,_e),ze=be.map((He,Qe)=>He-Te[Qe]);return{beta:_e,cov:ke,fitted:Te,residuals:ze}}function oe(ve,be){return ve.map(Oe=>Oe.reduce((Ce,Re,Be)=>Ce+Re*be[Be],0))}function le(ve,be){const Oe=ve.length,Ce=ve.map(ze=>ze[be]),Re=ve.map(ze=>[1,...ze.filter((He,Qe)=>Qe!==be)]),Be=ne(Re,Ce,null);if(!Be)return 1;const _e=Ce.reduce((ze,He)=>ze+He,0)/Oe;let ke=0,Te=0;for(let ze=0;ze<Oe;ze++)ke+=Be.residuals[ze]**2,Te+=(Ce[ze]-_e)**2;return Te===0?1:Math.max(0,Math.min(1,1-ke/Te))}function ae(ve){const be=[...ve].sort((Re,Be)=>Re-Be),Oe=se(be),Ce=ve.map(Re=>Math.abs(Re-Oe)).sort((Re,Be)=>Re-Be);return se(Ce)/.6745}function se(ve){const be=ve.length;if(!be)return 0;const Oe=Math.floor(be/2);return be%2?ve[Oe]:(ve[Oe-1]+ve[Oe])/2}function ee(ve,be,Oe={}){const Ce=Oe.method||"ols";if(J.has(Ce))throw new Error(`[lattice] regression method "${Ce}" is out of scope; use ols, wls or robust.`);if(Y.has(Ce))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!q.has(Ce))throw new Error(`[lattice] unknown regression method "${Ce}"; use ols, wls or robust.`);const Re=Array.isArray(be)?be.length:0,Be=Re&&Array.isArray(ve[0])?ve[0].length:0,_e=Be+1;if(!(Re>_e))return null;for(let Et=0;Et<Re;Et++){if(!Number.isFinite(be[Et])||!Array.isArray(ve[Et])||ve[Et].length!==Be)return null;for(let xt=0;xt<Be;xt++)if(!Number.isFinite(ve[Et][xt]))return null}let ke=null;if(Ce==="wls"){if(ke=Oe.weights,!Array.isArray(ke)||ke.length!==Re)return null;for(let Et=0;Et<Re;Et++)if(!(ke[Et]>0)||!Number.isFinite(ke[Et]))return null}const Te=ve.map(Et=>[1,...Et]);let ze,He=null;if(Ce==="robust"){if(ze=ne(Te,be,null),!ze)return null;for(let Et=0;Et<50;Et++){const xt=ae(ze.residuals);if(!(xt>0))break;const Ut=ze.residuals.map(Yt=>{const Jt=Math.abs(Yt/xt);return Jt<=te?1:te/Jt}),Wt=ne(Te,be,Ut);if(!Wt)return null;const Qt=Wt.beta.reduce((Yt,Jt,rn)=>Math.max(Yt,Math.abs(Jt-ze.beta[rn])),0);if(ze=Wt,He=Ut,Qt<1e-10)break}}else if(ze=ne(Te,be,ke),!ze)return null;const Qe=Ce==="robust"?He:ke,{beta:it,cov:st,fitted:ot,residuals:bt}=ze;let vt=0,pt=0,Ct=0;for(let Et=0;Et<Re;Et++){const xt=Qe?Qe[Et]:1;vt+=xt*bt[Et]**2,pt+=xt,Ct+=xt*be[Et]}const Ke=Ct/pt;let dt=0;for(let Et=0;Et<Re;Et++){const xt=Qe?Qe[Et]:1;dt+=xt*(be[Et]-Ke)**2}const rt=Re-_e,ut=vt/rt,kt=dt===0?1:Math.max(0,Math.min(1,1-vt/dt)),Nt=1-(1-kt)*(Re-1)/rt,gt=Array.isArray(Oe.names)&&Oe.names.length===Be?Oe.names:ve[0].map((Et,xt)=>`x${xt+1}`),Mt=At(Oe.confidence),Dt=rt>0?_(1-(1-Mt)/2,rt):1/0,tn=it.map((Et,xt)=>{const Ut=Math.sqrt(Math.max(0,ut*st[xt][xt])),Wt=Ut>0?Et/Ut:Et===0?0:1/0,Qt=Number.isFinite(Wt)?2*(1-X(Math.abs(Wt),rt)):0,Yt=Number.isFinite(Dt)?Dt*Ut:null;return{name:xt===0?"(intercept)":gt[xt-1],estimate:Et,stdError:Ut,t:Wt,p:Math.max(0,Math.min(1,Qt)),lower:Yt===null?null:Et-Yt,upper:Yt===null?null:Et+Yt}}),mn=new Array(Re),an=new Array(Re);for(let Et=0;Et<Re;Et++){const xt=Qe?Qe[Et]:1,Ut=Math.max(0,Math.min(1,xt*c(Te[Et],st)));mn[Et]=Ut;const Wt=(1-Ut)**2;an[Et]=Wt>0&&ut>0?bt[Et]**2/(_e*ut)*(Ut/Wt):null}const dn=ve[0].map((Et,xt)=>{if(Be<2)return 1;const Ut=le(ve,xt);return Ut>=1?1/0:1/(1-Ut)});let qt=null;{const Et=bt.map(Ut=>Ut*Ut),xt=ne(Te,Et,null);if(xt){const Ut=Et.reduce((en,cn)=>en+cn,0)/Re;let Wt=0,Qt=0;for(let en=0;en<Re;en++)Wt+=xt.residuals[en]**2,Qt+=(Et[en]-Ut)**2;const Yt=Qt===0?0:Math.max(0,Math.min(1,1-Wt/Qt)),Jt=Re*Yt,rn=U(Jt,Be);qt={statistic:Jt,df:Be,p:rn,heteroscedastic:rn<.05}}}let _t=null;if(Be===1){const Et=ve.map((xt,Ut)=>Ut).sort((xt,Ut)=>ve[xt][0]-ve[Ut][0]);_t={confidence:Mt,points:Et.map(xt=>{const Ut=Te[xt],Wt=Math.sqrt(Math.max(0,ut*c(Ut,st)));return{x:ve[xt][0],yhat:ot[xt],lower:ot[xt]-Dt*Wt,upper:ot[xt]+Dt*Wt}})}}return{method:Ce,coefficients:tn,r2:kt,adjR2:Nt,n:Re,df:rt,sigma2:ut,fitted:ot,residuals:bt,leverage:mn,cooksD:an,vif:dn,heteroscedasticity:qt,band:_t,weights:Qe?[...Qe]:null}}function ie(ve){const be=ve.length,Oe=Array.from({length:be},(Be,_e)=>_e).sort((Be,_e)=>ve[Be]-ve[_e]),Ce=new Float64Array(be);let Re=0;for(;Re<be;){let Be=Re;for(;Be+1<be&&ve[Oe[Be+1]]===ve[Oe[Re]];)Be++;const _e=(Re+Be)/2+1;for(let ke=Re;ke<=Be;ke++)Ce[Oe[ke]]=_e;Re=Be+1}return Ce}const ce=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function he(ve){const be=[.01,.05,.1],Oe=[ce["1%"],ce["5%"],ce["10%"]];if(ve<=Oe[0]){const Be=(Math.log(be[1])-Math.log(be[0]))/(Oe[1]-Oe[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(be[0])+Be*(ve-Oe[0]))))}if(ve>=Oe[2]){const Be=(Math.log(be[2])-Math.log(be[1]))/(Oe[2]-Oe[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(be[2])+Be*(ve-Oe[2]))))}const Ce=ve<Oe[1]?0:1,Re=(ve-Oe[Ce])/(Oe[Ce+1]-Oe[Ce]);return Math.exp(Math.log(be[Ce])+Re*(Math.log(be[Ce+1])-Math.log(be[Ce])))}function me(ve,be,Oe,Ce){const Re=Oe-Ce,Be=Ce+3,_e=new Array(Re),ke=new Array(Re);let Te=!0,ze=Ce;for(let ot=0;ot<Re;ot++){const bt=Ce+ot,vt=new Float64Array(Be);vt[0]=1,vt[1]=ot+1,vt[2]=ve[bt];for(let pt=1;pt<=Ce;pt++)vt[2+pt]=be[bt-pt];for(let pt=1;pt<Be;pt++)Number.isFinite(vt[pt])||(ze=Math.min(ze,pt-3));_e[ot]=vt,ke[ot]=be[bt],Number.isFinite(ke[ot])||(Te=!1)}if(!Te)return 0;const{xtwx:He,xtwy:Qe}=l(_e,ke,null);let it=0,st=1/0;for(let ot=0;ot<=ze;ot++){const bt=ot+3;if(!(Re>bt))continue;const vt=new Array(bt);for(let kt=0;kt<bt;kt++)vt[kt]=He[kt].slice(0,bt);const pt=w(vt);if(!pt)continue;const Ct=k(pt,Qe.slice(0,bt));let Ke=0;for(let kt=0;kt<Re;kt++){const Nt=_e[kt];let gt=0;for(let Mt=0;Mt<bt;Mt++)gt+=Nt[Mt]*Ct[Mt];Ke+=(ke[kt]-gt)**2}const rt=Ke/(Re-bt)*(Re-bt);if(!(rt>0))continue;const ut=Re*Math.log(rt/Re)+2*bt;ut<st&&(st=ut,it=ot)}return it}function Ee(ve,be={}){const Oe=[];for(let st=0;st<ve.length;st++){const ot=Number(ve[st]);Number.isFinite(ot)&&Oe.push(ot)}const Ce=Oe.length,Re=Ce-1;if(Ce<8||Re<6)return null;const Be=new Array(Re);for(let st=0;st<Re;st++)Be[st]=Oe[st+1]-Oe[st];let _e=Number.isFinite(be.maxlag)?Math.floor(be.maxlag):Math.ceil(12*(Ce/100)**.25);_e=Math.max(0,Math.min(_e,Math.floor((Re-5)/2)));const ke=(st,ot)=>{const bt=[],vt=[];for(let pt=ot;pt<Re;pt++){const Ct=[pt-ot+1,Oe[pt]];for(let Ke=1;Ke<=st;Ke++)Ct.push(Be[pt-Ke]);bt.push(Ct),vt.push(Be[pt])}return ee(bt,vt,{method:"ols"})},Te=me(Oe,Be,Re,_e),ze=ke(Te,Te);if(!ze||!ze.coefficients[2])return null;const He=ze.coefficients[2].t,Qe=he(He),it=He<ce["5%"];return{statistic:He,usedLag:Te,nobs:Re-Te,criticalValues:{...ce},pValue:Qe,pApproximate:!0,stationary:it,verdict:it?"stationary":"non-stationary",regression:"ct"}}function ge(ve,be={}){const Oe=[];for(let it=0;it<ve.length;it++){const st=Number(ve[it]);Number.isFinite(st)&&Oe.push(st)}const Ce=Oe.length;if(Ce<3)return null;let Re=Number.isFinite(be.maxlag)?Math.floor(be.maxlag):Math.min(10,Ce-1);Re=Math.max(1,Math.min(Re,Ce-1));let Be=0;for(const it of Oe)Be+=it;Be/=Ce;const _e=Oe.map(it=>it-Be);let ke=0;for(const it of _e)ke+=it*it;ke/=Ce;const Te=new Array(Re+1).fill(0);Te[0]=1;for(let it=1;it<=Re;it++){let st=0;for(let ot=it;ot<Ce;ot++)st+=_e[ot]*_e[ot-it];Te[it]=ke>0?st/Ce/ke:0}const ze=new Array(Re+1).fill(0);ze[0]=1;let He=[];for(let it=1;it<=Re;it++){let st=Te[it];for(let pt=1;pt<it;pt++)st-=He[pt-1]*Te[it-pt];let ot=1;for(let pt=1;pt<it;pt++)ot-=He[pt-1]*Te[pt];const bt=ot!==0?st/ot:0,vt=new Array(it);for(let pt=1;pt<it;pt++)vt[pt-1]=He[pt-1]-bt*He[it-1-pt];vt[it-1]=bt,ze[it]=bt,He=vt}const Qe=1.96/Math.sqrt(Ce);return{acf:Te,pacf:ze,bounds:{upper:Qe,lower:-Qe},n:Ce,nlags:Re,approximate:!0}}function je(ve,be,Oe){const{xs:Ce,ys:Re,n:Be}=A(ve,be,Oe);if(Be<2)return null;const _e=ie(Ce),ke=ie(Re);let Te=0,ze=0;for(let st=0;st<Be;st++)Te+=_e[st],ze+=ke[st];Te/=Be,ze/=Be;let He=0,Qe=0,it=0;for(let st=0;st<Be;st++){const ot=_e[st]-Te,bt=ke[st]-ze;He+=ot*bt,Qe+=ot*ot,it+=bt*bt}return Qe===0||it===0?null:Math.max(-1,Math.min(1,He/Math.sqrt(Qe*it)))}function pe(ve,be,Oe){const{xs:Ce,ys:Re,n:Be}=A(ve,be,Oe);if(Be<2||Be>t)return null;let _e=0,ke=0,Te=0,ze=0;for(let it=0;it<Be;it++)for(let st=it+1;st<Be;st++){const ot=Math.sign(Ce[it]-Ce[st]),bt=Math.sign(Re[it]-Re[st]),vt=ot*bt;vt>0?_e++:vt<0?ke++:ot===0&&bt===0||(ot===0?Te++:ze++)}const He=_e+ke+ze,Qe=_e+ke+Te;return He===0||Qe===0?null:(_e-ke)/Math.sqrt(He*Qe)}function we(ve,be={}){const Oe=ve.length;if(Oe<2)return null;const Ce=ve[0],Re=ve[Oe-1],Be=[];for(let pt=1;pt<Oe;pt++){const Ct=ve[pt-1];Ct!==0&&Be.push((ve[pt]-Ct)/Math.abs(Ct))}let _e=null;if(Be.length>1){let pt=0;for(const Ke of Be)pt+=Ke;pt/=Be.length;let Ct=0;for(const Ke of Be)Ct+=(Ke-pt)**2;_e=Math.sqrt(Ct/(Be.length-1))}const ke=Number(be.periodsPerYear)>0?Number(be.periodsPerYear):null;let Te=ve[0],ze=0,He=0,Qe=0,it=0;for(let pt=1;pt<Oe;pt++){if(ve[pt]>Te){Te=ve[pt],ze=pt;continue}if(Te<=0)continue;const Ct=(Te-ve[pt])/Te;Ct>He&&(He=Ct,Qe=ze,it=pt)}let st=null;if(Oe>2){let pt=0;for(let dt=0;dt<Oe;dt++)pt+=ve[dt];pt/=Oe;let Ct=0,Ke=0;for(let dt=0;dt<Oe;dt++){const rt=ve[dt]-pt;Ke+=rt*rt,dt>0&&(Ct+=rt*(ve[dt-1]-pt))}st=Ke>0?Ct/Ke:null}let ot=0,bt=0;for(const pt of Be)pt>0?ot++:pt<0&&bt++;let vt=null;if(Ce>0&&Re>0){const pt=(Re/Ce)**(1/(Oe-1))-1;vt=ke?(1+pt)**ke-1:pt}return{n:Oe,first:Ce,last:Re,change:Re-Ce,changePercent:Ce===0?null:(Re-Ce)/Math.abs(Ce)*100,volatility:_e,annualisedVolatility:_e!==null&&ke?_e*Math.sqrt(ke):null,growth:vt,maxDrawdown:He,maxDrawdownFrom:Qe,maxDrawdownTo:it,autocorrelation:st,upDays:ot,downDays:bt}}const ye=1.128,Ne=3.267;function $e(ve){const be=ve.length;if(be<2)return null;const Oe=[];for(let Re=1;Re<be;Re++)Oe.push(Math.abs(ve[Re]-ve[Re-1]));const Ce=Oe.reduce((Re,Be)=>Re+Be,0)/Oe.length;return{ranges:Oe,centre:Ce,upper:Ne*Ce,lower:0}}function Ve(ve){const be=ve.length;if(be<2)return null;let Oe=0;for(let Re=1;Re<be;Re++)Oe+=Math.abs(ve[Re]-ve[Re-1]);const Ce=Oe/(be-1);return{sigma:Ce/ye,meanRange:Ce}}function qe(ve,be){const Oe=ve.length;if(Oe<2||!be)return null;const Ce=Number.isFinite(Number(be.lower))?Number(be.lower):null,Re=Number.isFinite(Number(be.upper))?Number(be.upper):null;if(Ce===null&&Re===null)return null;let Be=0;for(let ot=0;ot<Oe;ot++)Be+=ve[ot];Be/=Oe;let _e=0;for(let ot=0;ot<Oe;ot++)_e+=(ve[ot]-Be)**2;const ke=Math.sqrt(_e/(Oe-1)),Te=Ve(ve),ze=Te?Te.sigma:null,He=ot=>{if(!ot||ot<=0)return{index:null,k:null};const vt=Ce!==null&&Re!==null?(Re-Ce)/(6*ot):null,pt=Re!==null?(Re-Be)/(3*ot):1/0,Ct=Ce!==null?(Be-Ce)/(3*ot):1/0;return{index:vt,k:Math.min(pt,Ct)}},Qe=He(ze),it=He(ke);let st=0;for(let ot=0;ot<Oe;ot++){if(Ce!==null&&ve[ot]<Ce){st++;continue}Re!==null&&ve[ot]>Re&&st++}return{n:Oe,mean:Be,lower:Ce,upper:Re,target:Number.isFinite(Number(be.target))?Number(be.target):null,sigmaWithin:ze,sigmaOverall:ke,cp:Qe.index,cpk:Qe.k,pp:it.index,ppk:it.k,outOfSpec:st,defectRate:Oe?st/Oe:null}}function Ae(ve){const be=ve.length;if(be<2)return null;const Oe=Ve(ve);if(!Oe||!(Oe.sigma>0))return null;let Ce=0;for(let Re=0;Re<be;Re++)Ce+=ve[Re];return Ce/=be,{centre:Ce,sigma:Oe.sigma,upper:Ce+3*Oe.sigma,lower:Ce-3*Oe.sigma}}function Ge(ve,be){if(!be||!(be.sigma>0))return[];const Oe=ve.length,{centre:Ce,sigma:Re}=be,Be=ke=>(ve[ke]-Ce)/Re,_e=[];for(let ke=0;ke<Oe;ke++){if(Math.abs(Be(ke))>3&&_e.push({index:ke,rule:1,description:"beyond three sigma"}),ke>=2)for(const Te of[1,-1]){let ze=0;for(let He=ke-2;He<=ke;He++)Be(He)*Te>2&&ze++;if(ze>=2){_e.push({index:ke,rule:2,description:"two of three past two sigma"});break}}if(ke>=4)for(const Te of[1,-1]){let ze=0;for(let He=ke-4;He<=ke;He++)Be(He)*Te>1&&ze++;if(ze>=4){_e.push({index:ke,rule:3,description:"four of five past one sigma"});break}}if(ke>=7)for(const Te of[1,-1]){let ze=!0;for(let He=ke-7;He<=ke;He++)if(Be(He)*Te<=0){ze=!1;break}if(ze){_e.push({index:ke,rule:4,description:"eight in a row on one side"});break}}}return _e}function Ze(ve,be){if(!be||!(be.sigma>0))return[];const Oe=ve.length,{centre:Ce,sigma:Re}=be,Be=Te=>(ve[Te]-Ce)/Re,_e=(Te,ze,He,Qe)=>{for(const it of[1,-1]){let st=0;for(let ot=Te;ot<=ze;ot++)Be(ot)*it>He&&st++;if(st>=Qe)return!0}return!1},ke=[];for(let Te=0;Te<Oe;Te++){if(Math.abs(Be(Te))>3&&ke.push({index:Te,rule:1,description:"beyond three sigma"}),Te>=8)for(const ze of[1,-1]){let He=!0;for(let Qe=Te-8;Qe<=Te;Qe++)if(Be(Qe)*ze<=0){He=!1;break}if(He){ke.push({index:Te,rule:2,description:"nine in a row on one side"});break}}if(Te>=5)for(const ze of[1,-1]){let He=!0;for(let Qe=Te-4;Qe<=Te;Qe++)if((ve[Qe]-ve[Qe-1])*ze<=0){He=!1;break}if(He){ke.push({index:Te,rule:3,description:ze>0?"six rising":"six falling"});break}}if(Te>=13){let ze=!0;for(let He=Te-12;He<=Te;He++){const Qe=ve[He]-ve[He-1],it=ve[He+1<=Te?He+1:He]-ve[He];if(He+1>Te)break;if(Qe===0||it===0||Qe>0==it>0){ze=!1;break}}ze&&ke.push({index:Te,rule:4,description:"fourteen alternating"})}if(Te>=2&&_e(Te-2,Te,2,2)&&ke.push({index:Te,rule:5,description:"two of three past two sigma"}),Te>=4&&_e(Te-4,Te,1,4)&&ke.push({index:Te,rule:6,description:"four of five past one sigma"}),Te>=14){let ze=!0;for(let He=Te-14;He<=Te;He++)if(Math.abs(Be(He))>=1){ze=!1;break}ze&&ke.push({index:Te,rule:7,description:"fifteen within one sigma"})}if(Te>=7){let ze=!0;for(let He=Te-7;He<=Te;He++)if(Math.abs(Be(He))<=1){ze=!1;break}ze&&ke.push({index:Te,rule:8,description:"eight beyond one sigma"})}}return ke}const tt=Object.freeze(["westernElectric","nelson"]);function at(ve,be,Oe="westernElectric"){return String(Oe)==="nelson"?Ze(ve,be):Ge(ve,be)}function ft(ve,be,Oe){let Ce=0;for(let Re=0;Re<ve.length;Re++)(ve[Re]<be||ve[Re]>Oe)&&Ce++;return Ce}function mt(ve,be,Oe,Ce=20){const Re=ve.length;if(!Re)return[];const Be=ve[0],_e=ve[Re-1];if(_e===Be)return[{from:Be,to:_e,count:Re}];const ke=Oe-be,Te=1.5*ke;let ze=ke>0?Math.max(Be,be-Te):Be,He=ke>0?Math.min(_e,Oe+Te):_e;He>ze||(ze=Be,He=_e);const Qe=ke>0?2*ke/Math.cbrt(Re):(He-ze)/(Math.ceil(Math.log2(Re))+1),it=Qe>0?Math.min(Ce,Math.max(1,Math.ceil((He-ze)/Qe))):1,st=(He-ze)/it,ot=[];for(let bt=0;bt<it;bt++)ot.push({from:ze+bt*st,to:ze+(bt+1)*st,count:0});for(let bt=0;bt<Re;bt++){const vt=Math.min(it-1,Math.max(0,Math.floor((ve[bt]-ze)/st)));ot[vt].count++}return ot[0].from=Be,ot[it-1].to=_e,ot}const Ot=.95;function At(ve){const be=Number(ve);return Number.isFinite(be)&&be>0&&be<1?be:Ot}function Pt(ve,be=Ot){const Oe=ve.length;if(Oe<2)return null;let Ce=0;for(let He=0;He<Oe;He++)Ce+=ve[He];const Re=Ce/Oe;let Be=0;for(let He=0;He<Oe;He++){const Qe=ve[He]-Re;Be+=Qe*Qe}const _e=Math.sqrt(Be/(Oe-1)),ke=At(be),ze=_(1-(1-ke)/2,Oe-1)*_e/Math.sqrt(Oe);return{mean:Re,lower:Re-ze,upper:Re+ze,margin:ze,n:Oe,confidence:ke}}function Tt(ve,be,Oe=Ot){const Ce=Number(ve),Re=Number(be);if(!(Re>0)||!(Ce>=0)||Ce>Re)return null;const Be=At(Oe),_e=W(1-(1-Be)/2),ke=Ce/Re,Te=_e*_e,ze=1+Te/Re,He=(ke+Te/(2*Re))/ze,Qe=_e/ze*Math.sqrt(ke*(1-ke)/Re+Te/(4*Re*Re));return{proportion:ke,lower:Math.max(0,He-Qe),upper:Math.min(1,He+Qe),n:Re,confidence:Be}}function It(ve,be=Ot){if(!ve||!(ve.n>2)||!Number.isFinite(ve.stdError))return null;const Oe=At(be),Re=_(1-(1-Oe)/2,ve.n-2)*ve.stdError;return{slope:ve.slope,lower:ve.slope-Re,upper:ve.slope+Re,margin:Re,confidence:Oe}}function Bt(ve,be,Oe=Ot){const Ce=Number(ve),Re=Number(be);if(!Number.isFinite(Ce)||!(Re>1))return null;const Be=At(Oe),ke=W(1-(1-Be)/2)*Math.sqrt(1/(9*Re)+Ce*Ce/(2*(Re-1)));return{index:Ce,lower:Ce-ke,upper:Ce+ke,margin:ke,n:Re,confidence:Be}}function ct(ve,be){return!ve||!(ve.sd>0)||!Number.isFinite(be)||!Number.isFinite(ve.mean)?null:(be-ve.mean)/ve.sd}function nt(ve){return Number.isFinite(ve)?Math.min(1,Math.max(0,2*H(Math.abs(ve)/2)-1)):0}function de(ve,be){const Oe=new Map,Ce=B(ve);let Re=0;for(let Be=0;Be<be.length;Be++){const _e=Ce(be[Be]);if(_e==null||_e===""||typeof _e=="number"&&Number.isNaN(_e))continue;const ke=_e instanceof Date?_e.getTime():typeof _e=="object"?String(_e):_e;Oe.set(ke,(Oe.get(ke)||0)+1),Re++}return{map:Oe,total:Re}}function Se(ve,be,Oe,Ce){if(!(be>0)||!(Ce>0))return null;let Re=0;const Be=new Set(ve.keys());for(const _e of Oe.keys())Be.add(_e);for(const _e of Be){const ke=(ve.get(_e)||0)/be,Te=(Oe.get(_e)||0)/Ce;Re+=Math.abs(ke-Te)}return Re/2}const Le=10;function Ie(ve,be,Oe){if(Oe&&Oe.numeric){const ke=u(ve,be),{n:Te,mean:ze}=j(ke),He=Te>0?ct({mean:Oe.mean,sd:Oe.sd},ze):null;return{measure:"standardizedMeanDifference",magnitude:He,distance:He===null?0:nt(He),direction:He===null?0:Math.sign(He),subsetN:Te,populationN:Oe.n||0,reliable:Te>=Le}}const{map:Re,total:Be}=de(ve,be),_e=Se(Re,Be,Oe.map,Oe.total);return{measure:"categoricalTotalVariation",magnitude:_e,distance:_e===null?0:_e,direction:0,subsetN:Be,populationN:Oe.total||0,reliable:Be>=Le}}function De(ve,be){if(ve&&(ve.kind==="float64"||ve.kind==="int32"))return!0;const Oe=B(ve);let Ce=0,Re=0;for(let Be=0;Be<be.length&&Ce<200;Be++){const _e=Oe(be[Be]);if(_e==null||_e==="")continue;if(_e instanceof Date)return!1;Ce++;const ke=typeof _e=="number"?_e:Number(_e);Number.isFinite(ke)&&Re++}return Ce===0?!1:Re/Ce>=.9}function Xe(ve,be){if(De(ve,be)){const Re=u(ve,be),{n:Be,mean:_e,m2:ke}=j(Re);return{numeric:!0,mean:_e,sd:Be>0?Math.sqrt(ke/Be):0,n:Be}}const{map:Oe,total:Ce}=de(ve,be);return{numeric:!1,map:Oe,total:Ce}}}),Fe("packages/core/src/compute/total.js",function(e,K){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return b}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=K("packages/core/src/compute/handle.js"),_=I.presenceReader,X=I.valueComparator,W=I.valueReader,H=K("packages/core/src/compute/statistics.js"),U=H.STAT_FNS,z=H.STAT_LABELS;function w(j){return!!j&&(j.kind==="float64"||j.kind==="int32")}function k(j,S){const y=S.length;let v=0;if(w(j)){const O=j.values,x=_(j);if(!x){for(let C=0;C<y;C++){const P=O[S[C]];Number.isNaN(P)||(v+=P)}return v}for(let C=0;C<y;C++){const P=S[C];if(x(P)===1){const F=O[P];Number.isNaN(F)||(v+=F)}}return v}const R=W(j);for(let O=0;O<y;O++){const x=f(R(S[O]));x!==null&&(v+=x)}return v}k.kernel=!0;function g(j,S){const y=S.length;let v=0;if(w(j)){const O=j.values,x=_(j);if(!x){for(let C=0;C<y;C++)Number.isNaN(O[S[C]])||v++;return v}for(let C=0;C<y;C++){const P=S[C];x(P)===1&&!Number.isNaN(O[P])&&v++}return v}const R=W(j);for(let O=0;O<y;O++){const x=R(S[O]);x!=null&&!(typeof x=="number"&&Number.isNaN(x))&&v++}return v}g.kernel=!0;function l(j,S){return S.length}l.kernel=!0;function c(j,S){const y=g(j,S);return y===0?null:k(j,S)/y}c.kernel=!0;function s(j,S,y,v){const R=S.length;if(w(j)){const P=j.values,F=_(j);let E=null;if(!F){for(let D=0;D<R;D++){const N=P[S[D]];Number.isNaN(N)||(E===null||(y<0?N<E:N>E))&&(E=N)}return E}for(let D=0;D<R;D++){const N=S[D];if(F(N)===0)continue;const M=P[N];Number.isNaN(M)||(E===null||(y<0?M<E:M>E))&&(E=M)}return E}const O=W(j),x=X(v);let C=null;for(let P=0;P<R;P++){const F=O(S[P]);F==null||typeof F=="number"&&Number.isNaN(F)||(C===null||(y<0?x(F,C)<0:x(F,C)>0))&&(C=F)}return C}function n(j,S,y){return s(j,S,-1,y&&y.locale)}n.kernel=!0;function t(j,S,y){return s(j,S,1,y&&y.locale)}t.kernel=!0;function r(j,S){return S.length===0?null:W(j)(S[0])}r.kernel=!0;function o(j,S){return S.length===0?null:W(j)(S[S.length-1])}o.kernel=!0;function f(j){if(typeof j=="number")return Number.isNaN(j)?null:j;if(j==null||j===""||typeof j=="boolean")return null;if(j instanceof Date)return j.getTime();const S=Number(j);return Number.isNaN(S)?null:S}const u={sum:k,min:n,max:t,avg:c,count:l,first:r,last:o,countValues:g,...U},i=Object.freeze({...z,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function m(j){return j?typeof j=="string"?i[j]||j:"Total":""}const d=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function h(j){const S=j&&j.dataType&&j.dataType.totals&&j.dataType.totals.supported;if(Array.isArray(S))return S.slice();const y=d.filter(v=>v in u);for(const v of Object.keys(u))y.includes(v)||y.push(v);return y}function a(j,S){return typeof S!="string"?!0:h(j).includes(S)}function p(j,S){const y=W(j),v=[];for(let R=0;R<S.length;R++){const O=y(S[R]);O!=null&&v.push(O)}return v}function b(j,S,y,v){const R=S||[];if(typeof y=="string"){const O=u[y];return O?O(j,R,v):(B(`total:${y}`,`unknown total function "${y}"; register it in config.totalFns`),null)}return $(y)?y.kernel===!0?y(j,R,v):y(p(j,R),v||{}):null}}),Fe("packages/core/src/compute/windowed.js",function(e,K){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/compute/sketch.js").Welford;class B{#e;#t;#n=[];#r;#o;constructor(H,U=0,z=Date.now){if(H!=="count"&&H!=="time"&&H!=="session")throw new RangeError(`unknown window kind: ${H}`);if((H==="count"||H==="time")&&!(U>0))throw new RangeError(`a ${H} window needs a positive span`);this.#e=H,this.#t=Math.floor(U),this.#r=z,this.#o=z()}get size(){return this.#n.length}push(H,U=this.#r()){Number.isFinite(H)&&(this.#n.push({t:U,v:H}),this.#i(U))}#i(H){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const U=H-this.#t;for(;this.#n.length&&this.#n[0].t<U;)this.#n.shift()}}spec(){const H=this.#e==="session"?this.#r()-this.#o:this.#t;return{kind:this.#e,span:H,size:this.#n.length}}values(){return this.#n.map(H=>H.v)}aggregate(){const H=this.spec();if(!this.#n.length)return{over:H,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const U=new $;let z=0,w=1/0,k=-1/0;for(const{v:g}of this.#n)z+=g,g<w&&(w=g),g>k&&(k=g),U.add(g);return{over:H,count:this.#n.length,sum:z,mean:U.mean(),min:w,max:k,variance:U.variance(),stddev:U.stddev()}}reduce(H){const U=this.aggregate(),z={sum:U.sum,avg:U.mean,mean:U.mean,min:U.min,max:U.max,count:U.count,variance:U.variance,stddev:U.stddev};if(!(H in z))throw new RangeError(`unknown windowed aggregate: ${H}`);return{value:z[H],over:U.over}}}const I=Object.freeze(["count","time","session"]);function _(W,H=Date.now){const U=W.kind==="time"&&W.minutes!=null?W.minutes*6e4:W.span??0;return new B(W.kind,U,H)}const X={Window:B,WINDOW_KINDS:I,openWindow:_}}),Fe("packages/core/src/compute/rolling.js",function(e,K){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const $=K("packages/core/src/compute/windowed.js").openWindow,I=K("packages/core/src/compute/sketch.js").KLL,_=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function X(i,m,d,h){if(i.kind==="count"){const a=Math.max(1,Math.floor(i.span||0));return{coverage:Math.min(1,m/a),partial:m<a}}if(i.kind==="time"){const a=i.minutes!=null?i.minutes*6e4:i.span||0;if(!(a>0))return{coverage:1,partial:!1};const p=d-h;return{coverage:Math.min(1,p/a),partial:p<a}}return{coverage:null,partial:!1}}function W(i,m){const d=$(m),h=new Map,a=i.length?i[0].at:0;for(let p=0;p<i.length;p++){const{key:b,at:j,value:S}=i[p];Number.isFinite(S)&&d.push(S,j);const y=d.aggregate(),v=X(m,y.count,j,a);b!=null&&h.set(String(b),{sum:y.sum,avg:y.mean,min:y.min,max:y.max,count:y.count,coverage:v.coverage,partial:v.partial})}return h}function H(i){const m=new Map;let d=0;for(const{key:h,value:a}of i)Number.isFinite(a)&&(d+=a),h!=null&&m.set(String(h),d);return m}function U(i,m=1){const d=new Map,h=Math.max(1,Math.floor(m));for(let a=0;a<i.length;a++){const{key:p,value:b}=i[a];if(p==null)continue;const j=a>=h?i[a-h].value:null,S=Number.isFinite(b)?b:null,y=Number.isFinite(j)?j:null;d.set(String(p),S!==null&&y!==null?S-y:null)}return d}const z=4096;function w(i){let m=i>>>0;return()=>{m+=1831565813;let d=m;return d=Math.imul(d^d>>>15,d|1),d^=d+Math.imul(d^d>>>7,d|61),((d^d>>>14)>>>0)/4294967296}}function k(i,m){const d=i.length;if(d===1)return i[0];const h=(d-1)*m,a=Math.floor(h),p=Math.ceil(h);return a===p?i[a]:i[a]+(h-a)*(i[p]-i[a])}function g(i,m,d={}){const h=Math.min(1,Math.max(0,d.q==null?.5:d.q)),a=Math.max(1,Math.floor(d.cap==null?z:d.cap)),p=w(d.seed==null?2654435769:d.seed),b=new Map,j=i.length?i[0].at:0;if(m.kind==="session"){const y=new I(200,p);let v=0;for(const{key:R,value:O}of i)Number.isFinite(O)&&(y.add(O),v++),R!=null&&b.set(String(R),{value:v?y.quantile(h):null,approx:v>0,count:v,coverage:null,partial:!1});return b}const S=$(m);for(const{key:y,at:v,value:R}of i){Number.isFinite(R)&&S.push(R,v);const O=S.values(),x=O.length;let C=null,P=!1;if(x)if(x<=a)C=k([...O].sort((E,D)=>E-D),h);else{const E=new I(200,p);for(const D of O)E.add(D);C=E.quantile(h),P=!0}const F=X(m,x,v,j);y!=null&&b.set(String(y),{value:C,approx:P,count:x,coverage:F.coverage,partial:F.partial})}return b}function l(i,m){const d=i.length,h=new Array(d).fill(null),a=Math.floor(m/2),p=m%2===0;for(let b=0;b<d;b++){if(b-a<0||b+a>=d)continue;let j=0,S=!0;if(p)for(let y=-a;y<=a;y++){const v=i[b+y];if(!Number.isFinite(v)){S=!1;break}j+=y===-a||y===a?v*.5:v}else for(let y=-a;y<=a;y++){const v=i[b+y];if(!Number.isFinite(v)){S=!1;break}j+=v}S&&(h[b]=j/m)}return h}function c(i,m){const d=new Map,h=Math.floor(Number(m&&m.period));if(!(h>=2))return d;const a=m&&m.model==="multiplicative",p=i.length,b=i.map(P=>Number.isFinite(P.value)?P.value:null),j=l(b,h),S=new Array(p).fill(null);for(let P=0;P<p;P++){const F=j[P],E=b[P];F===null||E===null||(a?F!==0&&(S[P]=E/F):S[P]=E-F)}const y=new Array(h).fill(0),v=new Array(h).fill(0);for(let P=0;P<p;P++){if(S[P]===null)continue;const F=P%h;y[F]+=S[P],v[F]+=1}const R=a?1:0,O=y.map((P,F)=>v[F]?P/v[F]:R),x=O.reduce((P,F)=>P+F,0)/h,C=a?O.map(P=>x!==0?P/x:1):O.map(P=>P-x);for(let P=0;P<p;P++){const{key:F}=i[P];if(F==null)continue;const E=j[P],D=C[P%h],N=b[P];let M=null;E!==null&&N!==null&&(M=a?E*D!==0?N/(E*D):null:N-E-D),d.set(String(F),{trend:E,seasonal:N===null?null:D,residual:M,coverage:E===null?0:1,partial:E===null})}return d}function s(i,m,d,h=80){const a=(Math.sqrt(5)-1)/2;let p=m,b=d,j=b-a*(b-p),S=p+a*(b-p),y=i(j),v=i(S);for(let R=0;R<h;R++)y<v?(b=S,S=j,v=y,j=b-a*(b-p),y=i(j)):(p=j,j=S,y=v,S=p+a*(b-p),v=i(S));return(p+b)/2}const n=1e-4,t=1-1e-4;function r(i,m){const d=i.length,h=new Array(d).fill(null),a=new Array(d).fill(null);let p=null,b=0;for(let j=0;j<d;j++){const S=i[j];if(!Number.isFinite(S)){p!==null&&(a[j]=p,h[j]=p);continue}if(p===null){p=S,a[j]=S,h[j]=S;continue}a[j]=p,b+=(S-p)**2,p=m*S+(1-m)*p,h[j]=p}return{smoothed:h,fitted:a,sse:b}}function o(i,m,d){const h=i.length,a=new Array(h).fill(null),p=new Array(h).fill(null);let b=null,j=null,S=0;for(let y=0;y<h;y++){const v=i[y];if(!Number.isFinite(v)){b!==null&&(b+=j,a[y]=b);continue}if(b===null){b=v,a[y]=v;continue}if(j===null){j=v-b;const x=b+j;p[y]=x,S+=(v-x)**2;const C=b;b=m*v+(1-m)*(C+j),j=d*(b-C)+(1-d)*j,a[y]=b;continue}const R=b+j;p[y]=R,S+=(v-R)**2;const O=b;b=m*v+(1-m)*(O+j),j=d*(b-O)+(1-d)*j,a[y]=b}return{smoothed:a,fitted:p,sse:S}}function f(i,m={}){const d=new Map,h=m.method==="holt",a=i.map(R=>Number.isFinite(R.value)?R.value:null),p=a.filter(R=>R!==null).length,b=R=>Math.min(t,Math.max(n,R)),j=()=>{for(const{key:R}of i)R!=null&&d.set(String(R),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return d};if(p<(h?2:1))return j();let S=Number.isFinite(m.alpha)?b(m.alpha):null,y=h&&Number.isFinite(m.beta)?b(m.beta):null;if(h){if(S===null||y===null){let R=S===null?.5:S,O=y===null?.5:y;for(let x=0;x<6;x++)S===null&&(R=s(C=>o(a,C,O).sse,n,t)),y===null&&(O=s(C=>o(a,R,C).sse,n,t));S=S===null?R:S,y=y===null?O:y}}else S===null&&(S=s(R=>r(a,R).sse,n,t));const v=h?o(a,S,y):r(a,S);for(let R=0;R<i.length;R++){const{key:O}=i[R];O!=null&&d.set(String(O),{smoothed:v.smoothed[R],fitted:v.fitted[R],alpha:S,beta:h?y:null,sse:v.sse})}return d}const u={ROLLING_WINDOW_FIELDS:_,QUANTILE_SPAN_CAP:z,rollingWindow:W,rollingQuantile:g,cumulativeToDate:H,periodOverPeriod:U,seasonalDecompose:c,exponentialSmoothing:f}}),Fe("packages/core/src/compute/compare.js",function(e,K){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/compute/statistics.js"),$=Q.numbers,B=Q.moments,I=Q.frequencyMap,_=Q.categoricalDistance,X=Q.normalTotalVariation,W=Q.isNumericColumn,H=Q.SUBSET_RELIABILITY_FLOOR,U=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function z(c,s){if(!c||!s||!(c.n>0)||!(s.n>0)||!Number.isFinite(c.mean)||!Number.isFinite(s.mean))return null;const n=(c.n*c.sd*c.sd+s.n*s.sd*s.sd)/(c.n+s.n);return n>0?(c.mean-s.mean)/Math.sqrt(n):null}function w(c,s){const n=$(c,s),{n:t,mean:r,m2:o}=B(n),f=t>0?Math.sqrt(o/t):0;return{mean:r,sd:f,n:t}}function k(c,s,n,t){return W(c,s)&&W(n,t)}function g(c,s,n,t){if(k(c,s,n,t)){const u=w(c,s),i=w(n,t),m=z(u,i);return{measure:U.numeric,magnitude:m,distance:m===null?0:X(m),direction:m===null?0:Math.sign(m),nA:u.n,nB:i.n,reliable:u.n>=H&&i.n>=H}}const r=I(c,s),o=I(n,t),f=_(r.map,r.total,o.map,o.total);return{measure:U.categorical,magnitude:f,distance:f===null?0:f,direction:0,nA:r.total,nB:o.total,reliable:r.total>=H&&o.total>=H}}function l(c,s,n={}){const t=new Set(c.columns),r=new Set(s.columns),o=c.columns.filter(d=>r.has(d)),f=Array.isArray(n.columns)&&n.columns.length?o.filter(d=>n.columns.includes(d)):o,u=c.indices(),i=s.indices(),m=[];for(const d of f){const h=c.handle(d),a=s.handle(d);if(!h||!a)continue;const p=g(h,u,a,i);m.push({column:d,name:c.name&&c.name(d)||s.name&&s.name(d)||d,measure:p.measure,magnitude:p.magnitude,distance:p.distance,direction:p.direction,nA:p.nA,nB:p.nB,reliable:p.reliable})}return m.sort((d,h)=>h.distance-d.distance||Math.abs(h.magnitude||0)-Math.abs(d.magnitude||0)),{ranked:m,nA:u.length,nB:i.length,unmatched:{onlyA:c.columns.filter(d=>!r.has(d)),onlyB:s.columns.filter(d=>!t.has(d))},measures:U}}}),Fe("packages/core/src/compute/anomaly.js",function(e,K){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u}});const $=K("packages/core/src/compute/statistics.js").quantileSorted,I=K("packages/core/src/compute/special.js").logGamma,_=.6745,X=3.5,W=1.5,H=.975,U=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function z(i){if(!i.length)return null;const d=Array.from(i,Number).sort((b,j)=>b-j),h=$(d,.5),a=d.map(b=>Math.abs(b-h)).sort((b,j)=>b-j),p=$(a,.5);return{median:h,mad:p}}function w(i,m={}){const d=Number.isFinite(m.threshold)?m.threshold:X,h=i.length,a=new Array(h).fill(null),p=new Array(h).fill(!1),b=[];for(let y=0;y<h;y++){const v=Number(i[y]);Number.isFinite(v)&&b.push(v)}if(!b.length)return{median:null,mad:null,threshold:d,scores:a,flags:p,flagged:0};const j=z(b);if(j.mad===0)return{median:j.median,mad:0,threshold:d,scores:a,flags:p,flagged:0};let S=0;for(let y=0;y<h;y++){const v=Number(i[y]);if(!Number.isFinite(v))continue;const R=_*(v-j.median)/j.mad;a[y]=R,Math.abs(R)>d&&(p[y]=!0,S++)}return{median:j.median,mad:j.mad,threshold:d,scores:a,flags:p,flagged:S}}function k(i,m={}){const d=Number.isFinite(m.k)?m.k:W,h=[];for(let S=0;S<i.length;S++){const y=Number(i[S]);Number.isFinite(y)&&h.push(y)}if(!h.length)return null;const a=h.sort((S,y)=>S-y),p=$(a,.25),b=$(a,.75),j=b-p;return{q1:p,q3:b,iqr:j,lower:p-d*j,upper:b+d*j,k:d}}function g(i,m){if(m<=0)return 0;const d=I(i);if(m<i+1){let y=i,v=1/i,R=v;for(let O=0;O<1e3&&(y+=1,R*=m/y,v+=R,!(Math.abs(R)<Math.abs(v)*1e-15));O++);return v*Math.exp(-m+i*Math.log(m)-d)}const h=1e-300;let a=m+1-i,p=1/h,b=1/a,j=b;for(let y=1;y<1e3;y++){const v=-y*(y-i);a+=2,b=v*b+a,Math.abs(b)<h&&(b=h),p=a+v/p,Math.abs(p)<h&&(p=h),b=1/b;const R=b*p;if(j*=R,Math.abs(R-1)<1e-15)break}return 1-Math.exp(-m+i*Math.log(m)-d)*j}function l(i,m){return i<=0?0:g(m/2,i/2)}function c(i,m=H){if(!(m>0)||!(m<1))return NaN;let d=0,h=Math.max(1,i);for(;l(h,i)<m;)h*=2;for(let a=0;a<200;a++){const p=(d+h)/2;if(l(p,i)<m?d=p:h=p,h-d<1e-10)break}return(d+h)/2}function s(i){const m=i.length,d=i.map((h,a)=>{const p=h.slice();for(let b=0;b<m;b++)p.push(a===b?1:0);return p});for(let h=0;h<m;h++){let a=h;for(let b=h+1;b<m;b++)Math.abs(d[b][h])>Math.abs(d[a][h])&&(a=b);if(Math.abs(d[a][h])<1e-12)return null;if(a!==h){const b=d[a];d[a]=d[h],d[h]=b}const p=d[h][h];for(let b=0;b<2*m;b++)d[h][b]/=p;for(let b=0;b<m;b++){if(b===h)continue;const j=d[b][h];if(j!==0)for(let S=0;S<2*m;S++)d[b][S]-=j*d[h][S]}}return d.map(h=>h.slice(m))}function n(i,m){const d=i.length,h=new Array(m).fill(0);for(const b of i)for(let j=0;j<m;j++)h[j]+=b[j];for(let b=0;b<m;b++)h[b]/=d;const a=Array.from({length:m},()=>new Array(m).fill(0));for(const b of i)for(let j=0;j<m;j++){const S=b[j]-h[j];for(let y=j;y<m;y++)a[j][y]+=S*(b[y]-h[y])}const p=d>1?d-1:1;for(let b=0;b<m;b++)for(let j=b;j<m;j++)a[b][j]/=p,a[j][b]=a[b][j];return{mean:h,cov:a}}function t(i,m={}){const d=Number.isFinite(m.p)?m.p:H,h=Number.isFinite(m.ridge)?m.ridge:1e-6,a=i.length;if(!a)return null;const p=i[0].length;if(!p)return null;const b=new Array(a).fill(null),j=new Array(a).fill(null),S=new Array(a).fill(!1),y=[],v=[];for(let D=0;D<a;D++){const N=i[D];let M=N.length===p;const A=new Array(p);for(let L=0;M&&L<p;L++){const G=Number(N[L]);Number.isFinite(G)?A[L]=G:M=!1}M&&(y.push(D),v.push(A))}const R=p,O=c(R,d);if(v.length<=p)return{center:[],df:R,cutoff:O,singular:!0,used:v.length,distances:b,squared:j,flags:S,flagged:0};const{mean:x,cov:C}=n(v,p);let P=s(C),F=!1;if(!P){F=!0;let D=0;for(let A=0;A<p;A++)D+=C[A][A];const N=D/p*h||h,M=C.map((A,L)=>A.map((G,q)=>L===q?G+N:G));if(P=s(M),!P)return{center:x,df:R,cutoff:O,singular:!0,used:v.length,distances:b,squared:j,flags:S,flagged:0}}let E=0;for(let D=0;D<v.length;D++){const N=v[D],M=new Array(p);for(let G=0;G<p;G++)M[G]=N[G]-x[G];let A=0;for(let G=0;G<p;G++){let q=0;for(let Y=0;Y<p;Y++)q+=P[G][Y]*M[Y];A+=M[G]*q}A<0&&(A=0);const L=y[D];j[L]=A,b[L]=Math.sqrt(A),A>O&&(S[L]=!0,E++)}return{center:x,df:R,cutoff:O,singular:F,used:v.length,distances:b,squared:j,flags:S,flagged:E}}const r=20,o=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function f(i,m={}){const d=m.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",h=Number.isFinite(m.windowLen)&&m.windowLen>=1?Math.floor(m.windowLen):r,a=Number.isFinite(m.threshold)?m.threshold:X,p=Number.isFinite(m.k)?m.k:W,b=Number.isFinite(m.minPeriods)&&m.minPeriods>=1?Math.floor(m.minPeriods):h,j=i.length,S=new Array(j).fill(null),y=new Array(j).fill(!1);let v=0;for(let R=0;R<j;R++){const O=Number(i[R]);if(!Number.isFinite(O))continue;const x=Math.max(0,R-h+1),C=[];for(let P=x;P<=R;P++){const F=Number(i[P]);Number.isFinite(F)&&C.push(F)}if(!(C.length<b))if(d==="rollingIqr"){const P=k(C,{k:p});if(!P)continue;(O<P.lower||O>P.upper)&&(y[R]=!0,v++)}else{const P=z(C);if(!P||P.mad===0)continue;const F=_*(O-P.median)/P.mad;S[R]=F,Math.abs(F)>a&&(y[R]=!0,v++)}}return{method:d,windowLen:h,minPeriods:b,threshold:a,k:p,scores:S,flags:y,flagged:v}}function u(i={}){const m=i||{},d=m.field;if(typeof d!="string"||!d)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const h=m.method||"modifiedZScore";if(!(U.includes(h)||o.includes(h))||h==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${h}'`);const p=typeof m.orderBy=="string"?m.orderBy:null,b=m.latest===!0,j=o.includes(h),S=y=>Number(y==null?NaN:y[d]);return y=>{const v=Array.isArray(y)?y.slice():[...y];p&&v.sort((P,F)=>{const E=P?.[p],D=F?.[p];return E===D?0:E==null?-1:D==null?1:E<D?-1:1});const R=v.map(S);let O,x;if(j)({flags:O,scores:x}=f(R,{method:h,windowLen:m.windowLen,threshold:m.threshold,k:m.k,minPeriods:m.minPeriods}));else if(h==="iqr"){const P=k(R,{k:m.k});O=R.map(F=>P?Number.isFinite(F)&&(F<P.lower||F>P.upper):!1),x=R.map(()=>null)}else({flags:O,scores:x}=w(R,{threshold:m.threshold}));if(b){const P=O.length-1;return P<0||!O[P]?!1:{method:h,field:d,flagged:[{row:v[P],score:x[P]}]}}const C=[];for(let P=0;P<O.length;P++)O[P]&&C.push({row:v[P],score:x[P]});return C.length?{method:h,field:d,flagged:C}:!1}}}),Fe("packages/core/src/compute/forecast.js",function(e,K){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const Q=K("packages/core/src/compute/special.js"),$=Q.normalQuantile,B=Q.studentTQuantile,_=K("packages/core/src/internal/util.js").warnOnce,X=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),W=1e-4,H=1-1e-4;function U(m){const d=[];for(let h=0;h<m.length;h++){const a=m[h];if(a!==null&&typeof a=="object"){const p=Number.isFinite(a.at)?a.at:h,b=Number.isFinite(a.value)?a.value:null;d.push({at:p,value:b})}else d.push({at:h,value:Number.isFinite(a)?Number(a):null})}return d}function z(m){const d=m.filter(j=>j.value!==null),h=d[0],a=d[d.length-1],p=a.at-h.at,b=d.length>1&&p>0?p/(d.length-1):1;return{lastAt:a.at,step:b}}function w(m){return Math.min(H,Math.max(W,m))}function k(m,d=W,h=H,a=80){const p=(Math.sqrt(5)-1)/2;let b=d,j=h,S=j-p*(j-b),y=b+p*(j-b),v=m(S),R=m(y);for(let O=0;O<a;O++)v<R?(j=y,y=S,R=v,S=j-p*(j-b),v=m(S)):(b=S,S=y,v=R,y=b+p*(j-b),R=m(y));return(b+j)/2}function g(m,d){let h=null,a=0,p=0;for(let b=0;b<m.length;b++){const j=m[b];if(j!==null){if(h===null){h=j;continue}a+=(j-h)**2,p+=1,h=d*j+(1-d)*h}}return{level:h,sse:a,m:p}}function l(m,d,h){let a=null,p=null,b=0,j=0;for(let S=0;S<m.length;S++){const y=m[S];if(y===null){a!==null&&p!==null&&(a+=p);continue}if(a===null){a=y;continue}p===null&&(p=y-a);const v=a+p;b+=(y-v)**2,j+=1;const R=a;a=d*y+(1-d)*(R+p),p=h*(a-R)+(1-h)*p}return{level:a,trend:p,sse:b,m:j}}function c(m,d,h,a,p){const b=m.length;if(b<2*d)return null;const j=F=>{let E=0,D=0;for(let N=F;N<F+d&&N<b;N++)m[N]!==null&&(E+=m[N],D+=1);return D?E/D:null},S=j(0),y=j(d);if(S===null||y===null)return null;let v=S,R=(y-S)/d;const O=new Array(d).fill(0);for(let F=0;F<d;F++)O[F]=m[F]===null?0:m[F]-v;const x=O.reduce((F,E)=>F+E,0)/d;for(let F=0;F<d;F++)O[F]-=x;let C=0,P=0;for(let F=d;F<b;F++){const E=F%d,D=O[E],N=m[F];if(N===null){v+=R;continue}const M=v+R+D;C+=(N-M)**2,P+=1;const A=v;v=h*(N-D)+(1-h)*(v+R),R=a*(v-A)+(1-a)*R,O[E]=p*(N-v)+(1-p)*D}return{level:v,trend:R,season:O,phase:(b-1)%d,sse:C,count:P}}function s(m,d,h){let a=1;for(const b of d)a+=b*b;const p=Math.sqrt(m*a);return{se:p,margin:h*p}}function n(m,d={}){if(!m||typeof m.length!="number"||m.length===0)return null;const h=X.includes(d.method)?d.method:"linear",a=Math.max(1,Math.floor(Number(d.horizon)||1)),p=Number.isFinite(d.confidence)&&d.confidence>0&&d.confidence<1?d.confidence:.95,b=1-(1-p)/2,j=U(m),S=j.map(C=>C.value),y=S.filter(C=>C!==null),v=y.length,{lastAt:R,step:O}=v?z(j):{lastAt:0,step:1},x=C=>R+C*O;return h==="linear"?t(j,v,a,p,b,x):h==="movingAverage"?r(y,v,a,p,b,d,x):h==="ses"?o(S,v,a,p,b,d,x):h==="holt"?f(S,v,a,p,b,d,x):u(S,v,a,p,b,d,x)}function t(m,d,h,a,p,b){if(d<2)return null;let j=0,S=0;for(const N of m)N.value!==null&&(j+=N.at,S+=N.value);j/=d,S/=d;let y=0,v=0,R=0;for(const N of m){if(N.value===null)continue;const M=N.at-j,A=N.value-S;y+=M*M,v+=M*A,R+=A*A}if(y===0)return null;const O=v/y,x=S-O*j,C=R===0?1:Math.max(0,Math.min(1,v*v/(y*R))),P=Math.max(0,R-O*v),F=d>2?Math.sqrt(P/(d-2)):null,E=d>2?B(p,d-2):null,D=[];for(let N=1;N<=h;N++){const M=b(N),A=x+O*M;let L=null,G=null,q=null,Y=null,J=null;if(F!==null){const te=1/d+(M-j)**2/y,ne=F*Math.sqrt(1+te),oe=F*Math.sqrt(te);J=ne,L=A-E*ne,G=A+E*ne,q=A-E*oe,Y=A+E*oe}D.push({step:N,at:M,mean:A,lower:L,upper:G,lowerMean:q,upperMean:Y,se:J})}return{method:"linear",horizon:h,confidence:a,n:d,sigma:F,r2:C,params:{slope:O,intercept:x},points:D}}function r(m,d,h,a,p,b,j){if(d<1)return null;const S=Math.max(1,Math.min(d,Math.floor(Number(b.windowLen)||d))),y=m.slice(d-S);let v=0;for(const F of y)v+=F;const R=v/S;let O=null,x=null;if(S>1){let F=0;for(const D of y)F+=(D-R)**2;O=Math.sqrt(F/(S-1))*Math.sqrt(1+1/S),x=B(p,S-1)}const C=O===null?null:x*O,P=[];for(let F=1;F<=h;F++)P.push({step:F,at:j(F),mean:R,lower:C===null?null:R-C,upper:C===null?null:R+C,se:O});return{method:"movingAverage",horizon:h,confidence:a,n:d,sigma:O===null?null:O,params:{windowLen:S},points:P}}function o(m,d,h,a,p,b,j){if(d<1)return null;let S=Number.isFinite(b.alpha)?w(b.alpha):null;S===null&&(S=k(x=>g(m,x).sse));const y=g(m,S),v=$(p),R=y.m>0?y.sse/y.m:null,O=[];for(let x=1;x<=h;x++){const C=y.level;let P=null,F=null,E=null;if(R!==null){const D=[];for(let M=1;M<x;M++)D.push(S);const N=s(R,D,v);E=N.se,P=C-N.margin,F=C+N.margin}O.push({step:x,at:j(x),mean:C,lower:P,upper:F,se:E})}return{method:"ses",horizon:h,confidence:a,n:d,sigma:R===null?null:Math.sqrt(R),params:{alpha:S},points:O}}function f(m,d,h,a,p,b,j){if(d<2)return null;let S=Number.isFinite(b.alpha)?w(b.alpha):null,y=Number.isFinite(b.beta)?w(b.beta):null;if(S===null||y===null){let P=S===null?.5:S,F=y===null?.5:y;for(let E=0;E<6;E++)S===null&&(P=k(D=>l(m,D,F).sse)),y===null&&(F=k(D=>l(m,P,D).sse));S=S===null?P:S,y=y===null?F:y}const v=l(m,S,y),R=$(p),O=v.m>0?v.sse/v.m:null,x=S*y,C=[];for(let P=1;P<=h;P++){const F=v.level+P*v.trend;let E=null,D=null,N=null;if(O!==null){const M=[];for(let L=1;L<P;L++)M.push(S+L*x);const A=s(O,M,R);N=A.se,E=F-A.margin,D=F+A.margin}C.push({step:P,at:j(P),mean:F,lower:E,upper:D,se:N})}return{method:"holt",horizon:h,confidence:a,n:d,sigma:O===null?null:Math.sqrt(O),params:{alpha:S,beta:y},points:C}}function u(m,d,h,a,p,b,j){const S=Math.floor(Number(b.period));if(!(S>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(d<2*S)return null;let y=Number.isFinite(b.alpha)?w(b.alpha):null,v=Number.isFinite(b.beta)?w(b.beta):null,R=Number.isFinite(b.gamma)?w(b.gamma):null;const O=(N,M,A)=>{const L=c(m,S,N,M,A);return L?L.sse:1/0};if(y===null||v===null||R===null){let N=y===null?.5:y,M=v===null?.5:v,A=R===null?.5:R;for(let L=0;L<8;L++)y===null&&(N=k(G=>O(G,M,A))),v===null&&(M=k(G=>O(N,G,A))),R===null&&(A=k(G=>O(N,M,G)));y=y===null?N:y,v=v===null?M:v,R=R===null?A:R}const x=c(m,S,y,v,R);if(!x)return null;const C=$(p),P=x.count>0?x.sse/x.count:null,F=y*v,E=R*(1-y),D=[];for(let N=1;N<=h;N++){const M=x.season[(x.phase+N)%S],A=x.level+N*x.trend+M;let L=null,G=null,q=null;if(P!==null){const Y=[];for(let te=1;te<N;te++)Y.push(y+te*F+(te%S===0?E:0));const J=s(P,Y,C);q=J.se,L=A-J.margin,G=A+J.margin}D.push({step:N,at:j(N),mean:A,lower:L,upper:G,se:q})}return{method:"holtWinters",horizon:h,confidence:a,n:d,sigma:P===null?null:Math.sqrt(P),params:{alpha:y,beta:v,gamma:R,period:S},points:D}}const i={FORECAST_METHODS:X,forecast:n}}),Fe("packages/core/src/compute/hypothesis.js",function(e,K){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return C}});const $=K("packages/core/src/internal/util.js").warnOnce,I=K("packages/core/src/compute/handle.js").valueReader,_=K("packages/core/src/compute/statistics.js"),X=_.numbers,W=_.moments,H=_.frequencyMap,U=_.categoricalDistance,z=_.isNumericColumn,w=_.jarqueBera,k=_.proportionInterval,g=_.SUBSET_RELIABILITY_FLOOR,c=K("packages/core/src/compute/compare.js").pooledStandardMeanDifference,s=K("packages/core/src/compute/special.js"),n=s.studentT,t=s.studentTQuantile,r=s.normalCdf,o=s.normalQuantile,f=s.chiSquareUpperTail,u=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),i=.05,m=2e6;function d(P){const F=Number(P);return Number.isFinite(F)&&F>0&&F<1?F:.95}function h(P){const{n:F,mean:E,m2:D}=W(P);return{mean:E,sd:F>0?Math.sqrt(D/F):0,n:F}}function a(P,F){const E=P.length;if(E<2)return 0;let D=0;for(let N=0;N<E;N++){const M=P[N]-F;D+=M*M}return D/(E-1)}function p(P,F){return{name:"pooledStandardMeanDifference",value:c(h(P),h(F))}}function b(P,F,E){const D=P.length,N=F.length;if(D<2||N<2)return null;const M=d(E),{mean:A}=W(P),{mean:L}=W(F),G=a(P,A),q=a(F,L),Y=G/D+q/N;if(!(Y>0))return null;const J=Math.sqrt(Y),te=(A-L)/J,ne=G/D*(G/D)/(D-1),oe=q/N*(q/N)/(N-1),le=Y*Y/(ne+oe),ae=Math.min(1,Math.max(0,2*(1-n(Math.abs(te),le)))),se=A-L,ee=t(1-(1-M)/2,le)*J;return{test:u.WELCH,statistic:te,statisticName:"t",df:le,pValue:ae,interval:{estimate:se,lower:se-ee,upper:se+ee,confidence:M,method:"welch-t (difference of means)"},effectSize:p(P,F),nA:D,nB:N,reliable:D>=g&&N>=g,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function j(P){const F=P.length;if(F===0)return Number.NaN;const E=F>>1;return F%2?P[E]:(P[E-1]+P[E])/2}function S(P,F,E){const D=P.length,N=F.length,M=D*N;if(M===0||M>m)return null;const A=new Float64Array(M);let L=0;for(let ne=0;ne<D;ne++)for(let oe=0;oe<N;oe++)A[L++]=P[ne]-F[oe];A.sort();const G=j(A),q=Math.sqrt(D*N*(D+N+1)/12),Y=o(1-(1-E)/2);let J=Math.round(M/2-Y*q);J>=0||(J=0);const te=Math.floor((M-1)/2);return J>te&&(J=te),{estimate:G,lower:A[J],upper:A[M-1-J],confidence:E,method:"hodges-lehmann (normal approximation)"}}function y(P,F,E){const D=P.length,N=F.length;if(D<1||N<1)return null;const M=d(E),A=D+N,L=new Array(A);for(let ae=0;ae<D;ae++)L[ae]={v:P[ae],g:0};for(let ae=0;ae<N;ae++)L[D+ae]={v:F[ae],g:1};L.sort((ae,se)=>ae.v-se.v);let G=0,q=0,Y=0;for(;Y<A;){let ae=Y;for(;ae<A&&L[ae].v===L[Y].v;)ae++;const se=ae-Y,ee=(Y+1+ae)/2;for(let ie=Y;ie<ae;ie++)L[ie].g===0&&(G+=ee);q+=se*se*se-se,Y=ae}const J=G-D*(D+1)/2,te=D*N/2,ne=D*N/12*(A+1-q/(A*(A-1)));let oe=1;if(ne>0){const ae=Math.max(0,Math.abs(J-te)-.5);oe=Math.min(1,2*r(-ae/Math.sqrt(ne)))}const le=S(P,F,M);return{test:u.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:oe,interval:le,effectSize:p(P,F),nA:D,nB:N,reliable:D>=g&&N>=g,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function v(P,F,E,D,N){const M=k(P,F,N),A=k(E,D,N);if(!M||!A)return null;const L=M.proportion-A.proportion,G=L-Math.sqrt((M.proportion-M.lower)**2+(A.upper-A.proportion)**2),q=L+Math.sqrt((M.upper-M.proportion)**2+(A.proportion-A.lower)**2);return{lower:G,upper:q}}function R(P,F,E,D,N,M={}){if(!(F>0)||!(D>0))return null;const A=new Set([...P.keys(),...E.keys()]),L=A.size;if(L<2)return null;const G=F+D;let q=0;for(const oe of A){const le=P.get(oe)||0,ae=E.get(oe)||0,se=le+ae,ee=F*se/G,ie=D*se/G;ee>0&&(q+=(le-ee)*(le-ee)/ee),ie>0&&(q+=(ae-ie)*(ae-ie)/ie)}const Y=L-1,J=f(q,Y);let te=null;M.category!==void 0&&A.has(M.category)?te=M.category:L===2&&([te]=[...A]);let ne=null;if(te!==null){const oe=v(P.get(te)||0,F,E.get(te)||0,D,d(N));oe&&(ne={estimate:(P.get(te)||0)/F-(E.get(te)||0)/D,lower:oe.lower,upper:oe.upper,confidence:d(N),method:"newcombe (difference in this category's share)",category:te})}return{test:u.CHI_SQUARE,statistic:q,statisticName:"chiSquare",df:Y,pValue:J,interval:ne,effectSize:{name:"categoricalTotalVariation",value:U(P,F,E,D)},nA:F,nB:D,reliable:F>=g&&D>=g,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function O(P){return P==null||P===""||typeof P=="number"&&Number.isNaN(P)?null:P instanceof Date?P.getTime():typeof P=="object"?String(P):P}function x(P,F,E){if(E===u.WELCH||E===u.MANN_WHITNEY)return{test:E,chosenBy:"override",reason:`caller override: ${E}`};const D=w(P),N=w(F),M=D===null?null:Math.exp(-D/2),A=N===null?null:Math.exp(-N/2);return M!==null&&M<i||A!==null&&A<i?{test:u.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${i})`}:{test:u.WELCH,chosenBy:"auto",reason:M!==null||A!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function C(P,F,E,D={}){if(!P||!F)return null;const N=d(D.confidence),M=I(F);let A;if(Array.isArray(D.groups)&&D.groups.length===2)A=[O(D.groups[0]),O(D.groups[1])];else{const{map:ae}=H(F,E),se=[...ae.entries()].sort((ee,ie)=>ie[1]-ee[1]).slice(0,2).map(ee=>ee[0]);if(se.length<2)return $("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;A=se}const[L,G]=A;if(L===null||G===null||L===G)return $("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const q=[],Y=[];for(let ae=0;ae<E.length;ae++){const se=O(M(E[ae]));se===L?q.push(E[ae]):se===G&&Y.push(E[ae])}if(q.length===0||Y.length===0)return $("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const J=D.test&&D.test!=="auto"?String(D.test):null,te=z(P,q.concat(Y));let ne,oe,le;if(J===u.CHI_SQUARE||!J&&!te){oe=J?"override":"auto",le=J?"caller override: chiSquare":"column family: categorical";const ae=H(P,q),se=H(P,Y);ne=R(ae.map,ae.total,se.map,se.total,N,{category:D.category})}else{if((J===u.WELCH||J===u.MANN_WHITNEY)&&!te)return $("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const ae=X(P,q),se=X(P,Y),ee=x(ae,se,J);oe=ee.chosenBy,le=ee.reason,ne=ee.test===u.MANN_WHITNEY?y(ae,se,N):b(ae,se,N)}return ne?{...ne,chosenBy:oe,reason:le,groups:[L,G]}:($("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Fe("packages/core/src/columns/detailcolumn.js",function(e,K){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const Q="__lattice_detail",$=36;function B(_){const X=_.config&&_.config.detailColumnWidth||$;return{id:Q,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:X,min:X,max:X,pin:_.config&&_.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(W,H){return!!(H&&H.expanded)},formatValue(){return""}}}const I=B}),Fe("packages/core/src/columns/treecolumn.js",function(e,K){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isFunction,B="__lattice_tree",I=260;function _(W){const H=W.tree||{},U=W.config&&W.config.treeColumnWidth||I,z=()=>(W.columns&&$(W.columns.visible)?W.columns.visible():[]).find(l=>!l.generated)||null,w=(g,l)=>{if(l&&l.group)return l.groupValue;if($(H.label))return H.label(g,l);if(typeof H.label=="string")return g==null?null:g[H.label];const c=z();return c&&$(c.getValue)?c.getValue(g,l):null},k=()=>{if(H.title)return H.title;const g=typeof H.label=="string"?W.columns&&$(W.columns.get)?W.columns.get(H.label):null:z();return g&&(g.title||g.id)||"Hierarchy"};return{id:B,get title(){return k()},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:U,min:140,pin:W.config&&W.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(g,l){return w(g,l)},formatValue(g,l){if(l&&l.grandTotal)return W.config&&W.config.grandTotalLabel||"Total";if(g==null)return"";if(!H.label){const c=z();if(c&&$(c.formatValue))return c.formatValue(g,l)}return String(g)}}}const X=_}),Fe("packages/core/src/columns/pivotcolumns.js",function(e,K){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return _}});const $=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_pivot",I=500;function _(U){const{pivot:z,valueColumns:w,config:k}=U,g=z&&z.paths||[],l=U.separator||k&&k.pivot&&k.pivot.separator||" | ",c=k&&k.pivot&&k.pivot.maxColumns||I;if(!g.length||!w.length)return{tree:[],leaves:[],error:null};const s=X(k),n=g.length*w.length+(s?w.length:0);if(n>c){const o=`pivot would generate ${n} columns, above the limit of ${c}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return $(`pivot.maxColumns:${n}`,o),{tree:[],leaves:[],error:o}}const t=[],r=[];for(const o of g){const f=[];for(const u of w){const i=H(o,u,l);f.push(i),r.push(i)}f.length===1?(f[0].title=String(o),t.push(f[0])):t.push({id:`${B}:group:${o}`,title:String(o),columns:f,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(s){const o=w.map(u=>W(u,k));r.push(...o);const f=k&&k.pivot&&k.pivot.totalsLabel||"Total";if(o.length===1)o[0].title=f,s==="before"?t.unshift(o[0]):t.push(o[0]);else{const u={id:`${B}:group:__totals`,title:f,columns:o,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};s==="before"?t.unshift(u):t.push(u)}}return{tree:t,leaves:r,error:null}}function X(U){const z=U&&U.pivot&&U.pivot.groupTotals;return z==="before"||z==="after"?z:null}function W(U,z){return{id:`${B}:__total${z&&z.pivot&&z.pivot.separator||" | "}${U.id}`,field:null,title:U.title||U.id,type:U.type,dataType:U.dataType,nullable:!0,align:U.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:U.id,total:!0},value:{pure:!0},cell:{align:U.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:U.total,lookup:null,layout:{width:U.layout&&U.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(w,k){const g=k&&k.totals;return g&&Object.hasOwn(g,U.id)?g[U.id]:null},formatValue(w,k){return w==null?"":U.formatValue?U.formatValue(w,k):String(w)}}}function H(U,z,w){return{id:`${B}:${U}${w}${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,path:U,sourceId:z.id},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(){return null},formatValue(k,g){return k==null?"":z.formatValue?z.formatValue(k,g):String(k)}}}}),Fe("packages/core/src/compute/group.js",function(e,K){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return k}});const Q=K("packages/core/src/compute/handle.js"),$=Q.dictSize,B=Q.identity,I=Q.presenceReader,_=Q.rowCount,X=Q.valueReader,W="",H="\0",U=1<<20;function z(g,l,c,s){const n=g.length,t=g.map(m=>X(m)),r=Array.isArray(s)&&s.some(Boolean),o=r?t.map((m,d)=>s[d]?h=>s[d](m(h)):m):t;if(!r&&n>0&&g.every(m=>m&&m.kind==="dictionary"&&m.dict)){const m=g.map(h=>$(h.dict)+1);let d=1;for(let h=0;h<n;h++)d*=m[h];if(d<=Number.MAX_SAFE_INTEGER){const h=g.map(j=>j.values),a=g.map(j=>I(j)),p=j=>{let S=0;for(let y=0;y<n;y++){const v=a[y],R=v&&v(j)===0?m[y]-1:h[y][j];S=S*m[y]+R}return S},b=new Float64Array(c);for(let j=0;j<c;j++)b[j]=p(l[j]);return{packed:b,strings:null,product:d,readers:o,keyOf:p}}}const u=m=>{let d="";for(let h=0;h<n;h++){const a=o[h](m);d+=(h===0?"":W)+(a==null?H:String(a))}return d},i=new Array(c);for(let m=0;m<c;m++)i[m]=u(l[m]);return{packed:null,strings:i,product:1/0,readers:o,keyOf:u}}function w(g,l,c,s){const n=new Uint32Array(s+1);for(let f=0;f<c;f++)n[l[f]+1]++;for(let f=0;f<s;f++)n[f+1]+=n[f];const t=new Uint32Array(c),r=n.slice(0,s);for(let f=0;f<c;f++)t[r[l[f]]++]=g[f];const o=new Array(s);for(let f=0;f<s;f++)o[f]=t.subarray(n[f],n[f+1]);return o}function k(g,l,c={}){const s=g||[],n=l||B(_(s[0],c)),t=n.length;if(s.length===0||t===0)return{keys:[],buckets:[]};const{packed:r,strings:o,product:f,readers:u}=z(s,n,t,c.project),i=new Uint32Array(t);let m=0,d=null;if(r&&f<=Math.max(1024,Math.min(U,t*4))){const b=f,j=new Int32Array(b).fill(-1);for(let S=0;S<t;S++)j[r[S]]=0;for(let S=0;S<b;S++)j[S]===0&&(j[S]=m++);for(let S=0;S<t;S++)i[S]=j[r[S]];d=new Float64Array(m);for(let S=0;S<b;S++)j[S]>=0&&(d[j[S]]=S)}else if(r){const b=new Map;for(let j=0;j<t;j++){const S=r[j];let y=b.get(S);y===void 0&&(y=m++,b.set(S,y)),i[j]=y}d=new Float64Array(m);for(const[j,S]of b)d[S]=j}else{const b=new Map;for(let j=0;j<t;j++){const S=o[j];let y=b.get(S);y===void 0&&(y=m++,b.set(S,y)),i[j]=y}}const h=w(n,i,t,m),a=new Array(m);for(let b=0;b<m;b++){const j=h[b][0],S=new Array(u.length);for(let y=0;y<u.length;y++)S[y]=u[y](j);a[b]=S}const p={keys:a,buckets:h};return d&&(p.packed=d),p}}),Fe("packages/core/src/compute/pivot.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return t}});const $=K("packages/core/src/internal/util.js").warnOnce,I=K("packages/core/src/compute/handle.js").valueComparator,X=K("packages/core/src/compute/group.js").packKeys,H=K("packages/core/src/compute/total.js").total,U="|",z="/",w=2e3;function k(f,u,i){return`${f}${U}${u}${U}${i}`}function g(f,u){let i="";for(let m=0;m<f.length;m++){const d=f[m];i+=(m===0?"":u)+(d==null?"":String(d))}return i}function l(f,u,i={}){const m=i.separator||z,d=u.length,{keyOf:h,readers:a}=X(f,u,0),p=new Map,b=[],j=[];for(let C=0;C<d;C++){const P=u[C],F=h(P);if(p.has(F))continue;p.set(F,b.length),j.push(F);const E=new Array(a.length);for(let D=0;D<a.length;D++)E[D]=a[D](P);b.push(E)}const S=I(i.locale),y=b.map((C,P)=>P);y.sort((C,P)=>{const F=b[C],E=b[P];for(let D=0;D<F.length;D++){const N=c(F[D],E[D],S);if(N!==0)return N}return C-P});const v=new Array(y.length),R=new Array(y.length),O=new Map;for(let C=0;C<y.length;C++){const P=y[C];v[C]=b[P],R[C]=g(b[P],m),O.set(j[P],C)}return{keys:v,paths:R,idOf:C=>{const P=O.get(h(C));return P===void 0?-1:P}}}function c(f,u,i){const m=f==null,d=u==null;return m||d?m&&d?0:m?1:-1:i(f,u)}function s(f){const u=f.values||f.totals||[];if(u.length&&typeof u[0]=="object"&&u[0]!==null)return u.filter(h=>h&&h.handle);const i=typeof f.handle=="function"?f.handle:null;if(!i)return u.length&&$("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 m=typeof f.totalOf=="function"?f.totalOf:null,d=[];for(const h of u){const a=i(h);a&&d.push({colId:h,handle:a,fn:m?m(h):"sum"})}return d}function n(f,u,i){if(Array.isArray(f)){const m=i||{};return{...m,pivotHandles:f,order:u||null,groups:m.groups||null}}return f||{}}function t(f,u,i){const m=n(f,u,i),d=m.separator||z,h=s(m),a=m.maxColumns===void 0?w:m.maxColumns,p=m.groups&&m.groups.buckets?m.groups:null,b=p?p.buckets:[m.order||new Uint32Array(0)],j=m.groupPaths||(p?p.keys.map(F=>g(F,d)):[""]),S=o(b),{keys:y,paths:v,idOf:R}=l(m.pivotHandles||[],S,m),O=v.length*Math.max(1,h.length),x=r(v,h,d);if(a&&O>a){const F=new Map;return{keys:y,paths:v,fields:x,groupPaths:j,columns:O,values:F,cells:F,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${O} columns, above pivot.maxColumns of ${a}. Narrow the pivot columns or raise the limit.`,columns:O,maxColumns:a}}}const C=new Map,P=v.length;for(let F=0;F<b.length;F++){const E=b[F],D=j[F]===void 0?"":j[F],N=E.length;if(N===0)continue;const M=new Int32Array(N),A=new Uint32Array(P+1);for(let q=0;q<N;q++){const Y=R(E[q]);M[q]=Y,Y>=0&&A[Y+1]++}for(let q=0;q<P;q++)A[q+1]+=A[q];const L=new Uint32Array(N),G=A.slice(0,P);for(let q=0;q<N;q++){const Y=M[q];Y>=0&&(L[G[Y]++]=E[q])}for(let q=0;q<P;q++){const Y=A[q],J=A[q+1];if(J===Y)continue;const te=L.subarray(Y,J);for(let ne=0;ne<h.length;ne++){const oe=h[ne],le=H(oe.handle,te,oe.fn,m.totalContext||{locale:m.locale});C.set(k(D,v[q],oe.colId),le)}}}return{keys:y,paths:v,fields:x,groupPaths:j,columns:O,values:C,cells:C,error:null}}function r(f,u,i){if(u.length===0)return f.slice();const m=[];for(const d of f)for(const h of u)m.push(`${d}${i}${h.colId}`);return m}function o(f){if(f.length===1)return f[0]||new Uint32Array(0);let u=0;for(const d of f)u+=d?d.length:0;const i=new Uint32Array(u);let m=0;for(const d of f)!d||d.length===0||(i.set(d,m),m+=d.length);return i}}),Fe("packages/core/src/store/bitset.js",function(e,K){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return $}});const Q=8;class ${static#e=new Uint8Array(256);static{for(let I=1;I<256;I++)$.#e[I]=$.#e[I>>1]+(I&1)}#t;#n;constructor(I=0){const _=Math.max(0,I|0);this.#n=_,this.#t=new Uint8Array(Math.ceil(_/Q))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(I){return I<0||I>=this.#n?0:this.#t[I>>3]>>(I&7)&1}set(I){return I>=0&&I<this.#n&&(this.#t[I>>3]|=1<<(I&7)),this}clear(I){return I>=0&&I<this.#n&&(this.#t[I>>3]&=~(1<<(I&7))),this}assign(I,_){return _?this.set(I):this.clear(I)}fill(I=!1){return this.#t.fill(I?255:0),I&&this.#r(),this}grow(I){const _=Math.max(0,I|0);if(_<=this.#n)return this;const X=Math.ceil(_/Q);if(X>this.#t.length){const W=new Uint8Array(X);W.set(this.#t),this.#t=W}return this.#n=_,this}count(){const I=this.#t,_=$.#e;let X=0;for(let W=0;W<I.length;W++)X+=_[I[W]];return X}and(I){const _=I instanceof $?I.words:I,X=this.#t,W=Math.min(X.length,_.length);for(let H=0;H<W;H++)X[H]&=_[H];for(let H=W;H<X.length;H++)X[H]=0;return this}or(I){const _=I instanceof $?I.words:I,X=this.#t,W=Math.min(X.length,_.length);for(let H=0;H<W;H++)X[H]|=_[H];return this}not(){const I=this.#t;for(let _=0;_<I.length;_++)I[_]=~I[_]&255;return this.#r(),this}clone(){const I=new $(this.#n);return I.words.set(this.#t.subarray(0,I.words.length)),I}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const I=this.#n&7;if(I===0)return;const _=this.#n>>3;_<this.#t.length&&(this.#t[_]&=(1<<I)-1)}static from(I){const _=Array.isArray(I)?I:Array.from(I),X=new $(_.length);for(let W=0;W<_.length;W++)_[W]&&X.set(W);return X}}}),Fe("packages/core/src/store/dictionary.js",function(e,K){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return I}});const Q=K("packages/core/src/internal/util.js"),$=Q.collator,B=Q.defaultCompare;class I{#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(X=[]){this.#e=[];for(let W=0;W<X.length;W++){const H=X[W];this.#t.has(H)||(this.#t.set(H,this.#e.length),this.#e.push(H))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let X=this.#e.length*8;for(let W=0;W<this.#e.length;W++){const H=this.#e[W];typeof H=="string"&&(X+=H.length*2),X+=16}return X}codeOf(X){const W=this.#t.get(X);if(W!==void 0)return W;const H=this.#e.length;return this.#e.push(X),this.#t.set(X,H),this.#n++,H}lookup(X){const W=this.#t.get(X);return W===void 0?-1:W}has(X){return this.#t.has(X)}valueOf(X){return this.#e[X]}values(){return this.#e}ranks(X){const W=X||"";if(this.#r&&this.#o===this.#n&&this.#i===W)return this.#r;const H=this.#e.length,U=new Array(H);for(let g=0;g<H;g++)U[g]=g;const z=$(X).compare,w=this.#e;U.sort((g,l)=>this.#s(w[g],w[l],z));const k=new Uint32Array(H);for(let g=0;g<H;g++)k[U[g]]=g;return this.#r=k,this.#o=this.#n,this.#i=W,k}#s(X,W,H){return typeof X=="string"&&typeof W=="string"?H(X,W):B(X,W)}}}),Fe("packages/core/src/store/multivalue.js",function(e,K){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return Q}});class Q{#e;#t;#n=0;#r=0;constructor(B={}){const I=Math.max(1,B.rows??16),_=Math.max(1,B.values??I);this.#e=new Int32Array(_),this.#t=new Uint32Array(I+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(B){return B<0||B>=this.#n?0:this.#t[B+1]-this.#t[B]}at(B){return B<0||B>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[B],this.#t[B+1])}has(B,I){if(B<0||B>=this.#n)return!1;const _=this.#e,X=this.#t[B+1];for(let W=this.#t[B];W<X;W++)if(_[W]===I)return!0;return!1}hasAny(B,I){for(let _=0;_<I.length;_++)if(this.has(B,I[_]))return!0;return!1}hasAll(B,I){for(let _=0;_<I.length;_++)if(!this.has(B,I[_]))return!1;return!0}hasNone(B,I){return!this.hasAny(B,I)}push(B){const I=this.#n,_=B.length;this.#o(I+1),this.#i(this.#r+_);const X=this.#r;for(let W=0;W<_;W++)this.#e[X+W]=B[W]|0;return this.#r+=_,this.#n=I+1,this.#t[I]=X,this.#t[I+1]=this.#r,I}write(B,I){if(B===this.#n){this.push(I);return}if(B<0||B>this.#n)return;const _=this.#t[B],X=this.#t[B+1],W=I.length;if(X-_===W){for(let H=0;H<W;H++)this.#e[_+H]=I[H]|0;return}this.#s(B,I)}compact(B,I,_){const X=this.#e,W=this.#t,H=this.#n,U=new Int32Array(Math.max(1,this.#r)),z=new Uint32Array(I+1);let w=0;for(let k=0;k<H;k++){if(B[k]===_)continue;const g=W[k],l=W[k+1];z[B[k]]=w;for(let c=g;c<l;c++)U[w++]=X[c];z[B[k]+1]=w}this.#e=U,this.#t=z,this.#n=I,this.#r=w}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#o(B){if(B+1<=this.#t.length)return;let I=this.#t.length-1;for(;I<B;)I=I*2||16;const _=new Uint32Array(I+1);_.set(this.#t),this.#t=_}#i(B){if(B<=this.#e.length)return;let I=this.#e.length;for(;I<B;)I=I*2||16;const _=new Int32Array(I);_.set(this.#e),this.#e=_}#s(B,I){const _=this.#e,X=this.#t,W=this.#n,H=I.length-(X[B+1]-X[B]),U=new Int32Array(Math.max(1,this.#r+H)),z=new Uint32Array(X.length);let w=0;for(let k=0;k<W;k++){if(z[k]=w,k===B)for(let g=0;g<I.length;g++)U[w++]=I[g]|0;else for(let g=X[k];g<X[k+1];g++)U[w++]=_[g];z[k+1]=w}this.#e=U,this.#t=z,this.#r=w}}}),Fe("packages/core/src/compute/sort.js",function(e,K){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return P}});const Q=K("packages/core/src/compute/handle.js"),$=Q.bitReader,B=Q.dictRanks,I=Q.dictSize,_=Q.identity,X=Q.isMissing,W=Q.presenceReader,H=Q.rowCount,U=Q.valueComparator,z=Q.valueReader,w=new Uint32Array(0),k=new ArrayBuffer(8),g=new Float64Array(k),l=new Uint32Array(k),c=(g[0]=-1,(l[1]&2147483648)!==0?1:0),s=c===1?0:1;function n(E,D){g[0]=E;let N=l[c],M=l[s];(N&2147483648)!==0?(N=~N>>>0,M=~M>>>0):N=(N^2147483648)>>>0,D[0]=M,D[1]=N}function t(E,D,N,M){if(M<2)return E;const A=new Uint32Array(256*8);for(let oe=0;oe<M;oe++){const le=D[oe],ae=N[oe];A[le&255]++,A[256+(le>>>8&255)]++,A[512+(le>>>16&255)]++,A[768+(le>>>24&255)]++,A[1024+(ae&255)]++,A[1280+(ae>>>8&255)]++,A[1536+(ae>>>16&255)]++,A[1792+(ae>>>24&255)]++}let L=E,G=D,q=N,Y=new Uint32Array(M),J=new Uint32Array(M),te=new Uint32Array(M);const ne=new Uint32Array(256);for(let oe=0;oe<8;oe++){const le=oe<<8,ae=(oe&3)<<3,se=oe>=4;let ee=!1;for(let he=0;he<256;he++)if(A[le+he]===M){ee=!0;break}if(ee)continue;let ie=0;for(let he=0;he<256;he++)ne[he]=ie,ie+=A[le+he];for(let he=0;he<M;he++){const me=G[he],Ee=q[he],ge=(se?Ee:me)>>>ae&255,je=ne[ge]++;Y[je]=L[he],J[je]=me,te[je]=Ee}let ce=L;L=Y,Y=ce,ce=G,G=J,J=ce,ce=q,q=te,te=ce}return L}function r(E,D,N){if(N<2)return E;const M=new Uint32Array(256*4);for(let J=0;J<N;J++){const te=D[J];M[te&255]++,M[256+(te>>>8&255)]++,M[512+(te>>>16&255)]++,M[768+(te>>>24&255)]++}let A=E,L=D,G=new Uint32Array(N),q=new Uint32Array(N);const Y=new Uint32Array(256);for(let J=0;J<4;J++){const te=J<<8,ne=J<<3;let oe=!1;for(let se=0;se<256;se++)if(M[te+se]===N){oe=!0;break}if(oe)continue;let le=0;for(let se=0;se<256;se++)Y[se]=le,le+=M[te+se];for(let se=0;se<N;se++){const ee=L[se],ie=Y[ee>>>ne&255]++;G[ie]=A[se],q[ie]=ee}let ae=A;A=G,G=ae,ae=L,L=q,q=ae}return A}function o(E,D,N,M){const A=new Uint32Array(M+1);for(let q=0;q<N;q++)A[D[q]]++;let L=0;for(let q=0;q<=M;q++){const Y=A[q];A[q]=L,L+=Y}const G=new Uint32Array(N);for(let q=0;q<N;q++)G[A[D[q]]++]=E[q];return G}function f(E,D,N,M){return N<2?E:M<=65536||M<=N*2?o(E,D,N,M):r(E,D,N)}function u(E,D){return E.length===D&&E.byteOffset===0?E:Uint32Array.prototype.slice.call(E,0,D)}function i(E,D,N=!1){const M=D||_(E.length),A=M.length;if(A<2)return Uint32Array.from(M);const L=new Uint32Array(A),G=new Uint32Array(A),q=new Uint32Array(A),Y=new Uint32Array(A),J=new Uint32Array(2);let te=0,ne=0;for(let ae=0;ae<A;ae++){const se=M[ae],ee=E[se];if(Number.isNaN(ee)){Y[ne++]=se;continue}n(ee,J),N?(G[te]=~J[0]>>>0,q[te]=~J[1]>>>0):(G[te]=J[0],q[te]=J[1]),L[te++]=se}const oe=t(L.subarray(0,te),G.subarray(0,te),q.subarray(0,te),te);if(ne===0)return u(oe,te);const le=new Uint32Array(A);return le.set(oe.subarray(0,te),0),le.set(Y.subarray(0,ne),te),le}function m(E,D,N=!1){const M=D||_(E.length),A=M.length;if(A<2)return Uint32Array.from(M);const L=Uint32Array.from(M),G=new Uint32Array(A);for(let q=0;q<A;q++){const Y=(E[L[q]]^2147483648)>>>0;G[q]=N?~Y>>>0:Y}return u(r(L,G,A),A)}function d(E,D,N={}){const M=D||_(H(E,N)),A=M.length;if(A<2)return Uint32Array.from(M);const L=B(E.dict,N.locale),G=E.values,q=W(E),Y=Math.max(I(E.dict),L.length),J=Y,te=Uint32Array.from(M),ne=new Uint32Array(A),oe=!!N.descending;for(let le=0;le<A;le++){const ae=te[le];let se=q&&q(ae)===0?J:L[G[ae]];se===void 0&&(se=J),ne[le]=oe?J-se:se}return u(f(te,ne,A,Y+1),A)}function h(E,D,N){const M=D.length;let A=Uint32Array.from(D);if(M<2)return A;let L=new Uint32Array(M);for(let G=1;G<M;G<<=1){for(let Y=0;Y<M;Y+=G<<1){const J=Math.min(Y+G,M),te=Math.min(Y+(G<<1),M);let ne=Y,oe=J,le=Y;for(;ne<J&&oe<te;)L[le++]=N(E[A[ne]],E[A[oe]])<=0?A[ne++]:A[oe++];for(;ne<J;)L[le++]=A[ne++];for(;oe<te;)L[le++]=A[oe++]}const q=A;A=L,L=q}return A}function a(E,D,N){const M=$(E.values),A=D.length,L=new Uint32Array(A),G=N?1:0;let q=0;for(let Y=0;Y<A;Y++)M(D[Y])===G&&(L[q++]=D[Y]);for(let Y=0;Y<A;Y++)M(D[Y])!==G&&(L[q++]=D[Y]);return L}function p(E,D){const N=E.values,M=E.kind;if((M==="object"||M===void 0)&&(Array.isArray(N)||ArrayBuffer.isView(N))&&!E.presence)return N;const L=z(E),G=new Array(H(E)||0);for(let q=0;q<D.length;q++){const Y=D[q];G[Y]=L(Y)}return G}function b(E,D){for(let N=0;N<D.length;N++)if(typeof E[D[N]]!="string")return!1;return!0}function j(E,D,N,M,A){const L=E.length,G=Uint32Array.from(E);if(L<2||M<1)return G;const q=new Uint32Array(L),Y=M-1;for(let J=0;J<L;J++){const te=N[D[J]];q[J]=A?Y-te:te}return u(f(G,q,L,M),L)}function S(E,D,N){const M=U(N),A=new Array(D);for(let G=0;G<D;G++)A[G]=G;A.sort((G,q)=>M(E[G],E[q])||G-q);const L=new Uint32Array(D);for(let G=0;G<D;G++)L[A[G]]=G;return L}function y(E,D,N){const M=D.length,A=new Map,L=[],G=new Uint32Array(M);for(let J=0;J<M;J++){const te=E[D[J]];let ne=A.get(te);ne===void 0&&(ne=L.length,A.set(te,ne),L.push(te)),G[J]=ne}const q=L.length,Y=S(L,q,N.locale);return j(D,G,Y,q,!!N.descending)}function v(E,D,N){const M=p(E,D);if(D.length>=2&&b(M,D)){const G=E.stringRank;return G&&G.version===E.version&&G.usable(D,M,N.locale)?G.sort(D,N):y(M,D,N)}const A=U(N.locale),L=N.descending?(G,q)=>A(q,G):A;return h(M,D,L)}function R(E,D,N){const M=p(E,D),A=N.compare,G=!!N.descending?(q,Y)=>-A(q,Y,void 0,void 0,!0):(q,Y)=>A(q,Y,void 0,void 0,!1);return h(M,D,G)}function O(E,D){const N=D.length,M=W(E),A=E.values,L=E.kind==="float64"&&!!A,G=E.kind==="object"||E.kind==="multi"||E.kind===void 0;if(!M&&!L&&!G)return{present:D,absent:w};const q=new Uint32Array(N),Y=new Uint32Array(N);let J=0,te=0;if(M&&L)for(let ne=0;ne<N;ne++){const oe=D[ne];M(oe)===1&&!Number.isNaN(A[oe])?q[J++]=oe:Y[te++]=oe}else if(L&&!M)for(let ne=0;ne<N;ne++){const oe=D[ne];Number.isNaN(A[oe])?Y[te++]=oe:q[J++]=oe}else if(M&&!G)for(let ne=0;ne<N;ne++){const oe=D[ne];M(oe)===1?q[J++]=oe:Y[te++]=oe}else{const ne=z(E);for(let oe=0;oe<N;oe++){const le=D[oe];X(ne(le))?Y[te++]=le:q[J++]=le}}return te===0?{present:D,absent:w}:{present:q.subarray(0,J),absent:Y.subarray(0,te)}}function x(E,D,N){if(D.length===0)return E;const M=new Uint32Array(E.length+D.length);return N?(M.set(D,0),M.set(E,D.length)):(M.set(E,0),M.set(D,E.length)),M}function C(E,D,N={}){const M=D||_(H(E,N));if(!E||M.length<2)return Uint32Array.from(M);const{present:A,absent:L}=O(E,M);if(A.length===0)return Uint32Array.from(M);const G=!!N.descending;let q;if(typeof N.compare=="function")q=R(E,A,N);else switch(E.kind){case"float64":q=i(E.values,A,G);break;case"int32":q=m(E.values,A,G);break;case"dictionary":q=d(E,A,N);break;case"bitset":q=a(E,A,G);break;default:q=v(E,A,N);break}return x(q,L,!!N.nullsFirst)}function P(E,D,N,M={}){const A=D||[],L=A.length&&(A[0].handle||F(E,A[0].col))||E&&E[0];let G=N||_(H(L,M));for(let q=A.length-1;q>=0;q--){const Y=A[q],J=Y.handle||F(E,Y.col)||E&&E[q];J&&(G=C(J,G,{descending:Y.descending!==void 0?!!Y.descending:Y.dir==="desc",nullsFirst:!!Y.nullsFirst,locale:Y.locale!==void 0?Y.locale:M.locale,compare:Y.compare}))}return G instanceof Uint32Array?G:Uint32Array.from(G)}function F(E,D){if(!(!E||D===void 0)){for(let N=0;N<E.length;N++)if(E[N]&&E[N].id===D)return E[N]}}}),Fe("packages/core/src/store/stringrank.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return _}});const Q=K("packages/core/src/compute/sort.js"),$=Q.collateStringRanks,B=Q.rankSortStrings,I=1e5;class _{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#s;#l=!1;#a=null;#u=-1;#c="\0";constructor(W=I){this.#s=W>0?W:I,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(W){this.#i=W}get generation(){return this.#o}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let W=this.#n.byteLength;const H=this.#e;for(let U=0;U<H.length;U++)W+=H[U].length*2+24;return W}#d(W,H){const U=this.#t.get(W);if(U!==void 0)return U;if(this.#l)return-1;if(H&&this.#e.length>=this.#s)return this.#l=!0,-1;const z=this.#e.length;return this.#e.push(W),this.#t.set(W,z),this.#o++,z}build(W,H){const U=H|0;this.#e=[],this.#t=new Map,this.#o=0,this.#l=!1,this.#a=null,this.#u=-1,this.#n=new Uint32Array(U);for(let z=0;z<U;z++){const w=W[z],k=typeof w=="string"?this.#d(w,!1):-1;this.#n[z]=k<0?0:k}this.#r=U}append(W,H,U){const z=(H|0)+(U|0);if(z>this.#n.length){const w=new Uint32Array(z);w.set(this.#n.subarray(0,this.#r)),this.#n=w}for(let w=H|0;w<z;w++){const k=W[w],g=typeof k=="string"?this.#d(k,!0):-1;this.#n[w]=g<0?0:g}this.#r=Math.max(this.#r,z)}ranks(W){const H=W||"";if(this.#a&&this.#u===this.#o&&this.#c===H)return this.#a;const U=$(this.#e,this.#e.length,W);return this.#a=U,this.#u=this.#o,this.#c=H,U}usable(W,H,U){if(this.#l||this.#e.length===0)return!1;const z=this.#n,w=this.#e,k=this.#r;for(let g=0;g<W.length;g++){const l=W[g];if(l>=k||w[z[l]]!==H[l])return!1}return!0}sort(W,H){const U=this.ranks(H.locale),z=this.#e.length,w=W.length,k=new Uint32Array(w),g=this.#n;for(let l=0;l<w;l++)k[l]=g[W[l]];return B(W,k,U,z,!!H.descending)}}}),Fe("packages/core/src/store/columnstore.js",function(e,K){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return d}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.isFunction,I=Q.pathGetter,X=K("packages/core/src/store/bitset.js").Bitset,H=K("packages/core/src/store/dictionary.js").Dictionary,z=K("packages/core/src/store/multivalue.js").MultiValue,k=K("packages/core/src/store/stringrank.js").StringRankIndex,g=4294967295,l=1024,c=5e3,s=.2,n=new Set(["float64","int32","bitset","dictionary","object","multi"]);function t(h){return h==null}function r(h){if(typeof h=="number")return h;if(h instanceof Date)return h.getTime();if(typeof h=="boolean")return h?1:0;const a=Number(h);return Number.isNaN(a)&&typeof h=="string"?Date.parse(h):a}function o(h){const a=r(h);return Number.isFinite(a)?a|0:0}function f(h){return t(h)?[]:Array.isArray(h)?h:[h]}function u(h,a){switch(h.kind){case"float64":case"int32":return h.buf[a];case"bitset":return h.bits.get(a)===1;case"dictionary":return h.dict.valueOf(h.buf[a]);case"multi":{const p=h.mv.at(a),b=new Array(p.length);for(let j=0;j<p.length;j++)b[j]=h.dict.valueOf(p[j]);return b}default:return h.buf[a]}}function i(h,a){switch(h.kind){case"float64":case"int32":return h.values[a];case"bitset":return(h.values[a>>3]&1<<(a&7))!==0;case"dictionary":return(h.table||[])[h.values[a]];case"multi":{const p=h.offsets[a],b=h.offsets[a+1],j=h.table||[],S=new Array(b-p);for(let y=p;y<b;y++)S[y-p]=j[h.values[y]];return S}default:return h.values[a]}}class m{#e;#t;#n;#r;#o;#i;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#f=null;#h;#p;#m=-1;#g=null;#b=0;#w=0;#S=null;#y=null;#O=!1;constructor(a,p){this.#e=a.id;const b=n.has(a.kind)?a.kind:"object";a.kind&&!n.has(a.kind)&&$(`store.kind.${a.id}`,`column "${a.id}" declares unknown storage kind "${a.kind}"; falling back to object`),this.#n=b,this.#t=b,this.#r=a.nullable!==!1,this.#s=a.dictionary??null,this.#i=p,this.#o=B(a.read)?a.read:I(a.field||a.id),this.#h=a.stringRankIndex!=="off",this.#p=typeof a.stringRankMaxDistinct=="number"?a.stringRankMaxDistinct:0,this.#S=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.#u.words:this.#t==="multi"?this.#c.values:this.#a:this.#C().values}get presence(){return this.#O||!this.#r?null:this.#l?this.#g:this.#C().presence}get dict(){return this.#O||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#O||!this.#h||this.kind!=="object")return null;const a=this.values,p=this.#i.physical();if(!a||p===0)return null;if(this.#f===null){if(typeof a[0]!="string")return null;const b=new k(this.#k());return b.build(a,p),b.version=this.#w,this.#f=b,this.#m=this.#w,b.capped?null:b}return this.#f.length<p&&this.#f.append(a,this.#f.length,p-this.#f.length),this.#f.version=this.#w,this.#m=this.#w,this.#f.capped?null:this.#f}#k(){return this.#p}#A(){this.#f=null,this.#m=-1}get offsets(){return this.#O||!this.#l||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#w}get bytes(){let a=0;return this.#a&&(a+=this.#a.byteLength??this.#a.length*8),this.#u&&(a+=this.#u.bytes),this.#c&&(a+=this.#c.bytes),this.#g&&(a+=this.#g.bytes),this.#d&&(a+=this.#d.bytes),this.#S&&(a+=this.#S.size*24),a}get(a){if(!this.#O&&!(a<0||a>=this.#i.physical())){if(!this.#l)return this.#M(a);if(this.#r&&this.#g.get(a)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[a];case"bitset":return this.#u.get(a)===1;case"dictionary":return this.#d.valueOf(this.#a[a]);case"multi":{const p=this.#c.at(a),b=new Array(p.length);for(let j=0;j<p.length;j++)b[j]=this.#d.valueOf(p[j]);return b}default:return this.#a[a]}}}set(a,p){this.#O||(this.#l?this.#T(a,p):this.#S.set(a,p===void 0?null:p),this.#f&&this.#A(),this.#w++)}read(a){return this.#o(a)}appendColumn(a,p,b){if(this.#O||b<=0)return;if(!this.#l){this.#w++;return}const j=this.#o,S=this.#r,y=this.#g;let v=!1;switch(this.#t){case"float64":{const R=this.#a;for(let O=0;O<b;O++){const x=j(a[O]);if(typeof x=="number"){S&&y.set(p+O),R[p+O]=x;continue}const C=x==null;S?y.assign(p+O,!C):C&&(v=!0),R[p+O]=C?NaN:r(x)}break}case"int32":{const R=this.#a;for(let O=0;O<b;O++){const x=j(a[O]),C=x==null;S?y.assign(p+O,!C):C&&(v=!0),R[p+O]=C?0:o(x)}break}case"bitset":{const R=this.#u;for(let O=0;O<b;O++){const x=j(a[O]),C=x==null;S?y.assign(p+O,!C):C&&(v=!0),R.assign(p+O,!C&&!!x)}break}case"dictionary":{const R=this.#a,O=this.#d;for(let x=0;x<b;x++){const C=j(a[x]),P=C==null;S?y.assign(p+x,!P):P&&(v=!0),R[p+x]=P?0:O.codeOf(C)}break}case"multi":{const R=this.#c,O=this.#d;for(let x=0;x<b;x++){const C=j(a[x]),P=C==null;S?y.assign(p+x,!P):P&&(v=!0);const F=f(C),E=new Array(F.length);for(let D=0;D<F.length;D++)E[D]=O.codeOf(F[D]);R.write(p+x,E)}break}default:{const R=this.#a;for(let O=0;O<b;O++){const x=j(a[O]),C=x==null;S?y.assign(p+O,!C):C&&(v=!0),R[p+O]=C?null:x}break}}v&&$(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#f&&this.#t==="object"&&(this.#f.append(this.#a,p,b),this.#f.version=this.#w+1,this.#m=this.#w+1),this.#w++}appendPacked(a,p,b){if(this.#O||b<=0||!a)return;if(!this.#l){this.#w++;return}const j=this.#g,S=a.presence;if(j)if(S)for(let v=0;v<b;v++)j.assign(p+v,(S[v>>3]&1<<(v&7))!==0);else for(let v=0;v<b;v++)j.set(p+v);const y=a.kind===this.#t;if(y&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(a.values,p),this.#w++;return}if(y&&this.#t==="bitset"){const v=a.values;for(let R=0;R<b;R++)this.#u.assign(p+R,(v[R>>3]&1<<(R&7))!==0);this.#w++;return}if(y&&this.#t==="dictionary"){const v=a.table||[],R=new Uint32Array(v.length);for(let P=0;P<v.length;P++)R[P]=this.#d.codeOf(v[P]);const O=a.values,x=this.#a,C=j;for(let P=0;P<b;P++){if(C&&(S&&(S[P>>3]&1<<(P&7))===0)){x[p+P]=0;continue}x[p+P]=R[O[P]]??0}this.#w++;return}if(y&&this.#t==="multi"){const v=a.table||[],R=new Uint32Array(v.length);for(let C=0;C<v.length;C++)R[C]=this.#d.codeOf(v[C]);const O=a.values,x=a.offsets;for(let C=0;C<b;C++){const P=x[C],F=x[C+1],E=new Array(F-P);for(let D=P;D<F;D++)E[D-P]=R[O[D]]??0;this.#c.write(p+C,E)}this.#w++;return}for(let v=0;v<b;v++){const R=S?(S[v>>3]&1<<(v&7))===0:a.kind==="object"?a.values[v]===null:!1;this.#T(p+v,R?null:i(a,v))}this.#w++}touch(){this.#w++}columnarise(a,p){if(this.#l||this.#O)return;const b=new Array(p);for(let j=0;j<p;j++)b[j]=this.#M(j);this.#t=this.#n,this.#l=!0,this.#j(a);for(let j=0;j<p;j++)this.#T(j,b[j]);this.#S.clear(),this.#y=null,this.#A(),this.#w++}grow(a){if(!(!this.#l||this.#O||a<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const p=new this.#a.constructor(a);p.set(this.#a),this.#a=p;break}case"bitset":this.#u.grow(a);break;case"multi":break;default:this.#a.length=a;break}this.#g&&this.#g.grow(a),this.#b=a,this.#w++}}convert(a){if(this.#O||!n.has(a)||(this.#n=a,!this.#l||a===this.#t))return!1;const p={kind:this.#t,buf:this.#a,bits:this.#u,mv:this.#c,dict:this.#d},b=this.#i.physical(),j=this.#g;this.#t=a,this.#j(this.#b);for(let S=0;S<b;S++){const y=j!==null&&j.get(S)===0;y&&a!=="multi"||this.#T(S,y?null:u(p,S))}return this.#A(),this.#w++,!0}compact(a,p,b){if(!this.#O){if(this.#A(),!this.#l){const j=this.#S;if(j.size){const S=new Map;for(const[y,v]of j)a[y]!==g&&S.set(a[y],v);this.#S=S}this.#y=null,this.#w++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const j=this.#a;for(let S=0;S<p;S++)a[S]!==g&&(j[a[S]]=j[S]);if(this.#t==="object")for(let S=b;S<p;S++)j[S]=void 0;break}case"bitset":{const j=this.#u;for(let S=0;S<p;S++)a[S]!==g&&j.assign(a[S],j.get(S)===1);for(let S=b;S<p;S++)j.clear(S);break}case"multi":this.#c.compact(a,b,g);break;default:break}if(this.#g){const j=this.#g;for(let S=0;S<p;S++)a[S]!==g&&j.assign(a[S],j.get(S)===1);for(let S=b;S<p;S++)j.clear(S)}this.#w++}}release(){this.#O||(this.#O=!0,this.#a=null,this.#u&&this.#u.release(),this.#u=null,this.#c&&this.#c.release(),this.#c=null,this.#g&&this.#g.release(),this.#g=null,this.#d=null,this.#f=null,this.#S=new Map,this.#y=null,this.#b=0,this.#w++)}#j(a){const p=Math.max(1,a);switch(this.#a=null,this.#u=null,this.#c=null,this.#t){case"float64":this.#a=new Float64Array(p);break;case"int32":this.#a=new Int32Array(p);break;case"bitset":this.#u=new X(p);break;case"dictionary":this.#a=new Uint32Array(p),this.#d=this.#d??new H(this.#s??[]);break;case"multi":this.#c=new z({rows:p,values:p}),this.#d=this.#d??new H(this.#s??[]);break;default:this.#a=new Array(p);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(p):this.#g=new X(p)),this.#b=p}#T(a,p){const b=t(p);switch(this.#r?this.#g.assign(a,!b):b&&$(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[a]=b?NaN:r(p);break;case"int32":this.#a[a]=b?0:o(p);break;case"bitset":this.#u.assign(a,!b&&!!p);break;case"dictionary":this.#a[a]=b?0:this.#d.codeOf(p);break;case"multi":{const j=f(p),S=new Array(j.length);for(let y=0;y<j.length;y++)S[y]=this.#d.codeOf(j[y]);this.#c.write(a,S);break}default:this.#a[a]=b?null:p;break}}#M(a){if(this.#S.has(a))return this.#S.get(a);const p=this.#o(this.#i.rowAt(a));return p===void 0?null:p}#C(){if(this.#y&&this.#y.version===this.#w)return this.#y;const a=this.#i.physical(),p=new Array(a),b=this.#r?new X(a):null;for(let j=0;j<a;j++){const S=this.#M(j);p[j]=S,b&&!t(S)&&b.set(j)}return this.#y={version:this.#w,values:p,presence:b},this.#y}}class d{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#s=0;#l=0;#a=new X(0);#u=!1;#c=!0;#d;#f;#h;#p=!1;constructor(a,p={}){this.#e=Array.isArray(a)?a:[],this.#f=Math.max(1,p.initialCapacity??l),this.#c=p.retainSource!==!1,this.#d=this.#c?p.columnarBelow??c:0,this.#h=p.compactRatio??s;const b={rowAt:j=>this.#r[j],physical:()=>this.#o};for(const j of this.#e){if(!j||!j.id)continue;if(this.#t.has(j.id)){$(`store.dup.${j.id}`,`duplicate column id "${j.id}" in the store schema; ignoring the second`);continue}const S=new m(j,b);this.#t.set(j.id,S),this.#n.push(S)}this.#d<=0&&this.#b()}get count(){return this.#s}get physical(){return this.#o}get capacity(){return this.#u?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#u}get destroyed(){return this.#p}get bytes(){let a=this.#a.bytes+this.#r.length*8;for(const p of this.#n)a+=p.bytes;return a}append(a){const p=this.#o;if(this.#p||!a)return{from:p,to:p};const b=a.length|0;if(b===0)return{from:p,to:p};if(this.#c)for(let S=0;S<b;S++)this.#r[p+S]=a[S];if(this.#o=p+b,this.#s+=b,this.#a.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#b();else for(const S of this.#n)S.touch();return{from:p,to:this.#o}}this.#m(this.#o);const j=this.#n;for(let S=0;S<j.length;S++)j[S].appendColumn(a,p,b);return{from:p,to:this.#o}}appendPacked(a,p){const b=this.#o;if(this.#p||!a)return{from:b,to:b};const j=a.count|0;if(j===0)return{from:b,to:b};if(this.#c&&p)for(let y=0;y<j;y++)this.#r[b+y]=p[y];this.#o=b+j,this.#s+=j,this.#a.grow(this.#o),this.#u||this.#b(),this.#m(this.#o);const S=new Map;for(const y of a.columns)S.set(y.id,y);for(const y of this.#n){const v=S.get(y.id);v?y.appendPacked(v,b,j):y.grow(this.#i)}return{from:b,to:this.#o}}source(a){if(this.#c)return this.#r[a];if(!(a<0||a>=this.#o))return this.#g(a)}setSource(a,p){this.#p||a<0||a>=this.#o||this.#c&&(this.#r[a]=p)}get(a,p){const b=this.#t.get(a);return b?b.get(p):void 0}set(a,p,b){if(this.#p||p<0||p>=this.#o)return;const j=this.#t.get(a);if(!j){$(`store.set.${a}`,`set() on unknown column "${a}"`);return}j.set(p,b)}remove(a){return this.#p||a<0||a>=this.#o||this.#a.get(a)===1?!1:(this.#a.set(a),this.#l++,this.#s--,!0)}live(a){return a<0||a>=this.#o?!1:this.#a.get(a)===0}compact(a={}){if(this.#p||this.#l===0||!a.force&&this.#l/this.#o<this.#h)return null;const p=this.#o,b=new Uint32Array(p);let j=0;for(let S=0;S<p;S++)b[S]=this.#a.get(S)===1?g:j++;for(const S of this.#n)S.compact(b,p,j);if(this.#c){const S=this.#r;for(let y=0;y<p;y++)b[y]!==g&&(S[b[y]]=S[y]);S.length=j}return this.#o=j,this.#s=j,this.#l=0,this.#a=new X(Math.max(this.#i,j)),b}column(a){return this.#t.get(a)}columns(){return this.#n.slice()}liveIndices(){const a=new Uint32Array(this.#s);if(this.#l===0){for(let b=0;b<this.#o;b++)a[b]=b;return a}let p=0;for(let b=0;b<this.#o;b++)this.#a.get(b)===0&&(a[p++]=b);return a}convert(a,p){const b=this.#t.get(a);return b?b.convert(p):!1}destroy(){if(!this.#p){this.#p=!0;for(const a of this.#n)a.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#o=0,this.#s=0,this.#l=0,this.#i=0}}#m(a){if(a<=this.#i)return;let p=this.#i||this.#f;for(;p<a;)p*=2;for(const b of this.#n)b.grow(p);this.#a.grow(p),this.#i=p}#g(a){const p={};for(const b of this.#n)p[b.id]=b.get(a);return p}#b(){if(this.#u)return;let a=this.#f;for(;a<this.#o;)a*=2;this.#u=!0,this.#i=a,this.#a.grow(a);for(const p of this.#n)p.columnarise(a,this.#o)}}}),Fe("packages/core/src/store/pool.js",function(e,K){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return _}});const Q=64,$=8;function B(W){let H=Q;for(;H<W;)H*=2;return H}class I{#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(H={}){this.#n=H.limit??$}get bytes(){return this.#r}mask(H){const U=new Uint8Array(this.#i(H),0,H);return U.fill(0),U}indices(H){return new Uint32Array(this.#i(H*4),0,H)}release(H){if(!H||!H.buffer)return!1;const U=H.buffer;if(!this.#t.has(U))return!1;this.#t.delete(U),this.#o.released++;const z=U.byteLength;let w=this.#e.get(z);return w||this.#e.set(z,w=[]),w.length>=this.#n||(w.push(U),this.#r+=z),!0}releaseAll(H){for(const U of H)this.release(U)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(H){const U=B(H),z=this.#e.get(U);this.#o.acquired++;let w;return z&&z.length?(w=z.pop(),this.#r-=U,this.#o.reused++):w=new ArrayBuffer(U),this.#t.add(w),w}}function _(){return X??=new I,X}let X=null}),Fe("packages/core/src/compute/sortspec.js",function(e,K){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return _}});function Q(X){return{locale:X===void 0?void 0:String(X),numeric:!0,sensitivity:"variant"}}function $(X){return!!X&&typeof X.compare!="function"}function B(X){if(!X)return!0;for(let W=0;W<X.length;W++)if(!$(X[W]))return!1;return!0}function I(X,W){const H=X.col!==void 0?X.col:X.handle&&X.handle.id,U=X.locale!==void 0?X.locale:W;return{col:H,descending:X.descending!==void 0?!!X.descending:X.dir==="desc",nullsFirst:!!X.nullsFirst,collation:Q(U)}}function _(X,W){const H=X||[],U=new Array(H.length);for(let z=0;z<H.length;z++)U[z]=I(H[z],W);return U}}),Fe("packages/core/src/compute/facet.js",function(e,K){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return j}});const Q=K("packages/core/src/compute/handle.js"),$=Q.presenceReader,B=Q.valueReader,I=Q.dictSize,_=Q.dictValue,X=Object.freeze(["equal","quantile","log"]),W=Object.freeze(["hour","day","week","month","quarter","year"]),H=20,U=50,z=1e4;function w(S,y){if(!S)return"none";const v=y;if(v&&(v.multi===!0||typeof v.items=="function"))return"category";const R=y&&y.base;if(R==="date"||R==="datetime"||R==="time"||R==="dateString")return"date";switch(S.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return R==="number"?"numeric":R==="boolean"?"boolean":R==="text"?"category":"none"}}function k(S){const y=S.values,v=S.kind;if((v==="float64"||v==="int32")&&y)return O=>y[O];const R=B(S);return O=>g(R(O))}function g(S){if(typeof S=="number")return S;if(S instanceof Date)return S.getTime();if(S==null||S==="")return NaN;if(typeof S=="boolean")return S?1:0;if(typeof S=="string"){const y=Number(S);if(Number.isFinite(y))return y;const v=Date.parse(S);return Number.isFinite(v)?v:NaN}return NaN}function l(S,y,v,R=U){if(!S)return{cardinality:0,exact:!0};if(S.dict)return{cardinality:I(S.dict),exact:!0};if(S.kind==="bitset")return{cardinality:2,exact:!0};const O=B(S),x=y?y.length:v,C=new Set;for(let P=0;P<x;P++){const F=O(y?y[P]:P);if(F!=null&&(C.add(F),C.size>R))return{cardinality:C.size,exact:!1}}return{cardinality:C.size,exact:!0}}const c=36e5,s=864e5;function n(S,y=H){const v=Number.isFinite(S)&&S>0?S:0,R=Math.max(1,y)*2;return v/c<=R?"hour":v/s<=R?"day":v/(7*s)<=R?"week":v/(30*s)<=R?"month":v/(91*s)<=R?"quarter":"year"}function t(S,y){if(!Number.isFinite(S))return NaN;const v=new Date(S);switch(y){case"hour":return v.setMinutes(0,0,0),v.getTime();case"day":return v.setHours(0,0,0,0),v.getTime();case"week":{v.setHours(0,0,0,0);const R=(v.getDay()+6)%7;return v.setDate(v.getDate()-R),v.getTime()}case"month":return v.setDate(1),v.setHours(0,0,0,0),v.getTime();case"quarter":return v.setMonth(Math.floor(v.getMonth()/3)*3,1),v.setHours(0,0,0,0),v.getTime();default:return v.setMonth(0,1),v.setHours(0,0,0,0),v.getTime()}}function r(S,y){const v=new Date(S);switch(y){case"hour":v.setHours(v.getHours()+1);break;case"day":v.setDate(v.getDate()+1);break;case"week":v.setDate(v.getDate()+7);break;case"month":v.setMonth(v.getMonth()+1);break;case"quarter":v.setMonth(v.getMonth()+3);break;default:v.setFullYear(v.getFullYear()+1);break}return v.getTime()}function o(S,y,v){const R=k(S),O=$(S),x=y?y.length:v;let C=1/0,P=-1/0,F=0,E=0;for(let D=0;D<x;D++){const N=y?y[D]:D;if(O&&!O(N)){F++;continue}const M=R(N);if(!Number.isFinite(M)){F++;continue}M<C&&(C=M),M>P&&(P=M),E++}return{min:C,max:P,nulls:F,finite:E}}function f(S,y,v,R){const O=k(S),x=$(S),C=y?y.length:v,P=C>R?C/R:1,F=[];for(let D=0;D<C;D+=P){const N=y?y[Math.floor(D)]:Math.floor(D);if(x&&!x(N))continue;const M=O(N);Number.isFinite(M)&&F.push(M)}const E=Float64Array.from(F);return E.sort(),E}function u(S,y,v,R={}){const O=R.kind||w(S,R.type);return O==="none"||!S?{kind:"none",buckets:[],suppressed:"type"}:O==="boolean"?i(S,y,v):O==="category"?m(S,y,v,R):d(S,y,v,O,R)}function i(S,y,v){const R=$(S);let O=0;if(R){const C=y?y.length:v;for(let P=0;P<C;P++)R(y?y[P]:P)||O++}const x=[{value:!1,label:"false"},{value:!0,label:"true"}];return O>0&&x.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:x}}function m(S,y,v,R){const O=R.cardinalityLimit??U,{cardinality:x}=l(S,y,v,O);if(x>O&&(R.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:x};const C=B(S),P=y?y.length:v,F=new Map;let E=0;for(let L=0;L<P;L++){const G=C(y?y[L]:L);if(G==null||G===""){E++;continue}if(Array.isArray(G)){if(!G.length){E++;continue}for(const q of G)F.set(q,(F.get(q)||0)+1);continue}F.set(G,(F.get(G)||0)+1)}let D=[...F.entries()];R.order==="alpha"?D.sort((L,G)=>String(L[0]).localeCompare(String(G[0]))):D.sort((L,G)=>G[1]-L[1]);let N=0,M=0;if(D.length>O){M=D.length-O;for(let L=O;L<D.length;L++)N+=D[L][1];D=D.slice(0,O)}const A=D.map(([L])=>({value:L,label:String(L)}));return N>0&&A.push({remainder:!0,label:`Other (${M} values)`}),E>0&&A.push({null:!0,label:"Empty"}),{kind:"category",buckets:A,cardinality:x}}function d(S,y,v,R,O){const{min:x,max:C,nulls:P,finite:F}=o(S,y,v);if(!F)return{kind:R,buckets:P?[{null:!0,label:"Empty"}]:[],empty:!0};const E=Math.max(1,Math.floor(O.buckets||H));let D=[];if(R==="date"){const M=W.includes(O.granularity)?O.granularity:n(C-x,E);let A=t(x,M);for(;A<=C&&D.length<4096;){const L=r(A,M);if(!(L>A))break;D.push({from:A,to:L}),A=L}return{kind:R,buckets:h(D,P),granularity:M}}const N=X.includes(O.strategy)?O.strategy:"equal";if(N==="quantile"){const M=f(S,y,v,z);if(M.length){const A=[M[0]];for(let L=1;L<E;L++){const G=M[Math.min(M.length-1,Math.floor(L/E*M.length))];G>A[A.length-1]&&A.push(G)}A.push(C);for(let L=0;L<A.length-1;L++)D.push({from:A[L],to:A[L+1]})}}else if(N==="log"&&x>0){const M=Math.log10(x),L=(Math.log10(C)-M)/E||1;for(let G=0;G<E;G++)D.push({from:10**(M+G*L),to:10**(M+(G+1)*L)})}if(!D.length){const M=(C-x)/E||1;for(let A=0;A<E;A++)D.push({from:x+A*M,to:x+(A+1)*M})}return D[D.length-1].to=C,{kind:R,buckets:h(D,P),strategy:N,min:x,max:C}}function h(S,y){return y>0?[...S,{null:!0,label:"Empty"}]:S}function a(S,y,v,R,O){const x=R&&R.buckets||[],C=O&&O.length>=x.length?O.subarray(0,x.length):new Uint32Array(x.length);if(C.fill(0),!S||!x.length)return C;const P=x.length-1,F=!!x[P]&&x[P].null===!0,E=y?y.length:v;if(R.kind==="boolean"){const L=B(S);for(let G=0;G<E;G++){const q=L(y?y[G]:G);if(q==null){F&&C[P]++;continue}C[q?1:0]++}return C}if(R.kind==="category"){const L=new Map;for(let Y=0;Y<x.length;Y++)!x[Y].null&&!x[Y].remainder&&L.set(x[Y].value,Y);const G=x.findIndex(Y=>Y.remainder),q=B(S);for(let Y=0;Y<E;Y++){const J=q(y?y[Y]:Y);if(J==null||J===""){F&&C[P]++;continue}if(Array.isArray(J)){if(!J.length){F&&C[P]++;continue}for(const ne of J){const oe=L.get(ne);oe!==void 0?C[oe]++:G>=0&&C[G]++}continue}const te=L.get(J);te!==void 0?C[te]++:G>=0&&C[G]++}return C}const D=F?x.length-1:x.length,N=new Float64Array(D+1);for(let L=0;L<D;L++)N[L]=x[L].from;N[D]=D?x[D-1].to:0;const M=k(S),A=$(S);for(let L=0;L<E;L++){const G=y?y[L]:L;if(A&&!A(G)){F&&C[P]++;continue}const q=M(G);if(!Number.isFinite(q)){F&&C[P]++;continue}const Y=p(N,D,q);Y>=0&&C[Y]++}return C}function p(S,y,v){if(!y||v<S[0])return-1;if(v>=S[y])return v===S[y]?y-1:-1;let R=0,O=y-1;for(;R<O;){const x=R+O+1>>>1;v>=S[x]?R=x:O=x-1}return R}function b(S,y,v,R={}){const O=R.bounds||u(S,R.boundsIndices??y,v,R);return{bounds:O,counts:a(S,y,v,O)}}const j=b}),Fe("packages/core/src/compute/pivotmatrix.js",function(e,K){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return t}});const $=K("packages/core/src/compute/handle.js").valueComparator,I=K("packages/core/src/compute/total.js").total,X=K("packages/core/src/compute/group.js").packKeys,W=K("packages/core/src/compute/pivot.js"),H=W.joinPath,U=W.DEFAULT_PATH_SEPARATOR,z=W.DEFAULT_MAX_COLUMNS,w="";function k(r,o,f={}){const u=f.separator||U,i=r||[],m=o instanceof Uint32Array?o:Uint32Array.from(o||[]),d=m.length;if(i.length===0)return{tuples:[[]],paths:[w],buckets:[m]};const{keyOf:h,readers:a}=X(i,m,0),p=new Map,b=[],j=[],S=[];for(let C=0;C<d;C++){const P=m[C],F=h(P);let E=p.get(F);if(E===void 0){E=b.length,p.set(F,E),j.push(F);const D=new Array(a.length);for(let N=0;N<a.length;N++)D[N]=a[N](P);b.push(D),S.push([])}S[E].push(P)}const y=$(f.locale),v=b.map((C,P)=>P);v.sort((C,P)=>{const F=b[C],E=b[P];for(let D=0;D<F.length;D++){const N=g(F[D],E[D],y);if(N!==0)return N}return C-P});const R=new Array(v.length),O=new Array(v.length),x=new Array(v.length);for(let C=0;C<v.length;C++){const P=v[C];R[C]=b[P],O[C]=H(b[P],u),x[C]=Uint32Array.from(S[P])}return{tuples:R,paths:O,buckets:x}}function g(r,o,f){const u=r==null,i=o==null;return u||i?u&&i?0:u?1:-1:f(r,o)}function l(r,o,f){const u=[];for(let i=0;i<r.length;i++)f.has(r[i])&&u.push(r[i]);return Uint32Array.from(u)}function c(r,o,f,u){return{value:o.length?I(r,o,f,u):null,leaves:o,count:o.length}}function s(r){const o=r&&r.opts||{},f=o.separator||U,u=o.totalContext||{locale:o.locale},i=(r.measures||[]).filter(O=>O&&O.handle),m=r.leaves instanceof Uint32Array?r.leaves:Uint32Array.from(r.leaves||[]),d=k(r.rowHandles||[],m,{...o,separator:f}),h=k(r.columnHandles||[],m,{...o,separator:f}),a=o.maxColumns===void 0?z:o.maxColumns,p=h.paths.length*Math.max(1,i.length),b=new Map;if(a&&p>a)return{rowAxis:d,columnAxis:h,measures:i.map(O=>({colId:O.colId,fn:O.fn})),body:b,rowMargin:b,columnMargin:b,grand:b,columns:p,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${p} columns, above pivot.maxColumns of ${a}. Narrow the pivot columns or raise the limit.`,columns:p,maxColumns:a}};const j=new Map,S=new Map,y=new Map,v=new Map,R=h.buckets.map(O=>new Set(O));for(let O=0;O<h.paths.length;O++){const x=h.buckets[O],C=h.paths[O];for(const P of i)y.set(t(C,P.colId),c(P.handle,x,P.fn,u))}for(let O=0;O<d.paths.length;O++){const x=d.buckets[O],C=d.paths[O];for(const P of i)S.set(t(C,P.colId),c(P.handle,x,P.fn,u));for(let P=0;P<h.paths.length;P++){const F=l(x,h.buckets[P],R[P]);if(F.length===0)continue;const E=h.paths[P];for(const D of i)j.set(n(C,E,D.colId),c(D.handle,F,D.fn,u))}}for(const O of i)v.set(O.colId,c(O.handle,m,O.fn,u));return{rowAxis:d,columnAxis:h,measures:i.map(O=>({colId:O.colId,fn:O.fn})),body:j,rowMargin:S,columnMargin:y,grand:v,columns:p,error:null}}function n(r,o,f){return`${r}\0${o}\0${f}`}function t(r,o){return`${r}\0${o}`}}),Fe("packages/core/src/compute/reference.js",function(e,K){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return s}});const $=K("packages/core/src/internal/util.js").getPath,B=K("packages/core/src/compute/handle.js"),I=B.isMissing,_=B.valueComparator,W=K("packages/core/src/compute/filter.js").testValue,H="",U="\0";function z(r,o){const f=o.includes(".")?$(r,o):r?.[o];return f===void 0?null:f}function w(r,o,f={}){const u=o||[];let i=r.map((m,d)=>d);if(u.length===0)return i;for(let m=u.length-1;m>=0;m--)i=k(r,i,u[m],f);return i}function k(r,o,f,u){const i=f.locale!==void 0?f.locale:u.locale,m=_(i),d=f.descending!==void 0?!!f.descending:f.dir==="desc",h=[],a=[];for(const j of o){const S=z(r[j],f.col);I(S)?a.push(j):h.push(j)}const p=new Map;for(let j=0;j<h.length;j++)p.set(h[j],j);const b=(j,S)=>{const y=z(r[j],f.col),v=z(r[S],f.col);let R;return typeof f.compare=="function"?(R=f.compare(y,v,r[j],r[S],d),d&&(R=-R)):R=d?m(v,y):m(y,v),R!==0?R:p.get(j)-p.get(S)};return h.sort(b),f.nullsFirst?a.concat(h):h.concat(a)}function g(r,o,f={}){const u=[];for(let i=0;i<r.length;i++)l(r[i],o,f,i)&&u.push(i);return u}function l(r,o,f,u){if(!o)return!0;if(Array.isArray(o.conditions)){const i=o.conditions.filter(d=>d!=null);if(i.length===0)return!0;if(o.op==="or")return i.some(d=>l(r,d,f,u));const m=i.every(d=>l(r,d,f,u));return o.op==="not"?!m:m}return o.col===void 0&&typeof f.custom=="function"?!!f.custom(o,r,u):W(z(r,o.col),o,f.locale)}function c(r,o,f,u){const i=f||r.map((a,p)=>p),m=new Map,d=[],h=[];for(const a of i){const p=o.map((S,y)=>{const v=z(r[a],S);return u&&u[y]?u[y](v):v}),b=p.map(S=>S==null?U:String(S)).join(H);let j=m.get(b);j===void 0&&(j=d.length,m.set(b,j),d.push(p),h.push([])),h[j].push(a)}return{keys:d,buckets:h}}function s(r,o,f={}){const u=_(f.locale),i=r.filter(d=>!I(d)),m=i.map(n).filter(d=>d!==null);switch(o){case"count":return r.length;case"countValues":return i.length;case"sum":return m.reduce((d,h)=>d+h,0);case"avg":return i.length===0?null:m.reduce((d,h)=>d+h,0)/i.length;case"min":return i.length===0?null:i.reduce((d,h)=>u(h,d)<0?h:d);case"max":return i.length===0?null:i.reduce((d,h)=>u(h,d)>0?h:d);case"first":return r.length===0?null:t(r[0]);case"last":return r.length===0?null:t(r[r.length-1]);default:return null}}function n(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const o=Number(r);return Number.isNaN(o)?null:o}function t(r){return r===void 0?null:r}}),Fe("packages/core/src/compute/index.js",function(e,K){"use strict";const Q=K("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return Q.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return Q.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return Q.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return Q.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return Q.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return Q.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return Q.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return Q.rankSortStrings}});const $=K("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return $.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return $.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return $.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return $.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return $.describeSort}});const B=K("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return B.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return B.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return B.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return B.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return B.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return B.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return B.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return B.mentionsColumn}});const I=K("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return I.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return I.packKeys}});const _=K("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const X=K("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return X.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return X.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return X.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return X.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return X.collectValues}});const W=K("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return W.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return W.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return W.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return W.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return W.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return W.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return W.DEFAULT_MAX_COLUMNS}});const H=K("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return H.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return H.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return H.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return H.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return H.GRAND_PATH}});const U=K("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return U.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return U.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return U.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return U.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return U.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return U.referenceValue}});const z=K("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return z.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return z.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return z.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return z.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return z.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return z.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return z.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return z.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return z.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return z.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return z.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return z.isMissing}});const w=K("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return w.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return w.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return w.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return w.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return w.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return w.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return w.SKETCH_BOUNDS}});const k=K("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return k.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return k.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return k.openWindow}});const g=K("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return g.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return g.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return g.maintenanceOf}});const l=K("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return l.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return l.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return l.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return l.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return l.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return l.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return l.anomalyCondition}});const c=K("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return c.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return c.forecast}})}),Fe("packages/core/src/source/rows.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.isFunction,I=32,_="\0";function X(c){return new W(c)}class W{#e;#t;constructor(s){this.#e=B(s&&s.rowKey)?s.rowKey:null;const n=s&&s.config?s.config.rowHeight:void 0;this.#t=typeof n=="number"||B(n)?n:I}get keyed(){return this.#e!==null}keyOf(s,n){if(this.#e){const t=this.#e(s);if(t!=null)return String(t)}else $("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${n}`}heightOf(s){return B(this.#t)?Number(this.#t(s))||I:this.#t}leaf(s,n,t=0,r=null){const o={key:this.keyOf(s,n),data:s,level:t,parent:r,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:n};return o.height=this.heightOf(o),o}group(s){const n={key:g(s.keyPath||s.path),data:null,level:s.level,parent:s.parent||null,children:[],group:!0,expanded:s.expanded!==!1,leafCount:s.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:s.column,groupValue:s.value,groupPath:s.path,hasChildren:s.hasChildren!==!1};return s.totals&&(n.totals=s.totals),n.height=this.heightOf(n),n}footer(s){const n={key:`${s.key}${_}footer`,data:null,level:s.level,parent:s,group:!0,footer:!0,expanded:!1,leafCount:s.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:s.groupColumn,groupValue:s.groupValue,groupPath:s.groupPath,hasChildren:!1,totals:s.totals};return n.height=this.heightOf(n),n}detail(s,n){return{key:`${s.key}${_}detail`,data:s.data,level:s.level+1,parent:s,group:!1,detail:!0,expanded:!1,leafCount:0,height:n,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:s.key}}grandTotal(s,n){const t={key:`${_}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:n,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:s};return t.height=this.heightOf(t),t}skeleton(s,n=0,t=!1){const r={key:`${_}pending${_}${s}`,data:null,level:n,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:s,selected:!1,physical:null,pending:!0};return t&&(r.loadError=!0),r.height=this.heightOf(r),r}}function H(c,s,n,t){return{key:`${_}pinned${_}${n}${_}${s}`,data:c,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,pinned:n}}function U(c,s){return new Proxy([],{get(n,t,r){if(t==="length")return c();if(typeof t=="string"){const o=Number(t);if(Number.isInteger(o)&&o>=0)return s(o)}return Reflect.get(n,t,r)},has(n,t){if(typeof t=="string"){const r=Number(t);if(Number.isInteger(r)&&r>=0)return r<c()}return Reflect.has(n,t)}})}function z(c){return c==null?"":String(c)}const w="";function k(c){if(c==null)return w;const s=String(c);return s.startsWith(w)?w+s:s}function g(c){const s=c||[];let n="g";for(let t=0;t<s.length;t++)n+=_+k(s[t]);return n}function l(c){const s=new Array(c.length),n=[];for(let t=0;t<c.length;t++)n.push(c[t]),s[t]=g(n);return s}}),Fe("packages/core/src/source/handles.js",function(e,K){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return _}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce;class I{#e;#t;#n;#r=new Map;#o=0;constructor(W,H,U){this.#e=W,this.#t=H,this.#n=$(U)?U:()=>!1}get store(){const W=this.#e.store;return W&&$(W.column)?W:null}invalidate(){this.#o++}handle(W){const H=this.store;if(H){const k=H.column(W);if(k)return k}const U=this.#r.get(W);if(U&&U.builtAt===this.#o)return U.handle;const z=this.#i(W);if(!z)return;if(H&&this.#n()){B(`source.dropped.${W}`,`column "${W}" 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 w=this.#s(z);return this.#r.set(W,{handle:w,builtAt:this.#o}),w}#i(W){const H=this.#e.columns;return H&&$(H.get)?H.get(W):void 0}#s(W){const H=this.#t()||[],U=H.length,z=new Array(U),w=$(W.getValue)?g=>W.getValue(g):g=>g?.[W.field||W.id];for(let g=0;g<U;g++)z[g]=H[g]===void 0?void 0:w(H[g]);const k=this.#o;return{id:W.id,kind:"object",nullable:!1,values:z,presence:null,dict:null,offsets:null,get(g){return z[g]},version:k}}}function _(X,W,H){return new I(X,W,H)}}),Fe("packages/core/src/compute/incremental.js",function(e,K){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const $=K("packages/core/src/store/columnstore.js").toFloat,B=Object.freeze(["sum","avg","countValues","min","max"]),I=Object.freeze(["float64"]),_=1e15;function X(z,w){return typeof z!="string"||!B.includes(z)?!1:!!w&&I.includes(w.kind)}function W(z){if(z==null)return null;const w=$(z);return Number.isNaN(w)?null:w}class H{#e;#t=0;#n=0;#r=0;#o=1/0;#i=-1/0;#s=!1;#l=!1;constructor(w){this.#e=w}get valid(){return this.#s&&!this.#l}get fn(){return this.#e}seed(w){this.#a();for(let k=0;k<w.length;k++){const g=W(w[k]);g!==null&&this.#u(g)}this.#s=!0}seedColumn(w,k,g){this.#a();for(let l=0;l<g.length;l++){const c=g[l];if(k&&k(c)===0)continue;const s=w[c];Number.isNaN(s)||this.#u(s)}this.#s=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#o=1/0,this.#i=-1/0,this.#l=!1}#u(w){if(!Number.isFinite(w)){this.#l=!0;return}const k=this.#t+w;this.#n+=Math.abs(this.#t)>=Math.abs(w)?this.#t-k+w:w-k+this.#t,this.#t=k,this.#r++,w<this.#o&&(this.#o=w),w>this.#i&&(this.#i=w)}#c(w){const k=this.#t-w;this.#n+=Math.abs(this.#t)>=Math.abs(w)?this.#t-k-w:-w-k+this.#t,this.#t=k,this.#r--}update(w,k){if(!this.#s)return!1;const g=W(w),l=W(k);return g===null&&l===null?!0:g!==null&&!Number.isFinite(g)||l!==null&&!Number.isFinite(l)?!1:this.#e==="min"||this.#e==="max"?g===null||l===null?!1:this.#e==="min"?l<this.#o?(this.#o=l,!0):g>this.#o:l>this.#i?(this.#i=l,!0):g<this.#i:Math.abs(this.#t)>_?!1:(g!==null&&this.#c(g),l!==null&&this.#u(l),!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.#o:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#s=!1}}const U=H}),Fe("packages/core/src/source/filterwire.js",function(e,K){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return y}});const $=K("packages/core/src/internal/util.js").warnOnce,B="source.remote.hostFilter",I="source.where.pageRelative";function _(O,x){!Array.isArray(O)||!O.length||$(I,`filters.where (${O.join(", ")}) runs over the rows the ${x} 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 X(O){const x=(O||{}).config;!x||!x.hostFilter||$(B,"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 W="source.where.notApplied";function H(O,x){$(`${W}:${O}`,`filters.where("${O}") is registered but the ${x} 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 U="source.where.overThreshold";function z(O,x,C,P){!Array.isArray(O)||!O.length||$(`${U}:${x}`,`filters.where (${O.join(", ")}) is not applied to the ${x} pushdown source:`,C===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${C.toLocaleString()} rows, at or past the whereRowLimit of ${P.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 w=new Map;function k(O){let x=w.get(O);return x||(x=new Intl.DateTimeFormat("en-US",{timeZone:O,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),w.set(O,x)),x}function g(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function l(O,x){const C=k(x).formatToParts(new Date(O)),P={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const F of C)F.type==="year"?P.y=+F.value:F.type==="month"?P.m=+F.value:F.type==="day"?P.d=+F.value:F.type==="hour"?P.h=+F.value%24:F.type==="minute"?P.mi=+F.value:F.type==="second"&&(P.s=+F.value);return P}function c(O,x){const C=l(O,x);return Date.UTC(C.y,C.m-1,C.d,C.h,C.mi,C.s)-Math.floor(O/1e3)*1e3}function s(O,x,C,P){const F=Date.UTC(O,x-1,C),E=F-c(F,P);return F-c(E,P)}function n(O,x,C){const P=new Date(Date.UTC(O.y,O.m-1,O.d+x));return s(P.getUTCFullYear(),P.getUTCMonth()+1,P.getUTCDate(),C)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function r(O,x){if(typeof O!="string")return null;const C=O.trim().toLowerCase().replace(/[\s_-]+/g,""),P=/^last(\d*|n)days?$/.exec(C);if(P){const F=P[1]==="n"?"":P[1],E=Number(F||x);return!Number.isFinite(E)||E<=0?null:{kind:"lastNDays",n:Math.floor(E)}}switch(C){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 o(O,x={}){const C=r(O,x.n);if(!C)return null;const P=x.tz||g(),F=x.now instanceof Date?x.now.getTime():typeof x.now=="number"?x.now:Date.now(),E=l(F,P),D=s(E.y,E.m,E.d,P),N=n(E,1,P);let M=D,A=N;switch(C.kind){case"today":break;case"yesterday":M=n(E,-1,P),A=D;break;case"lastNDays":A=x.includeToday?N:D,M=n(E,x.includeToday?-(C.n-1):-C.n,P);break;case"thisWeek":{const L=Number.isFinite(x.weekStartsOn)?Number(x.weekStartsOn):1,q=(new Date(Date.UTC(E.y,E.m-1,E.d)).getUTCDay()-L+7)%7;M=n(E,-q,P),A=n(E,-q+7,P);break}case"thisMonth":M=s(E.y,E.m,1,P),A=s(E.m===12?E.y+1:E.y,E.m===12?1:E.m+1,1,P);break;case"thisQuarter":case"quarterToDate":{const L=Math.floor((E.m-1)/3)*3+1;M=s(E.y,L,1,P),A=C.kind==="quarterToDate"?N:L===10?s(E.y+1,1,1,P):s(E.y,L+3,1,P);break}case"thisYear":case"yearToDate":M=s(E.y,1,1,P),A=C.kind==="yearToDate"?N:s(E.y+1,1,1,P);break;default:return null}return{from:new Date(M).toISOString(),to:new Date(A).toISOString(),bounds:"[)",tz:P,relative:C.kind==="lastNDays"?`last${C.n}Days`:C.kind,n:C.n}}function f(O){if(!O||typeof O!="object")return null;const x=O.value;if(x&&typeof x=="object"&&!Array.isArray(x)&&"relative"in x)return{token:String(x.relative),n:typeof x.n=="number"?x.n:void 0};if(O.op==="relative"&&typeof O.value=="string")return{token:O.value,n:void 0};const C=O.meta;return C&&typeof C.relative=="string"&&O.value===void 0?{token:C.relative,n:typeof C.n=="number"?C.n:void 0}:null}function u(){return`Known tokens: ${t.filter(x=>x!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function i(O){const x=f(O);return x?r(x.token,x.n)!==null:!1}function m(O,x={}){const C=f(O);if(!C)return O;const P=o(C.token,{...x,n:C.n});return P?{...O,type:O.type||"date",op:"between",value:[P.from,P.to],bounds:O.bounds||P.bounds,meta:{...O.meta||{},relative:P.relative,tz:P.tz}}:($(`source.relative.${C.token}`,`unknown relative date token "${C.token}"; sending the condition unresolved.`,u()),O)}function d(O){return!!O&&typeof O=="object"&&Array.isArray(O.conditions)}function h(O,x){if(O){if(d(O)){for(const C of O.conditions)h(C,x);return}x(O)}}function a(O,x){if(!O)return null;if(!d(O))return x(O);const C=O;let P=!1;const F=[];for(const E of C.conditions){const D=a(E,x);D!==E&&(P=!0),D&&F.push(D)}return!P&&F.length===C.conditions.length?O:F.length?{...C,conditions:F}:null}function p(O){if(!O)return null;if(!d(O))return O;const x=O,C=[];for(const P of x.conditions){const F=p(P);F&&C.push(F)}return C.length?{op:x.op,conditions:C}:null}function b(O){const x=p(O);return x?d(x)&&x.op==="and"?x:{op:"and",conditions:[x]}:null}function j(O){const x=(O||[]).filter(Boolean);return x.length?{op:"and",conditions:x}:null}function S(O,x={}){const C=a(O,P=>m(P,x));return b(C)}function y(O){const x=v(O.filters??null);return JSON.stringify([x,O.sort??null,O.quick??"",O.groupBy??null,O.pivotBy??null,R(O.context)])}function v(O){if(!O)return null;if(d(O)){const P=O;return{op:P.op,conditions:P.conditions.map(v)}}const x=O,C=x.meta&&typeof x.meta.relative=="string"?x.meta.relative:f(x)?.token;return{col:x.col,op:x.op,bounds:x.bounds??null,caseSensitive:x.caseSensitive??!1,value:C?`rel:${C}`:x.value??null}}function R(O){if(O==null)return null;try{return JSON.parse(JSON.stringify(O))}catch{return $("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Fe("packages/core/src/source/tree.js",function(e,K){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I="",_="\0tree:";function X(l,c){return{physical:l,key:c,level:0,children:[],value:void 0}}function W(l,c){const s=[],n=new Map;for(let t=0;t<l.length;t++){const r=l[t],o=c.pathOf(r),f=Array.isArray(o)?o.map(i=>String(i)):[];if(!f.length){const i=X(r,c.keyOf(r));s.push(i);continue}let u=null;for(let i=0;i<f.length;i++){const m=f.slice(0,i+1).join(I),d=i===f.length-1;let h=n.get(m);h&&d&&h.physical===-1&&(h.physical=r,h.key=c.keyOf(r)),h||(h=X(d?r:-1,d?c.keyOf(r):_+m),h.level=i,h.value=f[i],n.set(m,h),u?u.children.push(h):s.push(h)),u=h}}return{roots:s,nodes:n}}function H(l,c){const s=new Map,n=[];for(let f=0;f<l.length;f++){const u=l[f],i=c.keyOf(u),m=X(u,i);s.set(i,m);const d=c.parentOf(u);d!=null&&d!==""&&n.push({node:m,parent:String(d)})}let t=null;const r=new Map;for(const{node:f,parent:u}of n){const i=s.get(u);if(i){r.set(f.key,i);continue}c.orphans&&c.orphans!=="root"&&(t||(t=X(-1,`${_}orphans`),t.value=c.orphans),r.set(f.key,t))}const o=[];for(const f of s.values()){const u=r.get(f.key);u?u.children.push(f):o.push(f)}return t&&t.children.length&&o.push(t),{roots:U(o,s,c.orphans,t),nodes:s}}function U(l,c,s,n){const t=new Set,r=[...l];for(;r.length;){const m=r.pop();if(!t.has(m.key)){t.add(m.key);for(const d of m.children)r.push(d)}}const o=[];for(const m of c.values())t.has(m.key)||o.push(m);if(!o.length)return l;const f=!!s&&s!=="root";B("tree.cycle",`tree.parentKey produced ${o.length} row(s) inside a parent cycle; `+(f?`they are shown under "${s}".`:"they are shown at the root."));for(const m of o)m.children=m.children.filter(d=>t.has(d.key));if(!f)return[...l,...o];let u=n;const i=[...l];return u||(u=X(-1,`${_}orphans`),u.value=s,i.push(u)),u.children.push(...o),i}function z(l){let c=0;const s=(n,t)=>{for(const r of n)r.level=t,t>c&&(c=t),r.children.length&&s(r.children,t+1)};return s(l,0),c}function w(l,c){if(!l||typeof l!="object")return null;const s=l.path,n=l.parentKey,t=$(l.hasChildren)?r=>!!l.hasChildren(c.dataAt(r)):null;if($(s))return{mode:"path",pathOf:r=>s(c.dataAt(r)),keyOf:c.keyOf,declaresChildren:t};if(n!=null){const r=$(n)?n:o=>o?.[n];return{mode:"parentKey",parentOf:o=>r(c.dataAt(o)),keyOf:c.keyOf,orphans:l.orphans||"root",declaresChildren:t}}return B("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function k(l,c){const s=c.mode==="path"?W(l,c):H(l,c),n=z(s.roots);return{...s,depth:n}}function g(l,c){const s=new Map,n=t=>{for(let r=0;r<t.length;r++){const o=t[r];if(o.physical>=0){const f=c?c(o.physical):!1,u=f&&o.children.length===0;s.set(o.physical,{level:o.level,posinset:r+1,setsize:t.length,hasChildren:o.children.length>0||f,lazy:u})}o.children.length&&n(o.children)}};return n(l),s}}),Fe("packages/core/src/source/memory.js",function(e,K){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return N}});const Q=K("packages/core/src/internal/util.js"),$=Q.Lru,B=Q.warnOnce,I=Q.fail,_=Q.isFunction,X=Q.defaultCompare,W=Q.mergeRow,H=K("packages/core/src/source/rows.js"),U=H.createRowFactory,z=H.groupKey,w=H.groupPathElement,k=H.groupPrefixKeys,g=H.lazyRowView,c=K("packages/core/src/source/handles.js").createHandleProvider,s=K("packages/core/src/compute/incremental.js"),n=s.RunningTotal,t=s.isIncremental,o=K("packages/core/src/compute/handle.js").presenceReader,f=K("packages/core/src/source/filterwire.js"),u=f.querySignature,i=f.mapConditions,m=f.resolveRelativeCondition,d=K("packages/core/src/source/tree.js"),h=d.buildTree,a=d.resolveTree,p=d.indexTree,b=Object.freeze(["filter","sort","group","total","pivot","flatten"]),j=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function S(M){const A=M&&typeof M=="object"?M.reason:null;return typeof A=="string"&&j.includes(A)}const y=Object.freeze([]);function v(M,A){if(!M)return null;const L=A==="grand"?M.grandTotal:M.groupTotal;return L??M.total}function R(M){return!!M&&!M.running}function O(M){if(M)return M.value&&_(M.value.compare)?M.value.compare:_(M.compare)?M.compare:void 0}function x(M){const A=M&&M.dataType;return!A||!_(A.items)?null:{items:A.items,type:M.itemType&&M.itemType.name||"text"}}function C(M){return!!M&&(typeof M=="object"||typeof M=="function")&&_(M.then)}const P=new Uint32Array(0),F=4096;function E(M,A){return new N(M,A)}function D(M,A){if(A==="regex")try{const L=new RegExp(M,"iu");return G=>L.test(G)}catch{return L=>L.includes(M)}if(A==="fuzzy"){const L=[...M].filter(G=>G!==" ");return L.length?G=>{let q=0;for(let Y=0;Y<G.length&&q<L.length;Y++)G[Y]===L[q]&&q++;return q===L.length}:()=>!0}if(A==="words"){const L=M.split(/\s+/).filter(Boolean);return L.length?G=>L.every(q=>G.includes(q)):()=>!0}return L=>L.includes(M)}class N{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#s;#l=new Map;#a=!1;#u=0;#c=0;#d=new Map;#f=new Map;#h;#p=null;#m=N.#g();static#g(){return{slots:[],groupHeadings:y,unnumbered:y,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#b=new Map;#w=null;#S=new Map;#y=-1;#O=[];#k=new Map;#A=-1;#j=[];#T=null;#M=null;#C=null;#E=null;#L=null;#x=null;#B=null;#H=null;#U=Symbol("unset");#N=new Map;#$=null;get#z(){return this.#m.slots}set#z(A){this.#m.slots=A}get#_(){return this.#m.inlineLeaves}set#_(A){this.#m.inlineLeaves=A}get#Y(){return this.#m.groupHeadings}set#Y(A){this.#m.groupHeadings=A}get#le(){return this.#m.unnumbered}set#le(A){this.#m.unnumbered=A}get#re(){return this.#m.pivot}set#re(A){this.#m.pivot=A}constructor(A,L){this.#t=A||{mode:"memory"},this.#e=L||{};const G=this.#e.config||{};this.#n=this.#t.rows||G.rows||[],this.#i=U(this.#e),this.#s=c(this.#e,()=>this.#n,()=>this.#r),this.#h=new $(Number(G.rowCacheSize)||F);for(const q of b)this.#l.set(q,{key:null,result:null,id:0,computed:!1})}count(){this.#q();const A=this.#se();return A?A.length:this.#z.length}#se(){const A=Number(this.#K("pageSize",0))||0;if(A<=0)return null;const L=this.#z.length,G=Math.max(1,Math.ceil(L/A)),Y=Math.min(Math.max(0,Number(this.#K("page",0))||0),G-1)*A;return{offset:Y,length:Math.max(0,Math.min(A,L-Y))}}pageInfo(){this.#q();const A=Number(this.#K("pageSize",0))||0,L=this.#z.length;if(A<=0)return{page:0,pageSize:0,total:L,pageCount:1};const G=Math.max(1,Math.ceil(L/A));return{page:Math.min(Math.max(0,Number(this.#K("page",0))||0),G-1),pageSize:A,total:L,pageCount:G}}totalCount(){return this.#Ie().length}matchCount(){return this.#q(),this.#m.matchCount}at(A){this.#q();const L=this.#se();if(L)return A<0||A>=L.length?void 0:this.#qe(L.offset+A,A);if(!(A<0||A>=this.#z.length))return this.#qe(A,A)}byKey(A){this.#q(),this.#p||this.#Q();const L=this.#p.get(A);if(L!==void 0)return this.#Te(L);for(let G=0;G<this.#z.length;G++){const q=this.#z[G];if(typeof q!="number"&&q&&q.key===A)return this.#qe(G)}}loaded(A){return A>=0&&A<this.count()}hint(A,L){}display(){return this.#q(),this.#$||(this.#$=this.#Lt()),this.#$}invalidateQuickText(){this.#N.clear(),this.invalidate("filter")}invalidate(A){const L=b.indexOf(A);L<0&&I(`unknown pipeline stage "${A}"; expected one of ${b.join(", ")}`);for(let G=L;G<b.length;G++){const q=this.#l.get(b[G]);q.key=null,q.computed=!1}this.#$=null}apply(A){const L=[],G={added:[],updated:[],removed:[],rejected:L};if(!A)return G;let q=!1;const Y=new Set;if(A.remove&&A.remove.length)for(const J of A.remove){const te=this.#X(J);if(te===void 0){L.push({operation:"remove",id:this.#pe(J),reason:"unknown-id"});continue}G.removed.push(this.#i.keyOf(this.#r?this.#Ne(te):this.#n[te],te)),this.#r||(this.#n[te]=void 0),this.#h.delete(te),this.#N.delete(te),q=!0}if(A.update&&A.update.length){const J=this.#S.size||this.#ot()?this.#ut():null,te=this.#k.size?this.#ht():null,ne=te&&te.length?this.#ut():null;for(const oe of A.update){const le=this.#X(oe);if(le===void 0){L.push({operation:"update",id:this.#te(oe),reason:"unknown-id"});continue}const ae=this.#r?this.#o&&this.#o.has(le)?this.#o.get(le):this.#Ne(le):this.#n[le],se=W(ae,oe);for(const ee of this.#Z(ae,se))Y.add(ee);if(this.#r||(this.#n[le]=se),J&&this.#Ct(J,le,ae,se),ne&&this.#et(te,ne,le,ae,se),this.#p){const ee=this.#i.keyOf(ae,le),ie=this.#i.keyOf(se,le);ee!==ie&&(this.#p.delete(ee),this.#p.set(ie,le))}this.#h.delete(le),this.#N.delete(le),G.updated.push(this.#Te(le))}}if(A.add&&A.add.length&&this.#r){typeof A.at=="number"&&A.at<this.#at()&&(this.#h.clear(),this.#N.clear()),this.#p=null;for(const J of A.add){const te=this.#G(this.#te(J));te!==void 0&&G.added.push(this.#Te(te))}q=!0}else if(A.add&&A.add.length){const J=typeof A.at=="number"?A.at:this.#n.length,te=this.#n.length;let ne=A.add===this.#n?A.add.slice():A.add;if(this.#i.keyed){const oe=[];for(const le of ne){const ae=this.#te(le);if(this.#X(ae)!==void 0){L.push({operation:"add",id:ae,reason:"duplicate-id"});continue}oe.push(le)}oe.length!==ne.length&&(ne=oe)}if(!ne.length)return G;if(J>=te)for(let oe=0;oe<ne.length;oe++)this.#n.push(ne[oe]);else this.#n.splice(J,0,...ne),this.#h.clear(),this.#N.clear();for(let oe=0;oe<ne.length;oe++)G.added.push(this.#Te(J>=te?te+oe:J+oe));q=!0}return this.#u++,q&&(this.#p=null,this.#xe()),this.#s.invalidate(),this.#$=null,q||this.#ae(Y)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#He("rows:changed",{companion:!0,added:G.added.length,updated:G.updated.length,removed:G.removed.length}),this.#o=null,G}groupHeadingsAt(A){this.#q();const L=this.#Y;if(!L.length||!Number.isInteger(A)||A<0)return y;let G=0,q=L.length-1,Y=-1;for(;G<=q;){const te=G+q>>1;L[te].at<=A?(Y=te,G=te+1):q=te-1}if(Y<0)return y;const J=[];for(let te=L[Y].row;te;te=te.parent)J.push(te);return J.reverse(),J}unnumberedRowCount(A){this.#q();const L=this.#le;if(!L.length||!Number.isInteger(A)||A<0)return 0;let G=0,q=L.length-1,Y=-1;for(;G<=q;){const J=G+q>>1;L[J].at<=A?(Y=J,G=J+1):q=J-1}return Y+1}moveRow(A,L){if(this.#r)return B("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 G=this.#n;if(!Number.isInteger(A)||!Number.isInteger(L)||A<0||A>=G.length)return!1;const q=Math.max(0,Math.min(G.length-1,L));if(q===A)return!1;const[Y]=G.splice(A,1);return G.splice(q,0,Y),this.#u++,this.#c++,this.#p=null,this.#h.clear(),this.#N.clear(),this.#xe(),this.#s.invalidate(),this.#$=null,this.invalidate("filter"),this.#He("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(A){this.#ge(),this.#u++,this.#c++,this.#p=null,this.#N.clear(),this.#h.clear(),this.#xe(),this.#s.invalidate(),this.invalidate("filter"),this.#He("model:changed",{reason:"reload"})}destroy(){this.#ge(),this.#h.clear(),this.#N.clear(),this.#p=null,this.#z=[],this.#_=null,this.#$=null,this.#xe();for(const A of b)this.#l.set(A,{key:null,result:null,id:0,computed:!1})}#ge(){for(const{controller:A}of this.#b.values())try{A.abort()}catch{}this.#b.clear()}setRows(A){this.#n=A||[],this.#r=!1,this.#u++,this.#c++,this.#p=null,this.#N.clear(),this.#h.clear(),this.#xe(),this.#s.invalidate(),this.invalidate("filter")}notePriorRows(A){this.#o=A||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#N.clear(),this.#s.invalidate()}data(){if(!this.#r)return this.#n;const A=this.#e.store;if(!A||!_(A.source))return this.#n;const L=A.physical||0,G=new Array(L);for(let q=0;q<L;q++)G[q]=A.live&&!A.live(q)?void 0:A.source(q);return G}#Me(){const A=this.#K("detail",null);return!A||!_(A.isOpen)||A.inline===!1?null:A}#we(){const A=(this.#e.config||{}).tree;return this.#U!==A&&(this.#U=A,this.#H=a(A,{dataAt:L=>this.#Ne(L),keyOf:L=>this.#i.keyOf(this.#Ne(L),L)})),this.#H}#oe(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#oe())return null;this.#q();const A=this.#m.grand;return A?this.#i.grandTotal(A,this.#tt(this.#m.grandLeaves)):null}pivot(){return this.#q(),this.#re}pivotMatrix(){this.#q();const A=this.#m.groupLeaves,L=(this.#e.compute||{}).pivotMatrix;if(!_(L))return null;const G=this.#K("groupBy",[]),q=this.#K("pivotBy",[]);if(!G.length&&!q.length)return B("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 Y=this.#ut().map(te=>({colId:te.id,handle:this.#s.handle(te.id),fn:v(te,"group")})).filter(te=>te.handle&&te.fn),J=this.#e.config||{};return L({rowHandles:G.map(te=>this.#s.handle(te)).filter(Boolean),columnHandles:q.map(te=>this.#s.handle(te)).filter(Boolean),measures:Y,leaves:A||new Uint32Array(0),opts:{locale:J.locale,separator:(J.pivot||{}).separator,maxColumns:(J.pivot||{}).maxColumns}})}keysForLeaves(A){const L=[];if(!A)return L;for(let G=0;G<A.length;G++){const q=this.#Te(A[G]);q&&q.key!=null&&L.push(String(q.key))}return L}leavesOf(A){this.#q();const L=this.#l.get("group"),G=L&&L.result;if(!G||!G.nodes)return[];const q=G.nodes.get(A);if(!q)return[];const Y=[],J=te=>{const ne=te.row&&te.row.children;if(ne&&ne.length){for(const oe of ne){const le=G.nodes.get(oe.key);le&&J(le)}return}if(te.leaves)for(let oe=0;oe<te.leaves.length;oe++)Y.push(this.#Te(te.leaves[oe]))};return J(q),Y}#pe(A){return typeof A=="string"?A:this.#te(A)}#te(A){try{return this.#i.keyOf(A,-1)}catch{return"(unkeyed)"}}#X(A){if(typeof A=="string")return this.#G(A);if(this.#i.keyed){const G=this.#i.keyOf(A,-1),q=this.#G(G);if(q!==void 0)return q}if(this.#r)return;const L=this.#n.indexOf(A);return L>=0?L:void 0}#G(A){return this.#p||this.#Q(),this.#p.get(A)}#Q(){this.#p=new Map;const A=this.#at(),L=this.#e.store,G=L&&_(L.live)?q=>L.live(q):null;for(let q=0;q<A;q++){if(G&&!G(q))continue;const Y=this.#Ne(q);Y!==void 0&&this.#p.set(this.#i.keyOf(Y,q),q)}}#Z(A,L){const G=[];for(const q of this.#ie())this.#ze(q)&&this.#ve(q,A,L,new Set)&&G.push(q);return G}#ve(A,L,G,q){if(q.has(A))return!1;q.add(A);const Y=this.#ze(A);if(!Y)return!1;const J=Y.value&&Y.value.deps;return Array.isArray(J)&&J.length?J.some(te=>this.#ve(String(te),L,G,q)):_(Y.getValue)?!Object.is(Y.getValue(L),Y.getValue(G)):!1}#ie(){const A=new Set;for(const G of this.#K("sort",[]))A.add(G.col);for(const G of this.#K("groupBy",[]))A.add(G);const L=G=>{if(G){if(Array.isArray(G.conditions)){G.conditions.forEach(L);return}G.col&&A.add(G.col)}};return L(this.#K("filters",null)),[...A]}#ae(A){if(!A.size)return!1;if(this.#K("quick",""))return!0;for(const L of this.#ie())if(A.has(L))return!0;return!1}#q(){if(!this.#a){this.#a=!0;try{this.#me()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#me(){const A=this.#I("filter",()=>this.#ce(),()=>this.#ye()),L=this.#Ae(A),G=this.#I("group",()=>this.#Be(),()=>this.#We(L)),q=this.#I("total",()=>this.#Ge(),()=>this.#Fe(G));this.#I("pivot",()=>this.#Ke(),()=>this.#Ve(G)),this.#I("flatten",()=>this.#Pe(),()=>this.#st(G)),this.#ue(G,q)}#Ae(A){const L=this.#l.get("sort"),G=this.#fe();if(L.computed&&L.key===G&&!this.#b.has("sort"))return L.result;const q=this.#b.get("sort");return q&&q.key===G?L.result:L.result&&this.#ke(A)?(this.#de(A,G),L.result):this.#I("sort",()=>G,()=>this.#Ce(A))}#he(){if(this.#w===null){const A=this.#e.pipelineWorker,L=_(A)?A():null;this.#w=L||!1}return this.#w||null}#ne(){const A=this.#K("sort",[]);if(!Array.isArray(A)||!A.length)return null;const L=(this.#e.config||{}).locale,G=[],q=[];for(const Y of A){const J=this.#ze(Y.col);if(J&&J.running)continue;if(J&&J.value&&_(J.value.compare))return null;const te=this.#s.handle(Y.col);if(!te)return null;G.push({col:Y.col,descending:Y.dir==="desc",nullsFirst:!!Y.nullsFirst,locale:L}),q.push(te)}return G.length?{entries:G,handles:q,locale:L}:null}#ke(A){if(this.#v())return!1;const L=this.#he();if(!L)return!1;const G=Number(L.threshold);return Number.isFinite(G)&&A.length<G?!1:!!this.#ne()}#de(A,L){const G=this.#he(),q=G&&this.#ne();if(!q){this.#I("sort",()=>L,()=>this.#Ce(A));return}const Y=new AbortController;this.#b.set("sort",{key:L,controller:Y});const J=q.entries.length===1?G.sortColumn(q.handles[0],A,{descending:q.entries[0].descending,nullsFirst:q.entries[0].nullsFirst,locale:q.locale,signal:Y.signal,key:"sort"}):G.sortMulti(q.handles,q.entries.map((te,ne)=>({...te,handle:q.handles[ne]})),A,{signal:Y.signal,key:"sort"});if(!C(J)){this.#b.delete("sort"),this.#I("sort",()=>L,()=>J);return}J.then(te=>this.#V(L,te),te=>this.#R("sort",L,te))}#V(A,L){const G=this.#b.get("sort");if(!(!G||G.key!==A)){if(this.#fe()!==A){this.#b.delete("sort");return}this.#b.delete("sort"),this.#I("sort",()=>A,()=>L),this.#$=null,this.#q(),this.#He("model:changed",{reason:j[0]})}}#R(A,L,G){const q=this.#b.get(A);if(!(!q||q.key!==L)&&(this.#b.delete(A),!(G&&G.name==="AbortError")&&A==="sort"&&this.#fe()===L)){const Y=this.#I("filter",()=>this.#ce(),()=>this.#ye());this.#I("sort",()=>L,()=>this.#Ce(Y)),this.#$=null,this.#q(),B("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",G),this.#He("model:changed",{reason:j[1]})}}#ue(A,L){const G=A&&A.leaves?A.leaves.length:this.#m.slots.length;this.#m.matchCount=G,this.#m.grand=L&&L.grand||null,this.#m.grandLeaves=A&&A.leaves?A.leaves.length:0,this.#m.groupLeaves=A&&A.leaves?A.leaves:null}#I(A,L,G){const q=this.#l.get(A),Y=L();return q.computed&&q.key===Y||(q.result=G(),q.key=Y,q.computed=!0,q.id++,A==="flatten"&&(this.#$=null)),q.result}#D(A){return this.#l.get(A).id}#ce(){const A=(this.#e.config||{}).hostFilter,L=A&&_(A.active)&&A.active()?1:0,G=this.#K("where",null),q=G?G.version:0,Y=this.#bt("filter.sig",`${this.#ct()}`,()=>u({filters:this.#K("filters",null),quick:this.#K("quick",""),quickMode:this.#K("quickMode","contains")}));return`${this.#c}|${Y}|${L}|${q}`}#fe(){const A=this.#v();return`${this.#D("filter")}|${JSON.stringify(this.#K("sort",[]))}`+(A?`|manual:${A.version}`:"")}#v(){const A=this.#K("rowOrder",null);return A&&Array.isArray(A.keys)?A:null}#Se(A,L){this.#p||this.#Q();const G=this.#p,q=this.#at(),Y=L.keys.length,J=new Float64Array(q);for(let te=0;te<q;te++)J[te]=Y+te;for(let te=0;te<Y;te++){const ne=G.get(L.keys[te]);ne!==void 0&&(J[ne]=te)}return Uint32Array.from(A).sort((te,ne)=>J[te]-J[ne])}orderedKeys(){this.#p||this.#Q();const A=this.#p,L=new Map;for(const[te,ne]of A)L.set(ne,te);const G=Uint32Array.from([...L.keys()]).sort(),q=this.#v(),Y=q?this.#Se(G,q):this.#Ce(G),J=new Array(Y.length);for(let te=0;te<Y.length;te++)J[te]=L.get(Y[te]);return J}#Be(){const A=this.#K("pivotBy",[]).length>0?"p":"u";return`${this.#D("sort")}|${JSON.stringify(this.#K("groupBy",[]))}|${A}`}#Ge(){const A=this.#Ue()?"f":"a",L=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#D("group")}|${JSON.stringify(this.#K("totals",[]))}|${A}${L}|${this.#u}`}#Ke(){return`${this.#D("group")}|${JSON.stringify(this.#K("pivotBy",[]))}`}#Pe(){const L=this.#Qe()||!this.#oe()?this.#D("total"):"x",G=`${this.#ct()}`,q=this.#bt("flatten.keys",G,()=>{const J=this.#K("expanded",null);return J?[...J].sort().join(""):"*"}),Y=this.#bt("flatten.detail",G,()=>{const J=this.#K("detail",null);return J&&_(J.signature)?J.signature():""});return`${L}|${this.#D("pivot")}|${q}|${Y}`}#Qe(){const A=this.#K("groupBy",[]);return Array.isArray(A)&&A.length>0}stageState(){const A=[];for(const[L,G]of this.#l){const q=G.result;A.push({stage:L,materialised:!!G.computed,bytes:q&&typeof q.byteLength=="number"?q.byteLength:null,rows:q&&typeof q.length=="number"?q.length:null,rebuilds:G.id})}return A}facetIndices(A){return this.#ye(A||null)}facetRows(A){const L=this.facetIndices(A),G=[];for(let q=0;q<L.length;q++){const Y=this.#Te(L[q]);Y&&G.push(Y)}return G}invalidateRows(){this.#h.clear(),this.#N.clear(),this.#$=null}invalidateHandles(){this.#s.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Ie()}filteredIndices(){const A=this.#l.get("filter");if(A&&A.computed&&A.key===this.#ce())return A.result||this.#Ie();this.#q();const L=this.#l.get("filter");return(L&&L.computed?L.result:null)||this.#Ie()}unfilteredRows(){const A=this.#Ie(),L=[];for(let G=0;G<A.length;G++){const q=this.#Te(A[G]);q&&L.push(q)}return L}#ye(A=null){const L=this.#Ie(),G=this.#K("filters",null),q=A?this.#De("pruneColumn")(G,A):G,Y=this.#Ft(q),J=String(this.#K("quick","")||"").trim().toLowerCase(),te=J?D(J,String(this.#K("quickMode","contains")||"contains")):null,ne=(this.#e.config||{}).hostFilter,oe=!!(ne&&_(ne.active)&&ne.active()),le=this.#K("where",null),ae=!!(le&&le.active);if(!Y&&!J&&!oe&&!ae)return L;let se=null;Y&&(se=this.#De("evaluateFilters")(Y,{handle:he=>this.#s.handle(he),count:this.#at(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:he=>x(this.#ze(he))}));const ee=new Uint32Array(L.length);let ie=0;for(let ce=0;ce<L.length;ce++){const he=L[ce];if(!(se&&!se[he])&&!(te&&!this.#nt(he,te))){if(oe||ae){const me=this.#Te(he);if(oe&&!ne.passes(me)||ae&&!le.passes(me.data,me.key))continue}ee[ie++]=he}}if(se){const ce=(this.#e.compute||{}).releaseMask;_(ce)&&ce({pool:this.#e.pool},se)}return ee.subarray(0,ie)}handleFor(A){return this.#s.handle(A)}#Ce(A){const L=this.#v();if(L)return this.#Se(A,L);const G=this.#K("sort",[]).filter(J=>{const te=this.#ze(J.col);return!te||!te.running?!0:(B(`source.sort.running.${J.col}`,`sort ignores "${J.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(!G.length)return A;const q=(this.#e.config||{}).locale;if(G.length===1){const J=G[0],te=this.#s.handle(J.col);if(!te)return B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`),A;const ne=this.#ze(J.col);return this.#De("sortColumn")(te,A,{descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:q,compare:O(ne)})}const Y=[];for(const J of G){const te=this.#s.handle(J.col);if(!te){B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`);continue}Y.push({handle:te,descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:q,compare:O(this.#ze(J.col))})}return Y.length?this.#De("sortMulti")(Y.map(J=>J.handle),Y,A):A}#We(A){const L=this.#K("groupBy",[]),G=this.#we();if(G&&!L.length){const ce=h(A,G);return this.#x=p(ce.roots,G.declaresChildren),{roots:null,leaves:A,nodes:new Map,tree:ce}}if(this.#x=null,G&&L.length&&B("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!L.length)return{roots:null,leaves:A,nodes:new Map};const q=(this.#e.config||{}).timeZone,Y=[],J=[];let te=!1;for(const ce of L){const he=this.#s.handle(ce);if(!he){B(`source.group.${ce}`,`grouping ignores unknown column "${ce}".`);continue}Y.push(he);const me=this.#ze(ce),Ee=me&&me.dataType;if(Ee&&_(Ee.groupProjector)){const ge=me.typeOptions&&me.typeOptions.timeZone||q||void 0,je=Ee.groupProjector(me,ge);J.push(je||null),je&&(te=!0)}else J.push(null)}if(!Y.length)return{roots:null,leaves:A,nodes:new Map};const{keys:ne,buckets:oe}=this.#De("groupByColumns")(Y,A,{locale:(this.#e.config||{}).locale,project:te?J:void 0}),le=this.#K("pivotBy",[]).length>0,ae=[],se=new Map;for(let ce=0;ce<oe.length;ce++){const he=ne[ce];let me=null;const Ee=[];for(let ge=0;ge<he.length;ge++){Ee.push(w(he[ge]));const je=z(Ee),pe=ge===he.length-1;let we=se.get(je);if(!we){const ye=this.#i.group({path:[...Ee],column:L[ge],value:he[ge],level:ge,parent:me,expanded:le&&pe?!1:this.#gt(je,{key:je,column:L[ge],value:he[ge],level:ge,path:[...Ee]}),hasChildren:!(le&&pe)});we={row:ye,leaves:null},se.set(je,we),me?me.children.push(ye):ae.push(ye)}we.row.leafCount+=oe[ce].length,ge===he.length-1&&(we.leaves=oe[ce]),me=we.row}}const ee=this.#K("sort",[])||[],ie=(ce,he)=>{if(!ce||ce.length<2){if(ce)for(const je of ce)ie(je.children,he+1);return}const me=L[he],Ee=ee.find(je=>je.col===me),ge=Ee&&Ee.dir==="desc"?-1:1;ce.sort((je,pe)=>ge*X(je.groupValue,pe.groupValue));for(const je of ce)ie(je.children,he+1)};return ie(ae,0),{roots:ae,leaves:A,nodes:se,keys:ne,buckets:oe}}#_e(A,L){const G=new Map,q=new Map,Y=J=>{const te=J.physical>=0?[J.physical]:[];for(const ne of J.children)te.push(...Y(ne));if(J.children.length){const ne=this.#Ze(L,Uint32Array.from(te),null);J.physical>=0?G.set(J.physical,ne):q.set(J.key,ne)}return te};for(const J of A.roots)Y(J);return{byPhysical:G,byKey:q}}#Fe(A){const L=this.#ut();if(!L.length)return this.#M=null,this.#C=null,{grand:null};const G={id:this.#D("group"),columns:L.map(ee=>ee.id).join("")},q=this.#M&&this.#M.id===G.id&&this.#M.columns===G.columns,Y=this.#ot()&&q?this.#T:null,J=Y?L.filter(ee=>Y.has(ee.id)):L,te=q?this.#C:null,ne=this.#Ue()?null:this.#P(),oe=this.#be(L),le=ee=>{const ie=A.nodes.get(ee.key);let ce=ie&&ie.leaves?ie.leaves:null;if(ee.children&&ee.children.length){const Ee=ee.children.map(le);let ge=0;for(const we of Ee)ge+=we.length;const je=new Uint32Array(ge);let pe=0;for(const we of Ee)je.set(we,pe),pe+=we.length;ce=je}ce=ce||new Uint32Array(0);const he=ne?ne.get(ee.key)||P:ce,me=this.#ft(ee,Y?J:L,he,oe);return ee.totals=Y?{...ee.totals,...me}:me,ce};if(A.roots&&J.length)for(const ee of A.roots)le(ee);if(this.#B=A.tree?this.#_e(A.tree,L):null,this.#M=G,this.#T=this.#ot()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#O.length=0,this.#C=null,{grand:null};const se=ne?this.#mt():A.leaves;return this.#C=this.#Je(L,se,Y,te),{grand:this.#C}}#Je(A,L,G,q){const Y={},J=this.#D("group");J!==this.#y&&(this.#$e(),this.#y=J);const te=this.#O;this.#O=[];for(const ne of A){if(!R(ne))continue;const oe=this.#s.handle(ne.id);if(!oe)continue;const le=v(ne,"grand");if(!t(le,oe)){if(G&&!G.has(ne.id)&&q&&ne.id in q){Y[ne.id]=q[ne.id];continue}Y[ne.id]=this.#Ze([ne],L,null,"grand")[ne.id];continue}let ae=this.#S.get(ne.id);if((!ae||ae.fn!==le)&&(ae=new n(le),this.#S.set(ne.id,ae)),ae.valid){let se=!0;for(const ee of te)if(ee.colId===ne.id&&!ae.update(ee.before,ee.after)){se=!1;break}if(se){Y[ne.id]=ae.value();continue}ae.invalidate()}ae.seedColumn(oe.values,o(oe),L),Y[ne.id]=ae.valid?ae.value():this.#Ze([ne],L,null,"grand")[ne.id]}return Y}#be(A){const L=this.#D("group");L!==this.#A&&(this.#k.clear(),this.#A=L);const G=new Map;for(const Y of A){if(!R(Y))continue;const J=this.#s.handle(Y.id),te=v(Y,"group");t(te,J)&&G.set(Y.id,{fn:te})}if(!G.size)return this.#j.length=0,G;const q=this.#j;this.#j=[];for(const Y of q){const{beforeKeys:J,afterKeys:te,colDeltas:ne}=Y,oe=J.length?new Set(J):null,le=te.length?new Set(te):null;for(const{colId:ae,before:se,after:ee}of ne)if(G.has(ae)){for(const ie of J)le&&le.has(ie)||this.#W(ie,ae,se,null);for(const ie of te)oe&&oe.has(ie)||this.#W(ie,ae,null,ee);for(const ie of J)le&&!le.has(ie)||this.#W(ie,ae,se,ee)}}return G}#W(A,L,G,q){const Y=this.#k.get(A),J=Y&&Y.get(L);!J||!J.valid||J.update(G,q)||J.invalidate()}#ft(A,L,G,q){if(!q||!q.size)return this.#Ze(L,G,A);const Y={};let J=null,te=this.#k.get(A.key);for(const ne of L){const oe=q.get(ne.id);if(!oe){(J||(J=[])).push(ne);continue}const le=this.#s.handle(ne.id);if(!le)continue;te||(te=new Map,this.#k.set(A.key,te));let ae=te.get(ne.id);if((!ae||ae.fn!==oe.fn)&&(ae=new n(oe.fn),te.set(ne.id,ae)),ae.valid||ae.seedColumn(le.values,o(le),G),ae.valid){Y[ne.id]=ae.value();continue}(J||(J=[])).push(ne)}return J&&Object.assign(Y,this.#Ze(J,G,A)),Y}#Ct(A,L,G,q){const Y=!this.#Ue()||this.#it(L);for(const J of A){const te=J.getValue;if(!_(te))continue;const ne=te(G),oe=te(q);Object.is(ne,oe)||(this.#T&&this.#T.add(J.id),Y&&this.#S.has(J.id)&&this.#O.push({colId:J.id,before:ne,after:oe}))}}#ht(){const A=this.#K("groupBy",[]),L=[];for(const G of A){const q=this.#ze(G);q&&L.push(q)}return L}#pt(A,L){const G=new Array(A.length);for(let q=0;q<A.length;q++){const Y=A[q].getValue;G[q]=w(_(Y)?Y(L):void 0)}return G}#et(A,L,G,q,Y){if(this.#Ue()&&!this.#it(G))return;const J=k(this.#pt(A,q)),te=k(this.#pt(A,Y)),ne=J.length!==te.length||J.some((le,ae)=>le!==te[ae]),oe=[];for(const le of L){const ae=le.getValue;if(!_(ae))continue;const se=ae(q),ee=ae(Y);!ne&&Object.is(se,ee)||oe.push({colId:le.id,before:se,after:ee})}!oe.length&&!ne||this.#j.push({beforeKeys:J,afterKeys:te,colDeltas:oe})}#it(A){const L=this.#l.get("filter"),G=L&&L.computed?L.result:null;if(!G)return!0;let q=0,Y=G.length-1;for(;q<=Y;){const J=q+Y>>1,te=G[J];if(te===A)return!0;te<A?q=J+1:Y=J-1}return!1}#Ue(){return(this.#e.config||{}).totalFilteredOnly!==!1}#tt(A){return this.#Ue()?A:this.#mt().length}#mt(){return(!this.#E||this.#E.version!==this.#c)&&(this.#E={version:this.#c,indices:this.#Ie()}),this.#E.indices}#P(){const A=this.#K("groupBy",[]),L=`${this.#c}|${JSON.stringify(A)}`;if(this.#L&&this.#L.key===L)return this.#L.map;const G=new Map,q=[];for(const Y of A){const J=this.#s.handle(Y);J&&q.push(J)}if(q.length){const Y=this.#mt(),{keys:J,buckets:te}=this.#De("groupByColumns")(q,Y,{locale:(this.#e.config||{}).locale}),ne=new Map;for(let oe=0;oe<te.length;oe++){const le=J[oe],ae=[];for(let se=0;se<le.length;se++){ae.push(w(le[se]));const ee=z(ae);let ie=ne.get(ee);ie||(ie=[],ne.set(ee,ie));for(let ce=0;ce<te[oe].length;ce++)ie.push(te[oe][ce])}}for(const[oe,le]of ne)G.set(oe,Uint32Array.from(le))}return this.#L={key:L,map:G},G}#ot(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#xe(){this.#$e(),this.#Ee(),this.#T=null,this.#M=null,this.#C=null}#$e(){this.#S.clear(),this.#O.length=0,this.#y=-1}#Ee(){this.#k.clear(),this.#j.length=0,this.#A=-1}#Ve(A){const L=this.#K("pivotBy",[]);if(!L.length)return this.#re=null,null;const G=(this.#e.compute||{}).pivot;if(!_(G))return B("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#re=null,null;const q=L.map(J=>this.#s.handle(J)).filter(Boolean),Y=this.#ut();return this.#re=G(q,A.leaves,{groups:A.keys&&A.buckets?{keys:A.keys,buckets:A.buckets}:null,totals:Y.map(J=>J.id),handle:J=>this.#s.handle(J),totalOf:J=>v(Y.find(te=>te.id===J),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#re}#st(A){const L=this.#l.get("total").result,G=!!(this.#e.config||{}).groupFooter,q=this.#Me();if(A.tree)return this.#lt(A,L,q);if(!A.roots&&!q){if(L&&L.grand&&!this.#oe()){const le=this.#i.grandTotal(L.grand,this.#tt(A.leaves.length));if(this.#_===A.leaves&&Array.isArray(this.#z))this.#z[this.#z.length-1]=le;else{const ae=Array.from(A.leaves);ae.push(le),this.#z=ae,this.#_=A.leaves}this.#le=[{at:this.#z.length-1}]}else this.#_=null,this.#z=A.leaves,this.#le=y;return this.#Y=y,this.#z}const Y=[],J=[],te=[],ne=le=>{if(Y.push(le),!q)return;const ae=this.#Te(le);!ae||!q.isOpen(ae.key)||(ae.master=!0,ae.expanded=!0,te.push({at:Y.length}),Y.push(this.#i.detail(ae,q.heightOf(ae))))};if(!A.roots){for(let le=0;le<A.leaves.length;le++)ne(A.leaves[le]);return L&&L.grand&&!this.#oe()&&(te.push({at:Y.length}),Y.push(this.#i.grandTotal(L.grand,this.#tt(A.leaves.length)))),this.#_=null,this.#Y=y,this.#le=te.length?te:y,this.#z=Y,Y}const oe=(le,ae,se)=>{if(le.expanded=le.hasChildren===!1?!1:this.#gt(le.key,{key:le.key,column:le.groupColumn,value:le.groupValue,level:le.level,path:le.groupPath}),le.posinset=ae+1,le.setsize=se,J.push({at:Y.length,row:le}),te.push({at:Y.length}),Y.push(le),!!le.expanded){if(le.children&&le.children.length)for(let ee=0;ee<le.children.length;ee++)oe(le.children[ee],ee,le.children.length);else{const ee=A.nodes.get(le.key),ie=ee&&ee.leaves?ee.leaves:null;if(ie)for(let ce=0;ce<ie.length;ce++)ne(ie[ce])}G&&le.totals&&(te.push({at:Y.length}),Y.push(this.#i.footer(le)))}};for(let le=0;le<A.roots.length;le++)oe(A.roots[le],le,A.roots.length);return L&&L.grand&&!this.#oe()&&(te.push({at:Y.length}),Y.push(this.#i.grandTotal(L.grand,this.#tt(A.leaves.length)))),this.#Y=J,this.#le=te,this.#z=Y,Y}#Ie(){const A=this.#e.store;if(A&&_(A.liveIndices))return A.liveIndices();const L=new Uint32Array(this.#n.length);let G=0;for(let q=0;q<this.#n.length;q++)this.#n[q]!==void 0&&(L[G++]=q);return L.subarray(0,G)}#at(){const A=this.#e.store;return A&&typeof A.physical=="number"?A.physical:this.#n.length}#Ne(A){const L=this.#e.store;return L&&_(L.source)?L.source(A):this.#n[A]}#qe(A,L=A){const G=this.#z[A];if(typeof G!="number")return G.index=L,G;const q=this.#Te(G);return q.index=L,q}#Te(A){let L=this.#h.get(A);L||(L=this.#i.leaf(this.#Ne(A),A),this.#h.set(A,L));const G=this.#x?this.#x.get(A):null;if(G){L.level=G.level,L.posinset=G.posinset,L.setsize=G.setsize,L.hasChildren=G.hasChildren,L.expanded=G.hasChildren&&!G.lazy&&this.#gt(L.key);const q=this.#B?this.#B.byPhysical.get(A):void 0;q?L.totals=q:L.totals&&(L.totals=null)}else L.hasChildren&&(L.level=0,L.hasChildren=!1,L.expanded=!1,L.posinset=void 0,L.setsize=void 0);return L}#lt(A,L,G){const q=[],Y=[],J=ne=>{if(ne.leafCount!==void 0)return ne.leafCount;let oe=ne.physical>=0?1:0;for(const le of ne.children)oe+=J(le);return ne.leafCount=oe,oe},te=ne=>{const oe=this.#gt(ne.key);if(ne.physical>=0){if(q.push(ne.physical),G&&G.isOpen(this.#Te(ne.physical).key)){const le=this.#Te(ne.physical);Y.push({at:q.length}),q.push(this.#i.detail(le,G.heightOf(le)))}}else q.push(this.#i.group({path:[ne.key],column:null,value:ne.value,level:ne.level,parent:null,expanded:oe,hasChildren:ne.children.length>0,leafCount:J(ne),totals:this.#B?this.#B.byKey.get(ne.key):void 0}));if(oe)for(const le of ne.children)te(le)};for(const ne of A.tree.roots)te(ne);return L&&L.grand&&!this.#oe()&&(Y.push({at:q.length}),q.push(this.#i.grandTotal(L.grand,this.#tt(A.leaves.length)))),this.#_=null,this.#Y=y,this.#le=Y.length?Y:y,this.#z=q,q}#Lt(){return g(()=>this.count(),A=>this.at(A))}#nt(A,L){let G=this.#N.get(A);if(G===void 0){const q=this.#Ne(A),Y=this.#rt(),J=[],te=this.#e.columnHidden;for(const ne of Y){if(ne.quickFilter===!1||_(te)&&te(ne.id))continue;const oe=ne.value&&_(ne.value.quickFilterText)?ne.value.quickFilterText({value:void 0,data:q,row:null,column:ne,colId:ne.id,grid:null,context:this.#K("context",null)}):null,le=oe??(_(ne.formatValue)?ne.formatValue(_(ne.getValue)?ne.getValue(q):void 0):"");le!=null&&le!==""&&J.push(String(le))}G=J.join(" ").toLowerCase(),this.#N.set(A,G)}return L(G)}#ut(){const A=this.#K("totals",[]),L=A&&A.length?new Set(A):null;return this.#rt().filter(G=>L?L.has(G.id):!!(G.total||G.groupTotal||G.grandTotal))}#Ze(A,L,G,q="group"){const Y={},J=(this.#e.compute||{}).total;for(const te of A){if(!R(te))continue;const ne=this.#s.handle(te.id);if(!ne)continue;const oe=v(te,q);if(oe)if(_(oe)){const le=new Array(L.length);for(let ae=0;ae<L.length;ae++)le[ae]=ne.get(L[ae]);Y[te.id]=oe(le,{row:G,column:te,grid:this.#e.grid||null,context:this.#K("context",null),valueAt:(ae,se)=>{const ee=this.#s.handle(ae);return ee&&se>=0&&se<L.length?ee.get(L[se]):null}})}else _(J)&&(Y[te.id]=J(ne,L,oe))}return Y}#Ft(A){if(!A)return A;const L=this.#e.config||{},G={tz:L.timeZone,weekStartsOn:L.weekStartsOn};return i(A,q=>{const Y=m(q,G),J=this.#ze(Y&&Y.col),te=J&&J.type==="datetime";if(Y&&Y.type)return Y.type==="datetime"&&!Y.timeZone&&J?{...Y,timeZone:L.timeZone||void 0}:Y;if(te)return{...Y,type:"datetime",timeZone:L.timeZone||void 0};const ne=J&&(J.dataType?.base||J.type);return ne?{...Y,type:ne}:Y})}#gt(A,L){const G=this.#K("expanded",null);return G?_(G.has)?G.has(A,L):Array.prototype.includes.call(G,A):!0}#K(A,L){if(A==="context"||!_(this.#e.stateVersion))return this.#Et(A,L);const G=this.#yt(A),q=this.#d.get(A);if(q&&q.version===G)return q.value;const Y=this.#Et(A,L);return this.#d.set(A,{version:G,value:Y}),Y}#Et(A,L){const G=this.#e.state;if(G&&_(G[A])){const q=G[A]();return q??L}return L}#ct(){const A=this.#e.stateVersion;return _(A)?A():0}#St(){const A=this.#e.columnsVersion,L=this.#e.permissionsVersion;return`${_(A)?A():0}|${_(L)?L():0}`}#yt(A){return A==="totals"?this.#St():`${this.#ct()}`}#bt(A,L,G){if(!_(this.#e.stateVersion))return G();const q=this.#f.get(A);if(q&&q.version===L)return q.key;const Y=G();return this.#f.set(A,{version:L,key:Y}),Y}#De(A){const L=(this.#e.compute||{})[A];return _(L)||I(`ctx.compute.${A} is required by the memory source pipeline`),L}#rt(){const A=this.#e.columns;return A&&_(A.all)?A.all():[]}#ze(A){const L=this.#e.columns;return L&&_(L.get)?L.get(A):void 0}#He(A,L){const G=this.#e.emit;_(G)&&G(A,L)}}}),Fe("packages/core/src/source/abort.js",function(e,K){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return _}});class Q extends Error{constructor(W,H="superseded"){super(`[lattice] request ${W?`"${W}" `:""}${H}`),this.name="SupersededError",this.superseded=!0,this.key=W}}class ${#e;constructor(W,H,U,z){this.#e=W,this.key=H,this.controller=U,this.signal=U.signal,this.seq=z}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(W){this.signal.aborted||this.controller.abort(new Q(this.key,W)),this.#e.settle(this)}}class B{#e=new Map;#t=0;begin(W="",H="superseded"){const U=this.#e.get(W);U&&!U.signal.aborted&&U.controller.abort(new Q(W,H));const z=new $(this,W,new AbortController,++this.#t);return this.#e.set(W,z),z}tokenFor(W){return this.#e.get(W)}pending(W=""){const H=this.#e.get(W);return!!H&&!H.signal.aborted}get size(){return this.#e.size}settle(W){this.#e.get(W.key)===W&&this.#e.delete(W.key)}abort(W="",H="superseded"){const U=this.#e.get(W);U&&U.abort(H)}abortAll(W="superseded"){for(const H of[...this.#e.values()])H.abort(W);this.#e.clear()}}function I(){return new B}function _(X){if(!X||typeof X!="object")return!1;const W=X;return W.superseded===!0||W.name==="AbortError"||W.name==="SupersededError"}}),Fe("packages/core/src/source/blockcache.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return I}});const Q=100,$=32;class B{constructor(X){this.id=X,this.rows=null,this.state="pending",this.token=null,this.error=null}}class I{#e=new Map;#t;#n;#r=0;#o=-1;constructor(X={}){this.#t=Math.max(1,Math.floor(Number(X.pageSize)||Q)),this.#n=Math.max(1,Math.floor(Number(X.maxCachedPages)||$))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(X){return Math.floor(X/this.#t)}rangeOf(X){return{start:X*this.#t,end:(X+1)*this.#t}}has(X){return this.#e.has(X)}pending(X){const W=this.#e.get(X);return!!W&&W.state==="pending"}loaded(X){const W=this.#e.get(X);return!!W&&W.state==="loaded"}begin(X,W){let H=this.#e.get(X);return H||(H=new B(X)),H.state="pending",H.token=W,H.error=null,this.#i(X,H),H}fill(X,W){const H=this.#e.get(X)||new B(X);H.rows=W,H.state="loaded",H.token=null,this.#i(X,H)}failed(X,W){const H=this.#e.get(X)||new B(X);H.state="error",H.error=W,H.token=null,this.#i(X,H)}delete(X){return this.#e.delete(X)}rowAt(X){const W=this.blockOf(X),H=this.#e.get(W);if(!(!H||H.state!=="loaded"||!H.rows))return this.#i(W,H),H.rows[X-W*this.#t]}rowLoaded(X){const W=this.blockOf(X),H=this.#e.get(W);return!!H&&H.state==="loaded"&&!!H.rows&&X-W*this.#t<H.rows.length}erroredAt(X){const W=this.#e.get(this.blockOf(X));return!!W&&W.state==="error"}loadedExtent(){let X=0;for(const W of this.#e.values()){if(W.state!=="loaded"||!W.rows)continue;const H=W.id*this.#t+W.rows.length;H>X&&(X=H)}return X}fillOf(X){const W=this.#e.get(X);return W&&W.state==="loaded"&&W.rows?W.rows.length:null}protect(X,W){this.#r=this.blockOf(Math.max(0,X)),this.#o=this.blockOf(Math.max(0,W))}evict(){const X=[];if(this.#e.size<=this.#n)return X;for(const[W,H]of this.#e){if(this.#e.size-X.length<=this.#n)break;W>=this.#r&&W<=this.#o||H.state!=="pending"&&X.push(W)}for(const W of X)this.#e.delete(W);return X}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(X,W){this.#e.delete(X),this.#e.set(X,W)}}}),Fe("packages/core/src/source/pagewindow.js",function(e,K){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return Q}});function Q($,B,I,_){const X=Math.floor(Number($)||0);if(X<=0)return null;const W=Math.max(0,Math.floor(Number(B)||0)),H=Math.max(0,Math.floor(Number(I)||0));if(_){const U=Math.max(1,Math.ceil(H/X)),z=Math.min(W,U-1),w=z*X;return{page:z,pageSize:X,offset:w,length:Math.max(0,Math.min(X,H-w)),pageCount:U,total:H}}return{page:W,pageSize:X,offset:W*X,length:X,pageCount:Math.max(W+2,Math.ceil(H/X)),total:null}}}),Fe("packages/core/src/source/paged.js",function(e,K){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return i}});const Q=K("packages/core/src/internal/util.js"),$=Q.Lru,B=Q.isFunction,I=Q.warnOnce,_=Q.settleDebounce,X=K("packages/core/src/source/abort.js"),W=X.createAbortScope,H=X.isAbortError,U=K("packages/core/src/source/blockcache.js"),z=U.BlockCache,w=U.DEFAULT_PAGE_SIZE,k=U.DEFAULT_MAX_CACHED_PAGES,l=K("packages/core/src/source/rows.js").createRowFactory,c=K("packages/core/src/source/filterwire.js"),s=c.wireFilters,n=c.querySignature,t=c.warnHostFilterNotApplied,o=K("packages/core/src/source/pagewindow.js").pageWindow,f=120;function u(m,d){return new i(m,d)}class i{mode="paged";#e;#t;#n;#r=W();#o;#i;#s=new Map;#l=null;#a=null;#u=!1;#c=0;#d="";#f={start:0,end:0};#h;#p=!1;#m=0;#g="";constructor(d,h){this.#e=d||{mode:"paged"},this.#t=h||{},this.#n=new z({pageSize:this.#e.pageSize||w,maxCachedPages:this.#e.maxCachedPages||k}),this.#o=l(this.#t),this.#i=new $(this.#n.pageSize*4),this.#h=_((a,p)=>this.#y(a,p),f),this.#d=this.#T(),B(this.#e.fetch)||I("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),t(this.#t)}count(){const d=this.#w();return d?d.length:this.#b()}#b(){if(this.#A(),this.#l!==null)return this.#l;const d=Math.max(this.#c,this.#n.loadedExtent());return this.#u?d:d+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const d=this.#w();if(!d){const h=this.#b();return{page:0,pageSize:0,total:this.exact()?h:null,pageCount:1,counting:!1}}return{page:d.page,pageSize:d.pageSize,total:d.total,pageCount:d.pageCount,counting:d.total===null&&this.#r.size>0&&this.#c===0&&this.#n.loadedExtent()===0}}#w(){const d=this.#b(),h=o(this.#C("pageSize",0),this.#C("page",0),d,this.exact());if(!h)return this.#g="",null;const a=`${this.#m}:${h.offset}:${h.length}`;if(a!==this.#g&&!this.#p&&(this.#g=a,h.length>0)){const p=h.offset+h.length-1;this.#f={start:h.offset,end:p},this.#y(h.offset,p)}return h}at(d){const h=this.#w();if(h){if(d<0||d>=h.length)return;const a=this.#S(h.offset+d);return a&&(a.index=d),a}return this.#S(d)}#S(d){if(d<0||d>=this.#b())return;const h=this.#i.get(d);if(h&&(h.data!==null||!this.#n.rowLoaded(d)))return h;const a=this.#n.rowAt(d);if(a===void 0){const b=this.#o.skeleton(d,0,this.#n.erroredAt(d));return this.#i.set(d,b),b}const p=this.#o.leaf(a,d);return p.index=d,this.#i.set(d,p),this.#s.set(p.key,d),p}byKey(d){const h=this.#s.get(d);return h===void 0?void 0:this.#S(h)}loaded(d){const h=this.#w();return h?d>=0&&d<h.length&&this.#n.rowLoaded(h.offset+d):this.#n.rowLoaded(d)}loadedCount(){this.#A();let d=0;for(const h of this.#n.ids()){if(!this.#n.loaded(h))continue;const a=this.#n.fillOf(h);typeof a=="number"&&(d+=a)}return d}residentRows(){this.#A();const d=this.#w(),h=d?d.offset:0,a=d?d.offset+d.length:1/0,p=[],b=this.#n.ids().sort((j,S)=>j-S);for(const j of b){if(!this.#n.loaded(j))continue;const{start:S}=this.#n.rangeOf(j),y=this.#n.fillOf(j)||0;for(let v=S;v<S+y;v++){if(v<h||v>=a)continue;const R=this.#i.peek(v);if(R&&R.data!==null&&R.data!==void 0){p.push(R);continue}const O=this.#n.rowAt(v);if(O===void 0)continue;const x=this.#o.leaf(O,v);x.index=v,this.#i.set(v,x),this.#s.set(x.key,v),p.push(x)}}return p}hint(d,h){if(this.#p)return;const a=this.#A();let p=Math.max(0,Math.floor(d)),b=Math.max(p,Math.floor(h));const j=this.#w();if(j){if(j.length===0)return;p=j.offset,b=j.offset+j.length-1}this.#f={start:p,end:b},this.#n.protect(p,b);for(const S of this.#n.evict())this.#k(S);this.#h(p,b),a&&this.#h.flush()}#y(d,h){if(this.#p)return;this.#n.protect(d,h);const a=this.#n.blockOf(d),p=this.#n.blockOf(h);for(let b=a;b<=p&&!(this.#l!==null&&b*this.#n.pageSize>=this.#l);b++)this.#n.has(b)||this.#O(b)}apply(d){const h={added:[],updated:[],removed:[]};if(!d)return h;if(d.update)for(const a of d.update){const p=this.#o.keyOf(a,-1),b=this.#s.get(p);if(b===void 0)continue;const j=this.#o.leaf(a,b);j.index=b,this.#i.set(b,j),h.updated.push(j)}return(d.add&&d.add.length||d.remove&&d.remove.length)&&this.reload(),h}reload(d){this.#j("reload"),this.#h.cancel(),this.hint(this.#f.start,this.#f.end)}destroy(){this.#p=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#s.clear()}exact(){return this.#l!==null||this.#u}pending(){return this.#r.size}async#O(d){if(!B(this.#e.fetch))return;const h=this.#r.begin(`block:${d}`);this.#n.begin(d,h);const{start:a,end:p}=this.#n.rangeOf(d),b=this.#d;try{const j=await this.#e.fetch({range:{start:a,end:p},sort:this.#C("sort",[]),filters:s(this.#C("filters",null),this.#M()),quick:this.#C("quick","")||void 0,context:this.#C("context",null),signal:h.signal});if(!h.current||b!==this.#d||this.#p)return;h.settle();const S=j&&j.rows||[];this.#n.fill(d,S);for(let v=0;v<S.length;v++)this.#i.delete(a+v);const y=j&&typeof j.total=="number"?j.total:j&&typeof j.count=="number"?j.count:null;y!==null?(this.#l=y,this.#u=!0):S.length<this.#n.pageSize?(this.#u=!0,this.#l=a+S.length):this.#c=Math.max(this.#c,a+S.length),this.#E("model:changed",{reason:"page",block:d,from:a,to:a+S.length}),this.#E("rows:changed",{companion:!0,reason:"page",block:d,from:a,to:a+S.length}),this.#l!==null&&this.#l!==this.#a&&(this.#a=this.#l,this.#E("source:total",{total:this.#l,groupPath:[]}))}catch(j){if(h.settle(),H(j))return;this.#n.failed(d,j);for(let S=a;S<p;S++)this.#i.delete(S);this.#E("model:changed",{reason:"page-error",block:d,range:{start:a,end:p}}),this.#E("source:error",{error:j,block:d,range:{start:a,end:p}})}}#k(d){const{start:h,end:a}=this.#n.rangeOf(d);for(let p=h;p<a;p++){const b=this.#i.peek(p);b&&this.#s.delete(b.key),this.#i.delete(p)}}#A(){const d=this.#T();return d===this.#d?!1:(this.#d=d,this.#j("query"),!0)}#j(d){this.#r.abortAll(d),this.#n.clear(),this.#i.clear(),this.#s.clear(),this.#l=null,this.#a=null,this.#u=!1,this.#c=0,this.#m++,this.#E("model:changed",{reason:d})}#T(){return n({filters:this.#C("filters",null),sort:this.#C("sort",[]),quick:this.#C("quick",""),context:this.#C("context",null)})}#M(){const d=this.#t.config||{};return{tz:d.timeZone,weekStartsOn:d.weekStartsOn}}#C(d,h){const a=this.#t.state;if(a&&B(a[d])){const p=a[d]();return p??h}return h}#E(d,h){const a=this.#t.emit;B(a)&&a(d,h)}}}),Fe("packages/core/src/source/aggregates.js",function(e,K){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return U}});const Q=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 $(){const z=new Set;for(const[w,k]of Object.entries(Q))k.pushable&&z.add(w);return z}function B(z,w,k){let g=z.split("%c").join(w);return k!==void 0&&(g=g.split("%w").join(k)),g}function I(z){const w=z||{},k=w.default==="engine"||w.default==="engine-if-identical"?w.default:"client",g={};if(w.overrides&&typeof w.overrides=="object")for(const[l,c]of Object.entries(w.overrides))(c==="engine"||c==="client")&&(g[l]=c);return{default:k,overrides:g}}function _(z,w){const k=Q[z];if(!k||!k.pushable)return"client";const g=w.overrides[z];return g==="engine"||g==="client"?g:w.default==="client"?"client":w.default==="engine-if-identical"?k.class==="identical"?"engine":"client":"engine"}function X(z,w){const k=I(w),g=[],l=[];for(const c of z||[]){const s=Q[c.fn],n=_(c.fn,k),t={id:c.id,col:c.col,fn:c.fn,class:s?s.class:"fallback"};c.weight!==void 0&&(t.weight=c.weight),c.params!==void 0&&(t.params=c.params),n==="engine"?g.push(t):(t.reason=s&&!s.pushable?s.note||"the engine cannot express this stat":"client by config",l.push(t))}return{engine:g,client:l,config:k}}const W=/^[A-Za-z_][A-Za-z0-9_$]*$/;function H(z,w=[]){return(z||[]).every(g=>{if(typeof g=="string")return W.test(g);if(!g||typeof g!="object")return!1;const l=g;return Array.isArray(w)&&w.includes(l.bucket)&&typeof l.col=="string"&&W.test(l.col)&&typeof l.size=="number"&&Number.isFinite(l.size)&&l.size>0})}function U(){return Object.entries(Q).map(([z,w])=>({stat:z,class:w.class,sql:w.sql?B(w.sql,"col",w.twoColumn?"weight":void 0):"",note:w.note||(w.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Fe("packages/core/src/source/pushdown.js",function(e,K){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return A}});const Q=K("packages/core/src/internal/util.js"),$=Q.defaultCompare,B=Q.isFunction,I=Q.toArray,_=Q.warnOnce,X=K("packages/core/src/source/filterwire.js"),W=X.isGroup,H=X.warnWherePageRelative,U=X.warnWhereOverThreshold,z=K("packages/core/src/source/aggregates.js"),w=z.resolveAggregatePlan,k=z.groupKeysPushable,g=z.STAT_PUSHDOWN,c=K("packages/core/src/source/abort.js").SupersededError,s=1e3;function n(L){const G=L&&L.signal;if(!G||!G.aborted)return;const q=G.reason;throw q instanceof Error?q:new c("","superseded before it was sent")}const t=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function r(L){if(!L||typeof L!="object")return!1;const G=L.returning==="row"||L.returning==="key"?L.returning:"none";return{append:L.append===!0,update:L.update===!0,delete:L.delete===!0,returning:G}}function o(L,G){if(!L||typeof G!="string")return;if(!G.includes("."))return L[G];let q=L;for(const Y of G.split(".")){if(q===null||typeof q!="object")return;q=q[Y]}return q}function f(L){if(L===!0)return!0;if(!L||typeof L!="object")return!1;const G=L;return G.enabled===!1?!1:G.enabled===!0||B(G.commit)}function u(L){const G={...t,...L||{}};return G.operators=new Set(G.operators||[]),G.mutate=r(G.mutate),G}function i(L,G){return!L||!L.op||!G.operators.size?!1:G.operators.has(L.op)}function m(L,G){if(!L)return{pushed:null,residual:null};if(!G.filter)return{pushed:null,residual:L};if(G.filter==="term"){if(W(L)){const te=L.conditions||[];if(String(L.op)!=="and")return{pushed:null,residual:L};const ne=te.findIndex(le=>!W(le)&&i(le,G));if(ne<0)return{pushed:null,residual:L};const oe=te.filter((le,ae)=>ae!==ne);return{pushed:te[ne],residual:oe.length?{op:"and",conditions:oe}:null}}return i(L,G)?{pushed:L,residual:null}:{pushed:null,residual:L}}if(!W(L))return i(L,G)?{pushed:L,residual:null}:{pushed:null,residual:L};if(String(L.op)!=="and")return(L.conditions||[]).every(ne=>W(ne)?m(ne,G).residual===null:i(ne,G))?{pushed:L,residual:null}:{pushed:null,residual:L};const q=[],Y=[];for(const te of L.conditions||[]){if(W(te)){if(G.filter==="flat"){Y.push(te);continue}const ne=m(te,G);ne.pushed&&q.push(ne.pushed),ne.residual&&Y.push(ne.residual);continue}(i(te,G)?q:Y).push(te)}const J=te=>te.length===0?null:te.length===1?te[0]:{op:"and",conditions:te};return{pushed:J(q),residual:J(Y)}}const d="__lattice_leaves";function h(L){return L.aggregates?L.aggregates instanceof Set?L.aggregates:new Set(I(L.aggregates)):new Set}function a(L){const G=h(L);return G.size?G.has("count")?L.filter!=="tree"||!L.operators||!L.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 p(L,G,q,Y,J,te,ne){const oe=Array.isArray(L.groupBy)?L.groupBy:[],le=Array.isArray(L.groupPath)?L.groupPath:[],ae=Array.isArray(L.groupValues)?L.groupValues:null;if(!G.group){const se=a(G);if(se)return se}return k(oe)?q.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":Y?J?te?"a host `where` predicate can only run in the browser, over rows the engine grouped":ne?"fullDataset holds the whole matching set, so the grid groups it itself":!ae||ae.length!==le.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 b="pushdown:pivot-unsupported",j="pushdown:group-unsupported",S=Symbol("lattice.remote.ungroupedLevel");function y(L,G,q,Y,J,te){const ne=Array.isArray(L.pivotBy)?L.pivotBy:[],oe=Array.isArray(L.groupBy)?L.groupBy:[],le=Array.isArray(L.groupPath)?L.groupPath:[],ae=Array.isArray(L.groupValues)?L.groupValues:null;return G.pivot?k(ne)?oe.length&&!k(oe)?"a grouping key is not a plain column the engine can name in a GROUP BY":q.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":Y?J?te?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!ae||ae.length!==le.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 v(L,G,q=!1){const Y=m(L.filters||null,G),J=[];Y.residual&&J.push("filter");const te=L.sort||[],ne=te.length===0||G.sort==="multi"&&te.length>=1||G.sort==="single"&&te.length===1;!ne&&te.length&&J.push("sort");const oe=L.quick?String(L.quick):"",le=!oe||!!G.quick;le||J.push("quick");const ae=L.where&&L.where.active?L.where:null;ae&&J.push("where");const se={filters:Y.residual,sort:ne?null:te,quick:le?"":oe,where:ae},ee=!!q,ie=Array.isArray(L.groupBy)&&L.groupBy.length>0,ce=ie?p(L,G,Y,ne,le,ae,ee):"",he=L.pivotMode!==!1&&Array.isArray(L.pivotBy)&&L.pivotBy.length>0,me=he?y(L,G,Y,ne,le,ae):"",Ee=he&&me==="";he&&!Ee&&J.push("pivot");const ge=he?Ee&&ie:ie&&ce==="";ie&&!he&&!ge&&J.push("group");const je=(ge||Ee)&&Array.isArray(L.groupValues)?L.groupValues.length:0,pe=ge||he?!1:ee||!!(se.filters||se.sort||se.quick||se.where)||!G.range;return{pushed:{...L,filters:Y.pushed,sort:ne?te:[],quick:le?oe:"",range:pe?null:L.range},residual:se,needsAll:pe,unpushed:J,full:ee,grouped:ge,groupLevel:je,groupReason:he?"":ce,pivoted:Ee,pivotReason:me}}function R(L){const G=Array.isArray(L.totals)?L.totals:[],q=L.totalFns&&typeof L.totalFns=="object"?L.totalFns:{},Y=[],J=[];for(const te of G){const ne=String(te),oe=typeof q[ne]=="string"?q[ne]:null,le=oe?g[oe]:null;oe?!le||!le.pushable||!le.sql?J.push({id:ne,fn:oe,class:le?le.class:"fallback",reason:le&&le.note?le.note:`the pushdown map cannot express "${oe}"`}):le.twoColumn?J.push({id:ne,fn:oe,class:le.class,reason:`"${oe}" reduces two columns, and a grouped request carries no weight column`}):Y.push({id:ne,col:ne,fn:oe,class:le.class}):J.push({id:ne,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:Y,client:J}}const O=Object.freeze({items:L=>L==null?[]:Array.isArray(L)?L:[L]});function x(L,G,q){if(!G)return L;let Y=L;if(G.filters&&B(q.evaluateFilters)){const J=Y,te={count:Y.length,handle:le=>({id:le,get:ae=>o(J[ae],le)}),itemwise:le=>J.some(ae=>Array.isArray(o(ae,le)))?O:null},ne=q.evaluateFilters(G.filters,te),oe=[];for(let le=0;le<Y.length;le++)ne[le]&&oe.push(Y[le]);Y=oe}if(G.where&&G.where.active&&(G.whole||H(G.where.names,"pushdown"),Y=Y.filter(J=>G.where.passes(J))),G.quick){const J=G.quick.toLowerCase();Y=Y.filter(te=>{if(!te||typeof te!="object")return!1;for(const ne of Object.values(te))if(ne!=null&&String(ne).toLowerCase().includes(J))return!0;return!1})}if(G.sort&&G.sort.length&&B(q.sortMulti)){const J=[...new Set(G.sort.map(le=>le.col))],te=Y,ne=J.map(le=>({id:le,get:ae=>o(te[ae],le)})),oe=q.sortMulti(ne,G.sort.map(le=>({col:le.col,dir:le.dir})),Uint32Array.from({length:Y.length},(le,ae)=>ae),{});Y=Array.from(oe,le=>te[le])}return Y}function C(L){return JSON.stringify({filters:L.filters||null,sort:L.sort||[],quick:L.quick||"",groupBy:L.groupBy||[],groupPath:L.groupPath||[],context:L.context??null})}function P(L){if(!L||typeof L!="object")return 16;let G="";try{G=JSON.stringify(L)}catch{return 200}return G.length*2+64}function F(L){const G=L||{};return{enabled:!!G.enabled,maxRows:Number.isFinite(G.maxRows)?G.maxRows:1e6,maxBytesEstimate:Number.isFinite(G.maxBytesEstimate)?G.maxBytesEstimate:512*1024*1024}}const E=5e4;function D(L){return Number.isFinite(L)&&L>=0?L:E}function N(L){return!!L&&B(L.then)}async function M(L){if(!L||L.total!==void 0||!N(L.pendingTotal))return L;const G=await L.pendingTotal,{pendingTotal:q,...Y}=L;return typeof G=="number"?{...Y,total:G}:Y}function A(L={}){const G=L.adapter;if(!G||!B(G.execute))return _("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...L,mode:"remote",fetch:async()=>({rows:[],total:0})};const q=u(G.capabilities),Y=G.capabilities&&Object.getOwnPropertyDescriptor(G.capabilities,"operators");Y&&B(Y.get)&&Object.defineProperty(q,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(G.capabilities.operators||[]),set:()=>{}});const J=G.name||"adapter";let te=null;const ne=()=>B(G.ready)?(te||(te=Promise.resolve(G.ready()).then(()=>{Object.assign(q,u(G.capabilities))},Ie=>{throw te=null,Ie})),te):null,oe=F(L.fullDataset),le=!!L.allowPartialResults,ae=D(L.whereRowLimit);let se=null;const ee=L.aggregates;let ie=null,ce=null,he=null,me=null,Ee=null,ge,je=null,pe=0,we=null;const ye=()=>!oe.enabled||!ie?null:(we!==ie.key&&(pe++,we=ie.key),{rows:ie.rows,version:pe}),Ne=async Ie=>{const De=Ie.where&&Ie.where.active?Ie.where:null;if(!De)return{request:Ie,probe:null};const{where:Xe,...ve}=Ie,be=v(ve,q,oe.enabled);if(be.needsAll)return{request:Ie,probe:null};const Oe=C(be.pushed);let Ce=null;return(!se||se.key!==Oe)&&(q.total?(n(Ie),Ce=await M(await G.execute(be.pushed,Ie)),se={key:Oe,size:Ce&&typeof Ce.total=="number"?Ce.total:null}):se={key:Oe,size:null}),se.size!==null&&se.size<ae?{request:Ie,probe:null}:(U(De.names,J,se.size,ae),{request:ve,probe:Ce})},$e=async(Ie,De)=>{je=null;const Xe=R(Ie.pushed);he={engine:Xe.engine,client:Xe.client,groupBy:Ie.pushed.groupBy},Xe.client.length&&_(`source.pushdown.group.totals.${J}.${Xe.client.map(Oe=>Oe.id).join(".")}`,`the ${J} adapter cannot compute the group subtotal for ${Xe.client.map(Oe=>`"${Oe.id}" (${Oe.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 ve=await G.executeGroupLevel(Ie.pushed,Xe.engine,De)||{};let be=ve.rows||[];return!q.range&&De.range&&(be=be.slice(De.range.start,De.range.end)),Ge(ve),ve.total===void 0?{rows:be}:{rows:be,total:ve.total}},Ve=new Map,qe=64,Ae=async(Ie,De)=>{je=null;const Xe=Ie.pushed,ve=Xe.groupBy,be=Array.isArray(Xe.groupValues)?Xe.groupValues:[],Oe=be.length,Ce=[...Xe.filters?[Xe.filters]:[],...ve.slice(0,Oe).map((rt,ut)=>({col:rt,op:"eq",value:be[ut]===void 0?null:be[ut],caseSensitive:!0}))],Re=Ce.length===0?null:Ce.length===1?Ce[0]:{op:"and",conditions:Ce},Be=De.range?De.range.start:0;if(Oe>=ve.length){const rt={...Xe,filters:Re,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},ut=await M(await G.execute(rt,De))||{};let kt=ut.rows||[];return!q.range&&De.range&&(kt=kt.slice(De.range.start,De.range.end)),typeof ut.total=="number"?{rows:kt,total:ut.total}:{rows:kt}}const _e=ve[Oe],ke=R(Xe),Te=h(q),ze=ke.engine.filter(rt=>Te.has(rt.fn)),He=[...ke.engine.filter(rt=>!Te.has(rt.fn)).map(rt=>({id:rt.id,fn:rt.fn,class:rt.class,reason:`the ${J} adapter does not compute "${rt.fn}"`})),...ke.client];he={engine:ze,client:He,groupBy:ve},He.length&&_(`source.pushdown.group.totals.${J}.${He.map(rt=>rt.id).join(".")}`,`the ${J} adapter cannot compute the group subtotal for ${He.map(rt=>`"${rt.id}" (${rt.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 Qe=[...ze.map(rt=>({id:rt.id,col:rt.col,fn:rt.fn})),{id:d,col:_e,fn:"count"}],it={...Xe,filters:Re,range:null},st=JSON.stringify([C(it),be,_e,Qe]);let ot=Be>0?Ve.get(st):void 0;if(!ot){for(ot=Promise.resolve(G.executeGroupedAggregates(it,[_e],Qe)),Ve.delete(st),Ve.set(st,ot);Ve.size>qe;)Ve.delete(Ve.keys().next().value);ot.catch(()=>{Ve.get(st)===ot&&Ve.delete(st)})}const bt=await ot||[];n(De);const vt=rt=>{const ut={};for(const kt of ze)ut[kt.id]=rt?rt[kt.id]:void 0;return ut},pt=(Xe.sort||[]).find(rt=>rt&&rt.col===_e),Ct=pt&&pt.dir==="desc"?-1:1,Ke=bt.filter(rt=>rt&&rt.level===1).map(rt=>({[_e]:rt.keys[0]===void 0?null:rt.keys[0],leafCount:Number(rt.values&&rt.values[d])||0,totals:vt(rt.values)})).sort((rt,ut)=>Ct*$(rt[_e],ut[_e]));if(Oe===0){const rt=bt.find(kt=>kt&&kt.level===0),ut=rt?Number(rt.values&&rt.values[d]):NaN;Ge({matchCount:Number.isFinite(ut)?ut:Ke.reduce((kt,Nt)=>kt+Nt.leafCount,0),...rt?{grand:vt(rt.values)}:{}})}const dt=De.range?De.range.end:Ke.length;return{rows:Ke.slice(Be,dt),total:Ke.length}},Ge=Ie=>{typeof Ie.matchCount=="number"&&(me=Ie.matchCount,Ee=Ie.grand?{totals:Ie.grand,leafCount:Ie.matchCount}:null,ge===void 0&&B(G.unfilteredCount)&&(ge=null,Promise.resolve(G.unfilteredCount()).then(De=>{ge=typeof De=="number"?De:null}).catch(De=>{_(`source.pushdown.group.unfiltered.${J}`,`the ${J} adapter could not count the unfiltered set (${De&&De.message?De.message:De}), so "N of M" falls back to the display count for its denominator.`)})))},Ze=async(Ie,De)=>{je=null;const Xe=R(Ie.pushed);he={engine:Xe.engine,client:Xe.client,groupBy:Ie.pushed.groupBy,pivotBy:Ie.pushed.pivotBy},Xe.client.length&&_(`source.pushdown.pivot.totals.${J}.${Xe.client.map(Re=>Re.id).join(".")}`,`the ${J} adapter cannot compute the pivot cells for ${Xe.client.map(Re=>`"${Re.id}" (${Re.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 ve=await G.executePivotLevel(Ie.pushed,Xe.engine,De)||{};let be=ve.rows||[];!q.range&&De.range&&(be=be.slice(De.range.start,De.range.end)),Ge(ve);const Oe=ve.pivot&&typeof ve.pivot=="object"?ve.pivot:{},Ce={cells:Array.isArray(Oe.cells)?Oe.cells:[],...Array.isArray(Oe.axis)?{axis:Oe.axis}:{}};return ve.total===void 0?{rows:be,pivot:Ce}:{rows:be,total:ve.total,pivot:Ce}},tt=Ie=>{_(`source.pushdown.pivot.${J}.${Ie}`,`pushdown:pivot-unsupported: the ${J} adapter cannot pivot this query because ${Ie}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const De=new Error(`[lattice] ${b}: the ${J} adapter cannot pivot this query because ${Ie}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw De.code=b,De.reason=Ie,De},at=(Ie,De)=>{const Xe={key:De,state:"pending",value:null};return je=Xe,Ie.then(ve=>(je===Xe&&(je={key:De,state:"settled",value:typeof ve=="number"?ve:null}),ve),ve=>{throw je===Xe&&(je={key:De,state:"failed",value:null}),ve})};let ft=0,mt=[];const Ot=()=>ft===0?null:new Promise(Ie=>{const De=setTimeout(Ie,s);mt.push(()=>{clearTimeout(De),Ie()})}),At=async Ie=>{const De=ne();De&&await De;const ve=Ie&&Ie.pivotMode!==!1&&Array.isArray(Ie.pivotBy)&&Ie.pivotBy.length>0?{request:Ie,probe:null}:await Ne(Ie);n(Ie);let be=v(ve.request,q,oe.enabled);if(q.group&&be.grouped&&!be.pivoted&&!B(G.executeGroupLevel)&&(_(`source.pushdown.group.method.${J}`,`the ${J} 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.`),be=v(ve.request,{...q,group:!1,aggregates:null},oe.enabled)),be.pivoted&&!B(G.executePivotLevel)&&(be=v(ve.request,{...q,pivot:!1},oe.enabled),be.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),be.grouped&&!be.pivoted&&!q.group&&!B(G.executeGroupedAggregates)&&(_(`source.pushdown.group.aggregates.method.${J}`,`the ${J} 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\`.`),be=v(ve.request,{...q,aggregates:null},oe.enabled)),ce=be,be.pivoted)return Ze(be,Ie);if(be.pivotReason&&tt(be.pivotReason),be.grouped)return q.group?$e(be,Ie):Ae(be,Ie);const Ce=!!be.groupReason&&!be.full;Ce?_(`source.pushdown.group-unsupported.${J}.${be.groupReason}`,`pushdown:group-unsupported: the ${J} adapter was not asked to group this query because ${be.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.`):be.groupReason&&_(`source.pushdown.group.${J}.${be.groupReason}`,`the ${J} adapter was not asked to group this query because ${be.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 Re=Qe=>Ce?{...Qe,[S]:!0}:Qe;if(!be.needsAll){const Qe=ve.probe||await G.execute(be.pushed,Ie),it=Qe.rows||[];return N(Qe.pendingTotal)&&Qe.total===void 0?Re({rows:it,pendingTotal:at(Qe.pendingTotal,C(be.pushed))}):(je=null,!q.total&&Qe.total===void 0?Re({rows:it}):Re({rows:it,total:Qe.total??it.length}))}be.unpushed.length&&_(`source.pushdown.residual.${J}.${be.unpushed.join(".")}`,`the ${J} adapter cannot push ${be.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 Be=C(be.pushed);if(!ie||ie.key!==Be){const Qe=await M(await G.execute(be.pushed,Ie));je=null;const it=Qe.rows||[];if(be.full){const st=typeof Qe.total=="number"?Math.max(Qe.total,it.length):it.length;if(st>oe.maxRows)throw new Error(`[lattice] fullDataset refused: the ${J} adapter's matching set is ${st.toLocaleString()} rows, past the configured maxRows of ${oe.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 ot=it.length*P(it[0]);if(ot>oe.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${J} adapter's matching set is an estimated ${Math.round(ot/(1024*1024)).toLocaleString()} MB across ${it.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(oe.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 Qe.total=="number"&&it.length<Qe.total){const st=!!(be.residual.filters||be.residual.quick||be.residual.sort&&be.residual.sort.length);if(st&&!le)throw new Error(`[lattice] the ${J} adapter returned ${it.length} of ${Qe.total} matching rows when asked for the whole result, and the query has residual ${be.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.`);st?_(`source.pushdown.partial.residual.${J}`,`the ${J} adapter returned ${it.length} of ${Qe.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.`):_(`source.pushdown.partial.${J}`,`the ${J} adapter returned ${it.length} of ${Qe.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}ie={key:Be,rows:it,total:typeof Qe.total=="number"?Qe.total:null}}let _e=be;if(be.residual.where){const Qe=ie.total??ie.rows.length;if(Qe>=ae){U(be.residual.where.names,J,Qe,ae);const{where:it,...st}=ve.request;_e=v(st,q,oe.enabled),ce=_e}}const ke=ie.total!==null&&ie.rows.length>=ie.total,Te=x(ie.rows,{..._e.residual,whole:ke},L.compute||{}),ze=Ie.range?Ie.range.start:0,He=Ie.range?Ie.range.end:Te.length;return Re({rows:Te.slice(ze,He),total:Te.length})},Pt=async(Ie,De)=>{const Xe=Ot();Xe&&await Xe;const ve=ne();ve&&await ve;const be=v(Ie,q,oe.enabled);ce=be;const Oe=w(De,ee),Ce=Array.isArray(Ie.groupBy)?Ie.groupBy:[],Re=Ce.length>0,Be=!be.residual.filters&&!be.residual.quick,_e=!Re||k(Ce,q.buckets);let ke=Oe.engine,Te=Oe.client;if(q.aggregates&&ke.length){const it=q.aggregates instanceof Set?q.aggregates:new Set(I(q.aggregates)),st=ke.filter(ot=>!it.has(ot.fn));st.length&&(ke=ke.filter(ot=>it.has(ot.fn)),Te=[...st.map(ot=>({...ot,reason:`the ${J} adapter does not compute "${ot.fn}"`})),...Te])}const ze=it=>{Te=[...ke.map(st=>({...st,reason:it})),...Te],ke=[]};ke.length&&!Be?ze(be.residual.quick&&!be.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):ke.length&&!_e&&ze("a grouping key the engine cannot form forces all-client (no mixed provenance)");let He={},Qe;return ke.length&&(B(Re?G.executeGroupedAggregates:G.executeAggregates)?Re?Qe=await G.executeGroupedAggregates(be.pushed,Ce,ke)||[]:He=await G.executeAggregates(be.pushed,ke)||{}:(_(`source.pushdown.aggregates.${J}${Re?".grouped":""}`,`the ${J} adapter cannot compute ${Re?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),ze(`adapter cannot compute ${Re?"grouped ":""}aggregates`))),he={engine:ke,client:Te,...Re?{groupBy:Ce}:{}},{values:He,engine:ke,client:Te,...Qe!==void 0?{groups:Qe}:{}}},Tt=async Ie=>{ft++;try{return await At(Ie)}finally{if(ft--,ft===0&&mt.length){const De=mt;mt=[];for(const Xe of De)Xe()}}},It=f(L.edit),Bt=L.edit&&typeof L.edit=="object"&&B(L.edit.commit);let ct=L.edit;if(It&&!Bt)if(q.mutate&&q.mutate.update){const Ie=De=>{if(!q.mutate||!q.mutate.update)throw new Error(`[lattice] the ${J} 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 Xe={kind:"update",key:String(De.key),patch:{[De.colId]:De.value}};return G.mutate(Xe,De.request||{})};ct={...L.edit===!0?{}:L.edit,commit:Ie}}else _(`source.pushdown.readonly.${J}`,`edit is enabled but the ${J} adapter declares mutate: ${q.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 nt=It&&q.mutate&&(q.mutate.append||q.mutate.delete)?{append:q.mutate.append===!0,remove:q.mutate.delete===!0,returning:q.mutate.returning,mutate:(Ie,De)=>G.mutate(Ie,De||{})}:null,de=async Ie=>{const De=ne();De&&await De;const{range:Xe,signal:ve,export:be,...Oe}=Ie||{},Ce={...Oe,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:v(Ce,q,oe.enabled),signal:ve}};async function*Se(Ie,De={}){const{plan:Xe,signal:ve}=await de(Ie),be=Math.max(1,Math.floor(Number(De.pageSize))||5e3),Oe={signal:ve,stream:!0};if(!Xe.needsAll)for(let Be=0;;Be+=be){n(Oe);const _e=await G.execute({...Xe.pushed,range:{start:Be,end:Be+be}},Oe);_e&&N(_e.pendingTotal)&&_e.pendingTotal.then(null,()=>{});const ke=_e&&_e.rows||[];if(ke.length&&(yield ke),ke.length<be)return}n(Oe);const Ce=await M(await G.execute({...Xe.pushed,range:void 0},Oe)),Re=x(Ce&&Ce.rows||[],{...Xe.residual,whole:!0},L.compute||{});for(let Be=0;Be<Re.length;Be+=be)yield Re.slice(Be,Be+be)}return{...L,edit:ct,rowMutate:nt,mode:"remote",fetch:Tt,foregroundIdle:Ot,aggregate:Pt,countMatching:async Ie=>{const{plan:De,signal:Xe}=await de(Ie);if(!De.needsAll&&q.total){n({signal:Xe});const be=await M(await G.execute({...De.pushed,range:{start:0,end:0}},{signal:Xe}));if(be&&typeof be.total=="number")return be.total}let ve=0;for await(const be of Se(Ie))ve+=be.length;return ve},streamMatching:Se,lastPlan:()=>ce?{...ce,...he?{aggregates:he}:{},...je?{total:{deferred:!0,state:je.state,value:je.value}}:{}}:null,fullFrame:ye,counts:()=>({match:me,total:ge??null,pending:!!je&&je.state==="pending"}),grandTotals:()=>Ee}}}),Fe("packages/core/src/source/remote.js",function(e,K){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return P}});const Q=K("packages/core/src/internal/util.js"),$=Q.Lru,B=Q.isFunction,I=Q.warnOnce,_=Q.settleDebounce,X=K("packages/core/src/source/abort.js"),W=X.createAbortScope,H=X.isAbortError,U=K("packages/core/src/source/blockcache.js"),z=U.BlockCache,w=U.DEFAULT_PAGE_SIZE,k=U.DEFAULT_MAX_CACHED_PAGES,g=K("packages/core/src/source/rows.js"),l=g.createRowFactory,c=g.groupKey,s=K("packages/core/src/source/filterwire.js"),n=s.wireFilters,t=s.querySignature,r=s.warnHostFilterNotApplied,f=K("packages/core/src/source/pagewindow.js").pageWindow,i=K("packages/core/src/source/memory.js").MemorySource,d=K("packages/core/src/compute/handle.js").valueComparator,h=K("packages/core/src/compute/pivot.js"),a=h.pivotKey,p=h.joinPath,b=h.DEFAULT_PATH_SEPARATOR,S=K("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,y=1,v=120,R=1e3;function O(F,E,D){for(let N=0;N<Math.max(F.length,E.length);N++){const M=F[N],A=E[N],L=M==null,G=A==null;if(L||G){if(L&&G)continue;return L?1:-1}const q=D(M,A);if(q!==0)return q}return 0}function x(F,E){return new P(F,E)}class C{constructor(E,D,N,M){this.path=E,this.keyPath=M||E,this.values=[],this.level=D,this.key=c(this.keyPath),this.cache=new z(N),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 P{mode="remote";#e;#t;#n;#r;#o=new Map;#i=new Set;#s=W();#l;#a;#u=new Map;#c=[];#d=null;#f="";#h;#p=!1;#m=!1;#g=[];#b=0;#w="";#S=null;#y=-1;constructor(E,D){this.#e=E||{mode:"remote"},this.#t=D||{},B(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#x(),this.unfilteredIndices=()=>this.#B(),this.handleFor=G=>this.#H(G),this.display=()=>this.#U(),this.grandTotalRow=()=>this.#$(),this.unfilteredRows=()=>this.#Y(),this.facetIndices=G=>this.#N(G));const N=this.#e.counts;B(N)&&(this.matchCount=()=>this.#z("match"),this.totalCount=()=>this.#z("total"));const M=this.#e.grandTotals;B(M)&&(this.grandTotalRow=()=>this.#_());const A=this.#e.foregroundIdle;B(A)&&(this.foregroundIdle=()=>this.#oe(A));const L=this.#e;B(L.countMatching)&&B(L.streamMatching)&&(this.selectionQuery=()=>this.#le(),this.countMatching=G=>L.countMatching(G),this.streamMatching=(G,q)=>L.streamMatching(G,q),this.loadedRows=()=>this.#re(),this.resident=()=>this.#E()!==null),this.#n={pageSize:this.#e.pageSize||w,maxCachedPages:this.#e.maxCachedPages||k},this.#l=l(this.#t),this.#a=new $(this.#n.pageSize*4),this.#h=_((G,q)=>this.#M(G,q),v),this.#r=new C([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#f=this.#he(),B(this.#e.fetch)||I("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#R()}count(){const E=this.#A();return E?E.length:this.#O()}#O(){const E=this.#E();return E?E.count():(this.#me(),this.#Q(this.#r))}#k(){if(this.#E())return!0;const E=D=>{if(D.count===null&&!D.complete)return!1;for(const N of D.children.values())if(this.#ne(N.key)&&!E(N))return!1;return!0};return E(this.#r)}pageInfo(){const E=this.#A(),D=this.totalPending();if(!E){const N=this.#O();return{page:0,pageSize:0,total:this.#k()?N:null,pageCount:1,counting:D}}return{page:E.page,pageSize:E.pageSize,total:E.total,pageCount:E.pageCount,counting:D||E.total===null&&this.#s.size>0&&this.#r.cache.loadedExtent()===0}}#A(){const E=this.#O(),D=f(this.#I("pageSize",0),this.#I("page",0),E,this.#k());if(!D)return this.#w="",null;const N=`${this.#b}:${D.offset}:${D.length}`;return N!==this.#w&&!this.#p&&(this.#w=N,D.length>0&&!this.#E()&&this.#M(D.offset,D.offset+D.length-1)),D}at(E){const D=this.#A();if(D){if(E<0||E>=D.length)return;const N=this.#j(D.offset+E);return N&&(N.index=E),N}return this.#j(E)}#j(E){const D=this.#E();if(D)return D.at(E);if(this.#me(),E<0||E>=this.#O())return;const N=this.#ve(this.#r,E);if(!N)return;const M=this.#ie(N.node,N.local);return M&&(M.index=E),M||this.#l.skeleton(E,N.node.level,N.node.cache.erroredAt(N.local))}byKey(E){const D=this.#E();if(D)return D.byKey(E);const N=this.#u.get(E);if(!N)return;const M=N.lastIndexOf(":"),A=this.#o.get(N.slice(0,M));return A&&this.#ie(A,Number(N.slice(M+1)))||void 0}loaded(E){const D=this.#A();if(D){if(E<0||E>=D.length)return!1;E+=D.offset}const N=this.#E();if(N)return N.loaded(E);if(E<0||E>=this.#O())return!1;const M=this.#ve(this.#r,E);return!!M&&M.node.cache.rowLoaded(M.local)}hint(E,D){if(this.#p)return;const N=this.#me();let M=Math.max(0,Math.floor(E)),A=Math.max(M,Math.floor(D));const L=this.#A();if(L){if(L.length===0)return;M=L.offset,A=L.offset+L.length-1}for(const[G,q]of this.#T(M,A)){G.cache.protect(q.min,q.max);for(const Y of G.cache.evict())this.#q(G,Y)}this.#h(M,A),N&&this.#h.flush()}#T(E,D){const N=this.#O(),M=new Map;for(let A=E;A<=D&&A<N;A++){const L=this.#ve(this.#r,A);if(!L)continue;const G=M.get(L.node);G?(G.min=Math.min(G.min,L.local),G.max=Math.max(G.max,L.local)):M.set(L.node,{min:L.local,max:L.local})}return M.size||M.set(this.#r,{min:E,max:E}),M}#M(E,D){if(!this.#p)for(const[N,M]of this.#T(E,D)){N.cache.protect(M.min,M.max);const A=N.cache.blockOf(M.min),L=N.cache.blockOf(M.max);for(let G=A;G<=L&&!(N.count!==null&&G*N.cache.pageSize>=N.count);G++)N.cache.has(G)||this.#ge(N,G)}}apply(E){const D={added:[],updated:[],removed:[]};if(!E)return D;if(E.update)for(const N of E.update){const M=this.#u.get(this.#l.keyOf(N,-1));if(!M)continue;this.#a.delete(M);const A=M.lastIndexOf(":"),L=this.#o.get(M.slice(0,A));if(!L)continue;const G=Number(M.slice(A+1)),q=L.cache.blockOf(G);if(!L.cache.loaded(q))continue;const{start:Y}=L.cache.rangeOf(q),J=[];for(let ne=Y;ne<Y+L.cache.pageSize;ne++){const oe=L.cache.rowAt(ne);if(oe===void 0)break;J.push(ne===G?N:oe)}L.cache.fill(q,J);const te=this.#ie(L,G);te&&D.updated.push(te)}return(E.add&&E.add.length||E.remove&&E.remove.length)&&this.reload({keepExpanded:!0}),D}reload(E){this.#s.abortAll("reload"),this.#h.cancel(),E&&E.keepExpanded===!1&&this.#i.clear(),this.#Ae(),this.#D("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#s.abortAll("destroyed"),this.#Ae(),this.#o.clear(),this.#i.clear(),this.#S&&B(this.#S.destroy)&&this.#S.destroy(),this.#S=null}expand(E){this.#i.has(E)||(this.#i.add(E),this.#D("group:toggled",{key:E,expanded:!0}),this.#D("model:changed",{reason:"expand",key:E}))}collapse(E){this.#i.delete(E)&&(this.#D("group:toggled",{key:E,expanded:!1}),this.#D("model:changed",{reason:"collapse",key:E}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}pivot(){this.#me();const E=this.#d;if(!E||!E.keys.size||!this.#I("pivotBy",[]).length)return null;if(!E.result){const D=d((this.#t.config||{}).locale),N=[...E.keys.entries()].sort((A,L)=>O(A[1],L[1],D)),M=N.map(([A])=>A);E.result={keys:N.map(([,A])=>A),paths:M,fields:this.#X(M),groupPaths:[],columns:M.length*Math.max(1,this.#ke().length),values:E.cells,cells:E.cells,error:null}}return E.result}invalidateHandles(){this.#S&&(B(this.#S.invalidateHandles)&&this.#S.invalidateHandles(),B(this.#S.invalidate)&&this.#S.invalidate("filter"))}#C(){const E=this.#e.fullFrame;return B(E)?E():null}#E(){const E=this.#C();return E?(this.#S||(this.#S=new i({mode:"memory"},this.#L())),E.version!==this.#y&&(this.#S.setRows(E.rows),this.#y=E.version),this.#S):null}#L(){const E=this.#t,D=E.state||{};return{...E,state:{...D,page:()=>0,pageSize:()=>0}}}#x(){const E=this.#E();return E?E.filteredIndices():new Uint32Array(0)}#B(){const E=this.#E();return E?E.unfilteredIndices():new Uint32Array(0)}#H(E){const D=this.#E();return D?D.handleFor(E):void 0}#U(){const E=this.#E();return E?E.display():[]}#N(E){const D=this.#E();return D&&B(D.facetIndices)?D.facetIndices(E):new Uint32Array(0)}#$(){const E=this.#E();return E&&B(E.grandTotalRow)?E.grandTotalRow():null}#z(E){const D=this.#E();if(D){const L=E==="match"?D.matchCount:D.totalCount;if(B(L))return L.call(D)}const N=this.#e.counts,M=B(N)?N():null,A=M?M[E]:null;return typeof A=="number"?A:this.#O()}#_(){const E=this.#E();if(E&&B(E.grandTotalRow))return E.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const N=this.#e.grandTotals,M=B(N)?N():null;return!M||!M.totals?null:this.#l.grandTotal(M.totals,M.leafCount||0)}#Y(){const E=this.#E();if(E&&B(E.unfilteredRows))return E.unfilteredRows();const D=[],N=this.count();for(let M=0;M<N;M++){const A=this.at(M);A&&D.push(A)}return D}#le(){const E=this.#I("quick",""),D={protocol:y,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:n(this.#I("filters",null),this.#ue()),sort:this.#I("sort",[]),context:this.#I("context",null)};E&&(D.quick=E);const N=this.#I("where",null);return N&&N.active&&(D.where=N),D}#re(){const E=this.#I("groupBy",[]).length,D=[];for(const N of this.#o.values())if(!(N.level!==E&&!N.flat))for(const M of N.cache.ids()){if(!N.cache.loaded(M))continue;const{start:A,end:L}=N.cache.rangeOf(M);for(let G=A;G<L&&N.cache.rowLoaded(G);G++){const q=this.#ie(N,G);q&&!q.group&&D.push(q)}}return D}loadedCount(){const E=this.#E();if(E){const M=E.matchCount();return typeof M=="number"?M:E.count()}this.#me();const D=this.#I("groupBy",[]).length;let N=0;for(const M of this.#o.values())if(!(M.level!==D&&!M.flat))for(const A of M.cache.ids()){if(!M.cache.loaded(A))continue;const L=M.cache.fillOf(A);typeof L=="number"&&(N+=L)}return N}residentRows(){const E=this.#E();return E?E.display():this.#I("groupBy",[]).length>0?null:(this.#me(),this.#re())}#se(E,D,N){const{start:M,end:A}=E.cache.rangeOf(D),L=this.#I("groupBy",[]),G=this.#I("pivotBy",[]),q=this.#I("quick",""),Y=this.#ke(),J={protocol:y,range:{start:M,end:A},groupPath:E.path,groupValues:E.values,groupBy:L,totals:Y,totalFns:this.#de(Y),pivotBy:G,pivotMode:G.length>0,filters:n(this.#I("filters",null),this.#ue()),sort:this.#I("sort",[]),context:this.#I("context",null),signal:N};q&&(J.quick=q);const te=this.#I("where",null);return te&&te.active&&(J.where=te),J}async#ge(E,D){if(!B(this.#e.fetch))return;if(!this.#m){this.#m=!0;const L=this.#g;this.#g=[],queueMicrotask(()=>{for(const G of L)G()})}const N=this.#s.begin(`${E.key}:${D}`);E.cache.begin(D,N);const M=this.#f,{start:A}=E.cache.rangeOf(D);try{const L=await this.#e.fetch(this.#se(E,D,N.signal));if(!N.current||M!==this.#f||this.#p)return;N.settle();const G=L&&L.rows||[];if(!!(L&&L[S])&&!E.flat){E.flat=!0,E.children.clear();for(const[te,ne]of[...this.#u])ne.startsWith(`${E.key}:`)&&(this.#a.delete(ne),this.#u.delete(te))}E.cache.fill(D,G),E.failed=!1;for(let te=0;te<G.length;te++)this.#a.delete(`${E.key}:${A+te}`);const Y=L&&typeof L.count=="number"?L.count:L&&typeof L.total=="number"?L.total:null,J=L&&B(L.pendingTotal?.then)?L.pendingTotal:null;Y!==null?(E.count=Y,E.complete=!0):G.length<E.cache.pageSize?(E.count=A+G.length,E.complete=!0):J&&(E.counting=!0,E.announced=null),L&&Array.isArray(L.pivotFields)&&this.#pe(L.pivotFields),L&&L.pivot&&typeof L.pivot=="object"&&this.#G(L.pivot),this.#D("model:changed",{reason:"page",groupPath:E.path,block:D}),this.#D("rows:changed",{companion:!0,reason:"page",groupPath:E.path,block:D}),this.#we(E),J&&this.#Me(E,J,M)}catch(L){if(N.settle(),H(L))return;E.cache.failed(D,L),E.failed=!0;const{end:G}=E.cache.rangeOf(D);for(let q=A;q<G;q++)this.#a.delete(`${E.key}:${q}`);this.#D("model:changed",{reason:"page-error",groupPath:E.path,block:D}),this.#D("source:error",{error:L,groupPath:E.path,block:D})}}async#Me(E,D,N){let M;try{M=await D}catch(A){if(N!==this.#f||this.#p)return;E.counting=!1,H(A)||(E.failed=!0),H(A)||this.#D("source:error",{error:A,groupPath:E.path});return}N!==this.#f||this.#p||(E.counting=!1,typeof M=="number"&&(E.count=M,E.complete=!0,this.#we(E),this.#D("model:changed",{reason:"total",count:M,groupPath:E.path})))}#we(E){typeof E.count!="number"||!E.complete||E.announced!==E.count&&(E.announced=E.count,this.#D("source:total",{total:E.count,groupPath:E.path}))}#oe(E){if(this.#p)return null;const D=this.#m?null:new Promise(G=>{this.#g.push(G),setTimeout(G,R)}),N=E();if(!D&&!N)return null;const M=(async()=>{D&&await D;for(let G=E();G;G=E())await G})();let A;const L=new Promise(G=>{A=setTimeout(G,R)});return Promise.race([M,L]).then(()=>clearTimeout(A))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#E())return!1;this.#me();const E=this.#r;return E.count===null&&!E.complete&&E.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#pe(E){E.length===this.#c.length&&E.every((D,N)=>D===this.#c[N])||(this.#c=E,this.#D("column:pivoted",{pivotFields:E,remote:!0}))}#te(){const E=this.#t.config||{};return E.pivot&&E.pivot.separator||b}#X(E){const D=this.#te(),N=this.#ke();if(!N.length)return E.slice();const M=[];for(const A of E)for(const L of N)M.push(`${A}${D}${L}`);return M}#G(E){const D=this.#te();this.#d||(this.#d={keys:new Map,cells:new Map,result:null});const N=this.#d;let M=!1;const A=G=>{const q=Array.isArray(G)?G:[G],Y=p(q,D);return N.keys.has(Y)||(N.keys.set(Y,q),M=!0),Y},L=this.#I("groupBy",[]).length>0;for(const G of Array.isArray(E.axis)?E.axis:[])A(G);for(const G of Array.isArray(E.cells)?E.cells:[]){if(!G||typeof G!="object")continue;const q=A(G.pivot);if(L&&!(Array.isArray(G.group)&&G.group.length))continue;const Y=p(Array.isArray(G.group)?G.group:[],D);for(const[J,te]of Object.entries(G.values||{}))N.cells.set(a(Y,q,J),te)}N.result=null,M&&this.#pe((this.pivot()||{fields:[]}).fields)}#Q(E){let D=this.#Z(E);for(const N of E.children.values())this.#ne(N.key)&&(D+=this.#Q(N));return D}#Z(E){if(E.count!==null)return E.count;const D=E.cache.loadedExtent();return E.complete?D:E.row&&E.row.leafCount>0?E.level>=this.#I("groupBy",[]).length?Math.max(D,E.row.leafCount):D===0?1:Math.min(D+E.cache.pageSize,Math.max(D,E.row.leafCount)):D+E.cache.pageSize}#ve(E,D){let N=D,M=0;const A=[...E.children.entries()].filter(([,G])=>this.#ne(G.key)).sort((G,q)=>G[0]-q[0]);for(const[G,q]of A){const Y=G-M+1;if(N<Y)return{node:E,local:M+N};N-=Y,M=G+1;const J=this.#Q(q);if(N<J)return this.#ve(q,N);N-=J}const L=this.#Z(E);return M+N<L?{node:E,local:M+N}:null}#ie(E,D){const N=`${E.key}:${D}`,M=this.#a.get(N);if(M)return M;const A=E.cache.rowAt(D);if(A===void 0)return null;const L=this.#I("groupBy",[]);let G;if(E.level<L.length&&!E.flat){const q=L[E.level],Y=this.#d!==null&&E.level===L.length-1&&this.#I("pivotBy",[]).length>0,J=this.#V(A,q),te=J==null,ne=[...E.path,te?"":String(J)],oe=[...E.keyPath,te?null:String(J)];if(G=this.#l.group({path:ne,keyPath:oe,column:q,value:J,level:E.level,parent:E.row,leafCount:Number(A.leafCount)||0,expanded:Y?!1:this.#ne(c(oe)),...Y?{hasChildren:!1}:{}}),G.totals=this.#ae(A),G.data=A,!Y){let le=this.#o.get(G.key);le?le.row=G:(le=new C(ne,E.level+1,this.#n,oe),le.row=G,this.#o.set(le.key,le)),le.values=[...E.values,J],E.children.set(D,le)}}else G=this.#l.leaf(A,D,E.level,E.row);return this.#a.set(N,G),this.#u.set(G.key,N),G}#ae(E){const D=E||{};if(D.totals&&typeof D.totals=="object")return D.totals;const N={};for(const M of this.#ke())Object.hasOwn(D,M)&&(N[M]=D[M]);return N}#q(E,D){const{start:N,end:M}=E.cache.rangeOf(D);for(let A=N;A<M;A++){const L=`${E.key}:${A}`,G=this.#a.peek(L);G&&this.#u.delete(G.key),this.#a.delete(L)}}#me(){const E=this.#he();return E===this.#f?!1:(this.#f=E,this.#s.abortAll("query"),this.#Ae(),this.#D("model:changed",{reason:"query"}),!0)}#Ae(){for(const E of this.#o.values())E.cache.clear(),E.count=null,E.complete=!1,E.announced=null,E.counting=!1,E.failed=!1,E.children.clear(),E.flat=!1;this.#a.clear(),this.#u.clear(),this.#b++,this.#d=null}#he(){const E=this.#I("where",null);return`${t({filters:this.#I("filters",null),sort:this.#I("sort",[]),quick:this.#I("quick",""),groupBy:this.#I("groupBy",[]),pivotBy:this.#I("pivotBy",[]),context:this.#I("context",null)})}|${E?E.version:0}`}#ne(E){const D=this.#I("expanded",null);return D?B(D.has)?D.has(E):Array.prototype.includes.call(D,E):this.#i.has(E)}#ke(){const E=this.#I("totals",[]);if(E&&E.length)return[...E];const D=this.#t.columns;return!D||!B(D.all)?[]:D.all().filter(N=>!!N.total).map(N=>N.id)}#de(E){const D=this.#t.columns,N={};if(!D||!B(D.get))return N;for(const M of E){const A=D.get(M);if(!A)continue;const L=A.groupTotal!=null?A.groupTotal:A.total;typeof L=="string"&&(N[M]=L)}return N}#V(E,D){const N=this.#t.columns,M=N&&B(N.get)?N.get(D):void 0;return M&&B(M.getValue)?M.getValue(E):E?.[D]}#R(){r(this.#t)}#ue(){const E=this.#t.config||{};return{tz:E.timeZone,weekStartsOn:E.weekStartsOn}}#I(E,D){const N=this.#t.state;if(N&&B(N[E])){const M=N[E]();return M??D}return D}#D(E,D){const N=this.#t.emit;B(N)&&N(E,D)}}}),Fe("packages/core/src/source/gapbuffer.js",function(e,K){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return $}});const Q=64;class ${#e;#t=0;#n=0;constructor(I=Q){this.#e=new Uint32Array(Math.max(1,I)),this.#n=this.#e.length}static from(I,_=Q){const X=new $(I.length+Math.max(1,_));return X.#e.set(I,0),X.#t=I.length,X.#n=X.#e.length,X}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(I){return I<0||I>=this.length?0:I<this.#t?this.#e[I]:this.#e[I+(this.#n-this.#t)]}insert(I,_){const X=I<0?0:I>this.length?this.length:I;this.#r(X),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=_}push(I){this.insert(this.length,I)}removeAt(I){return!Number.isInteger(I)||I<0||I>=this.length?!1:(this.#r(I),this.#n++,!0)}toArray(){const I=new Uint32Array(this.length);return I.set(this.#e.subarray(0,this.#t),0),I.set(this.#e.subarray(this.#n),this.#t),I}clear(){this.#t=0,this.#n=this.#e.length}#r(I){if(I!==this.#t)if(I<this.#t){const _=this.#t-I;this.#e.copyWithin(this.#n-_,I,this.#t),this.#t=I,this.#n-=_}else{const _=I-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+_),this.#t=I,this.#n+=_}}#o(){const I=this.#e.length-this.#n,_=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+Q));_.set(this.#e.subarray(0,this.#t),0),_.set(this.#e.subarray(this.#n),_.length-I),this.#e=_,this.#n=_.length-I}}}),Fe("packages/core/src/store/ingest.js",function(e,K){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return n}});const Q=K("packages/core/src/internal/util.js"),$=Q.now,B=Q.nextFrame,I=Q.infoOnce,_=Q.warnOnce,X=Q.isFunction,W=Q.pathGetter,U=K("packages/core/src/store/columnstore.js").ColumnStore,z=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function w(t,r={}){if(r.multi)return"multi";if(t.length===0)return"object";let o=0,f=0,u=0,i=0,m=0;for(let h=0;h<t.length;h++){const a=t[h];typeof a=="number"?o++:typeof a=="boolean"?f++:typeof a=="string"?u++:a instanceof Date?i++:Array.isArray(a)&&m++}const d=t.length;return o===d?"float64":f===d?"bitset":i===d?"float64":u===d?"text":m===d?"multi":"object"}function k(t,r,o){return r<=0||t<o*r?"dictionary":"object"}function g(t,r,o){const f=new Map,u=new Map;for(const y of t){if(y.computed)continue;const v=X(y.read)?y.read:W(y.field||y.id);u.set(y.id,v),f.set(y.id,v)}const i=r?.order??[],m=r?.fns??{},d=r?.deps??{},h=r?.wrapDeps??null,a=i.filter(y=>X(m[y])),p=a.some(y=>d[y]==="*");let b=new WeakMap;const j=y=>{const v={};if(p)for(const[R,O]of u)v[R]=O(y);for(const R of a){const O=d[R];let x;if(O==="*")x=v;else{x={};const C=O||[];for(let P=0;P<C.length;P++){const F=C[P];x[F]=F in v?v[F]:u.get(F)?.(y)}}v[R]=m[R](h?h(x,R):x,{data:y,row:null,column:null,grid:null,context:o})}return v},S=y=>{if(y===null||typeof y!="object"&&typeof y!="function")return j(y);let v=b.get(y);return v===void 0&&(v=j(y),b.set(y,v)),v};for(const y of a)f.set(y,v=>S(v)[y]);return{readers:f,reset(){b=new WeakMap}}}class l{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(r,o){this.spec=r,this.read=o,this.kind="object",this.inferred=!1,this.nullable=r.nullable!==!1}}class c{#e;#t=[];#n=null;#r;#o=0;#i;#s=!1;#l=!1;#a=0;#u;constructor(r,o={},f={}){this.#e=Array.isArray(r)?r:Array.from(r||[]),this.#i={...z,...f};const u=o.columns??[];this.#r=g(u,o.computed??null,o.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(u,o.computed??null),this.#n=new U(this.#t.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#s||this.#l}get progress(){return this.#o}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const r=$(),{chunkMs:o,chunkRows:f}=this.#i,u=this.#e.length;do{const i=Math.min(this.#o+f,u);this.#n.append(this.#e.slice(this.#o,i)),this.#d(this.#o,i),this.#o=i,this.#r.reset(),this.#h(!1)}while(this.#o<u&&$()-r<o);return this.#a+=$()-r,this.#i.onProgress?.({loaded:this.#o,total:u}),this.#o>=u?(this.#h(!0),this.#s=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(r=>({id:r.spec.id,kind:r.kind,nullable:r.nullable,read:r.read,dictionary:r.spec.dictionary})),decisions:this.#t.map(r=>({id:r.spec.id,kind:r.kind,nullable:r.nullable,inferred:r.inferred,distinct:r.candidate||r.change?this.#f(r):null,change:r.change,reason:r.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#c(r,o){const f=this.#e,u=Math.min(this.#i.sampleSize,f.length),i=this.#i.dictionaryRatio,m=o?.pure instanceof Set?o.pure:new Set(o?.pure??o?.order??[]);for(const d of r){if(!d||!d.id)continue;if(d.computed&&(d.pure===!1||o&&!m.has(d.id))){_(`ingest.impure.${d.id}`,`column "${d.id}" is an impure computed column and is not materialised into the store`);continue}const h=this.#r.readers.get(d.id)??(X(d.read)?d.read:W(d.field||d.id)),a=new l(d,h);if(d.kind)a.kind=d.kind,a.reason="declared by the caller";else if(d.dictionary)a.kind=d.multi?"multi":"dictionary",a.reason="value table supplied (lookup column)";else{const p=[];for(let j=0;j<u&&p.length<this.#i.sampleSize;j++){const S=h(f[j]);S!=null&&p.push(S)}a.inferred=!0;const b=w(p,{multi:d.multi});if(b==="text"){const j=new Set(p).size;a.kind=k(j,p.length,i),a.candidate=this.#u,a.reason=`sampled ${j} distinct in ${p.length}`}else a.kind=b,a.reason=`inferred from ${p.length} sampled values`,b==="object"&&p.length&&I(`ingest.mixed.${d.id}`,`column "${d.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);a.kind==="object"&&a.candidate&&(a.distinct=new Set(p))}this.#t.push(a)}}#d(r,o){const f=this.#e;for(const u of this.#t){if(!u.candidate||!u.distinct)continue;const i=u.distinct;for(let m=r;m<o;m++){const d=u.read(f[m]);d!=null&&i.add(d)}}}#f(r){if(r.distinct)return r.distinct.size;const o=this.#n.column(r.spec.id);return o?.dict?o.dict.size:0}#h(r){const o=this.#i.dictionaryRatio,f=this.#e.length;for(const u of this.#t){if(!u.candidate)continue;const i=this.#f(u);if(u.kind==="dictionary"&&i>=o*f){const m=this.#n.column(u.spec.id);u.distinct=new Set(m?.dict?m.dict.values():[]),this.#n.convert(u.spec.id,"object"),u.kind="object",u.change="demoted",u.reason=`${i} distinct values is at or above ${o*100}% of ${f} rows`;continue}if(u.kind==="object"&&i>=o*f){u.candidate=!1,u.distinct=null,u.reason=`${i} distinct values is at or above ${o*100}% of ${f} rows`;continue}r&&u.kind==="object"&&i<o*f&&(this.#n.convert(u.spec.id,"dictionary"),u.kind="dictionary",u.change=u.change==="demoted"?null:"promoted",u.reason=`${i} distinct values is below ${o*100}% of ${f} rows`,u.distinct=null),r&&(u.candidate=!1)}}}async function s(t,r={},o={}){const f=new c(t,r,o),u=o.scheduler?.frame??B;for(;f.slice();)await new Promise(i=>{u(i)});return f.result()}function n(t,r={},o={}){const f=new c(t,r,{...o,chunkMs:1/0});for(;f.slice(););return f.result()}}),Fe("packages/core/src/store/columnpack.js",function(e,K){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return c}});const $=K("packages/core/src/internal/util.js").pathGetter,B=K("packages/core/src/store/ingest.js"),I=B.inferKind,_=B.decideText,X=B.INGEST_DEFAULTS,H=K("packages/core/src/store/columnstore.js").toFloat,U=new Set(["float64","int32","bitset","dictionary","object","multi"]);function z(s){if(!Array.isArray(s)||s.length===0)return!1;for(const n of s)if(!n||typeof n.id!="string"||typeof n.field!="string"||n.field===""||n.kind&&!U.has(n.kind))return!1;return!0}function w(s){const n=H(s);return Number.isFinite(n)?n|0:0}function k(s){return s==null?[]:Array.isArray(s)?s:[s]}function g(s,n,t,r){if(s.kind)return s.kind;const o=[];for(let i=0;i<n.length&&o.length<X.sampleSize;i++){const m=n[i];m!=null&&o.push(m)}const f=I(o,{multi:s.multi});if(f!=="text")return f;const u=new Set(o).size;return _(u,o.length,r)}function l(s,n,t={}){const r=n.length|0,o=t.dictionaryRatio??X.dictionaryRatio,f=[];for(const u of s){const i=$(u.field||u.id),m=u.nullable!==!1,d=new Array(r);for(let j=0;j<r;j++){const S=i(n[j]);d[j]=S===void 0?null:S}const h=g(u,d,r,o),a=m?new Uint8Array(r+7>>3):null,p=j=>{a&&(a[j>>3]|=1<<(j&7))};let b;switch(h){case"float64":{const j=new Float64Array(r);for(let S=0;S<r;S++){const y=d[S],v=y===null;v||p(S),j[S]=v?NaN:H(y)}b={id:u.id,kind:h,nullable:m,values:j,presence:a,offsets:null,table:null};break}case"int32":{const j=new Int32Array(r);for(let S=0;S<r;S++){const y=d[S],v=y===null;v||p(S),j[S]=v?0:w(y)}b={id:u.id,kind:h,nullable:m,values:j,presence:a,offsets:null,table:null};break}case"bitset":{const j=new Uint8Array(r+7>>3);for(let S=0;S<r;S++){const y=d[S],v=y===null;v||p(S),!v&&y&&(j[S>>3]|=1<<(S&7))}b={id:u.id,kind:h,nullable:m,values:j,presence:a,offsets:null,table:null};break}case"dictionary":{const j=new Uint32Array(r),S=[],y=new Map;for(let v=0;v<r;v++){const R=d[v];if(R===null){j[v]=0;continue}p(v);let O=y.get(R);O===void 0&&(O=S.length,S.push(R),y.set(R,O)),j[v]=O}b={id:u.id,kind:h,nullable:m,values:j,presence:a,offsets:null,table:S};break}case"multi":{const j=[],S=new Map,y=new Uint32Array(r+1),v=[];for(let R=0;R<r;R++){const O=d[R];y[R]=v.length,O===null||p(R);const C=k(O);for(let P=0;P<C.length;P++){const F=C[P];let E=S.get(F);E===void 0&&(E=j.length,j.push(F),S.set(F,E)),v.push(E)}}y[r]=v.length,b={id:u.id,kind:h,nullable:m,values:Int32Array.from(v),presence:a,offsets:y,table:j};break}default:{const j=new Array(r);for(let S=0;S<r;S++){const y=d[S];y!==null&&p(S),j[S]=y}b={id:u.id,kind:"object",nullable:m,values:j,presence:a,offsets:null,table:null};break}}f.push(b)}return{count:r,columns:f}}function c(s){const n=[];if(!s||!Array.isArray(s.columns))return n;const t=r=>{ArrayBuffer.isView(r)&&r.buffer&&!n.includes(r.buffer)&&n.push(r.buffer)};for(const r of s.columns)t(r.values),t(r.presence),t(r.offsets);return n}}),Fe("packages/core/src/source/stream.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return O}});const Q=K("packages/core/src/internal/util.js"),$=Q.Lru,B=Q.isFunction,I=Q.now,_=Q.nextFrame,X=Q.cancelFrame,W=Q.whenIdle,H=Q.defaultCompare,U=Q.warnOnce,z=Q.infoOnce,w=Q.getPath,k=K("packages/core/src/source/abort.js"),g=k.createAbortScope,l=k.isAbortError,c=K("packages/core/src/source/rows.js"),s=c.createRowFactory,n=c.lazyRowView,r=K("packages/core/src/source/gapbuffer.js").GapBuffer,f=K("packages/core/src/source/memory.js").createMemorySource,i=K("packages/core/src/source/filterwire.js").querySignature,d=K("packages/core/src/store/columnpack.js").isPortableSchema,h=25e4,a=Symbol("lattice.stream.storeBacked"),p=8,b=.1,j=1e3,S=50;function y(x){return Math.min(j,Math.max(S,Math.floor(x/4)))}function v(x){if(x instanceof Date)return x.getTime();if(typeof x=="number")return Number.isFinite(x)?x:NaN;if(typeof x=="string"){const C=x.trim();if(!C)return NaN;const P=Date.parse(C);return Number.isNaN(P)?Number(C):P}return NaN}function R(x,C){return new O(x,C)}class O{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#o=[];#i=null;#s;#l;#a=new Map;#u=g();#c={loaded:0,estimated:void 0};#d=null;#f=0;#h=0;#p=0;#m=0;#g=null;#b=null;#w=null;#S=!1;#y=!1;#O=!1;#k=!1;#A="";#j=0;#T=0;#M=0;#C=null;#E=1/0;#L=!1;#x=null;#B=null;#H=null;#U=null;#N=!1;#$=0;#z=0;#_=!1;constructor(C,P){this.#e=C||{mode:"stream"},this.#t=P||{},this.#s=s(this.#t),this.#l=new $(4096),this.#A=this.#Je();const F=(this.#t.config||{}).ingest;this.#N=!!F&&F.retainSource===!1,B(this.#e.open)||U("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.#U=setInterval(()=>{this.#k||this.reload()},E),this.#U&&B(this.#U.unref)&&this.#U.unref()),this.#le()}#Y(){const C=Number(this.#e.maxAge);return Number.isFinite(C)&&C>0?C:0}#le(){const C=this.#Y();if(!C)return;const P=this.#e.ageBy;B(P)?this.#B=P:typeof P=="string"&&P?this.#B=F=>w(F,P):this.#B=null,this.#C=[],this.#x=setInterval(()=>{this.#k||this.#re()&&(this.#Ae(),this.#v())},y(C)),this.#x&&B(this.#x.unref)&&this.#x.unref()}#re(){const C=this.#Y();return!C||!this.#C?!1:this.#L?!0:this.#E<Date.now()-C*(1+b)}#se(C,P){if(!this.#C)return;const F=this.#B?v(this.#B(P)):Date.now();this.#C[C]=F,Number.isNaN(F)||(F<this.#E&&(this.#E=F),F<Date.now()-this.#Y()&&(this.#L=!0))}#ge(){return this.#be("groupBy",[]).length>0?!0:!!this.#be("pivotMode",!1)&&this.#be("pivotBy",[]).length>0}#Me(){if(this.#g||this.#k)return;const C=this.#ge();if(C&&!this.#b){this.#b=f({mode:"memory",rows:this.#n},this.#we()),this.#S=!1;return}!C&&this.#b&&(this.#b.destroy(),this.#b=null)}#we(){if(this.#w)return this.#w;const C=this,P={liveIndices:()=>C.#oe(),live:F=>C.#n[F]!==void 0,source:F=>C.#Pe(F),get physical(){return C.#n.length}};return this.#N&&(P.column=F=>{const E=C.#t.store;return E&&B(E.column)?E.column(F):void 0}),this.#w=Object.create(this.#t,{store:{value:P,enumerable:!0,configurable:!0}}),this.#w}#oe(){const C=new Uint32Array(this.#n.length);let P=0;for(let F=0;F<this.#n.length;F++)this.#n[F]!==void 0&&(C[P++]=F);return C.subarray(0,P)}#pe(){return this.#g?this.#g:this.#b?(this.#S&&(this.#S=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(C="filter"){if(this.#g){this.#g.invalidate(C);return}this.#Me(),this.#b&&this.#b.invalidate(C),(C==="filter"||C==="sort")&&this.#de()}count(){const C=this.#pe();return C?C.count():this.#r?this.#r.length:this.#j}matchCount(){const C=this.#pe();return C&&B(C.matchCount)?C.matchCount():this.#r?this.#r.length:this.#j}totalCount(){const C=this.#pe();return C&&B(C.totalCount)?C.totalCount():this.#j}unfilteredRows(){const C=this.#pe();if(C&&B(C.unfilteredRows))return C.unfilteredRows();const P=[];for(let F=0;F<this.#n.length;F++){if(!this.#n[F])continue;const E=this.#ye(F);E&&P.push(E)}return P}at(C){const P=this.#pe();if(P)return P.at(C);if(C<0||C>=this.count())return;const F=this.#r?this.#r.at(C):C,E=this.#ye(F);return E.index=C,E}byKey(C){const P=this.#pe();if(P)return P.byKey(C);const F=this.#a.get(C);return F===void 0?void 0:this.#ye(F)}leavesOf(C){const P=this.#pe();return P&&B(P.leavesOf)?P.leavesOf(C):[]}loaded(C){return C>=0&&C<this.count()}hint(C,P){if(this.#g){this.#g.hint(C,P);return}this.#te(),this.#p=Math.max(0,Math.floor(C))}#te(){this.#k||this.#Je()===this.#A||this.reload()}display(){const C=this.#pe();return C?C.display():n(()=>this.count(),P=>this.at(P))}apply(C){if(this.#g)return this.#g.apply(C);const P={added:[],updated:[],removed:[]};if(!C)return P;if(C.update){let F=!1;for(const E of C.update){const D=this.#a.get(this.#s.keyOf(E,-1));if(D===void 0)continue;const N=this.#ue(D);this.#N?this.#Qe(D,E):this.#n[D]=E,this.#l.delete(D),this.#I(D,N),this.#C&&(this.#se(D,E),F=!0),this.#S=!0,P.updated.push(this.#ye(D))}F&&this.#Ae()}if(C.add&&C.add.length){const F=this.#q(C.add);for(const E of F)P.added.push(this.#ye(E))}return C.remove&&C.remove.length&&U("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#v(),P}reload(C){this.#u.abortAll("reload"),this.#Fe(),this.#b&&(this.#b.destroy(),this.#b=null),this.#S=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#j=0,this.#T=0,this.#M=0,this.#C&&(this.#C=[]),this.#E=1/0,this.#L=!1,this.#y=!1,this.#O=!1,this.#c={loaded:0,estimated:void 0},this.#A=this.#Je(),this.#W("model:changed",{reason:"reload"}),this.start()}destroy(){this.#k=!0,this.#U!==null&&(clearInterval(this.#U),this.#U=null),this.#x!==null&&(clearInterval(this.#x),this.#x=null),this.#C=null,this.#u.abortAll("destroyed"),this.#Fe(),this.#d!==null&&(this.#Ke(this.#d),this.#d=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.#k||!B(this.#e.open))return;this.#O=!0;const C=this.#u.begin("stream");this.#de(),this.#Me();let P;try{P=this.#e.open({sort:this.#be("sort",[]),filters:this.#be("filters",null),quick:this.#be("quick","")||void 0,context:this.#be("context",null),signal:C.signal})}catch(E){this.#W("source:error",{error:E});return}const F=B(P[Symbol.asyncIterator])?P[Symbol.asyncIterator]():P[Symbol.iterator]();this.#H=F;try{for(;;){const E=await F.next();if(!C.current||this.#k)return;if(E.done){this.#fe();return}if(await this.#X(E.value,C),!C.current||this.#k)return;if(E.value&&E.value.done){this.#fe();return}if(await this.#Se(),!C.current||this.#k)return}}catch(E){if(l(E))return;this.#W("source:error",{error:E})}finally{C.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#y,live:this.#j,evicted:this.#T}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const C=this.#pe();C&&(B(C.invalidateHandles)&&C.invalidateHandles(),B(C.invalidate)&&C.invalidate("sort"))}renderCount(){return this.#f}ingestStats(){return{worker:this.#$,inline:this.#z,storeBacked:this.#N}}#X(C,P){if(!C)return;const F=C.rows;if(F&&F.length&&this.#Q(F))return this.#ve(C,P);const E=I();F&&F.length&&(this.#q(F),this.#z++),this.#G(C),this.#h+=I()-E,this.#v()}#G(C){this.#c.loaded=C.progress&&typeof C.progress.loaded=="number"?C.progress.loaded:this.#n.length,C.progress&&typeof C.progress.estimated=="number"&&(this.#c.estimated=C.progress.estimated)}#Q(C){if(this.#_||this.#g)return!1;const P=this.#ie();if(!P)return!1;const F=this.#t.store;if(!F||!B(F.appendPacked))return!1;const E=this.#ae();return!E||!d(E)?(this.#_=!0,z("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):C.length<P.threshold?!1:!this.#Z(C)}#Z(C){if(!this.#s.keyed)return!1;const P=new Set;for(let F=0;F<C.length;F++){const E=this.#s.keyOf(C[F],this.#n.length+F);if(E!=null){if(P.has(E)||this.#a.has(E))return!0;P.add(E)}}return!1}async#ve(C,P){const F=C.rows,E=this.#ie(),D=this.#ae();let N;try{N=await E.columnize(D,F,{key:"ingest:stream",signal:P&&P.signal})}catch(q){if(l(q)||(U("source.stream.columnize","worker columnization failed; columnizing on the main thread",q),this.#_=!0,P&&(!P.current||this.#k)))return;this.#q(F),this.#z++,this.#G(C),this.#v();return}if(P&&(!P.current||this.#k))return;const M=this.#t.store,A=this.#N?void 0:F,{from:L}=M.appendPacked(N,A),G=N.count|0;for(let q=0;q<G;q++){const Y=L+q,J=F[q],te=this.#s.keyed?this.#s.keyOf(J,Y):null;if(this.#n[Y]=this.#N?a:J,this.#j++,this.#se(Y,J),te!==null&&this.#a.set(te,Y),!this.#r||!this.#V(Y))continue;const ne=this.#D(Y);this.#r.insert(ne,Y),ne<=this.#p&&this.#m++}this.#S=!0,this.#Ae(),this.#$++,this.#G(C),this.#v()}#ie(){const C=this.#t.ingestWorker;return B(C)?C():null}#ae(){const C=this.#t.storeSchema;return B(C)?C():null}#q(C){const P=[],F=this.#t.store,E=new Array(C.length),D=[],N=new Set;for(let A=0;A<C.length;A++){const L=this.#s.keyed?this.#s.keyOf(C[A],this.#n.length+D.length):null;E[A]=L,!(L!==null&&(this.#a.has(L)||N.has(L)))&&(L!==null&&N.add(L),D.push(C[A]))}let M=D.length&&F&&B(F.append)?F.append(D).from:this.#n.length;for(let A=0;A<C.length;A++){const L=C[A],G=E[A];if(G!==null&&this.#a.has(G)){const J=this.#a.get(G),te=this.#ue(J);this.#N||(this.#n[J]=L,F&&B(F.setSource)&&F.setSource(J,L)),this.#Qe(J,L),this.#l.delete(J),this.#se(J,L),this.#I(J,te);continue}const q=M++;if(this.#n[q]=this.#N?a:L,this.#j++,this.#se(q,L),G!==null&&this.#a.set(G,q),P.push(q),!this.#r||!this.#V(q))continue;const Y=this.#D(q);this.#r.insert(Y,q),Y<=this.#p&&this.#m++}return this.#S=!0,this.#Ae(),P}#me(C){const P=this.#n[C];let F=!1;if(this.#r){const M=this.#ke(C);M>=0&&M<=this.#p&&(F=!0)}else C<=this.#p&&(F=!0);const E=P===a?this.#Pe(C):P,D=this.#s.keyed?this.#s.keyOf(E,C):null;D!==null&&this.#a.get(D)===C&&this.#a.delete(D),this.#n[C]=void 0,this.#C&&(this.#C[C]=NaN),this.#l.delete(C);const N=this.#t.store;return N&&B(N.remove)&&N.remove(C),this.#j--,F}#Ae(){let C=0,P=0;const F=this.#ne();C+=F.dropped,P+=F.aboveAnchor;const E=this.#he();C+=E.dropped,P+=E.aboveAnchor,C&&(this.#S=!0,this.#T+=C,this.#de(),this.#m-=P,this.#W("stream:evicted",{evicted:C,total:this.#T,live:this.#j}))}#he(){const C=this.#e.maxRows;if(!Number.isFinite(C)||C<=0||this.#j<=C)return{dropped:0,aboveAnchor:0};const P=Math.max(1,Math.floor(C*(1-b)));let F=0,E=0;for(;this.#j>P&&this.#M<this.#n.length;){const D=this.#M++;this.#n[D]!==void 0&&(this.#me(D)&&E++,F++)}return{dropped:F,aboveAnchor:E}}#ne(){const C=this.#Y();if(!C||!this.#C||!this.#re())return{dropped:0,aboveAnchor:0};const P=Date.now()-C;let F=0,E=0,D=1/0;for(let N=this.#M;N<this.#n.length;N++){if(this.#n[N]===void 0)continue;const M=this.#C[N];if(!(Number.isNaN(M)||M===void 0)){if(M>=P){M<D&&(D=M);continue}this.#me(N)&&E++,F++}}for(this.#E=D,this.#L=!1;this.#M<this.#n.length&&this.#n[this.#M]===void 0;)this.#M++;return{dropped:F,aboveAnchor:E}}#ke(C){if(!this.#r)return C;for(let P=0;P<this.#r.length;P++)if(this.#r.at(P)===C)return P;return-1}#de(){this.#o=this.#be("sort",[]),this.#i=this.#be("filters",null);const C=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#Y()>0,P=this.#be("where",null),F=(this.#t.config||{}).hostFilter,E=!!(P&&P.active)||!!(F&&B(F.active)&&F.active());if(!(C||this.#o.length>0||!!this.#i||!!this.#be("quick","")||E)){this.#r=null;return}this.#r=new r(Math.max(64,this.#n.length+64));for(let N=0;N<this.#n.length;N++)this.#n[N]!==void 0&&this.#V(N)&&this.#r.insert(this.#D(N),N)}#V(C){const P=this.#Pe(C);if(this.#i&&!this.#R(this.#i,P))return!1;const F=String(this.#be("quick","")||"").toLowerCase();if(F&&!this.#We(P).includes(F))return!1;const E=(this.#t.config||{}).hostFilter;if(E&&B(E.active)&&E.active()&&!E.passes(this.#ye(C)))return!1;const D=this.#be("where",null);if(D&&D.active){const N=this.#ye(C);if(!D.passes(N.data,N.key))return!1}return!0}#R(C,P){if(!C)return!0;const F=C;if(Array.isArray(F.conditions))return F.op==="or"?F.conditions.some(N=>this.#R(N,P)):F.op==="not"?!F.conditions.some(N=>this.#R(N,P)):F.conditions.every(N=>this.#R(N,P));const E=C,D=(this.#t.compute||{}).testValue;return B(D)?!!D(this.#Ce(P,E.col),E,(this.#t.config||{}).locale):(U("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#ue(C){if(!this.#r)return-1;if(!this.#o.length)return this.#ke(C);let P=0,F=this.#r.length;for(;P<F;){const E=P+F>>>1;this.#ce(this.#r.at(E),C)<0?P=E+1:F=E}for(let E=P;E<this.#r.length;E++){const D=this.#r.at(E);if(D===C)return E;if(this.#ce(D,C)>0)break}return this.#ke(C)}#I(C,P){if(!this.#r||!this.#o.length)return;const F=this.#V(C);if(P>=0&&this.#r.at(P)===C)this.#r.removeAt(P),P<=this.#p&&this.#m--;else if(P>=0)return;if(!F)return;const E=this.#D(C);this.#r.insert(E,C),E<=this.#p&&this.#m++}#D(C){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let P=0,F=this.#r.length;for(;P<F;){const E=P+F>>>1;this.#ce(C,this.#r.at(E))<0?F=E:P=E+1}return P}#ce(C,P){const F=this.#Pe(C),E=this.#Pe(P);for(const D of this.#o){const N=this.#_e(D.col),M=this.#Ce(F,D.col),A=this.#Ce(E,D.col),G=(N&&N.value&&B(N.value.compare)?N.value.compare:H)(M,A);if(G!==0)return D.dir==="desc"?-G:G}return 0}#fe(){this.#y=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const C=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:h;!this.#N&&this.#n.length<C&&(this.#g=f({mode:"memory",rows:this.#n},this.#t),this.#x!==null&&(clearInterval(this.#x),this.#x=null),this.#b&&(this.#b.destroy(),this.#b=null)),this.#v(),this.#W("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:C})}#v(){this.#d!==null||this.#k||(this.#d=this.#Ge(()=>{this.#d=null,this.#f++;const C=this.#m;this.#m=0,this.#h=0,this.#W("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#f}),this.#W("model:changed",{reason:"stream",shiftAboveViewport:C,anchor:this.#p}),this.#W("rows:changed",{companion:!0,reason:"stream"})}))}#Se(){return this.#f===0||this.#h<this.#Be()?Promise.resolve():(this.#h=0,new Promise(C=>{const P=(this.#t.scheduler||{}).idle;B(P)?P(()=>C()):W(()=>C())}))}#Be(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:p}#Ge(C){const P=this.#t.scheduler||{};return B(P.frame)?P.frame(C):_(C)}#Ke(C){const P=this.#t.scheduler||{};B(P.cancel)?P.cancel(C):X(C)}#Pe(C){const P=this.#n[C];if(P!==void 0&&P!==a)return P;if(P===void 0)return;const F=this.#t.store;return F&&B(F.source)?F.source(C):void 0}#Qe(C,P){const F=this.#t.store;if(!F||!B(F.set))return;const E=this.#ae();if(Array.isArray(E))for(const D of E){if(!D||!D.id)continue;const N=B(D.read)?D.read:M=>w(M,D.field||D.id);F.set(D.id,C,N(P))}}#ye(C){let P=this.#l.get(C);return P||(P=this.#s.leaf(this.#Pe(C),C),this.#l.set(C,P)),P}#Ce(C,P){const F=this.#_e(P);return F&&B(F.getValue)?F.getValue(C):C?.[P]}#We(C){const P=this.#t.columns,F=P&&B(P.all)?P.all():[],E=[];for(const D of F){const N=B(D.getValue)?D.getValue(C):void 0;N!=null&&N!==""&&E.push(String(N))}return E.join(" ").toLowerCase()}#_e(C){const P=this.#t.columns;return P&&B(P.get)?P.get(C):void 0}#Fe(){const C=this.#H;if(this.#H=null,C&&B(C.return))try{C.return()}catch{}}#Je(){return i({context:this.#be("context",null)})}#be(C,P){const F=this.#t.state;if(F&&B(F[C])){const E=F[C]();return E??P}return P}#W(C,P){const F=this.#t.emit;B(F)&&F(C,P)}}}),Fe("packages/core/src/source/url.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.isObject,I=Q.isFunction,_=Q.getPath,W=K("packages/core/src/source/abort.js").isAbortError,H=500,U=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),z=Symbol("lattice.url.skip");function w(d,h={}){const a=B(h)?h:{},p=I(a.fetch)?a.fetch:typeof globalThis<"u"&&I(globalThis.fetch)?globalThis.fetch:null,b=a.format==="json"||a.format==="ndjson"?a.format:void 0,j=typeof a.rowsPath=="string"&&a.rowsPath?a.rowsPath:void 0,S=I(a.map)?a.map:void 0,y=B(a.headers)?a.headers:void 0,v=Number.isFinite(a.batchSize)&&a.batchSize>0?Math.floor(a.batchSize):H,R=a.lenient===!0,O=Number.isFinite(a.poll)&&a.poll>0?Math.floor(a.poll):void 0,x=typeof d=="string"&&d.length>0;x||$("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*C(F={}){if(!x)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const E=F&&F.signal;let D;try{D=await p(d,y?{signal:E,headers:y}:{signal:E})}catch(A){throw W(A)?A:new Error(`[lattice] createUrlSource: request to ${d} failed — ${A&&A.message||A}`)}if(!D||!D.ok){const A=D?D.status:"no response";throw new Error(`[lattice] createUrlSource: ${A} for ${d}`)}const N=k(d,b,D),M=D.body&&I(D.body.getReader)?D.body.getReader():null;try{if(!M){const G=await D.text();(N||c(G,d))==="ndjson"?yield*f(null,null,G,0,D,d,v,R):yield*o(G,d,j,S);return}const A=new TextDecoder("utf-8");if(N==="json"){yield*o(await r(M,A,""),d,j,S);return}if(N==="ndjson"){yield*f(M,A,"",0,D,d,v,R);return}const L=await s(M,A,d);L.format==="json"?yield*o(await r(M,A,L.seed),d,j,S):yield*f(M,A,L.seed,L.bytes,D,d,v,R)}finally{if(M&&I(M.cancel))try{await M.cancel()}catch{}}}const P={mode:"stream",open:C,autoStart:a.autoStart!==!1};return O!==void 0&&(P.poll=O),Number.isFinite(a.maxRows)&&(P.maxRows=a.maxRows),Number.isFinite(a.maxAge)&&(P.maxAge=a.maxAge),(typeof a.ageBy=="string"||I(a.ageBy))&&(P.ageBy=a.ageBy),Number.isFinite(a.coalesceMs)&&(P.coalesceMs=a.coalesceMs),Number.isFinite(a.promoteToMemoryBelow)&&(P.promoteToMemoryBelow=a.promoteToMemoryBelow),P}function k(d,h,a){if(h)return h;const p=g(d);if(p)return p;const b=a&&a.headers&&I(a.headers.get)?a.headers.get("content-type"):null;return l(b)}function g(d){const h=String(d).split(/[?#]/)[0].toLowerCase();if(h.endsWith(".ndjson")||h.endsWith(".jsonl"))return"ndjson";if(h.endsWith(".json"))return"json"}function l(d){if(!d)return;const h=d.split(";")[0].trim().toLowerCase();if(U.has(h))return"ndjson";if(h==="application/json"||h==="text/json"||h.endsWith("+json"))return"json"}function c(d,h){const a=d.replace(/^\s+/,""),p=n(a);if(p==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${h} — pass opts.format: 'json' | 'ndjson'.`);return p}async function s(d,h,a){let p="",b=0;for(;;){const{value:S,done:y}=await d.read();if(S&&(b+=S.byteLength,p+=h.decode(S,{stream:!0})),y){p+=h.decode();break}const v=p.replace(/^\s+/,"");if(v){if(v[0]==="[")return{format:"json",seed:p,bytes:b};if(v[0]!=="{"||p.indexOf(`
8
8
  `)!==-1)break}}const j=n(p.replace(/^\s+/,""));if(j==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${a} — pass opts.format: 'json' | 'ndjson'.`);return{format:j,seed:p,bytes:b}}function n(d){if(!d||d[0]==="[")return"json";if(d[0]!=="{")return"error";const h=d.indexOf(`
9
9
  `);if(h===-1)return"json";let a=d.slice(0,h);return a.endsWith("\r")&&(a=a.slice(0,-1)),t(a)?"ndjson":"json"}function t(d){try{return JSON.parse(d),!0}catch{return!1}}async function r(d,h,a){let p=a;for(;;){const{value:b,done:j}=await d.read();if(b&&(p+=h.decode(b,{stream:!0})),j)break}return p+=h.decode(),p}function*o(d,h,a,p){let b;try{b=JSON.parse(d)}catch(S){throw new Error(`[lattice] createUrlSource: ${h} is not valid JSON — ${S.message}`)}let j=a!==void 0?_(b,a):b;if(p&&(j=p(j)),!Array.isArray(j)){const S=a!==void 0||p?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${h} did not resolve to an array${S}.`)}yield{rows:j,progress:{loaded:j.length,estimated:j.length}}}async function*f(d,h,a,p,b,j,S,y){const v=m(b);let R=a||"",O=p||0,x=0,C=0,P=[];function*F(){let D;for(;(D=R.indexOf(`
@@ -56,6 +56,6 @@ ${te}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
56
56
  `);return C===R?!1:(h.value=a.slice(0,y)+C+a.slice(v),this.#r(Math.max(y,p+(d?-j.length:j.length)),Math.max(y,b+x)),this.revalidate(),!0)}#r(d,h){const a=this.input;a&&(a.selectionStart=d,a.selectionEnd=h===void 0?d:h,W(a.setSelectionRange)&&a.setSelectionRange(a.selectionStart,a.selectionEnd))}format(d){const h=this.input;if(!h||this.language!=="json")return!1;const a=s(h.value);if(!a.ok)return this.revalidate(),!1;if(a.value===null&&h.value.trim()==="")return!1;try{const p=JSON.stringify(a.value,null,d===void 0?this.indent:d);return p===void 0?!1:(h.value=p,this.#r(p.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const d=this.input?this.input.value:"",h=o(d,this.language);this.lastResult=h;const a=this.errorNode;return a&&(a.textContent=h.ok?"":f(h),a.classList.toggle(w.errorOn,!h.ok)),this.input&&(h.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),h.ok||!a?this.input.removeAttribute("aria-errormessage"):(a.id||(a.id=H("lat-err")),this.input.setAttribute("aria-errormessage",a.id))),h}text(){return this.input?this.input.value:""}readValue(){const d=this.text();if(d.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return d;const a=s(d);return a.ok?a.value:d}checkValue(d){if(this.props.allowInvalid===!0)return!0;const h=this.revalidate();return h.ok?!0:f(h)}toClipboard(){return this.text()}fromClipboard(d){const h=d==null?"":String(d);return this.input&&(this.input.value=h),this.revalidate(),h.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:h}:{ok:!0,value:z(h)}}destroy(){for(const d of this.#e)d();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const i=u}),Fe("packages/dom/src/editors/unit.js",function(e,K){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/unit.js"),U=H.parseUnit,z=H.formatUnit,w=H.findUnit;function k(c,s){return z(c,s)}class g extends ${input=null;hint=null;opts=null;#e=[];buildOptions(){const s=this.props,n=this.params.column&&this.params.column.dataType||null,t=n&&n.unitConfig||{};return{system:s.system||t.system||"data",unit:s.unit??t.unit,binary:s.binary===!0||s.binary===void 0&&t.binary===!0,display:s.display??t.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const s=this.props;this.opts=this.buildOptions();const n=this.symbol(),t=`${this.id}-unit`,r=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:s.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":n?t:null}});r.value=k(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(r.value=this.params.key),this.input=r;const o=typeof s.step=="number"?s.step:0;return o>0&&this.#e.push(_(r,"keydown",f=>{f.key==="ArrowUp"?(W(f.preventDefault)&&f.preventDefault(),this.nudge(o)):f.key==="ArrowDown"&&(W(f.preventDefault)&&f.preventDefault(),this.nudge(-o))})),this.hint=I(this.doc,"span",{class:`${B.editor}__suffix`,text:n,attrs:{id:t,"aria-hidden":"true"}}),I(this.doc,"div",{class:`${B.editor}__unit`,children:[r,this.hint]})}symbol(){const s=w(this.opts.system,this.opts.unit);return s?s.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const s=this.input;s&&!this.params.key&&this.props.selectOnFocus!==!1&&W(s.select)&&s.select()}nudge(s){const n=U(this.input?this.input.value:"",this.opts);let t=(n??0)+s;const{min:r,max:o}=this.props;typeof r=="number"&&t<r&&(t=r),typeof o=="number"&&t>o&&(t=o),this.input&&(this.input.value=k(t,this.opts))}readValue(){const s=this.input?this.input.value:"";if(String(s).trim()==="")return null;const n=U(s,this.opts);if(n===null)return NaN;if(this.mode()!=="clamp")return n;const{min:t,max:r}=this.props;let o=n;return typeof t=="number"&&o<t&&(o=t),typeof r=="number"&&o>r&&(o=r),o}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(s){if(s===null)return!0;if(typeof s!="number"||Number.isNaN(s)){const n=this.symbol();return n?`Enter a value such as 10 ${n}`:"Enter a value"}if(this.mode()==="reject"){const{min:n,max:t}=this.props;if(typeof n=="number"&&s<n)return`Must be ${this.describe(n)} or more`;if(typeof t=="number"&&s>t)return`Must be ${this.describe(t)} or less`}return!0}describe(s){return z(s,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return z(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(s){const n=s==null?"":String(s);if(n.trim()==="")return{ok:!0,value:null};const t=U(n,this.opts),r=t===null?NaN:t,o=this.checkValue(r);return o!==!0?{ok:!1,message:o}:{ok:!0,value:r}}destroy(){for(const s of this.#e)s();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const l=g}),Fe("packages/dom/src/editors/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=K("packages/core/src/internal/util.js"),W=X.isFunction,H=X.uid,U=K("packages/core/src/columns/types/radix.js"),z=U.compileRadixFormat,w=U.compileRadixParse,k=U.normaliseRadixOptions,g=U.radixRange,l=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),c=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),s=new Map;function n(f){const u=f||"";let i=s.get(u);if(i)return i;try{i=new Intl.NumberFormat(f||void 0,{maximumFractionDigits:0})}catch{i={format:m=>String(m)}}return s.set(u,i),i}function t(f,u){const i=u||{},m={};if(f){for(const h of c)f[h]!==void 0&&(m[h]=f[h]);const d=g(f.bitWidth??null,f.signed!==!1);typeof f.min=="number"&&f.min>d.min&&(m.min=f.min),typeof f.max=="number"&&f.max<d.max&&(m.max=f.max)}for(const d of c)i[d]!==void 0&&(m[d]=i[d]);return typeof i.min=="number"&&(m.min=i.min),typeof i.max=="number"&&(m.max=i.max),k(m)}class r extends ${input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const u=this.params.column&&this.params.column.dataType;this.options=t(u&&u.radix||null,this.props),this.format=z(this.options),this.parse=w(this.options);const i=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:this.options.radix===2?"numeric":"text",autocomplete:"off",autocapitalize:"off",spellcheck:"false",placeholder:this.props.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-valuemin":this.options.min,"aria-valuemax":this.options.max}});i.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(i.value=this.params.key),this.input=i;const m=I(this.doc,"span",{class:l.hint,attrs:{"aria-live":"polite"}});this.hint=m,this.#e.push(_(i,"input",()=>this.refresh())),this.#e.push(_(i,"keydown",h=>this.#n(h)));const d=I(this.doc,"div",{class:l.root,children:[i,m]});return this.refresh(),d}focusTarget(){return this.input}attached(){super.attached();const u=this.input;u&&!this.params.key&&this.props.selectOnFocus!==!1&&W(u.select)&&u.select()}#t(u){return u.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(u)}#n(u){const i=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;u.key==="ArrowUp"?(W(u.preventDefault)&&u.preventDefault(),this.nudge(i)):u.key==="ArrowDown"&&(W(u.preventDefault)&&u.preventDefault(),this.nudge(-i))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(u){const{min:i,max:m}=this.options;return u<i?i:u>m?m:u}evaluate(){const u=this.input?String(this.input.value):"";if(u.trim()==="")return{value:null,message:null};const i=this.parse(u);return i.ok?{value:this.mode()==="clamp"?this.clamp(i.value):i.value,message:null}:this.mode()==="clamp"&&typeof i.value=="number"&&(i.reason==="range"||i.reason==="negative")?{value:this.clamp(i.value),message:null}:{value:NaN,message:this.messageFor(i.reason)}}messageFor(u){const i=this.options;return u==="negative"?`This column holds an unsigned ${i.bitWidth}-bit pattern; enter ${this.format(0)} or more`:u==="range"?`Must be between ${this.format(i.min)} and ${this.format(i.max)}`:`Enter a ${i.name} value, e.g. ${this.format(i.radix===2?5:26)}`}refresh(){const{value:u,message:i}=this.evaluate();if(this.input&&this.input.classList&&(i?this.input.classList.add(B.invalid):this.input.classList.remove(B.invalid),this.input.setAttribute("aria-invalid",i?"true":"false"),i&&this.hint?(this.hint.id||(this.hint.id=H("lat-err")),this.input.setAttribute("aria-errormessage",this.hint.id)):this.input.removeAttribute("aria-errormessage")),!!this.hint){if(i){this.hint.textContent=i,this.hint.classList&&this.hint.classList.add(l.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(l.hintInvalid),this.hint.textContent=u===null?"":`= ${n(this.params.locale).format(u)}`}}nudge(u){if(!this.input)return;const i=this.parse(this.input.value);let m;typeof i.value=="number"?m=i.value:typeof this.params.value=="number"?m=this.params.value:m=0,this.input.value=this.format(this.clamp(m+u)),this.refresh()}readValue(){return this.evaluate().value}checkValue(u){return u===null?!0:typeof u!="number"||Number.isNaN(u)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&u<0?this.messageFor("negative"):this.mode()==="reject"&&(u<this.options.min||u>this.options.max)?this.messageFor("range"):!0}toClipboard(){const u=this.readValue();return u===null||Number.isNaN(u)?this.input?String(this.input.value):"":this.format(u)}fromClipboard(u){const i=u==null?"":String(u);if(i.trim()==="")return{ok:!0,value:null};const m=this.parse(i);let d;if(m.ok)d=m.value;else if(this.mode()==="clamp"&&typeof m.value=="number"&&(m.reason==="range"||m.reason==="negative"))d=this.clamp(m.value);else return{ok:!1,message:this.messageFor(m.reason)};const h=this.checkValue(d);return h!==!0?{ok:!1,message:h}:{ok:!0,value:d}}destroy(){for(const u of this.#e)u();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const o=r}),Fe("packages/dom/src/editors/segmented.js",function(e,K){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=Q.keyOf,W=Q.normaliseLookup,H=Q.documentFor,U=Q.lookupFor,w=K("packages/dom/src/editors/select.js").SelectEditor,g=K("packages/core/src/internal/util.js").isFunction,c=K("packages/dom/src/cell/icons.js").createIcon,s=6;class n extends ${static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(f){const u=f||{},i=t(u),m=U(u,i,{colId:u.column&&(u.column.id||u.column.field)}),d=Number(i.max??s),h=m.options().length;if(Number.isFinite(d)&&h>d){const a=new w;a.init(u),this.#e=a,this.params=u,this.doc=H(u),this.props=i,this.lookup=m,this.popup=a.popup;return}super.init(u),(!this.lookup||!this.lookup.options().length)&&(this.lookup=m)}usesFallback(){return this.#e!==null}build(){const f=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const u=I(f,"div",{class:`${B.editor}__segmented`,attrs:{role:"radiogroup","aria-label":this.params.column&&this.params.column.title||null,"data-size":this.props.size?String(this.props.size):null}});for(let i=0;i<this.options.length;i++)u.appendChild(this.buildSegment(this.options[i],i));return this.props.allowClear===!0&&u.appendChild(this.buildClear()),this.#t.push(_(u,"keydown",i=>this.onKeyDown(i))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),u}buildSegment(f,u){const i=this.doc,m=I(i,"button",{class:`${B.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":u,"data-variant":f.variant??null,"aria-disabled":f.disabled===!0?"true":null}});return f.icon&&m.appendChild(c(i,f.icon,{className:B.icon})),m.appendChild(I(i,"span",{class:`${B.editor}__segment-label`,text:f.label})),this.#t.push(_(m,"mousedown",d=>{d&&g(d.preventDefault)&&d.preventDefault(),f.disabled!==!0&&(this.focused=u,this.select(u,{commit:!0}))})),this.segments.push(m),m}buildClear(){const f=I(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(_(f,"mousedown",u=>{u&&g(u.preventDefault)&&u.preventDefault(),this.clearSelection()})),f}indexOf(f){if(f==null)return-1;const u=X(f);for(let i=0;i<this.options.length;i++)if(X(this.options[i].id)===u)return i;return-1}paint(){for(let f=0;f<this.segments.length;f++){const u=f===this.indexOf(this.selected),i=this.segments[f];i.setAttribute("aria-checked",u?"true":"false"),i.setAttribute("tabindex",f===this.focused?"0":"-1"),i.classList.toggle(`${B.editor}__segment--active`,u),i.classList.toggle(`${B.editor}__segment--disabled`,this.options[f].disabled===!0)}}select(f,u){const i=this.options[f];!i||i.disabled===!0||(this.selected=i.id,this.paint(),u&&u.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(f){const u=this.segments.length;if(!u)return;let i=this.focused;for(let m=0;m<u;m++)if(i=(i+f+u)%u,this.options[i].disabled!==!0){this.focusAt(i);return}}focusAt(f){if(f<0||f>=this.segments.length)return;this.focused=f,this.paint();const u=this.segments[f];u&&g(u.focus)&&u.focus()}edgeIndex(f){const u=this.options.length;for(let i=0;i<u;i++){const m=f===1?i:u-1-i;if(this.options[m].disabled!==!0)return m}return-1}onKeyDown(f){const u=()=>{g(f.preventDefault)&&f.preventDefault()};switch(f.key){case"ArrowRight":case"ArrowDown":u(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":u(),this.moveFocus(-1);break;case"Home":u(),this.focusAt(this.edgeIndex(1));break;case"End":u(),this.focusAt(this.edgeIndex(-1));break;case"Enter":u(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":u(),this.select(this.focused);break;case"Escape":u(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(u(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(f){return f==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(f)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(f)}" is not a valid option`}element(){return this.#e?this.#e.element():super.element()}value(){return this.#e?this.#e.value():super.value()}focusTarget(){if(!this.segments.length)return super.focusTarget();const f=this.indexOf(this.selected);return this.segments[f>=0?f:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const f=this.lookup.ready();!f||!g(f.then)||f.then(()=>{if(!super.element()||this.options.length)return;const u=super.element();this.options=this.lookup.options();for(let i=0;i<this.options.length;i++)u.appendChild(this.buildSegment(this.options[i],i));this.focused=Math.max(0,this.indexOf(this.selected)),this.paint()})}cancelBeforeStart(){return this.#e?this.#e.cancelBeforeStart():super.cancelBeforeStart()}cancelOnClose(){return this.#e?this.#e.cancelOnClose():super.cancelOnClose()}commit(){return this.#e?this.#e.commit():super.commit()}cancel(){this.#e?this.#e.cancel():super.cancel()}validate(f){return this.#e?this.#e.validate(f):super.validate(f)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(f){return this.#e?this.#e.fromClipboard(f):super.fromClipboard(f)}destroy(){for(const f of this.#t)f();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function t(o){return{...o.column&&o.column.edit&&o.column.edit.props||{},...o.props||{}}}const r=n}),Fe("packages/dom/src/editors/rating.js",function(e,K){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,W=K("packages/dom/src/cell/icons.js").createIcon,H=K("packages/dom/src/cell/renderers/rating.js"),U=H.ratingFills,z=H.fillState,w=H.ratingText,k=H.clampRating,g=H.DEFAULT_RATING_ICON,l=H.DEFAULT_RATING_MAX,s=K("packages/core/src/internal/util.js").isFunction;class n extends ${static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const f=Math.floor(Number(this.props.max??l));return Number.isFinite(f)&&f>0?f:l}step(){return this.props.allowHalf===!0?.5:1}build(){const f=this.doc,u=this.max();this.rating=t(this.params.value,u,this.props.allowHalf===!0);const i=I(f,"div",{class:`${B.editor}__rating`}),m=I(f,"div",{class:`${B.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(u),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let h=0;h<u;h++)m.appendChild(this.buildItem(h));i.appendChild(m),this.slider=m;const d=I(f,"span",{class:`${B.editor}__rating-value`});return i.appendChild(d),this.readout=d,this.props.allowClear===!0&&i.appendChild(this.buildClear()),this.#e.push(_(m,"keydown",h=>this.onKeyDown(h))),this.props.hoverPreview!==!1&&this.#e.push(_(m,"mouseleave",()=>{this.preview=null,this.paint()})),this.params.key&&/^[0-9]$/.test(this.params.key)&&(this.rating=Math.min(Number(this.params.key),u)),this.paint(),i}buildItem(f){const u=this.doc,i=String(this.props.icon??g),m=I(u,"span",{class:`${B.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[W(u,i,{className:B.icon})]}),d=I(u,"span",{class:`${B.editor}__rating-item`,attrs:{"data-index":f,"data-icon":i,"aria-hidden":"true"},children:[W(u,i,{className:B.icon}),m]});return this.fills.push(m),this.#e.push(_(d,"mousedown",h=>{h&&s(h.preventDefault)&&h.preventDefault(),this.setRating(this.ratingAt(f,h),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(_(d,"mousemove",h=>{const a=this.ratingAt(f,h);a!==this.preview&&(this.preview=a,this.paint())})),this.items.push(d),d}buildClear(){const f=I(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(_(f,"mousedown",u=>{u&&s(u.preventDefault)&&u.preventDefault(),this.setRating(null)})),f}ratingAt(f,u){if(this.props.allowHalf!==!0)return f+1;const i=this.items[f],m=i&&Number(i.offsetWidth),d=u&&Number(u.offsetX);return!Number.isFinite(m)||m<=0||!Number.isFinite(d)?f+1:d*2<m?f+.5:f+1}focusTarget(){return this.slider}setRating(f,u){this.rating=f===null?null:k(f,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),u&&u.commit&&this.commit()}nudge(f){const u=this.rating===null?0:this.rating;this.setRating(u+f)}paint(){const f=this.max(),u=this.props.allowHalf===!0,i=this.preview===null?this.rating:this.preview,m=U(i===null?0:i,f,{allowHalf:u});for(let a=0;a<this.items.length;a++){const p=z(m[a]);this.items[a].setAttribute("data-fill",p),this.items[a].classList.toggle(`${B.editor}__rating-item--filled`,p!=="empty"),this.fills[a]&&this.fills[a].style.setProperty("--lat-rating-fill",`${(m[a]*100).toFixed(2)}%`)}const d=i===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:w(i),max:f}),h=this.slider;h&&(h.setAttribute("aria-valuenow",i===null?"0":String(i)),h.setAttribute("aria-valuetext",d),h.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=d)}onKeyDown(f){const u=()=>{s(f.preventDefault)&&f.preventDefault()},i=this.step();if(/^[0-9]$/.test(f.key)){u(),this.setRating(Math.min(Number(f.key),this.max()));return}switch(f.key){case"ArrowRight":case"ArrowUp":u(),this.nudge(i);break;case"ArrowLeft":case"ArrowDown":u(),this.nudge(-i);break;case"Home":u(),this.setRating(0);break;case"End":u(),this.setRating(this.max());break;case"Enter":u(),this.commit();break;case"Escape":u(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(u(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(f){if(f==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof f!="number"||!Number.isFinite(f))return"Enter a rating";const u=this.max();return f<0?"Must be 0 or more":f>u?`Must be ${u} or less`:this.props.allowHalf!==!0&&!Number.isInteger(f)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":w(this.rating)}fromClipboard(f){const u=String(f??"").trim();if(u==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const i=Number(u);if(!Number.isFinite(i))return{ok:!1,message:`"${u}" is not a rating`};const m=this.checkValue(i);return m!==!0?{ok:!1,message:m}:{ok:!0,value:i}}destroy(){for(const f of this.#e)f();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function t(o,f,u){if(o==null||o==="")return null;const i=Number(o);return Number.isFinite(i)?k(i,f,u,!1):null}const r=n}),Fe("packages/dom/src/editors/slider.js",function(e,K){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=K("packages/dom/src/editors/number.js"),W=X.parseNumberText,H=X.presentNumber,z=K("packages/core/src/internal/util.js").isFunction,w=0,k=100;class g extends ${static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const r=Number(this.props.min??w);return Number.isFinite(r)?r:w}max(){const r=Number(this.props.max??k);return Number.isFinite(r)?r:k}step(){const r=Number(this.props.step??1);return Number.isFinite(r)&&r>0?r:1}build(){const r=this.doc,o=this.min(),f=this.max(),u=this.step(),i=s(this.props.marks);this.marks=i,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const m=I(r,"div",{class:`${B.editor}__slider`});this.root=m;const d=I(r,"input",{class:`${B.editor}__slider-input`,attrs:{type:"range",min:String(o),max:String(f),step:String(u),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:i.length?`${this.id}-marks`:null}});if(this.range=d,m.appendChild(d),i.length){const a=I(r,"datalist",{attrs:{id:`${this.id}-marks`}}),p=I(r,"div",{class:`${B.editor}__slider-marks`});for(const b of i){a.appendChild(I(r,"option",{attrs:{value:String(b.value),label:b.label}}));const j=I(r,"span",{class:`${B.editor}__slider-mark`,text:b.label,attrs:{"data-value":String(b.value)}});j.style&&z(j.style.setProperty)&&j.style.setProperty("--lat-slider-mark",`${(l(b.value,o,f)*100).toFixed(2)}%`),p.appendChild(j)}m.appendChild(a),m.appendChild(p)}const h=I(r,"input",{class:`${B.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=h,m.appendChild(h),this.props.showValue!==!1){const a=I(r,"span",{class:`${B.editor}__slider-value`});m.appendChild(a),this.readout=a}return this.#e.push(_(d,"input",()=>this.setAmount(Number(d.value),"range"))),this.#e.push(_(d,"change",()=>this.setAmount(Number(d.value),"range"))),this.#e.push(_(d,"keydown",a=>this.onKeyDown(a))),this.#e.push(_(h,"input",()=>this.onFieldInput())),this.#e.push(_(h,"change",()=>this.paint())),this.#e.push(_(h,"keydown",a=>this.onKeyDown(a))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(h.value=this.params.key,this.onFieldInput()),this.paint(),m}focusTarget(){return this.field}attached(){super.attached();const r=this.field;r&&!this.params.key&&this.props.selectOnFocus!==!1&&z(r.select)&&r.select()}snap(r){if(!Number.isFinite(r))return this.min();const o=this.min(),f=this.max(),u=this.step(),i=Math.min(Math.max(r,o),f),m=o+Math.round((i-o)/u)*u,d=c(u),h=d>0?Number(m.toFixed(d)):Math.round(m);return Math.min(Math.max(h,o),f)}setAmount(r,o){this.amount=r===null?null:this.snap(r),this.paint(o)}onFieldInput(){const r=this.field?String(this.field.value):"";if(r.trim()===""){this.amount=null,this.paint("field");return}const o=W(r,this.params.locale);if(o===null||Number.isNaN(o)){this.paint("field");return}this.setAmount(o,"field")}paint(r){const o=this.min(),f=this.max(),u=this.amount,i=u===null?o:u;this.range&&r!=="range"&&(this.range.value=String(i)),this.field&&r!=="field"&&(this.field.value=u===null?"":H(u,this.props));const m=this.root;m&&m.style&&z(m.style.setProperty)&&m.style.setProperty("--lat-slider-pos",`${(l(i,o,f)*100).toFixed(2)}%`),m&&m.setAttribute&&m.setAttribute("data-empty",u===null?"true":"false");const d=this.labelFor(u);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",d),this.readout&&(this.readout.textContent=d)}labelFor(r){if(r===null)return String(this.props.emptyLabel??"");const o=this.marks.find(u=>u.value===r),f=H(r,this.props);return o&&o.label!==f?`${f} (${o.label})`:f}onKeyDown(r){if(r.key==="Escape"){z(r.preventDefault)&&r.preventDefault(),this.cancel();return}if(r.key==="Enter"){z(r.preventDefault)&&r.preventDefault(),this.commit();return}r.key==="Tab"&&this.commit()}readValue(){const r=this.field?String(this.field.value):"";if(r.trim()==="")return null;const o=W(r,this.params.locale);return o===null||Number.isNaN(o)?NaN:this.snap(o)}checkValue(r){return r==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof r!="number"||Number.isNaN(r)?"Enter a number":r<this.min()?`Must be ${this.min()} or more`:r>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(r){const o=String(r??"").trim();if(o==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const f=W(o,this.params.locale);if(f===null||Number.isNaN(f))return{ok:!1,message:"Enter a number"};const u=this.snap(f),i=this.checkValue(u);return i!==!0?{ok:!1,message:i}:{ok:!0,value:u}}destroy(){for(const r of this.#e)r();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function l(t,r,o){const f=o-r;return!Number.isFinite(f)||f===0?0:Math.min(1,Math.max(0,(Number(t)-r)/f))}function c(t){if(!Number.isFinite(t))return 0;const r=String(t),o=r.indexOf("e");if(o>=0){const u=r.slice(0,o),i=u.indexOf("."),m=i<0?0:u.length-i-1;return Math.min(15,Math.max(0,m-Number(r.slice(o+1))))}const f=r.indexOf(".");return f<0?0:Math.min(15,r.length-f-1)}function s(t){if(!t)return[];const r=[];if(Array.isArray(t)){for(const o of t){if(o&&typeof o=="object"){const u=Number(o.value);Number.isFinite(u)&&r.push({value:u,label:String(o.label??u)});continue}const f=Number(o);Number.isFinite(f)&&r.push({value:f,label:String(f)})}return r}if(typeof t=="object")for(const[o,f]of Object.entries(t)){const u=Number(o);Number.isFinite(u)&&r.push({value:u,label:String(f)})}return r}const n=g}),Fe("packages/dom/src/editors/colour.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=K("packages/dom/src/cell/renderers/colour.js"),W=X.normaliseColour,H=X.parseColour,z=K("packages/core/src/internal/util.js").isFunction,w=Object.freeze(["neutral","info","success","warning","danger","accent"]),k=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function g(r){if(r==null)return null;if(typeof r=="object"){const u=r,i=g(u.token??u.value??u.colour??u.color);return i?{...i,label:u.label==null?i.label:String(u.label)}:null}const o=String(r).trim();if(o==="")return null;const f=W(o);return f?{token:null,hex:f,label:f}:Object.hasOwn(k,o)?{token:o,hex:k[o],label:o}:null}function l(r,o){const f=r&&r.ownerDocument,u=f&&f.defaultView;if(!u||!z(u.getComputedStyle))return null;try{const i=u.getComputedStyle(r);return!i||!z(i.getPropertyValue)?null:W(String(i.getPropertyValue(`--lattice-variant-${o}-solid`)).trim())}catch{return null}}class c extends ${static popup=!0;swatches=[];buttons=[];native=null;hex=null;preview=null;#e=[];alpha(){return this.props.alpha===!0}build(){const o=this.doc;this.swatches=s(this.props.swatches);const f=I(o,"div",{class:`${B.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=I(o,"span",{class:`${B.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),f.appendChild(this.preview),this.swatches.length){const i=I(o,"div",{class:`${B.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let m=0;m<this.swatches.length;m++)i.appendChild(this.buildSwatch(this.swatches[m],m));f.appendChild(i)}this.native=I(o,"input",{class:`${B.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),f.appendChild(this.native),this.hex=I(o,"input",{class:`${B.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),f.appendChild(this.hex),this.props.allowClear===!0&&f.appendChild(this.buildClear()),this.#e.push(_(this.native,"input",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(_(this.native,"change",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(_(this.hex,"input",()=>this.paint())),this.#e.push(_(this.hex,"change",()=>this.paint())),this.#e.push(_(this.hex,"keydown",i=>this.onKeyDown(i))),this.#e.push(_(f,"keydown",i=>this.onKeyDown(i)));const u=W(this.params.value,{alpha:this.alpha()});return this.hex.value=u===null?this.params.value==null?"":String(this.params.value):u,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),f}buildSwatch(o,f){const u=I(this.doc,"button",{class:`${B.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":o.label,"data-index":f,"data-variant":o.token}});return o.token||n(u,o.hex),this.#e.push(_(u,"mousedown",i=>{i&&z(i.preventDefault)&&i.preventDefault(),this.setColour(this.swatches[f].hex)})),this.buttons.push(u),u}buildClear(){const o=I(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(_(o,"mousedown",f=>{f&&z(f.preventDefault)&&f.preventDefault(),this.setColour(null)})),o}focusTarget(){return this.hex}attached(){super.attached();for(let o=0;o<this.swatches.length;o++){const f=this.swatches[o];if(!f.token)continue;const u=l(this.buttons[o]||this.element(),f.token);u&&(f.hex=u)}this.paint()}setColour(o){const f=o===null?null:W(o,{alpha:this.alpha()});this.hex&&(this.hex.value=f===null?"":f),this.paint()}current(){const o=this.hex?String(this.hex.value).trim():"";return o===""?null:W(o,{alpha:this.alpha()})}paint(){const o=this.current(),f=o===null?null:o.slice(0,7);n(this.preview,f),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",o===null?"true":"false"),this.native&&(this.native.value=f===null?"#000000":f);for(let u=0;u<this.buttons.length;u++){const i=o!==null&&this.swatches[u].hex.toLowerCase()===o.toLowerCase();this.buttons[u].setAttribute("aria-checked",i?"true":"false"),this.buttons[u].classList.toggle(`${B.editor}__colour-swatch--selected`,i),this.swatches[u].token||n(this.buttons[u],this.swatches[u].hex)}}onKeyDown(o){if(o.key==="Escape"){z(o.preventDefault)&&o.preventDefault(),this.cancel();return}if(o.key==="Enter"){z(o.preventDefault)&&o.preventDefault(),this.commit();return}o.key==="Tab"&&this.commit()}readValue(){const o=this.hex?String(this.hex.value).trim():"";if(o==="")return null;const f=W(o,{alpha:this.alpha()});return f===null?o:f}checkValue(o){if(o==null||o==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const f=H(o);return f?!this.alpha()&&f.a<1?"This column does not accept transparency":!0:`"${String(o)}" is not a colour`}toClipboard(){const o=this.current();return o===null?"":o}fromClipboard(o){const f=String(o??"").trim();if(f==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const u=W(f,{alpha:this.alpha()});if(u===null)return{ok:!1,message:`"${f}" is not a colour`};const i=this.checkValue(u);return i!==!0?{ok:!1,message:i}:{ok:!0,value:u}}destroy(){for(const o of this.#e)o();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function s(r){const o=Array.isArray(r)&&r.length?r:r===!1?[]:w,f=[];for(const u of o){const i=g(u);i&&f.push(i)}return f}function n(r,o){const f=r&&r.style;if(f){if(o===null){z(f.removeProperty)&&f.removeProperty("--lat-swatch");return}z(f.setProperty)&&f.setProperty("--lat-swatch",o)}}const t=c}),Fe("packages/dom/src/editors/treeselect.js",function(e,K){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const $=K("packages/dom/src/editors/select.js").SelectEditorBase,I=K("packages/dom/src/cell/icons.js").createIcon,_=K("packages/dom/src/editors/common.js"),X=_.CLS,W=_.el,H=_.on,U=_.clear,z=_.keyOf,w=_.rawOptions,k=_.lookupKey,g=K("packages/core/src/internal/util.js"),l=g.isFunction,c=g.isObject,s="\0";class n extends ${static popup=!0;roots=[];nodes=new Map;expanded=new Set;matched=new Set;selected=null;leavesOnly=!0;build(){this.leavesOnly=this.props.selectLeavesOnly!==!1;const o=super.build();return o.classList.add("lat-treeselect"),this.list&&this.list.element().setAttribute("role","tree"),o}initSelection(){this.rebuild(),this.selected=this.params.value??null;const o=this.nodeById(this.selected);if(o)for(let f=o.parent;f;f=f.parent)this.expanded.add(f.key)}rebuild(){const o=w(this.params,this.props),f=this.props.keys||{},u=f.value||k(this.params,"valueKey")||"id",i=f.label||k(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const m of o){if(!c(m)){this.addNode(null,String(m??""),m,null);continue}Array.isArray(m.path)&&m.path.length?this.addByPath(m,u,i):this.addByChildren(m,null,u,i)}if(this.props.defaultExpanded===!0)for(const m of this.nodes.keys())this.expanded.add(m)}addNode(o,f,u,i){const m=o?`${o.key}${s}${f}`:f;let d=this.nodes.get(m);return d?d.id===void 0&&u!==void 0&&(d.id=u):(d={id:u,label:f,key:m,parent:o,children:[],depth:o?o.depth+1:0,disabled:!1},this.nodes.set(m,d),(o?o.children:this.roots).push(d)),i&&(i.disabled===!0&&(d.disabled=!0),i.icon!==void 0&&(d.icon=i.icon),i.variant!==void 0&&(d.variant=i.variant)),d}addByPath(o,f,u){const i=o.path;let m=null;for(let d=0;d<i.length;d++){const h=d===i.length-1,a=String(i[d]),p=h&&o[u]!=null?String(o[u]):a,b=this.addNode(m,a,h?o[f]:void 0,h?o:null);h&&(b.label=p),m=b}}addByChildren(o,f,u,i){const m=o[u],d=o[i]!=null?String(o[i]):String(m??""),h=this.addNode(f,d,m,o),a=Array.isArray(o.children)?o.children:[];for(const p of a)c(p)?this.addByChildren(p,h,u,i):this.addNode(h,String(p??""),p,null)}nodeById(o){if(o==null)return;const f=z(o);for(const u of this.nodes.values())if(u.id!==void 0&&z(u.id)===f)return u}filterOptions(o){const f=String(o||"").trim().toLowerCase(),u=f!=="";this.matched=u?this.computeMatches(f):new Set;const i=[],m=d=>{for(const h of d)u&&!this.matched.has(h.key)||(i.push(h),h.children.length&&(u||this.expanded.has(h.key))&&m(h.children))};return m(this.roots),i}computeMatches(o){const f=new Set,u=i=>{let m=i.label.toLowerCase().includes(o);for(const d of i.children)u(d)&&(m=!0);return m&&f.add(i.key),m};for(const i of this.roots)u(i);return f}repaint(o){if(this.refreshOptions(),!o||!this.list)return;const f=this.visible.findIndex(u=>u.key===o);f>=0&&this.list.setActive(f)}isBranch(o){return!!o&&o.children.length>0}isSelectable(o){return!o||o.disabled||o.id===void 0||o.id===null?!1:!(this.leavesOnly&&this.isBranch(o))}setExpanded(o,f){this.isBranch(o)&&(f?this.expanded.add(o.key):this.expanded.delete(o.key),this.repaint(o.key))}choose(o){if(o){if(!this.isSelectable(o)){this.isBranch(o)&&this.setExpanded(o,!this.expanded.has(o.key));return}this.selected=o.id,this.input&&(this.input.value=""),this.query="",this.repaint(o.key),this.paintDisplay(),this.commit()}}isSelected(o){return this.selected!=null&&o&&o.id!==void 0&&z(o.id)===z(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}checkValue(o){if(o==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a value";if(!this.nodes.size)return!0;const f=this.nodeById(o);return f&&this.isSelectable(f)?!0:f?`"${f.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(o)}" is not a valid option`}renderOption(o,f,u){U(f),f.setAttribute("role","treeitem"),f.setAttribute("aria-level",String(o.depth+1)),f.setAttribute("data-depth",String(o.depth));const i=W(this.doc,"span",{class:"lat-tree__indent"});for(let b=0;b<o.depth;b++)i.appendChild(W(this.doc,"span",{class:"lat-tree__guide"}));f.appendChild(i);const m=this.isBranch(o),d=m&&(this.expanded.has(o.key)||this.query.trim()!==""),h=m?d?"chevronDown":"chevronRight":"blank",a=W(this.doc,"span",{class:m?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[I(this.doc,h,{className:X.icon})],attrs:{"data-icon":m?h:null,"aria-hidden":"true"}});m&&H(a,"mousedown",b=>{l(b.preventDefault)&&b.preventDefault(),l(b.stopPropagation)&&b.stopPropagation(),this.setExpanded(o,!this.expanded.has(o.key))}),f.appendChild(a),o.icon&&f.appendChild(I(this.doc,o.icon,{className:X.icon})),f.appendChild(W(this.doc,"span",{class:`${X.option}__label`,text:o.label})),o.variant?f.setAttribute("data-variant",o.variant):f.removeAttribute("data-variant"),m?f.setAttribute("aria-expanded",d?"true":"false"):f.removeAttribute("aria-expanded");const p=this.isSelected(o);f.classList.toggle(X.optionSelected,p),f.classList.toggle(X.optionDisabled,!this.isSelectable(o)),f.classList.toggle("lat-tree__row--branch",m),f.setAttribute("aria-selected",p?"true":"false"),this.isSelectable(o)?f.removeAttribute("aria-disabled"):f.setAttribute("aria-disabled","true")}paintDisplay(){const o=this.display;if(!o)return;if(U(o),this.selected==null){o.removeAttribute("data-variant");return}const f=this.nodeById(this.selected);if(!f){o.appendChild(W(this.doc,"span",{text:String(this.selected)}));return}f.icon&&o.appendChild(I(this.doc,f.icon,{className:X.icon})),o.appendChild(W(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(f)})),f.variant?o.setAttribute("data-variant",f.variant):o.removeAttribute("data-variant")}pathLabel(o){const f=[];for(let u=o;u;u=u.parent)f.unshift(u.label);return f.join(String(this.props.pathSeparator??" / "))}onKeyDown(o){const f=this.list,u=f&&f.active>=0?this.visible[f.active]:null;switch(o.key){case"ArrowRight":{if(l(o.preventDefault)&&o.preventDefault(),!u)return;this.isBranch(u)&&!this.expanded.has(u.key)?this.setExpanded(u,!0):this.isBranch(u)&&f&&f.setActive(Math.min(this.visible.length-1,f.active+1));return}case"ArrowLeft":{if(l(o.preventDefault)&&o.preventDefault(),!u)return;this.isBranch(u)&&this.expanded.has(u.key)?this.setExpanded(u,!1):u.parent&&this.focusNode(u.parent.key);return}case"Home":l(o.preventDefault)&&o.preventDefault(),f&&this.visible.length&&f.setActive(0);return;case"End":l(o.preventDefault)&&o.preventDefault(),f&&this.visible.length&&f.setActive(this.visible.length-1);return;default:super.onKeyDown(o)}}focusNode(o){if(!this.list)return;const f=this.visible.findIndex(u=>u.key===o);f>=0&&this.list.setActive(f)}acceptHighlight(o){const f=this.list,u=f&&f.active>=0?this.visible[f.active]:null;if(!u){o&&o.commit&&this.commit();return}if(this.isSelectable(u)){this.choose(u);return}this.isBranch(u)?this.setExpanded(u,!this.expanded.has(u.key)):o&&o.commit&&this.commit()}moveHighlight(o){const f=this.list;if(!f)return;let u=f.active;for(let i=0;i<this.visible.length;i++){if(u+=o,u<0||u>=this.visible.length)return;if(!this.visible[u].disabled){f.setActive(u);return}}}}const t=n}),Fe("packages/dom/src/editors/objectpicker.js",function(e,K){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const $=K("packages/dom/src/editors/select.js").SelectEditorBase,B=K("packages/dom/src/editors/common.js"),I=B.CLS,_=B.el,X=B.on,W=B.clear,H=B.keyOf,U=B.debounce,z=B.rawOptions,w=B.optionSource,k=B.lookupSearch,g=B.lookupKey,l=K("packages/core/src/internal/util.js"),c=l.isFunction,s=l.isObject,n=l.getPath,r=K("packages/dom/src/cell/icons.js").createIcon;class o extends ${static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const h=super.build();if(h.classList.add("lat-objectpicker"),c(this.props.search)&&!(this.lookup&&this.lookup.search)){const a=Number(this.props.searchDebounce)||200;this.#n=U(p=>this.runRemoteSearch(String(p)),a)}return h}onQuery(h){super.onQuery(h),this.#n&&this.#n(h)}initSelection(){const h=z(this.params,this.props).map(a=>this.toOption(a));(h.length||!this.all.length)&&(this.all=h),this.selected=this.params.value??null}toOption(h){if(!s(h)){const y=h==null?"":String(h);return{id:h,label:y,secondary:"",avatar:"",initials:u(y),disabled:!1,raw:{}}}const a=this.props.valueKey||g(this.params,"valueKey")||"id",p=this.props.labelKey||g(this.params,"labelKey")||"label",b=f(h,this.props.template??p,""),j=f(h,this.props.secondary,""),S=f(h,this.props.avatar,"");return{id:h[a],label:b||String(h[a]??""),secondary:j,avatar:S,initials:u(b||String(h[a]??"")),disabled:h.disabled===!0,icon:h.icon,variant:h.variant,raw:h}}attached(){if(super.attached(),this.#t||this.all.length)return;const h=w(this.params,this.props);c(h)&&(this.#t=!0,Promise.resolve(h()).then(a=>{!this.element()||!Array.isArray(a)||(this.all=a.map(p=>this.toOption(p)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(h){const a=String(h||"").trim().toLowerCase();if(a==="")return this.all;const p=i(this.props.searchFields);return this.all.filter(b=>{if(!p)return b.label.toLowerCase().includes(a)||b.secondary.toLowerCase().includes(a);for(const j of p){const S=c(j)?j(b.raw):n(b.raw,j);if(S!=null&&String(S).toLowerCase().includes(a))return!0}return!1})}async runRemoteSearch(h){const a=k(this.params,this.props);if(!a)return;this.#e&&this.#e.abort();const p=new AbortController;this.#e=p;try{const b=await a(h,p.signal);if(p.signal.aborted||this.#e!==p)return;this.refreshOptions(Array.isArray(b)?b.map(j=>this.toOption(j)):[])}catch(b){if(!p.signal.aborted)throw b}finally{this.#e===p&&(this.#e=null)}}choose(h){!h||h.disabled||(this.selected=h.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(h){return this.selected!=null&&h!=null&&H(h.id)===H(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}optionById(h){if(h==null)return;const a=H(h);return this.all.find(p=>H(p.id)===a)}checkValue(h){return h==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.all.length||this.optionById(h)||this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(h)}" is not a valid option`}renderOption(h,a,p){W(a),a.appendChild(this.buildAvatar(h));const b=_(this.doc,"span",{class:"lat-object__text"});b.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:h.label})),h.secondary&&b.appendChild(_(this.doc,"span",{class:"lat-object__secondary",text:h.secondary})),a.appendChild(b),h.icon&&a.appendChild(r(this.doc,h.icon,{className:I.icon})),h.variant?a.setAttribute("data-variant",h.variant):a.removeAttribute("data-variant");const j=this.isSelected(h);a.classList.add("lat-object__row"),a.classList.toggle(I.optionSelected,j),a.classList.toggle(I.optionDisabled,h.disabled===!0),a.setAttribute("aria-selected",j?"true":"false"),h.disabled?a.setAttribute("aria-disabled","true"):a.removeAttribute("aria-disabled")}buildAvatar(h){const a=_(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!h.avatar)return a.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:h.initials})),a.setAttribute("data-fallback","initials"),a;const p=_(this.doc,"img",{class:"lat-avatar__image",attrs:{src:h.avatar,alt:"",loading:"lazy",decoding:"async"}});return X(p,"error",()=>{p.parentNode===a&&(a.removeChild(p),a.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:h.initials})),a.setAttribute("data-fallback","initials"))}),a.appendChild(p),a}paintDisplay(){const h=this.display;if(!h)return;if(W(h),this.selected==null){h.removeAttribute("data-variant");return}const a=this.optionById(this.selected);if(!a){h.appendChild(_(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}h.appendChild(this.buildAvatar(a)),h.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:a.label})),a.variant?h.setAttribute("data-variant",a.variant):h.removeAttribute("data-variant")}destroy(){this.#e&&(this.#e.abort(),this.#e=null),this.#n&&(this.#n.cancel(),this.#n=null),this.all=[],super.destroy()}}function f(d,h,a){if(h==null)return a;const p=c(h)?h(d):n(d,String(h));return p==null?a:String(p)}function u(d){const h=String(d||"").trim().split(/\s+/).filter(b=>b!=="");if(!h.length)return"";const a=[...h[0]][0]||"";if(h.length===1)return a.toUpperCase();const p=[...h[h.length-1]][0]||"";return(a+p).toUpperCase()}function i(d){if(d==null)return null;const a=(Array.isArray(d)?d:[d]).filter(p=>typeof p=="string"||c(p));return a.length?a:null}const m=o}),Fe("packages/dom/src/editors/iconpicker.js",function(e,K){"use strict";Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveNames",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.VirtualList,_=Q.el,X=Q.on,W=Q.clear,H=K("packages/dom/src/cell/icons.js"),U=H.createIcon,z=H.iconNames,k=K("packages/core/src/internal/util.js").isFunction;class g extends ${static popup=!0;input=null;display=null;list=null;names=[];matches=[];rows=[];columns=8;cursor=-1;selected=null;query="";off=[];build(){const n=this.props;this.columns=Math.max(1,Math.floor(Number(n.columns)||8)),this.names=l(n.icons),this.selected=this.params.value==null?null:String(this.params.value);const t=_(this.doc,"div",{class:["lat-iconpicker",`${B.editor}__select`],attrs:{role:"combobox","aria-expanded":"true"}});return this.display=_(this.doc,"div",{class:`${B.editor}__display`}),this.input=_(this.doc,"input",{class:B.input,attrs:{type:"text",autocomplete:"off",placeholder:n.placeholder??"Search icons","aria-label":this.params.column&&this.params.column.title||"Search icons","aria-autocomplete":"list"}}),this.input.value="",this.list=new I({document:this.doc,itemHeight:Number(n.rowHeight)||34,height:Number(n.listHeight)||204,renderItem:(r,o,f)=>this.renderRow(r,o,f)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),t.appendChild(this.display),t.appendChild(this.input),n.allowClear===!0&&t.appendChild(this.buildClearButton()),t.appendChild(this.list.element()),this.off.push(X(this.input,"input",()=>this.onQuery(this.input?this.input.value:""))),this.off.push(X(this.input,"keydown",r=>this.onKeyDown(r))),this.refreshIcons(),this.paintDisplay(),this.params.key&&this.params.key.length===1&&(this.input.value=this.params.key,this.onQuery(this.params.key)),t}buildClearButton(){const n=_(this.doc,"button",{class:"lat-iconpicker__clear",text:this.t("editor.noIcon"),attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.noIcon")}});return this.off.push(X(n,"mousedown",t=>{k(t.preventDefault)&&t.preventDefault(),this.selected=null,this.paintDisplay(),this.commit()})),n}focusTarget(){return this.input}onQuery(n){this.query=n,this.refreshIcons()}refreshIcons(){const n=this.query.trim().toLowerCase();this.matches=n===""?this.names.slice():this.names.filter(r=>r.toLowerCase().includes(n)),this.rows=[];for(let r=0;r<this.matches.length;r+=this.columns)this.rows.push(this.matches.slice(r,r+this.columns));const t=this.selected?this.matches.indexOf(this.selected):-1;this.cursor=t>=0?t:this.matches.length?0:-1,this.list&&this.list.setItems(this.rows,this.rowOf(this.cursor))}rowOf(n){return n<0?-1:Math.floor(n/this.columns)}moveCursor(n){if(!this.matches.length)return-1;const t=Math.max(0,Math.min(this.matches.length-1,this.cursor+n));return this.setCursor(t)}setCursor(n){return this.cursor=n,this.list&&this.list.setActive(this.rowOf(n)),this.cursor}cursorName(){return this.cursor>=0&&this.cursor<this.matches.length?this.matches[this.cursor]:null}renderRow(n,t,r){t.setAttribute("role","row"),t.classList.add("lat-iconpicker__row");let o=t.__latIconCells;if(!o){o=[],W(t);for(let f=0;f<this.columns;f++){const u=_(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});X(u,"mousedown",i=>{k(i.preventDefault)&&i.preventDefault();const m=u.getAttribute("data-icon");m&&this.choose(m)}),t.appendChild(u),o.push(u)}t.__latIconCells=o}for(let f=0;f<o.length;f++){const u=o[f],i=n[f];if(i===void 0){u.setAttribute("aria-hidden","true"),u.removeAttribute("data-icon"),u.removeAttribute("title"),u.removeAttribute("aria-label"),u.classList.add("lat-iconpicker__cell--empty"),u.classList.remove("lat-iconpicker__cell--active"),u.classList.remove("lat-iconpicker__cell--selected"),u.__latIconName!==void 0&&(W(u),u.__latIconName=void 0);continue}const m=r*this.columns+f;u.removeAttribute("aria-hidden"),u.classList.remove("lat-iconpicker__cell--empty"),u.setAttribute("data-icon",i),u.setAttribute("title",i),u.setAttribute("aria-label",i),u.__latIconName!==i&&(W(u),u.appendChild(U(this.doc,i,{className:B.icon})),u.__latIconName=i);const d=this.selected===i;u.classList.toggle("lat-iconpicker__cell--active",m===this.cursor),u.classList.toggle("lat-iconpicker__cell--selected",d),u.setAttribute("aria-selected",d?"true":"false")}}paintDisplay(){const n=this.display;if(n){if(W(n),this.selected==null){n.appendChild(_(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}n.appendChild(U(this.doc,this.selected,{className:B.icon})),n.appendChild(_(this.doc,"span",{text:this.selected}))}}choose(n){this.selected=n;const t=this.matches.indexOf(n);t>=0&&(this.cursor=t),this.list&&this.list.paint(),this.paintDisplay(),this.commit()}readValue(){return this.selected??null}checkValue(n){return n==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose an icon":this.names.includes(String(n))?!0:`"${String(n)}" is not a known icon name`}onKeyDown(n){const t=()=>{k(n.preventDefault)&&n.preventDefault()};switch(n.key){case"ArrowRight":t(),this.moveCursor(1);return;case"ArrowLeft":t(),this.moveCursor(-1);return;case"ArrowDown":t(),this.moveCursor(this.columns);return;case"ArrowUp":t(),this.moveCursor(-this.columns);return;case"PageDown":t(),this.moveCursor(this.columns*5);return;case"PageUp":t(),this.moveCursor(-this.columns*5);return;case"Home":t(),this.setCursor(this.matches.length?0:-1);return;case"End":t(),this.setCursor(this.matches.length-1);return;case"Enter":{t();const r=this.cursorName();r&&this.choose(r);return}case"Escape":t(),this.cancel();return;case"Tab":{const r=this.cursorName();r&&(this.selected=r),this.commit();return}default:break}}destroy(){for(const n of this.off)n();this.off.length=0,this.list&&(this.list.destroy(),this.list=null),this.input=null,this.display=null,this.rows=[],super.destroy()}}function l(s){const n=z();if(Array.isArray(s)&&s.length){const t=new Set(n);return s.map(r=>String(r)).filter(r=>t.has(r))}return n.filter(t=>t!=="blank")}const c=g}),Fe("packages/dom/src/editors/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/temperature.js"),U=H.formatTemperature,z=H.parseTemperature,w=H.findScale;function k(c,s){return U(c,{...s,decimals:void 0,minDecimals:0,maxDecimals:20})}class g extends ${input=null;hint=null;opts=null;#e=[];buildOptions(){const s=this.params.column&&this.params.column.dataType||null,n=s&&s.temperatureConfig||{};return{scale:this.props.scale||n.scale||"C",locale:this.params.locale}}build(){const s=this.props;this.opts=this.buildOptions();const n=w(this.opts.scale),t=n?n.scale.symbol:"",r=`${this.id}-scale`,o=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:s.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?r:null}});o.value=k(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(o.value=this.params.key),this.input=o;const f=typeof s.step=="number"?s.step:0;return f>0&&this.#e.push(_(o,"keydown",u=>{u.key==="ArrowUp"?(W(u.preventDefault)&&u.preventDefault(),this.nudge(f)):u.key==="ArrowDown"&&(W(u.preventDefault)&&u.preventDefault(),this.nudge(-f))})),this.hint=I(this.doc,"span",{class:`${B.editor}__suffix`,text:t,attrs:{id:r,"aria-hidden":"true"}}),I(this.doc,"div",{class:`${B.editor}__unit`,children:[o,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const s=this.input;s&&!this.params.key&&this.props.selectOnFocus!==!1&&W(s.select)&&s.select()}nudge(s){const n=z(this.input?this.input.value:"",this.opts);let t=(n??0)+s;const{min:r,max:o}=this.props;typeof r=="number"&&t<r&&(t=r),typeof o=="number"&&t>o&&(t=o),this.input&&(this.input.value=k(t,this.opts))}readValue(){const s=this.input?String(this.input.value).trim():"";if(s==="")return null;const n=z(s,this.opts);return n===null?Number.NaN:n}checkValue(s){if(s===null)return!0;if(typeof s!="number"||Number.isNaN(s))return"Enter a temperature";const{min:n,max:t}=this.props;return typeof n=="number"&&s<n?`Must be ${n} or more`:typeof t=="number"&&s>t?`Must be ${t} or less`:!0}destroy(){for(const s of this.#e)s();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const l=g}),Fe("packages/dom/src/editors/currency.js",function(e,K){"use strict";Object.defineProperty(e,"presentAmount",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/currency.js"),U=H.parseMoney,z=H.toMoney,w=H.normaliseCode,k=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function g(s){const n=z(s);return n?String(n.amount):""}class l extends ${input=null;picker=null;opts=null;#e=[];buildOptions(){const n=this.params.column&&this.params.column.dataType||null,t=n&&n.currencyConfig||{},r=z(this.params.value),o=w(this.props.code)||r&&r.code||w(t.code)||"USD";let f=this.props.codes||t.codes||k;return f=f.map(u=>w(u)).filter(Boolean),f.includes(o)||(f=[o,...f]),{code:o,codes:f,locale:this.params.locale}}build(){const n=this.props;this.opts=this.buildOptions();const t=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:n.placeholder??null,"aria-label":this.params.column&&this.params.column.title||"Amount"}});t.value=g(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(t.value=this.params.key),this.input=t;const r=I(this.doc,"select",{class:`${B.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const o of this.opts.codes){const f=I(this.doc,"option",{text:o,attrs:{value:o}});o===this.opts.code&&(f.selected=!0),r.appendChild(f)}return this.picker=r,I(this.doc,"div",{class:`${B.editor}__unit`,children:[t,r]})}focusTarget(){return this.input}attached(){super.attached();const n=this.input;n&&!this.params.key&&this.props.selectOnFocus!==!1&&W(n.select)&&n.select()}readValue(){const n=this.input?String(this.input.value).trim():"";if(n==="")return null;const t=this.picker?this.picker.value:this.opts.code,r=U(n,{...this.opts,code:t});return r===null?Number.NaN:r}checkValue(n){if(n===null)return!0;if(!n||typeof n!="object"||!Number.isFinite(n.amount))return"Enter an amount";const t=n.amount,{min:r,max:o}=this.props;return typeof r=="number"&&t<r?`Must be ${r} or more`:typeof o=="number"&&t>o?`Must be ${o} or less`:!0}destroy(){for(const n of this.#e)n();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const c=l}),Fe("packages/dom/src/editors/index.js",function(e,K){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"NumberEditor",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DateEditor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"CheckboxEditor",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return ce}});const $=K("packages/dom/src/editors/text.js").TextEditor,I=K("packages/dom/src/editors/textarea.js").TextareaEditor,X=K("packages/dom/src/editors/number.js").NumberEditor,H=K("packages/dom/src/editors/date.js").DateEditor,z=K("packages/dom/src/editors/checkbox.js").CheckboxEditor,k=K("packages/dom/src/editors/select.js").SelectEditor,l=K("packages/dom/src/editors/multiselect.js").MultiSelectEditor,s=K("packages/dom/src/editors/time.js").TimeEditor,t=K("packages/dom/src/editors/datetime.js").DateTimeEditor,o=K("packages/dom/src/editors/duration.js").DurationEditor,u=K("packages/dom/src/editors/ipaddress.js").IpAddressEditor,m=K("packages/dom/src/editors/password.js").PasswordEditor,h=K("packages/dom/src/editors/code.js").CodeEditor,p=K("packages/dom/src/editors/unit.js").UnitEditor,j=K("packages/dom/src/editors/radix.js").RadixEditor,y=K("packages/dom/src/editors/segmented.js").SegmentedEditor,R=K("packages/dom/src/editors/rating.js").RatingEditor,x=K("packages/dom/src/editors/slider.js").SliderEditor,P=K("packages/dom/src/editors/colour.js").ColourEditor,E=K("packages/dom/src/editors/treeselect.js").TreeSelectEditor,N=K("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,A=K("packages/dom/src/editors/iconpicker.js").IconPickerEditor,G=K("packages/dom/src/editors/temperature.js").TemperatureEditor,Y=K("packages/dom/src/editors/currency.js").CurrencyEditor,J=K("packages/core/src/internal/util.js"),te=J.isCtor,ne=J.isFunction,oe=J.warnOnce,le=K("packages/dom/src/editors/common.js");for(const he of Object.keys(le))he!=="default"&&Object.defineProperty(e,he,{enumerable:!0,get:function(){return le[he]}});const ae=Object.freeze({text:$,textarea:I,number:X,date:H,checkbox:z,select:k,multiSelect:l,temperature:G,currency:Y,time:s,datetime:t,duration:o,ipaddress:u,password:m,code:h,unit:p,radix:j,slider:x,rating:R,segmented:y,treeSelect:E,objectPicker:N,iconPicker:A,colour:P}),se=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function ee(he,me){const Ee=he&&he.edit&&he.edit.editor,ge=me&&me.editors||{},je=!!(he&&he.lookup&&he.lookup.multiple);if(te(Ee)||ne(Ee))return Ee;if(typeof Ee=="string"){if(je&&Ee==="select")return l;const ye=ge[Ee]||ae[Ee];if(ye)return ye;oe(`editor:missing:${Ee}`,`unknown editor "${Ee}"; falling back to the data type default`)}const pe=he&&he.type||"text";if(pe==="lookup"||he&&he.lookup)return je?l:k;const we=se[pe];return we&&(ge[we]||ae[we])||null}function ie(he,me){const Ee=ee(he.column||{},me);if(!Ee)return null;const ge=new Ee;return ge.init(he),ne(ge.cancelBeforeStart)&&ge.cancelBeforeStart()===!0?(ne(ge.destroy)&&ge.destroy(),null):ge}const ce=ae}),Fe("packages/dom/src/ui/statusbar.js",function(e,K){"use strict";Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction;function z(d){let h=0,a=0,p=0,b=null,j=null;for(const S of d||[]){if(S==null||S==="")continue;h++;const y=typeof S=="number"?S:Number(S);Number.isFinite(y)&&(a++,p+=y,(b===null||y<b)&&(b=y),(j===null||y>j)&&(j=y))}return{count:h,numericCount:a,sum:a?p:null,min:b,max:j,avg:a?p/a:null}}class w{root=null;valueNode=null;init(h){this.ctx=h,this.doc=h.document,this.root=I(this.doc,"div",{class:`${$.statusBar}__panel`,attrs:{"data-align":h.align||"end"}}),h.label&&this.root.appendChild(I(this.doc,"span",{class:`${$.statusBar}__label`,text:h.label})),this.valueNode=I(this.doc,"span",{class:`${$.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(h,a){const p=this.ctx&&this.ctx.messages;return(p&&U(p.t)?p:W).t(h,a)}element(){return this.root}refresh(){const h=this.read();this.valueNode&&this.valueNode.textContent!==h&&(this.valueNode.textContent=h)}read(){return""}destroy(){this.root=null,this.valueNode=null}}class k extends w{read(){const h=this.ctx.host||{},a=U(h.totalRowCount)?h.totalRowCount():0,p=U(h.loadError)?h.loadError():null;if(p)return p;if(a==null)return this.t("status.counting");const b=U(h.rowCount)?h.rowCount():a;if(b==null)return p||this.t("status.counting");const j=this.ctx.noun,S=y=>j===void 0?this.t("count.rows",{count:y}):`${f(y,this.ctx.locale)}${j?` ${j}`:""}`;return b===a?this.t("status.total",{rows:S(a)}):this.t("status.shownOfTotal",{shown:f(b,this.ctx.locale),total:S(a)})}}class g extends w{read(){const h=this.ctx.host||{},a=U(h.selectedAcrossSource)?h.selectedAcrossSource():null;if(a)return typeof a.count=="number"?this.t("status.selectedAcrossSource",{count:a.count}):this.t("status.selectedAcrossSourceCounting");const p=U(h.selectedCount)?h.selectedCount():0;return p?this.t("status.selected",{count:p}):""}}class l extends w{read(){const h=this.ctx.host||{},a=U(h.rangeValues)?h.rangeValues():[],p=z(a);if(!p.count)return"";const b=this.ctx.stats||["count","sum","min","max","avg"],j=[];for(const S of b){if(S==="count"){j.push(this.t("status.count",{count:p.count}));continue}const y=p[S];y!==null&&j.push(`${this.t(`status.stat.${S}`)} ${i(y,this.ctx.locale)}`)}return j.join(" ")}}class c extends w{read(){const h=this.ctx.host||{},a=U(h.progress)?h.progress():null;if(!a)return"";const{loaded:p,estimated:b,done:j}=a;if(j)return"";if(!b)return this.t("status.loading",{count:p||0});const S=Math.min(100,Math.round((p||0)/b*100));return this.t("status.loadingOf",{loaded:p||0,total:b,percent:S})}}class s extends w{read(){const h=this.ctx.host||{},a=U(h.updateStats)?h.updateStats():null;return a?a.paused?a.pending?this.t("status.pausedWaiting",{waiting:this.t("count.waiting",{count:a.pending})}):this.t("status.paused"):a.coalescedTotal?this.t("status.coalesced",{count:a.coalescedTotal}):"":""}}class n extends w{read(){const h=this.ctx.host||{},a=U(h.hiddenUnresolved)?h.hiddenUnresolved():0;return a?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:a})}):""}}const t=Object.freeze({rowCount:k,selectedCount:g,aggregation:l,progress:c,updates:s,comments:n});class r{panels=[];root=null;init(h){const a=h||{};this.doc=B(a),this.host=a.host||{},this.messages=a.messages||null,this.root=I(this.doc,"div",{class:$.statusBar,attrs:{role:"status","aria-live":"polite"}});const p=a.registry||{},b=Array.isArray(a.panels)&&a.panels.length?a.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const j of b){const S=typeof j=="string"?j:j.name,y=typeof j=="function"?j:p[S]||t[S];if(!y)continue;const v=new y;v.init({document:this.doc,host:this.host,locale:a.locale,messages:this.messages,...typeof j=="object"?j.props||{}:{}}),this.panels.push({name:String(S||"panel"),panel:v}),this.root.appendChild(v.element())}this.refresh()}element(){return this.root}addPanel(h,a,p){const b=new a;return b.init({document:this.doc,host:this.host,messages:this.messages,...p||{}}),this.panels.push({name:h,panel:b}),this.root&&this.root.appendChild(b.element()),b.refresh(),b}removePanel(h){const a=this.panels.findIndex(j=>j.name===h);if(a<0)return!1;const[p]=this.panels.splice(a,1),b=p.panel.element();return b&&b.parentNode&&b.parentNode.removeChild(b),U(p.panel.destroy)&&p.panel.destroy(),!0}refresh(){for(const h of this.panels)h.panel.refresh()}destroy(){for(const h of this.panels)U(h.panel.destroy)&&h.panel.destroy();this.panels=[],this.root&&_(this.root),this.root=null}}const o=new Map;function f(d,h){const a=h||"";let p=o.get(a);return p||(p=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:0}),o.set(a,p)),p.format(Number(d)||0)}const u=new Map;function i(d,h){const a=h||"";let p=u.get(a);return p||(p=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:3}),u.set(a,p)),p.format(Number(d)||0)}const m=r}),Fe("packages/dom/src/ui/contextmenu.js",function(e,K){"use strict";Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,H=K("packages/core/src/internal/util.js").isFunction,z=K("packages/dom/src/renderer/direction.js").isRtlElement,k=K("packages/dom/src/cell/icons.js").renderIconInto;function g(t,r){const o=[];for(const f of t||[]){const u=H(f)?f(r):f;if(u==null||u===!1)continue;if(u==="separator"){o.push({separator:!0});continue}if(typeof u=="string"){o.push({name:u});continue}const i=u,m=i.subMenu||i.children;m?o.push({...i,subMenu:g(m,r)}):o.push(i)}return o.filter((f,u,i)=>f.separator?u===0||u===i.length-1?!1:!i[u-1].separator:!0)}class l{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(r){const o=r||{};this.doc=B(o),this.host=o.host||this.doc.body,this.ctx=o.ctx||{},this.onClose=o.onClose||null,this.parent=o.parent||null}place(r){const o=this.host,f=H(o.getBoundingClientRect)?o.getBoundingClientRect():{left:0,top:0},u=H(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},i=this.doc.defaultView||{innerWidth:0,innerHeight:0},m=i.innerWidth||0,d=i.innerHeight||0;let h=r.x||0,a=r.y||0;const p=z(o);if(r.anchor&&H(r.anchor.getBoundingClientRect)){const S=r.anchor.getBoundingClientRect();r.placement==="below"?(h=p?S.right-u.width:S.left,a=S.bottom):(h=p?S.left-u.width:S.right,a=S.top)}else p&&(h-=u.width);const b={left:Math.max(0,f.left||0),top:Math.max(0,f.top||0),right:Math.min(m||1/0,(f.left||0)+(f.width||1/0)),bottom:Math.min(d||1/0,(f.top||0)+(f.height||1/0))};h+u.width>b.right&&(h-=u.width),h<b.left&&(h=b.left),a+u.height>b.bottom&&(a-=u.height),a<b.top&&(a=b.top);const j=b.bottom-a;u.height>j&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(j))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(h-f.left+(o.scrollLeft||0))}px`,this.root.style.top=`${Math.round(a-f.top+(o.scrollTop||0))}px`}show(r){return this.hide(),r.ctx&&(this.ctx={...this.ctx||{},...r.ctx}),this.items=g(r.items,this.ctx),this.returnFocus=r.returnFocus||null,this.anchor=r.anchor&&H(r.anchor.setAttribute)&&r.anchor.getAttribute&&r.anchor.getAttribute("aria-haspopup")?r.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=I(this.doc,"div",{class:$.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((o,f)=>{if(o.separator){this.root.appendChild(I(this.doc,"div",{class:$.menuSeparator,attrs:{role:"separator"}}));return}const u=I(this.doc,"div",{class:[$.menuItem,o.cssClass||""],attrs:{role:o.checked===void 0?"menuitem":"menuitemcheckbox",tabindex:"-1","aria-disabled":o.disabled?"true":null,"aria-checked":o.checked===void 0?null:String(o.checked===!0),"aria-haspopup":o.subMenu?"true":null,"aria-expanded":o.subMenu?"false":null,"data-index":f}});if(o.icon!=null&&o.icon!==""){const m=I(this.doc,"span",{class:$.icon});k(m,o.icon,`menu:${o.name||f}`),u.appendChild(m)}u.appendChild(I(this.doc,"span",{class:`${$.menuItem}__label`,text:o.name||""})),o.shortcut&&u.appendChild(I(this.doc,"span",{class:`${$.menuItem}__shortcut`,text:o.shortcut})),o.subMenu&&u.appendChild(I(this.doc,"span",{class:`${$.menuItem}__arrow`,text:"›"}));const i=this.itemNodes.length;this.off.push(_(u,"click",()=>this.invoke(i))),this.off.push(_(u,"mouseenter",()=>{this.focus(i),o.subMenu?this.openSubMenu(i):this.closeChild()})),this.itemNodes.push(u),this.root.appendChild(u)}),this.host.appendChild(this.root),this.place(r),this.open=!0,this.off.push(_(this.root,"keydown",o=>this.onKeyDown(o))),H(this.doc.addEventListener)&&this.off.push(_(this.doc,"mousedown",this.outside=o=>{this.root&&!s(this.root,o.target)&&!(this.child&&this.child.root&&s(this.child.root,o.target))&&this.hide()},!0)),H(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let r=0;r<this.itemNodes.length;r++)if(!this.itemAt(r).disabled)return r;return-1}itemAt(r){const o=this.itemNodes[r];return o?this.items[Number(o.getAttribute("data-index"))]||{}:{}}focus(r){if(r<0||r>=this.itemNodes.length)return;const o=this.itemNodes[this.focused];o&&o.classList.remove(`${$.menuItem}--focused`),this.focused=r;const f=this.itemNodes[r];f.classList.add(`${$.menuItem}--focused`),H(f.focus)&&f.focus(),H(f.scrollIntoView)&&f.scrollIntoView({block:"nearest",inline:"nearest"})}move(r){const o=this.itemNodes.length;if(!o)return;let f=this.focused;for(let u=0;u<o;u++)if(f=(f+r+o)%o,!this.itemAt(f).disabled){this.focus(f);return}}invoke(r){const o=this.itemAt(r);if(!(!o||o.disabled)){if(o.subMenu){this.openSubMenu(r);return}H(o.action)&&o.action({...this.ctx,item:o}),this.hideRoot()}}openSubMenu(r){const o=this.itemAt(r);o.subMenu&&(this.closeChild(),this.child=new l({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:o.subMenu,anchor:this.itemNodes[r]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(r){switch(r.key){case"ArrowDown":c(r),this.move(1);break;case"ArrowUp":c(r),this.move(-1);break;case"Home":c(r),this.focus(this.firstEnabled());break;case"End":c(r),this.focus(this.itemNodes.length-1);break;case"ArrowRight":c(r),this.openSubMenu(this.focused);break;case"ArrowLeft":c(r),this.parent&&(this.hide(),H(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":c(r),this.invoke(this.focused);break;case"Escape":c(r),this.hideRoot();break;default:r.key&&r.key.length===1&&this.jumpTo(r.key);break}}jumpTo(r){const o=r.toLowerCase(),f=this.itemNodes.length;for(let u=1;u<=f;u++){const i=(this.focused+u+f)%f,m=this.itemAt(i);if(!m.disabled&&(m.name||"").toLowerCase().startsWith(o)){this.focus(i);return}}}hideRoot(){let r=this;for(;r.parent;)r=r.parent;r.hide()}hide(){this.closeChild();for(const r of this.off)r();this.off.length=0,this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.itemNodes=[],this.focused=-1,this.anchor&&H(this.anchor.setAttribute)&&this.anchor.setAttribute("aria-expanded","false"),this.anchor=null,this.open&&this.returnFocus&&H(this.returnFocus.focus)&&this.returnFocus.focus(),this.open=!1,H(this.onClose)&&this.onClose()}destroy(){this.hide(),this.items=[]}}function c(t){H(t.preventDefault)&&t.preventDefault(),H(t.stopPropagation)&&t.stopPropagation()}function s(t,r){let o=r;for(;o;){if(o===t)return!0;o=o.parentNode}return!1}const n=l}),Fe("packages/dom/src/viewpicker.js",function(e,K){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Q=K("packages/dom/src/editors/common.js"),$=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,w=K("packages/dom/src/cell/icons.js").createIcon,k=Object.freeze({root:"lat-views",head:"lat-views__head",title:"lat-views__title",count:"lat-views__count",list:"lat-views__list",empty:"lat-views__empty",item:"lat-views__item",itemActive:"lat-views__item--active",itemEditing:"lat-views__item--editing",apply:"lat-views__apply",name:"lat-views__name",description:"lat-views__description",badges:"lat-views__badges",badge:"lat-views__badge",badgeDefault:"lat-views__badge--default",badgeShared:"lat-views__badge--shared",badgePrivate:"lat-views__badge--private",diff:"lat-views__diff",diffClean:"lat-views__diff--clean",actions:"lat-views__actions",action:"lat-views__action",actionIcon:"lat-views__action-icon",actionDanger:"lat-views__action--danger",confirm:"lat-views__confirm",foot:"lat-views__foot",input:"lat-views__input",save:"lat-views__save"});class g{root=null;off=[];host={};props={};editing=null;confirming=null;draft="";t(n,t){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(n,t)}init(n){this.messages=n&&n.messages||n&&n.grid&&n.grid.messages||W;const t=n||{};this.doc=$(t),this.host=t.host||{},this.props=t.props||{},this.root=B(this.doc,"div",{class:k.root,attrs:{role:"group","aria-label":String(this.props.title||"Saved views")}}),this.refresh()}element(){return this.root}refresh(){const n=this.root;if(!n)return;for(const u of this.off)u();this.off.length=0,_(n),this.diffs=new Map;const t=this.views(),r=t.filter(u=>u.builtin),o=t.filter(u=>!u.builtin);r.length&&(n.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),r.length)),n.appendChild(this.buildList(r))),n.appendChild(this.buildHead(String(this.props.title||"Saved views"),o.length)),o.length?n.appendChild(this.buildList(o)):n.appendChild(B(this.doc,"p",{class:k.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const f=this.buildFoot();f&&n.appendChild(f)}buildList(n){const t=B(this.doc,"div",{class:k.list,attrs:{role:"list"}});for(const r of n)t.appendChild(this.buildItem(r));return t}views(){const n=U(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?n:n.slice().sort((t,r)=>String(t.name||"").localeCompare(String(r.name||"")))}activeId(){return U(this.host.activeId)?this.host.activeId():null}buildHead(n,t){return B(this.doc,"div",{class:k.head,children:[B(this.doc,"span",{class:k.title,text:String(n)}),B(this.doc,"span",{class:k.count,text:String(t)})]})}buildItem(n){const t=String(n.id),r=this.activeId()===t,o=U(this.host.canEdit)?this.host.canEdit(n)!==!1:!0,f=B(this.doc,"div",{class:[k.item,r?k.itemActive:"",this.editing===t?k.itemEditing:""],attrs:{role:"listitem","data-view":t,"data-shared":n.shared?"true":"false"}});if(this.editing===t)return f.appendChild(this.buildRenameRow(n)),f;const u=B(this.doc,"button",{class:k.apply,attrs:{type:"button","aria-current":r?"true":null,title:[r?`${n.name} is applied`:`Apply ${n.name}`,n.shared?"Shared with everyone":"Private to you"].join(": ")},children:[B(this.doc,"span",{class:k.name,text:String(n.name||"")}),n.isDefault?this.buildBadges(n):null].filter(Boolean)});U(this.host.apply)?this.off.push(I(u,"click",()=>this.applyView(t))):u.setAttribute("disabled",""),n.description&&u.appendChild(B(this.doc,"span",{class:k.description,text:String(n.description)}));const i=this.buildDiff(t,r);return i&&u.appendChild(i),f.appendChild(u),n.builtin||f.appendChild(this.confirming===t?this.buildConfirm(n):this.buildActions(n,o)),f}buildBadges(n){const t=B(this.doc,"span",{class:k.badges});return n.isDefault&&t.appendChild(B(this.doc,"span",{class:[k.badge,k.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),t}buildDiff(n,t){if(this.props.showDiff!==!0||!U(this.host.diff))return null;const r=this.diffOf(n);if(!r)return null;if(!r.changed)return B(this.doc,"span",{class:[k.diff,k.diffClean],text:this.t(t?"views.applied":"views.matchesGrid")});const o=l(r);return o.length?B(this.doc,"span",{class:k.diff,text:o.join(" · ")}):null}diffOf(n){if(!U(this.host.diff))return null;if(this.diffs.has(n))return this.diffs.get(n);let t=null;try{t=this.host.diff(n)}catch{t=null}return this.diffs.set(n,t),t}buildActions(n,t){const r=String(n.id),o=B(this.doc,"span",{class:k.actions});if(t&&U(this.host.rename)&&o.appendChild(this.buildAction("Rename",`Rename ${n.name}`,()=>{this.editing=r,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),n.isDefault&&U(this.host.clearDefault)?o.appendChild(this.buildAction("Unset default",`Stop applying ${n.name} at load`,()=>{this.host.clearDefault(r),this.refresh()},"pin")):!n.isDefault&&U(this.host.setDefault)&&o.appendChild(this.buildAction("Make default",`Apply ${n.name} when the grid loads`,()=>{this.host.setDefault(r),this.refresh()},"pin")),U(this.host.export)&&o.appendChild(this.buildAction("Share",`Export ${n.name}`,()=>this.host.export(r),"share")),t&&U(this.host.remove)){const f=this.buildAction("Delete",`Delete ${n.name}`,()=>{this.confirming=r,this.refresh()},"trash");f.classList.add(k.actionDanger),o.appendChild(f)}return o}buildConfirm(n){const t=String(n.id),r=B(this.doc,"span",{class:k.confirm});r.appendChild(B(this.doc,"span",{text:this.t("views.confirmDelete",{name:n.name})}));const o=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:n.name}),()=>{this.confirming=null,this.host.remove(t),this.refresh()});return o.classList.add(k.actionDanger),r.appendChild(o),r.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),r}buildRenameRow(n){const t=String(n.id),r=B(this.doc,"span",{class:k.confirm}),o=B(this.doc,"input",{class:k.input,attrs:{type:"text","aria-label":`New name for ${n.name}`}});o.value=String(n.name||""),this.input=o;const f=()=>{const i=String(o.value||"").trim();this.editing=null,i&&i!==n.name&&this.host.rename(t,i),this.refresh()},u=()=>{this.editing=null,this.refresh()};return this.off.push(I(o,"keydown",i=>{i.key==="Enter"?f():i.key==="Escape"&&u()})),r.appendChild(o),r.appendChild(this.buildAction("Save","Save the new name",f)),r.appendChild(this.buildAction("Cancel","Leave the name alone",u)),r}buildFoot(){if(this.props.allowSave===!1||!U(this.host.saveAs))return null;const n=B(this.doc,"div",{class:k.foot}),t=B(this.doc,"input",{class:k.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});t.value=this.draft,this.editing===null&&(this.input=t);const r=()=>{const f=String(t.value||"").trim();if(!f){U(t.focus)&&t.focus();return}this.draft="",this.host.saveAs(f),this.refresh()};this.off.push(I(t,"input",()=>{this.draft=String(t.value||"")})),this.off.push(I(t,"keydown",f=>{f.key==="Enter"&&r()}));const o=B(this.doc,"button",{class:k.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(I(o,"click",r)),n.appendChild(t),n.appendChild(o),n}buildAction(n,t,r,o){const f=B(this.doc,"button",{class:k.action,text:o?null:n,attrs:{type:"button",title:t,"aria-label":t,"data-action":n}});return o&&f.appendChild(w(this.doc,o,{className:k.actionIcon})),this.off.push(I(f,"click",r)),f}applyView(n){this.confirming=null,this.host.apply(n),this.refresh()}focusInput(){const n=this.input;n&&U(n.focus)&&n.focus(),n&&U(n.select)&&n.select()}destroy(){for(const n of this.off)n();this.off.length=0,this.root=null,this.input=null,this.diffs=new Map}}function l(s,n=3){if(!s||!s.changed)return[];const t=s.counts||{},r=[],o=(f,u,i)=>{f&&r.push((f===1?u:i).replace("%",String(f)))};if(o(t.columnsHidden,"hides % column","hides % columns"),o(t.columnsShown,"shows % column","shows % columns"),o(t.columnsMoved,"moves % column","moves % columns"),o(t.columnsPinned,"repins % column","repins % columns"),o(t.columnsResized,"resizes % column","resizes % columns"),s.filters&&s.filters.changed){const f=t.filterColumns||0;r.push(f?`changes ${f} filter${f===1?"":"s"}`:"changes the filter")}return s.quick&&s.quick.changed&&r.push("changes the search"),s.sort&&s.sort.changed&&r.push("changes the sort"),s.group&&s.group.changed&&r.push("changes the grouping"),s.pivot&&s.pivot.changed&&r.push("changes the pivot"),o(t.columnsTotalled,"changes % total","changes % totals"),s.pagination&&s.pagination.changed&&r.push("changes the page size"),r.length<=n?r:[...r.slice(0,n),`and ${r.length-n} more`]}const c=g}),Fe("packages/dom/src/ui/panelbase.js",function(e,K){"use strict";Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return X}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.el,_=K("packages/core/src/i18n/index.js").defaultMessages;class X{root=null;off=[];init(H){this.ctx=H,this.doc=H.document,this.host=H.host||{},this.props=H.props||{},this.root=B(this.doc,"div",{class:`${$.panel}__body`}),this.refresh()}t(H,U){const z=this.host||{};if(typeof z.t=="function")return z.t(H,U);const w=this.ctx||{};if(w.messages&&typeof w.messages.t=="function")return w.messages.t(H,U);const k=w.grid;return(k&&k.messages?k.messages:_).t(H,U)}element(){return this.root}refresh(){}destroy(){for(const H of this.off)H();this.off.length=0,this.root=null}}}),Fe("packages/dom/src/formattingpanel.js",function(e,K){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,H=K("packages/core/src/internal/util.js").isFunction,z=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,w=K("packages/core/src/formatting/rules.js"),k=w.compileRules,g=w.summariseColumn,l=w.needsDistribution,c=w.DISTRIBUTION_LABELS,s="*",n=8,t=Object.freeze([{op:"gt",label:"greater than",values:1},{op:"gte",label:"at least",values:1},{op:"lt",label:"less than",values:1},{op:"lte",label:"at most",values:1},{op:"eq",label:"equal to",values:1},{op:"ne",label:"not equal to",values:1},{op:"between",label:"between",values:2},{op:"outside",label:"outside",values:2},{op:"contains",label:"contains",values:1},{op:"notContains",label:"does not contain",values:1},{op:"startsWith",label:"starts with",values:1},{op:"endsWith",label:"ends with",values:1},{op:"blank",label:"is blank",values:0},{op:"notBlank",label:"is not blank",values:0}]),r=Object.freeze([{op:"topPercent",label:c.topPercent,values:1},{op:"bottomPercent",label:c.bottomPercent,values:1},{op:"topN",label:c.topN,values:1},{op:"bottomN",label:c.bottomN,values:1},{op:"aboveMean",label:c.aboveMean,values:0},{op:"belowMean",label:c.belowMean,values:0},{op:"aboveMedian",label:c.aboveMedian,values:0},{op:"belowMedian",label:c.belowMedian,values:0},{op:"zAbove",label:c.zAbove,values:1},{op:"zBelow",label:c.zBelow,values:1},{op:"outlier",label:c.outlier,values:0}]),o=Object.freeze([...t,...r]),f=Object.freeze([{name:"Red",background:"#fbeceb",color:"#b03030"},{name:"Amber",background:"#fdf3e0",color:"#9a6400"},{name:"Green",background:"#e8f5ee",color:"#1a7f4b"},{name:"Blue",background:"#e7f0fb",color:"#1a6bc7"},{name:"Grey",background:"#f1f3f5",color:"#5b6570"}]),u=Object.freeze([{name:"White → Blue",colours:["#f8f9fa","#1a6bc7"]},{name:"White → Green",colours:["#f8f9fa","#1a7f4b"]},{name:"Red → Green",colours:["#d64545","#f6e58d","#1a7f4b"]},{name:"Blue → White → Red",colours:["#1a6bc7","#f8f9fa","#d64545"]}]),i=Object.freeze([{from:"minmax",label:"across the full range"},{from:"quantile",label:"across the middle 90%"},{from:"stddev",label:"within 2 deviations of the mean"}]);function m(b){const j=o.find(S=>S.op===b);return j?j.values:1}function d(b){if(!b)return"";if(b.scale){const{min:v,max:R,from:O}=b.scale;if(Number.isFinite(v)&&Number.isFinite(R))return`Colour scale, ${v} to ${R}`;const x=i.find(C=>C.from===O);return x?`Colour scale ${x.label}`:"Colour scale"}const j=b.when||{},S=o.find(v=>v.op===j.op),y=S?S.label:j.op;return!S||S.values===0?`Value ${y}`:S.values===2?`Value ${y} ${j.value} and ${j.value2}`:`Value ${y} ${j.value}`}class h extends z{scope=s;mode="condition";refresh(){const j=this.root;if(j){for(const S of this.off)S();this.off.length=0,X(j),j.appendChild(this.#o()),j.appendChild(this.#i()),j.appendChild(this.#l())}}#e(){const j=H(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:s,title:"All columns"},...j]}#t(){return H(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(j){if(!H(this.host.columnSamples))return[];const S=this.host.columnSamples(j);return Array.isArray(S)?S:[...S||[]]}#r(j,S,y){const v=l(j)?g(S):null;return k(j,v)({value:y})}#o(){const j=I(this.doc,"div",{class:`${$.panel}__row`});j.appendChild(I(this.doc,"label",{class:`${$.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const S=I(this.doc,"select",{class:`${$.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const y of this.#e()){const v=I(this.doc,"option",{text:y.title,attrs:{value:y.id}});y.id===this.scope&&v.setAttribute("selected","selected"),S.appendChild(v)}return S.value=this.scope,this.off.push(_(S,"change",()=>{this.scope=S.value||s,this.refresh()})),j.appendChild(S),j}#i(){const j=I(this.doc,"ul",{class:`${$.panel}__list`}),S=this.#t();if(!S.length)return j.appendChild(I(this.doc,"li",{class:`${$.panel}__empty`,text:this.t("formatting.noRules")})),j;S.forEach((R,O)=>{const x=I(this.doc,"li",{class:`${$.panel}__item`,attrs:{"data-rule":R.id}}),C=I(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${d(R)}`}});C.checked=R.enabled!==!1,this.off.push(_(C,"change",()=>{this.#c("updateRule",this.scope,R.id,{enabled:C.checked})})),x.appendChild(C);const P=I(this.doc,"span",{class:`${$.panel}__swatch`}),F=R.style||{};if(F.background&&P.style&&P.style.setProperty)P.style.setProperty("background",String(F.background));else if(R.scale&&R.scale.colours&&P.style&&P.style.setProperty){const M=R.scale.colours;P.style.setProperty("background",`linear-gradient(90deg, ${M[0]}, ${M[M.length-1]})`)}x.appendChild(P),x.appendChild(I(this.doc,"span",{class:`${$.panel}__text`,text:d(R)}));const E=I(this.doc,"button",{class:`${$.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...O===0?{disabled:"disabled"}:{}}});this.off.push(_(E,"click",()=>this.#c("moveRule",this.scope,R.id,O-1))),x.appendChild(E);const D=I(this.doc,"button",{class:`${$.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...O===S.length-1?{disabled:"disabled"}:{}}});this.off.push(_(D,"click",()=>this.#c("moveRule",this.scope,R.id,O+1))),x.appendChild(D);const N=I(this.doc,"button",{class:`${$.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${d(R)}`}});this.off.push(_(N,"click",()=>this.#c("removeRule",this.scope,R.id))),x.appendChild(N),j.appendChild(x)});const y=this.#s(S);y&&j.appendChild(y);const v=I(this.doc,"button",{class:`${$.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(_(v,"click",()=>this.#c("clearRules",this.scope))),j.appendChild(v),j}#s(j){const S=this.#n(this.scope);if(!S.length)return null;const y=j.filter(R=>R.enabled!==!1);if(!y.length)return null;const v=I(this.doc,"div",{class:`${$.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const R of S.slice(0,n)){const O=this.#r(y,S,R),x=I(this.doc,"span",{class:`${$.panel}__previewcell`,text:String(R)});O&&x.style&&x.style.setProperty&&(O.background&&x.style.setProperty("background",String(O.background)),O.color&&x.style.setProperty("color",String(O.color))),v.appendChild(x)}return v}#l(){const j=I(this.doc,"div",{class:`${$.panel}__form`}),S=I(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return S.appendChild(I(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),S.appendChild(I(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),S.value=this.mode,this.off.push(_(S,"change",()=>{this.mode=S.value==="scale"?"scale":"condition",this.refresh()})),j.appendChild(S),this.mode==="scale"?j.appendChild(this.#u()):j.appendChild(this.#a()),j}#a(){const j=I(this.doc,"div",{class:`${$.panel}__form`}),S=I(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),y=I(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const N of t)y.appendChild(I(this.doc,"option",{text:N.label,attrs:{value:N.op}}));S.appendChild(y);const v=I(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const N of r)v.appendChild(I(this.doc,"option",{text:N.label,attrs:{value:N.op}}));S.appendChild(v),S.value="gt",j.appendChild(S);const R=I(this.doc,"input",{class:`${$.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),O=I(this.doc,"input",{class:`${$.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});j.appendChild(R),j.appendChild(O);const x=()=>{const N=m(S.value);R.style.setProperty("display",N>=1?"":"none"),O.style.setProperty("display",N>=2?"":"none"),E()};this.off.push(_(S,"change",x));const C=I(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const N of f)C.appendChild(I(this.doc,"option",{text:N.name,attrs:{value:N.name}}));C.value=f[0].name,j.appendChild(C);const P=I(this.doc,"div",{class:`${$.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});j.appendChild(P);const F=()=>{const N=f.find(L=>L.name===C.value)||f[0],M=m(S.value),A={op:S.value};return M>=1&&(A.value=R.value),M>=2&&(A.value2=O.value),{when:A,style:{background:N.background,color:N.color}}},E=()=>{X(P);const N=this.#n(this.scope);if(N.length)for(const M of N.slice(0,n)){const A=this.#r([F()],N,M),L=I(this.doc,"span",{class:`${$.panel}__previewcell`,text:String(M)});A&&L.style&&L.style.setProperty&&(A.background&&L.style.setProperty("background",String(A.background)),A.color&&L.style.setProperty("color",String(A.color))),P.appendChild(L)}};this.off.push(_(R,"input",E)),this.off.push(_(O,"input",E)),this.off.push(_(C,"change",E)),x();const D=I(this.doc,"button",{class:`${$.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(D,"click",()=>{this.#c("addRule",this.scope,F()),R.value="",O.value=""})),j.appendChild(D),j}#u(){const j=I(this.doc,"div",{class:`${$.panel}__form`}),S=I(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const C of u)S.appendChild(I(this.doc,"option",{text:C.name,attrs:{value:C.name}}));S.value=u[0].name,j.appendChild(S);const y=I(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const C of i)y.appendChild(I(this.doc,"option",{text:C.label,attrs:{value:C.from}}));y.value=i[0].from,j.appendChild(y);const v=I(this.doc,"div",{class:`${$.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});j.appendChild(v);const R=()=>{const C=u.find(P=>P.name===S.value)||u[0];return{scale:{from:y.value,colours:[...C.colours]}}},O=()=>{X(v);const C=this.#n(this.scope);if(C.length)for(const P of C.slice(0,n)){const F=this.#r([R()],C,P),E=I(this.doc,"span",{class:`${$.panel}__previewcell`,text:String(P)});F&&F.background&&E.style&&E.style.setProperty&&E.style.setProperty("background",String(F.background)),v.appendChild(E)}};this.off.push(_(S,"change",O)),this.off.push(_(y,"change",O)),O();const x=I(this.doc,"button",{class:`${$.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(x,"click",()=>{this.#c("addRule",this.scope,R())})),j.appendChild(x),j}#c(j,...S){H(this.host[j])&&this.host[j](...S),this.refresh()}}function a(b={}){const j=new h;return j.init({document:B(b),host:b.host||{}}),j}const p=h}),Fe("packages/dom/src/statisticspanel.js",function(e,K){"use strict";Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return l}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,U=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"},{key:"min",label:"stats.min",kind:"value"},{key:"max",label:"stats.max",kind:"value"},{key:"mean",label:"stats.mean",kind:"value"},{key:"median",label:"stats.median",kind:"value"},{key:"q1",label:"stats.q1",kind:"value"},{key:"q3",label:"stats.q3",kind:"value"},{key:"iqr",label:"stats.iqr",kind:"value"},{key:"stddev",label:"stats.stddev",kind:"value"},{key:"outliers",label:"stats.outliers",kind:"count"}]),w=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),k=Object.freeze([{label:"stats.section.shape",kernels:["skewness","kurtosis","jarqueBera"]},{label:"stats.section.robust",kernels:["trimmedMean","winsorizedMean","mad","robustOutliers"]},{label:"stats.section.concentration",kernels:["gini","hhi","entropy","evenness","top3Share"]}]);function g(c){if(c==null||!Number.isFinite(c))return"—";if(Number.isInteger(c))return String(c);const s=Math.abs(c);return s!==0&&(s<.001||s>=1e7)?c.toExponential(2):String(Number(c.toPrecision(4)))}class l extends U{column=null;#e=0;#t(){return W(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const s=this.root;if(!s)return;for(const r of this.off)r();this.off.length=0,_(s);const n=this.#t();if(!n.length){s.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("stats.noColumns")}));return}n.some(r=>r.id===this.column)||(this.column=n[0].id),s.appendChild(this.#o(n));const t=W(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!t&&W(this.host.columnProfileAsync)){const r=B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("facets.computing")});s.appendChild(r);const o=++this.#e,f=this.column;Promise.resolve(this.host.columnProfileAsync(f)).then(u=>{if(o!==this.#e||this.root!==s||this.column!==f)return;const i=B(this.doc,"div",{});this.#n(i,u);for(const m of[...i.children])s.insertBefore(m,r);s.removeChild(r)},()=>{o!==this.#e||this.root!==s||(r.textContent=this.t("stats.noValues"))});return}this.#e++,this.#n(s,t)}#n(s,n){if(!n||!n.present){s.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("stats.noValues")}));const r=this.#r(n);r&&s.appendChild(r);return}if(s.appendChild(B(this.doc,"p",{class:`${$.panel}__count`,text:this.t("stats.filtered",{count:n.rows})})),Array.isArray(n.topValues)){s.appendChild(this.#l(n,w)),s.appendChild(this.#a(n.topValues));const r=this.#r(n);r&&s.appendChild(r);return}if(s.appendChild(this.#l(n)),n.computed!=="source"){for(const o of k){const f=this.#i(o);f&&s.appendChild(f)}const r=this.#s();r&&s.appendChild(r)}n.histogram&&n.histogram.length>1&&s.appendChild(this.#u(n.histogram));const t=this.#r(n);t&&s.appendChild(t)}#r(s){const n=s&&Array.isArray(s.unavailable)?s.unavailable:[];if(!n.length)return null;const t=this.doc.createElement("div");t.setAttribute("data-unavailable",""),t.appendChild(B(this.doc,"p",{class:`${$.panel}__count`,text:this.t("stats.unavailable",{stats:n.map(o=>o.stat).join(", ")})}));const r=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const o of n)r.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:o.stat})),r.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,text:o.reasonKey?this.t(o.reasonKey,o.reasonParams):o.reason}));return t.appendChild(r),t}#o(s){const n=B(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const t of s){const r=B(this.doc,"option",{text:t.title,attrs:{value:t.id,selected:t.id===this.column?!0:null}});n.appendChild(r)}return n.value=this.column,this.off.push(I(n,"change",()=>{this.column=n.value,this.refresh()})),B(this.doc,"label",{class:`${$.panel}__field`,children:[B(this.doc,"span",{class:`${$.panel}__label`,text:this.t("stats.column")}),n]})}#i(s){const n=this.host.reduceColumn;if(!W(n)||!this.column)return null;const t=[];for(const f of s.kernels){const u=n(this.column,f);u==null||Number.isNaN(u)||t.push([f,u])}if(!t.length)return null;const r=this.doc.createElement("div");r.appendChild(B(this.doc,"h4",{class:`${$.panel}__subtitle`,text:this.t(s.label)}));const o=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const[f,u]of t)o.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:this.t(`total.${f}`)})),o.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,text:typeof u=="number"?g(u):String(u)}));return r.appendChild(o),r}#s(){const s=this.host.columnCapability;if(!W(s)||!this.column)return null;const n=s(this.column);if(!n)return null;const t=this.doc.createElement("div");t.appendChild(B(this.doc,"h4",{class:`${$.panel}__subtitle`,text:this.t("stats.section.capability")}));const r=B(this.doc,"dl",{class:`${$.panel}__stats`}),o=[["stats.cp",n.cp,null],["stats.cpk",n.cpk,n.interval],["stats.pp",n.pp,null],["stats.ppk",n.ppk,n.intervalPp],["stats.outOfSpec",n.outOfSpec,null]];for(const[f,u,i]of o){if(u==null)continue;r.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:this.t(f)}));const m=[B(this.doc,"span",{text:g(u)})];i&&Number.isFinite(i.lower)&&m.push(B(this.doc,"span",{class:`${$.panel}__stat-interval`,text:`${g(i.lower)} – ${g(i.upper)}`,attrs:{title:`${Math.round(i.confidence*100)}%`}})),r.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,children:m}))}return t.appendChild(r),t}#l(s,n=z){const t=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const r of n){const o=s[r.key];t.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:this.t(r.label)})),t.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,text:r.kind==="count"?String(o??0):g(o)}))}return t}#a(s){const n=this.doc.createElement("div");n.appendChild(B(this.doc,"h4",{class:`${$.panel}__subtitle`,text:this.t("stats.topValues")}));const t=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const r of s)t.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:String(r.value)})),t.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,children:[B(this.doc,"span",{text:String(r.count)}),B(this.doc,"span",{class:`${$.panel}__stat-interval`,text:`${Math.round(r.share*100)}%`})]}));return n.appendChild(t),n}#u(s){const n=s.reduce((r,o)=>Math.max(r,o.count),0)||1,t=B(this.doc,"div",{class:`${$.panel}__histogram`});t.appendChild(B(this.doc,"h4",{class:`${$.panel}__subtitle`,text:this.t("stats.distribution")}));for(const r of s){const o=B(this.doc,"div",{class:`${$.panel}__bar`,style:{width:`${r.count?Math.max(2,r.count/n*100):0}%`}});t.appendChild(B(this.doc,"div",{class:`${$.panel}__bin`,attrs:{title:this.t("stats.bin",{count:r.count,from:g(r.from),to:g(r.to)})},children:[o]}))}return t}}}),Fe("packages/dom/src/regressionpanel.js",function(e,K){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.el,I=Q.clear,X=K("packages/core/src/internal/util.js").isFunction,H=K("packages/dom/src/ui/panelbase.js").ToolPanelBase;function U(k,g=4){const l=Number(k);return Number.isFinite(l)?l.toFixed(g):l===1/0?"∞":"—"}class z extends H{#e(){const g=this.props||{};if(Array.isArray(g.predictors)&&g.predictors.length&&g.response)return g;const l=this.ctx&&this.ctx.grid,c=l&&X(l.get)?l.get("regression"):null;return c&&Array.isArray(c.predictors)&&c.response?c:null}refresh(){const g=this.root;if(!g)return;I(g);const l=this.#e();if(!l){g.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("regression.noModel")}));return}const c=X(this.host.regressionModel)?this.host.regressionModel(l):null;if(!c){g.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("regression.cannotFit")}));return}g.appendChild(B(this.doc,"p",{class:`${$.panel}__count`,text:this.t("regression.observations",{count:c.n})})),g.appendChild(this.#t(c)),g.appendChild(this.#n(c));const s=this.#r(c,l);s&&g.appendChild(s),g.appendChild(this.#o(c))}#t(g){const l=B(this.doc,"dl",{class:`${$.panel}__stats`}),c=(s,n)=>{l.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-label`,text:s})),l.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,text:n}))};return c(this.t("regression.r2"),U(g.r2,4)),c(this.t("regression.adjR2"),U(g.adjR2,4)),l}#n(g){const l=B(this.doc,"div",{class:`${$.panel}__section`});l.appendChild(B(this.doc,"h4",{class:`${$.panel}__heading`,text:this.t("regression.coefficients")}));const c=B(this.doc,"table",{class:`${$.panel}__coef-table`}),s=B(this.doc,"tr");for(const n of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])s.appendChild(B(this.doc,"th",{text:this.t(n)}));c.appendChild(s);for(const n of g.coefficients){const t=B(this.doc,"tr");t.appendChild(B(this.doc,"td",{text:n.name})),t.appendChild(B(this.doc,"td",{text:`${U(n.estimate)} ± ${U(n.stdError)}`})),t.appendChild(B(this.doc,"td",{text:U(n.stdError)})),t.appendChild(B(this.doc,"td",{text:U(n.t,3)})),t.appendChild(B(this.doc,"td",{text:U(n.p,4)})),c.appendChild(t)}return l.appendChild(c),l}#r(g,l){if(!Array.isArray(g.vif)||g.vif.length<2)return null;const c=B(this.doc,"div",{class:`${$.panel}__section`});c.appendChild(B(this.doc,"h4",{class:`${$.panel}__heading`,text:this.t("regression.vif")}));const s=B(this.doc,"dl",{class:`${$.panel}__stats`});return g.vif.forEach((n,t)=>{s.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-label`,text:l.predictors[t]})),s.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,text:U(n,3)}))}),c.appendChild(s),c}#o(g){const l=g.heteroscedasticity,c=B(this.doc,"div",{class:`${$.panel}__section`});return c.appendChild(B(this.doc,"h4",{class:`${$.panel}__heading`,text:this.t("regression.heteroscedasticity")})),l?(c.appendChild(B(this.doc,"p",{class:`${$.panel}__flag`,attrs:{"data-heteroscedastic":l.heteroscedastic?"true":"false"},text:this.t(l.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:U(l.statistic,3),p:U(l.p,4)})})),c):(c.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("regression.cannotFit")})),c)}}const w=z}),Fe("packages/dom/src/comparepanel.js",function(e,K){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return k}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,U=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=Object.freeze([{key:"pearson",label:"compare.pearson"},{key:"spearman",label:"compare.spearman"},{key:"kendall",label:"compare.kendall"},{key:"slope",label:"compare.slope"},{key:"intercept",label:"compare.intercept"},{key:"r2",label:"compare.r2"},{key:"stdError",label:"compare.stdError"},{key:"covariance",label:"compare.covariance"},{key:"weighted",label:"compare.weighted"}]);function w(g){if(g==null||!Number.isFinite(g))return"—";if(Number.isInteger(g))return String(g);const l=Math.abs(g);return l!==0&&(l<.001||l>=1e7)?g.toExponential(2):String(Number(g.toPrecision(4)))}class k extends U{first=null;second=null;#e(){return W(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const l=this.root;if(!l)return;for(const t of this.off)t();this.off.length=0,_(l);const c=this.#e();if(c.length<2){l.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("compare.needTwo")}));return}c.some(t=>t.id===this.first)||(this.first=c[0].id),(!c.some(t=>t.id===this.second)||this.second===this.first)&&(this.second=(c.find(t=>t.id!==this.first)||c[0]).id),l.appendChild(this.#t("compare.first",c,this.first,t=>{this.first=t,this.second===t&&(this.second=(c.find(r=>r.id!==t)||c[0]).id),this.refresh()})),l.appendChild(this.#t("compare.second",c,this.second,t=>{this.second=t,this.first===t&&(this.first=(c.find(r=>r.id!==t)||c[0]).id),this.refresh()}));const s=W(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!s||!s.n){l.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("compare.noPairs")}));return}l.appendChild(B(this.doc,"p",{class:`${$.panel}__count`,text:this.t("compare.pairs",{count:s.n})}));const n=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const t of z){const r=s[t.key];r!=null&&(n.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:this.t(t.label)})),n.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,text:w(r)})))}l.appendChild(n)}#t(l,c,s,n){const t=B(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t(l)}});for(const r of c)t.appendChild(B(this.doc,"option",{text:r.title,attrs:{value:r.id,selected:r.id===s?!0:null}}));return t.value=s,this.off.push(I(t,"change",()=>n(t.value))),B(this.doc,"label",{class:`${$.panel}__field`,children:[B(this.doc,"span",{class:`${$.panel}__label`,text:this.t(l)}),t]})}}}),Fe("packages/dom/src/insightspanel.js",function(e,K){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return k}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,U=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=Object.freeze([{key:"stats.cp",field:"cp",interval:null},{key:"stats.cpk",field:"cpk",interval:"interval"},{key:"stats.pp",field:"pp",interval:null},{key:"stats.ppk",field:"ppk",interval:"intervalPp"},{key:"stats.outOfSpec",field:"outOfSpec",interval:null}]);function w(g){if(g==null||!Number.isFinite(g))return"—";if(Number.isInteger(g))return String(g);const l=Math.abs(g);return l!==0&&(l<.001||l>=1e7)?g.toExponential(2):String(Number(g.toPrecision(4)))}class k extends U{column=null;by=null;#e(){return W(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const l=this.root;if(!l)return;for(const o of this.off)o();this.off.length=0,_(l);const c=this.#e();if(!c.length){l.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("insights.empty")}));return}const s=this.#t();s&&l.appendChild(s);const n=this.#n();n&&l.appendChild(n),l.appendChild(this.#o(c));const t=this.#s();t&&l.appendChild(t);const r=this.#u();r&&l.appendChild(r)}#t(){if(!W(this.host.subsetVsPopulation))return null;const l=this.host.subsetVsPopulation();if(!l)return null;const c=this.#c("insights.subset");return l.filtered?(c.appendChild(B(this.doc,"p",{class:`${$.panel}__count`,text:this.t("stats.filtered",{count:l.subsetN})})),c.appendChild(this.#r(l.ranked)),c):(c.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("insights.noFilter")})),c)}#n(){const l=this.props&&this.props.other;if(!l||!W(this.host.datasetVsDataset))return null;let c;try{c=this.host.datasetVsDataset(l)}catch{return null}if(!c||!c.ranked)return null;const s=this.#c("insights.dataset");return s.appendChild(this.#r(c.ranked)),s}#r(l){const c=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const s of l||[]){const n=B(this.doc,"dt",{class:`${$.panel}__stat-name`});n.appendChild(B(this.doc,"span",{text:String(s.name??s.column)})),n.appendChild(B(this.doc,"span",{class:`${$.panel}__stat-interval`,text:String(s.measure||"")}));const t=B(this.doc,"dd",{class:`${$.panel}__stat-value`});t.appendChild(B(this.doc,"span",{text:w(s.magnitude)})),s.reliable===!1&&t.appendChild(B(this.doc,"span",{class:`${$.panel}__stat-interval`,text:this.t("insights.smallSample")})),c.appendChild(n),c.appendChild(t)}return c}#o(l){const c=this.#c("insights.groups");l.some(n=>n.id===this.column)||(this.column=l[0].id),(!l.some(n=>n.id===this.by)||this.by===this.column)&&(this.by=(l.find(n=>n.id!==this.column)||l[0]).id),c.appendChild(this.#d("stats.column",l,this.column,n=>{this.column=n,this.by===n&&(this.by=(l.find(t=>t.id!==n)||l[0]).id),this.refresh()})),c.appendChild(this.#d("insights.by",l,this.by,n=>{this.by=n,this.column===n&&(this.column=(l.find(t=>t.id!==n)||l[0]).id),this.refresh()}));const s=W(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return s?(c.appendChild(this.#i(s)),c):(c.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("insights.needGroups")})),c)}#i(l){const c=B(this.doc,"dl",{class:`${$.panel}__stats`});Array.isArray(l.groups)&&l.groups.length===2&&this.#a(c,"insights.groups",`${l.groups[0]} · ${l.groups[1]}`),this.#a(c,"insights.test",String(l.method||l.test||""));const s=l.effectSize||{};this.#a(c,"insights.effect",`${s.name||""} ${w(s.value)}`.trim());const n=l.interval;let t="—";if(n&&Number.isFinite(n.lower)&&Number.isFinite(n.upper)){const o=Number.isFinite(n.confidence)?` (${Math.round(n.confidence*100)}%)`:"";t=`${w(n.lower)} – ${w(n.upper)}${o}`}const r=this.#a(c,"insights.interval",t);return n&&n.method&&r.appendChild(B(this.doc,"span",{class:`${$.panel}__stat-interval`,text:String(n.method)})),Number.isFinite(l.pValue)&&this.#a(c,"insights.pValue",w(l.pValue)),c}#s(){if(!W(this.host.anomalies))return null;let l;try{l=this.host.anomalies()}catch{return null}if(!l)return null;const c=this.#c("insights.anomalies");c.appendChild(B(this.doc,"p",{class:`${$.panel}__count`,text:this.t("insights.anomalyCount",{count:l.flagged||0,n:l.n||0})}));const s=B(this.doc,"dl",{class:`${$.panel}__stats`});this.#a(s,"insights.anomalyMethod",String(l.method||""));const n=this.#l(l);n!==null&&this.#a(s,"insights.anomalyThreshold",w(n)),c.appendChild(s);const t=(l.rows||[]).map(r=>({name:r.rowKey!=null?String(r.rowKey):`#${r.index}`,measure:(r.why||[]).map(o=>o.name||o.column).join(", "),magnitude:r.score}));return c.appendChild(this.#r(t)),c}#l(l){if(l.method==="mahalanobis")return Number.isFinite(l.cutoff)?l.cutoff:null;if(l.method==="iqr")return Number.isFinite(l.k)?l.k:null;const c=Array.isArray(l.columns)?l.columns[0]:null;return c&&Number.isFinite(c.threshold)?c.threshold:null}#a(l,c,s){l.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:this.t(c)}));const n=B(this.doc,"dd",{class:`${$.panel}__stat-value`});return n.appendChild(B(this.doc,"span",{text:s})),l.appendChild(n),n}#u(){if(!W(this.host.columnCapability)||!this.column)return null;const l=this.host.columnCapability(this.column);if(!l)return null;const c=this.#c("stats.section.capability"),s=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const n of z){const t=l[n.field];if(t==null)continue;s.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:this.t(n.key)}));const r=[B(this.doc,"span",{text:w(t)})],o=n.interval?l[n.interval]:null;o&&Number.isFinite(o.lower)&&r.push(B(this.doc,"span",{class:`${$.panel}__stat-interval`,text:`${w(o.lower)} – ${w(o.upper)}`,attrs:{title:`${Math.round(o.confidence*100)}%`}})),s.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,children:r}))}return c.appendChild(s),c}#c(l){const c=this.doc.createElement("div");return c.appendChild(B(this.doc,"h4",{class:`${$.panel}__subtitle`,text:this.t(l)})),c}#d(l,c,s,n){const t=B(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t(l)}});for(const r of c)t.appendChild(B(this.doc,"option",{text:r.title,attrs:{value:r.id,selected:r.id===s?!0:null}}));return t.value=s,this.off.push(I(t,"change",()=>n(t.value))),B(this.doc,"label",{class:`${$.panel}__field`,children:[B(this.doc,"span",{class:`${$.panel}__label`,text:this.t(l)}),t]})}}}),Fe("packages/dom/src/ui/toolpanel.js",function(e,K){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return E}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.cssEscape,I=Q.documentFor,_=Q.el,X=Q.on,W=Q.clear,U=K("packages/core/src/i18n/index.js").defaultMessages,z=K("packages/core/src/internal/util.js"),w=z.isFunction,k=z.nextFrame,g=K("packages/dom/src/cell/icons.js"),l=g.createIcon,c=g.updateIcon,s=g.icon,t=K("packages/dom/src/viewpicker.js").ViewPicker,o=K("packages/dom/src/formattingpanel.js").FormattingPanel,u=K("packages/dom/src/statisticspanel.js").StatisticsPanel,m=K("packages/dom/src/regressionpanel.js").RegressionPanel,h=K("packages/dom/src/comparepanel.js").ComparePanel,p=K("packages/dom/src/insightspanel.js").InsightsPanel,j=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,y=K("packages/core/src/compute/total.js").TOTAL_LABELS;class v extends j{dragging=null;collapsed=new Set;refresh(){const M=this.root;if(!M)return;for(const Y of this.off)Y();this.off.length=0,W(M);const A=_(this.doc,"input",{class:`${$.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.query&&(A.value=this.query),this.off.push(X(A,"input",()=>{this.query=A.value,this.paintList()})),M.appendChild(A),M.appendChild(this.buildZone("group","Row groups")),M.appendChild(this.buildZone("values","Grouped row calculation")),M.appendChild(this.buildZone("pivot","Pivot"));const L=_(this.doc,"div",{class:`${$.panel}__heading`});L.appendChild(_(this.doc,"span",{text:this.t("panel.columns")}));const G=_(this.doc,"button",{class:`${$.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),q=_(this.doc,"button",{class:`${$.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(X(G,"click",()=>{const Y=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);w(this.host.showColumns)&&this.host.showColumns(Y),this.refresh()})),this.off.push(X(q,"click",()=>{const Y=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);w(this.host.hideColumns)&&this.host.hideColumns(Y),this.refresh()})),L.appendChild(G),L.appendChild(q),M.appendChild(L),this.list=_(this.doc,"div",{class:`${$.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),M.appendChild(this.list),this.paintList()}columns(){const M=this.host;return w(M.columns)?M.columns()||[]:M.columns&&w(M.columns.all)?M.columns.all():[]}paintList(){const M=this.list;if(!M)return;W(M);const A=String(this.query||"").trim().toLowerCase();this.paintNodes(M,this.bandTree(),A)}paintNodes(M,A,L,G=!1){let q=0;for(const Y of A){if(Y.column){const ae=String(Y.column.title||Y.column.id||"");if(L&&!G&&!ae.toLowerCase().includes(L))continue;M.appendChild(this.buildColumnRow(Y.column)),q++;continue}const J=!!L&&this.bandTitle(Y.band).toLowerCase().includes(L),te=_(this.doc,"div",{class:`${$.panel}__bandBody`}),ne=this.paintNodes(te,Y.children,L,G||J);if(L&&!ne&&!J)continue;const oe=_(this.doc,"div",{class:`${$.panel}__band`,attrs:{role:"group","aria-label":this.bandTitle(Y.band),"data-band":Y.band.id}}),le=!this.collapsed.has(Y.band.id);oe.appendChild(this.buildBandRow(Y,le)),(le||L)&&oe.appendChild(te),M.appendChild(oe),q++}return q}bandTree(){const M=this.columns(),A=new Map,L=this.host;if(w(L.columnGroups)){const Y=J=>{for(const te of J||[])Array.isArray(te.columns)&&(A.set(te.id,te.title),Y(te.columns))};Y(L.columnGroups())}const G=[],q=new Map;for(const Y of M){let J=G,te="";for(const ne of Y.groupPath||[]){te+=`/${ne}`;let oe=q.get(te);oe||(oe={band:{id:ne,title:A.has(ne)?A.get(ne):""},children:[],ids:[]},q.set(te,oe),J.push(oe)),oe.ids.push(Y.id),J=oe.children}J.push({column:Y})}return G}bandTitle(M){return String(M.title||"")||this.t("columngroup.untitled")}buildColumnRow(M){const A=String(M.title||M.id||""),L=_(this.doc,"div",{class:`${$.panel}__column`,attrs:{"data-col":M.id,draggable:"true",title:this.t("panel.columnDragHint",{column:A})}});L.appendChild(_(this.doc,"span",{class:`${$.panel}__grip`,attrs:{"aria-hidden":"true"}}));const G=_(this.doc,"input",{attrs:{type:"checkbox","aria-label":A}});return G.checked=!(M.layout&&M.layout.hidden),M.layout&&M.layout.lockVisible&&G.setAttribute("disabled",""),this.off.push(X(G,"change",()=>this.setVisible(M.id,G.checked))),L.appendChild(G),L.appendChild(_(this.doc,"span",{text:A})),L.setAttribute("tabindex","0"),L.setAttribute("role","listitem"),this.off.push(X(L,"keydown",q=>this.onRowKey(q,M))),this.off.push(X(L,"dragstart",()=>{this.dragging=M.id})),this.off.push(X(L,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(X(L,"dragover",q=>{if(!this.dragging||this.dragging===M.id)return;if(w(q.preventDefault)&&q.preventDefault(),this.bandDrop(this.dragging,M)){L.setAttribute("data-drop","into");return}const J=D(q,L);L.setAttribute("data-drop",J?"before":"after")})),this.off.push(X(L,"dragleave",()=>L.removeAttribute("data-drop"))),this.off.push(X(L,"drop",q=>{w(q.preventDefault)&&q.preventDefault();const Y=this.dragging;if(this.dragging=null,this.clearDropMark(),!Y||Y===M.id)return;const J=this.bandDrop(Y,M);if(J==="leave"){this.leaveBand(Y);return}if(J){this.joinBand(Y,J);return}this.moveColumn(Y,M.id,D(q,L))})),L}bandOf(M){const A=typeof M=="string"?this.columns().find(G=>G.id===M):M,L=A&&A.groupPath||[];return L.length?L[L.length-1]:null}bandDrop(M,A){const L=this.host;if(!w(L.groupColumns))return null;const G=this.bandOf(M),q=this.bandOf(A);return q&&q!==G?q:G&&!q?"leave":null}joinBand(M,A){const L=this.columns().find(q=>q.id===M),G=this.titleOf(M);if(L&&L.layout&&L.layout.lockPosition){this.announce(this.t("a11y.column.cannotGroup",{column:G}),{repeat:!0});return}this.host.groupColumns([M],{groupId:A}),this.announce(this.t("a11y.column.addedToGroup",{column:G,group:this.bandName(A)}),{repeat:!0}),this.refresh()}leaveBand(M){w(this.host.ungroupColumn)&&(this.host.ungroupColumn(M),this.announce(this.t("a11y.column.removedFromGroup",{column:this.titleOf(M)}),{repeat:!0}),this.refresh())}bandName(M){const A=G=>{for(const q of G){if(!q.band)continue;if(q.band.id===M)return q.band;const Y=A(q.children);if(Y)return Y}return null},L=A(this.bandTree());return L?this.bandTitle(L):M}buildBandRow(M,A){const{band:L,ids:G}=M,q=this.bandTitle(L),Y=_(this.doc,"div",{class:`${$.panel}__bandRow`,attrs:{"data-band-row":L.id,tabindex:"0",role:"listitem","aria-label":q}}),J=_(this.doc,"button",{class:`${$.panel}__bandToggle`,attrs:{type:"button","aria-expanded":A?"true":"false","aria-label":this.t(A?"panel.bandCollapse":"panel.bandExpand",{band:q})},text:A?"▾":"▸"});this.off.push(X(J,"click",()=>this.toggleBand(L.id))),Y.appendChild(J);const te=new Map(this.columns().map(se=>[se.id,se])),ne=G.filter(se=>!(te.get(se).layout&&te.get(se).layout.hidden)).length,oe=_(this.doc,"input",{attrs:{type:"checkbox","aria-label":this.t("panel.bandVisible",{band:q})}});oe.checked=ne===G.length,oe.indeterminate=ne>0&&ne<G.length,ne>0&&ne<G.length&&oe.setAttribute("aria-checked","mixed");const le=G.filter(se=>!(te.get(se).layout&&te.get(se).layout.lockVisible));le.length||oe.setAttribute("disabled",""),this.off.push(X(oe,"change",()=>{const se=this.host;oe.checked?w(se.showColumns)&&se.showColumns(le):w(se.hideColumns)&&se.hideColumns(le),this.refresh()})),Y.appendChild(oe);const ae=_(this.doc,"span",{class:`${$.panel}__bandTitle`,text:q});if(Y.appendChild(ae),w(this.host.renameGroup)){const se=_(this.doc,"button",{class:`${$.panel}__link`,text:this.t("columngroup.rename"),attrs:{type:"button","aria-label":this.t("panel.bandRenameFor",{band:q})}});this.off.push(X(se,"click",()=>this.startBandRename(Y,ae,L))),Y.appendChild(se)}if(w(this.host.dissolveGroup)){const se=_(this.doc,"button",{class:`${$.panel}__link`,text:this.t("columngroup.dissolve"),attrs:{type:"button","aria-label":this.t("panel.bandDissolveFor",{band:q})}});this.off.push(X(se,"click",()=>this.dissolveBand(L.id))),Y.appendChild(se)}return this.off.push(X(Y,"keydown",se=>this.onBandKey(se,L,Y))),this.off.push(X(Y,"dragover",se=>{!this.dragging||!w(this.host.groupColumns)||this.bandOf(this.dragging)===L.id||(w(se.preventDefault)&&se.preventDefault(),Y.setAttribute("data-drop","into"))})),this.off.push(X(Y,"dragleave",()=>Y.removeAttribute("data-drop"))),this.off.push(X(Y,"drop",se=>{w(se.preventDefault)&&se.preventDefault();const ee=this.dragging;this.dragging=null,this.clearDropMark(),!(!ee||!w(this.host.groupColumns)||this.bandOf(ee)===L.id)&&this.joinBand(ee,L.id)})),Y}toggleBand(M){this.collapsed.has(M)?this.collapsed.delete(M):this.collapsed.add(M),this.paintList(),this.focusBand(M)}focusBand(M){const A=this.list&&this.list.querySelector?this.list.querySelector(`[data-band-row="${B(M)}"]`):null;A&&w(A.focus)&&A.focus()}dissolveBand(M){if(!w(this.host.dissolveGroup))return;const A=this.bandName(M);this.collapsed.delete(M),this.host.dissolveGroup(M),this.announce(this.t("a11y.group.dissolved",{group:A}),{repeat:!0}),this.refresh()}startBandRename(M,A,L){const G=_(this.doc,"input",{class:`${$.panel}__bandRename`,attrs:{type:"text","aria-label":this.t("columngroup.rename")}});G.value=L.title||"";let q=!1;const Y=J=>{q||(q=!0,J?(this.host.renameGroup(L.id,G.value),this.announce(this.t("a11y.group.renamed",{group:G.value}),{repeat:!0}),this.refresh()):this.paintList(),this.focusBand(L.id))};this.off.push(X(G,"keydown",J=>{J.key==="Enter"?(w(J.preventDefault)&&J.preventDefault(),Y(!0)):J.key==="Escape"&&(w(J.preventDefault)&&J.preventDefault(),Y(!1))})),this.off.push(X(G,"blur",()=>Y(!0))),A.parentNode&&A.parentNode.replaceChild(G,A),w(G.focus)&&G.focus(),w(G.select)&&G.select()}onBandKey(M,A,L){if(M.target&&M.target!==L)return;const G=M.key;G==="Enter"?(w(M.preventDefault)&&M.preventDefault(),this.toggleBand(A.id)):G==="Delete"?(w(M.preventDefault)&&M.preventDefault(),this.dissolveBand(A.id)):(G==="ArrowUp"||G==="ArrowDown")&&(w(M.preventDefault)&&M.preventDefault(),this.walk(L,G==="ArrowUp"))}walk(M,A){const L=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col], [data-band-row]")]:[],G=L.indexOf(M),q=L[G+(A?-1:1)];q&&w(q.focus)&&q.focus()}onRowKey(M,A){const L=M&&M.key,G=v.zoneKeys[String(L).toLowerCase()];if(G&&!M.ctrlKey&&!M.metaKey&&!M.altKey){w(M.preventDefault)&&M.preventDefault(),this.toggleZone(G,A);return}if(L!=="ArrowUp"&&L!=="ArrowDown")return;const q=L==="ArrowUp",Y=this.columns().map(ae=>ae.id),J=Y.indexOf(A.id);if(J<0)return;if(w(M.preventDefault)&&M.preventDefault(),!M.shiftKey){const ae=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col], [data-band-row]")]:[],se=ae.findIndex(ie=>ie.getAttribute("data-col")===A.id),ee=ae[se+(q?-1:1)];ee&&w(ee.focus)&&ee.focus();return}const te=A.layout&&(A.layout.movable===!1||A.layout.lockPosition),ne=String(A.title||A.id||"");if(te){this.announce(this.t("a11y.panel.cannotMove",{column:ne}),{repeat:!0});return}const oe=Y[J+(q?-1:1)];if(!oe){this.announce(this.t(q?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:ne}),{repeat:!0});return}this.moveColumn(A.id,oe,q),this.announce(this.t("a11y.panel.moved",{column:ne,at:q?J:J+2,of:Y.length}),{repeat:!0});const le=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(A.id)}"]`):null;le&&w(le.focus)&&le.focus()}toggleZone(M,A){const L=this.titleOf(A.id),G=this.t(v.zoneLabel[M]||"panel.zone.group");if(this.zoneColumns(M).includes(A.id)){this.dropFromZone(M,A.id),this.announce(this.t("a11y.panel.removedFrom",{column:L,list:G}),{repeat:!0}),this.restoreFocus(A.id);return}if(this.addToZone(M,A.id)){this.announce(this.t("a11y.panel.addedTo",{column:L,list:G}),{repeat:!0}),this.restoreFocus(A.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:L,list:G}),{repeat:!0})}restoreFocus(M){const A=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(M)}"]`):null;A&&w(A.focus)&&A.focus()}announce(M,A){const L=this.host||{};w(L.announce)&&L.announce(M,A)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const M of this.list.querySelectorAll("[data-drop]"))M.removeAttribute("data-drop")}moveColumn(M,A,L){const G=this.host||{};w(G.moveColumn)&&(G.moveColumn(M,A,L),this.refresh())}buildZone(M,A){const L=_(this.doc,"div",{class:`${$.panel}__zone`,attrs:{"data-zone":M,role:"group","aria-label":A}});L.appendChild(_(this.doc,"div",{class:`${$.panel}__zoneTitle`,text:A}));const G=this.zoneColumns(M);let q=v.zoneAbout[M]||"";M==="values"&&G.length&&!this.zoneColumns("group").length&&(q+=" Add a row group to see them."),q&&L.appendChild(_(this.doc,"div",{class:`${$.panel}__zoneAbout`,text:q}));const Y=_(this.doc,"div",{class:`${$.panel}__zoneBody`});G.length||Y.appendChild(_(this.doc,"span",{class:`${$.panel}__zoneHint`,text:this.t(v.zoneHint[M]||"panel.zoneHint.any")})),M==="values"&&Y.classList.add(`${$.panel}__zoneBody--rows`);for(const J of G){const te=_(this.doc,"span",{class:[$.chip,M==="values"?`${$.chip}--row`:""]});if(te.appendChild(_(this.doc,"span",{class:`${$.chip}__label`,text:this.titleOf(J)})),M==="values"&&w(this.host.setValueAggregation)){const oe=w(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",le=_(this.doc,"select",{class:`${$.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const ae of v.aggregations)le.appendChild(_(this.doc,"option",{text:this.t(`total.${ae.name}`),attrs:{value:ae.name,selected:ae.name===oe?"":null}}));le.value=oe,this.off.push(X(le,"change",()=>{this.host.setValueAggregation(J,le.value),this.refresh()})),te.appendChild(le)}const ne=_(this.doc,"button",{class:$.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(X(ne,"click",()=>this.dropFromZone(M,J))),te.appendChild(ne),Y.appendChild(te)}return this.off.push(X(L,"dragover",J=>{w(J.preventDefault)&&J.preventDefault(),L.setAttribute("data-over","true")})),this.off.push(X(L,"dragleave",()=>L.removeAttribute("data-over"))),this.off.push(X(L,"drop",J=>{w(J.preventDefault)&&J.preventDefault(),L.removeAttribute("data-over"),this.dragging&&this.addToZone(M,this.dragging)})),L.appendChild(Y),L}static aggregations=Object.freeze(Object.keys(y).map(M=>({name:M})));static zoneAbout=Object.freeze({group:"Rows are grouped by these columns, in order.",values:"Each column here is calculated for every group. Pick the calculation on its chip.",pivot:"Generates a column for each distinct value."});static zoneHint=Object.freeze({group:"panel.zoneHint.group",values:"panel.zoneHint.values",pivot:"panel.zoneHint.pivot"});static zoneKeys=Object.freeze({g:"group",v:"values",p:"pivot"});static zoneLabel=Object.freeze({group:"panel.zone.group",values:"panel.zone.values",pivot:"panel.zone.pivot"});static zoneApi=Object.freeze({group:{read:"groupBy",write:"setGroupBy",permission:"allowGroup"},values:{read:"valueColumns",write:"setValueColumns",permission:"allowTotal"},pivot:{read:"pivotBy",write:"setPivotBy",permission:"allowPivot"}});zoneColumns(M){const A=v.zoneApi[M],L=this.host;return A&&w(L[A.read])?L[A.read]()||[]:[]}titleOf(M){const A=this.columns().find(L=>L.id===M);return String(A&&(A.title||A.id)||M)}addToZone(M,A){const L=v.zoneApi[M],G=this.columns().find(Y=>Y.id===A);if(!L||!G||G[L.permission]===!1||!w(this.host[L.write]))return!1;const q=this.zoneColumns(M);return q.includes(A)?!1:(this.host[L.write]([...q,A]),this.refresh(),!0)}dropFromZone(M,A){const L=v.zoneApi[M];return!L||!w(this.host[L.write])?!1:(this.host[L.write](this.zoneColumns(M).filter(G=>G!==A)),this.refresh(),!0)}setVisible(M,A){const L=this.host;A&&w(L.showColumns)?L.showColumns([M]):!A&&w(L.hideColumns)&&L.hideColumns([M])}}class R extends j{open=new Set;query="";#e=!1;#t=!1;refresh(){if(this.#e){this.#t=!0;return}this.#e=!0;try{do this.#t=!1,this.#n();while(this.#t)}finally{this.#e=!1}}#n(){const M=this.root;if(!M)return;for(const te of this.off)te();this.off.length=0,W(M);const A=this.host,L=(w(A.columns)?A.columns():[]).filter(te=>!(te.filter&&te.filter.enabled===!1));if(!w(A.filterFor))return;const G=L.filter(te=>this.isFiltered(te.id));M.appendChild(this.buildSearch()),M.appendChild(this.buildSummary(G.length,L.length));const q=this.query.trim().toLowerCase(),Y=q?L.filter(te=>String(te.title||te.id).toLowerCase().includes(q)):L;if(!Y.length){M.appendChild(_(this.doc,"p",{class:`${$.panel}__empty`,text:q?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=_(this.doc,"div",{class:`${$.panel}__filters`});for(const te of Y)J.appendChild(this.buildSection(te));M.appendChild(J)}isFiltered(M){const A=this.host;return w(A.isFiltered)?A.isFiltered(M)===!0:!1}buildSearch(){const M=_(this.doc,"input",{class:`${$.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return M.value=this.query,this.off.push(X(M,"input",()=>{this.query=M.value||"",this.refresh();const A=this.root&&this.root.querySelector?this.root.querySelector(`.${$.panel}__search`):null;A&&w(A.focus)&&A.focus()})),M}buildSummary(M,A){const L=_(this.doc,"div",{class:`${$.panel}__filterSummary`});if(L.appendChild(_(this.doc,"span",{class:`${$.panel}__filterCount`,text:M?this.t("panel.filterSummaryActive",{active:M,total:A}):this.t("panel.filterSummaryNone",{total:A}),attrs:{"data-active":M?"true":"false"}})),!M)return L;const G=_(this.doc,"button",{class:`${$.panel}__clearAll`,text:this.t("panel.clearAll"),attrs:{type:"button"}});return this.off.push(X(G,"click",()=>{w(this.host.clearAllFilters)&&this.host.clearAllFilters(),this.refresh()})),L.appendChild(G),L}buildSection(M){const A=M.id,L=String(M.title||A),G=this.isFiltered(A),q=this.open.has(A),Y=_(this.doc,"section",{class:`${$.panel}__filter`,attrs:{"data-col":A,"data-filtered":G?"true":null}}),J=_(this.doc,"button",{class:`${$.panel}__filterTitle`,attrs:{type:"button","aria-expanded":q?"true":"false",title:this.t(G?"panel.filteredBy":"panel.filterBy",{column:L})},children:[l(this.doc,q?"chevronDown":"chevronRight",{className:`${$.panel}__twisty`}),_(this.doc,"span",{class:`${$.panel}__filterName`,text:L})]});G&&J.appendChild(_(this.doc,"span",{class:`${$.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const te=_(this.doc,"div",{class:`${$.panel}__filterBody`,style:{display:q?"":"none"}}),ne=()=>{if(te.firstChild)return;const oe=this.host.filterFor(A);oe&&w(oe.element)&&te.appendChild(oe.element())};if(this.off.push(X(J,"click",()=>{const oe=this.open.has(A);oe?this.open.delete(A):this.open.add(A),J.setAttribute("aria-expanded",oe?"false":"true"),te.style.display=oe?"none":"";const le=J.firstElementChild;le&&c(le,oe?"chevronRight":"chevronDown"),oe||ne()})),Y.appendChild(J),G){const oe=_(this.doc,"button",{class:`${$.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:L}),title:this.t("panel.clearFilter")},children:[l(this.doc,"close",{className:$.icon})]});this.off.push(X(oe,"click",le=>{w(le.stopPropagation)&&le.stopPropagation(),w(this.host.clearFilter)&&this.host.clearFilter(A),this.refresh()})),Y.appendChild(oe)}return Y.appendChild(te),q&&ne(),Y}}class O extends j{refresh(){const M=this.root;if(!M)return;if(this.box){const q=w(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==q&&(this.box.value=q),this.paintCount();return}for(const q of this.off)q();this.off.length=0,W(M);const A=w(this.host.quickFilter)?this.host.quickFilter():"",L=_(this.doc,"input",{class:`${$.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});L.value=A||"",this.off.push(X(L,"input",()=>{w(this.host.setQuickFilter)&&this.host.setQuickFilter(L.value),this.paintCount()})),M.appendChild(L),this.box=L;const G=_(this.doc,"button",{class:`${$.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(X(G,"click",()=>{L.value="",w(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),w(L.focus)&&L.focus()})),M.appendChild(G),this.count=_(this.doc,"p",{class:`${$.panel}__count`}),M.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){k(()=>{this.box&&w(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const M=w(this.host.rowCount)?this.host.rowCount():null,A=w(this.host.totalRowCount)?this.host.totalRowCount():null;if(M===null||A===null||M===void 0){this.count.textContent="";return}this.count.textContent=M===A?this.t("count.rows",{count:A}):this.t("panel.rowsOf",{shown:M,total:A})}}const x=Object.freeze({columns:v,filters:R,views:t,quick:O,formatting:o,statistics:u,regression:m,compare:h,insights:p}),C=Object.freeze({columns:"panel.columns",filters:"panel.filters",views:"panel.views",quick:"panel.quickFilter",formatting:"panel.formatting",statistics:"panel.statistics",regression:"panel.regression",compare:"panel.compare",insights:"panel.insights"}),P=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class F{panels=[];actions=[];root=null;openPanel=null;off=[];t(M,A){return(this.messages&&typeof this.messages.t=="function"?this.messages:U).t(M,A)}init(M){const A=M||{};this.doc=I(A),this.host=A.host||{},this.messages=A.messages||A.grid&&A.grid.messages||U,this.icons=A.icons===void 0?A.side==="left":!!A.icons,this.side=A.side==="left"?"left":"right",this.root=_(this.doc,"div",{class:[$.panel,`${$.panel}--${this.side}`,this.icons?`${$.panel}--icons`:null]}),this.tabs=_(this.doc,"div",{class:`${$.panel}__tabs`,attrs:{role:"tablist"}}),this.body=_(this.doc,"div",{class:`${$.panel}__content`}),this.side==="left"?(this.root.appendChild(this.tabs),this.root.appendChild(this.body)):(this.root.appendChild(this.body),this.root.appendChild(this.tabs)),this.actionGroup=_(this.doc,"div",{class:`${$.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const q of Array.isArray(A.actions)?A.actions:[])this.registerAction(q);const L=A.registry||{},G=Array.isArray(A.panels)&&A.panels.length?A.panels:["columns","filters"];for(const q of G){const Y=typeof q=="string"?q:q.name,J=typeof q=="function"?q:L[Y]||x[Y];J&&this.registerPanel(String(Y),J,typeof q=="object"?q:{})}A.openPanel&&this.show(A.openPanel)}registerPanel(M,A,L){const G=new A;G.init({document:this.doc,host:this.host,props:L&&L.props||{}});const q=L&&L.title||M,Y=L&&L.icon||M,J=_(this.doc,"button",{class:`${$.panel}__tab`,text:this.icons?null:q,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":M,title:this.icons?q:null,"aria-label":this.icons?q:null}});return this.icons&&J.appendChild(l(this.doc,Y,{className:`${$.panel}__icon`})),this.off.push(X(J,"click",()=>this.toggle(M))),this.tabs.appendChild(J),this.panels.push({name:M,title:q,panel:G}),G}registerAction(M){if(!M||!M.name)return null;if(M.separator)return this.actionGroup.appendChild(_(this.doc,"div",{class:`${$.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const A=_(this.doc,"button",{class:`${$.panel}__action`,text:this.icons?null:w(M.title)?String(M.title()):M.title,attrs:{type:"button","data-action":M.name,title:w(M.title)?null:M.title,"aria-label":w(M.title)?null:M.title}});if(this.icons){const q=(w(M.icon)?M.icon():M.icon)||(s(M.name)?M.name:"blank");A.appendChild(l(this.doc,q,{className:`${$.panel}__icon`})),A.setAttribute("data-icon",q)}const L=X(A,"click",()=>{w(M.enabled)&&!M.enabled()||(w(M.run)&&M.run(),this.paintActions())});return this.off.push(L),this.actionGroup.appendChild(A),this.actions.push({...M,button:A,offClick:L}),this.paintActions(),A}removeAction(M){const A=this.actions.findIndex(G=>G.name===M);if(A<0)return!1;const L=this.actions[A];return w(L.offClick)&&L.offClick(),L.button&&L.button.parentNode&&L.button.parentNode.removeChild(L.button),this.actions.splice(A,1),!0}paintActions(){for(const M of this.actions){if(!M.button)continue;const A=w(M.enabled)?!!M.enabled():!0;if(M.button.disabled=!A,M.button.setAttribute("aria-disabled",A?"false":"true"),w(M.active)&&M.button.setAttribute("aria-pressed",M.active()?"true":"false"),w(M.title)){const L=String(M.title());M.button.setAttribute("title",L),M.button.setAttribute("aria-label",L),!this.icons&&M.button.textContent!==L&&(M.button.textContent=L)}if(this.icons&&w(M.icon)){const L=String(M.icon());M.button.getAttribute("data-icon")!==L&&(W(M.button),M.button.appendChild(l(this.doc,L,{className:`${$.panel}__icon`})),M.button.setAttribute("data-icon",L))}}}show(M){const A=this.panels.find(L=>L.name===M);return A?(W(this.body),w(A.panel.refresh)&&A.panel.refresh(),this.body.appendChild(A.panel.element()),this.openPanel=M,this.paintTabs(),w(A.panel.focus)&&A.panel.focus(),!0):!1}hide(){W(this.body),this.openPanel=null,this.paintTabs()}toggle(M){this.openPanel===M?this.hide():this.show(M)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let M=0;M<this.tabs.childNodes.length;M++){const A=this.tabs.childNodes[M];A&&A.setAttribute&&A.setAttribute("aria-selected",A.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const M=this.panels.find(A=>A.name===this.openPanel);M&&w(M.panel.refresh)&&!this.#e(M.panel)&&M.panel.refresh(),this.paintActions()}#e(M){const A=this.doc&&this.doc.activeElement;if(!A||A===this.doc.body)return!1;const L=w(M.element)?M.element():null;return!!(L&&w(L.contains)&&L.contains(A))}destroy(){for(const M of this.off)M();this.off.length=0;for(const M of this.panels)w(M.panel.destroy)&&M.panel.destroy();this.panels=[],this.root=null}}const E=F;function D(N,M){if(!M.getBoundingClientRect||typeof N.clientY!="number")return!0;const A=M.getBoundingClientRect();return N.clientY<A.top+A.height/2}}),Fe("packages/dom/src/ui/groupbyzone.js",function(e,K){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return k}});const $=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,B=K("packages/dom/src/editors/common.js"),I=B.CLS,_=B.el,X=B.on,W=B.clear,H=B.cssEscape,z=K("packages/core/src/internal/util.js").isFunction,w="text/x-lattice-col";class k extends ${dragging=null;#e=[];init(l){this.ctx=l,this.doc=l.document,this.host=l.host||{},this.props=l.props||{},this.root=_(this.doc,"div",{class:I.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const l=this.host;return z(l.columns)?l.columns()||[]:l.columns&&z(l.columns.all)?l.columns.all():[]}groups(){return z(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(l){z(this.host.setGroupBy)&&this.host.setGroupBy(l)}titleOf(l){const c=this.columns().find(s=>s.id===l);return String(c&&(c.title||c.id)||l)}canGroup(l){const c=this.columns().find(s=>s.id===l);return!!c&&c.allowGroup!==!1&&!c.generated}announce(l,c){z(this.host.announce)&&this.host.announce(l,c)}refresh(){const l=this.root;if(!l)return;for(const n of this.off)n();this.off.length=0,W(l),l.appendChild(_(this.doc,"span",{class:I.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const c=this.groups(),s=_(this.doc,"div",{class:I.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});c.length||s.appendChild(_(this.doc,"span",{class:I.groupZoneHint,text:this.t("groupZone.hint")})),c.forEach((n,t)=>s.appendChild(this.#t(n,t,c.length))),l.appendChild(s),this.chips=s,l.appendChild(this.#i(c)),this.off.push(X(l,"dragover",n=>{this.dragging==null&&!this.#l(n)||(z(n.preventDefault)&&n.preventDefault(),l.setAttribute("data-over","true"))})),this.off.push(X(l,"dragleave",()=>l.removeAttribute("data-over"))),this.off.push(X(l,"drop",n=>{z(n.preventDefault)&&n.preventDefault(),l.removeAttribute("data-over");const t=this.#l(n)||this.dragging;t!=null&&this.#o(t,this.groups().length)})),this.#s()}#t(l,c,s){const n=this.titleOf(l),t=_(this.doc,"div",{class:[I.chip,I.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":l,"aria-label":this.t("groupZone.chip",{column:n,at:c+1,of:s})}});t.appendChild(_(this.doc,"span",{class:I.groupZoneChipText,text:n}));const r=_(this.doc,"button",{class:I.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:n})}});return this.off.push(X(r,"click",()=>this.#r(l))),t.appendChild(r),this.off.push(X(t,"dragstart",o=>{this.dragging=l,o.dataTransfer&&z(o.dataTransfer.setData)&&o.dataTransfer.setData(w,l)})),this.off.push(X(t,"dragend",()=>{this.dragging=null})),this.off.push(X(t,"dragover",o=>{const f=this.#l(o)||this.dragging;f==null||f===l||z(o.preventDefault)&&o.preventDefault()})),this.off.push(X(t,"drop",o=>{const f=this.#l(o)||this.dragging;f!=null&&(z(o.preventDefault)&&o.preventDefault(),z(o.stopPropagation)&&o.stopPropagation(),this.#o(f,c))})),this.off.push(X(t,"keydown",o=>this.#n(o,l,c))),t}#n(l,c,s){const n=l&&l.key,t=this.groups();if(n==="Delete"||n==="Backspace"){z(l.preventDefault)&&l.preventDefault(),this.#r(c,t,s);return}const r=n==="ArrowLeft"||n==="ArrowUp",o=n==="ArrowRight"||n==="ArrowDown",f=n==="Home",u=n==="End";if(!r&&!o&&!f&&!u)return;if(z(l.preventDefault)&&l.preventDefault(),l.shiftKey&&(r||o)){const d=s+(r?-1:1);if(d<0||d>=t.length){this.announce(this.t(r?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(c)}),{repeat:!0});return}const h=t.slice();h.splice(s,1),h.splice(d,0,c),this.setGroups(h),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(c),at:d+1,of:h.length}),{repeat:!0}),this.#a(c);return}let i=s+(r?-1:o?1:0);f&&(i=0),u&&(i=t.length-1);const m=t[i];m&&this.#a(m)}#r(l,c=this.groups(),s=c.indexOf(l)){const n=this.titleOf(l);this.setGroups(c.filter(r=>r!==l)),this.announce(this.t("a11y.panel.removedFrom",{column:n,list:this.t("panel.zone.group")}),{repeat:!0});const t=this.groups();t.length?this.#a(t[Math.min(s,t.length-1)]):this.#u()}#o(l,c){if(!this.canGroup(l)){this.announce(this.t("a11y.panel.cannotAddTo",{column:this.titleOf(l),list:this.t("panel.zone.group")}),{repeat:!0});return}const s=this.groups(),n=s.indexOf(l),t=s.slice();n>=0&&(t.splice(n,1),n<c&&(c-=1)),t.splice(Math.max(0,Math.min(c,t.length)),0,l),this.setGroups(t);const r=t.indexOf(l);this.announce(this.t(n>=0?"a11y.panel.moved":"a11y.panel.addedTo",n>=0?{column:this.titleOf(l),at:r+1,of:t.length}:{column:this.titleOf(l),list:this.t("panel.zone.group")}),{repeat:!0}),this.#a(l)}#i(l){const c=new Set(l),s=_(this.doc,"label",{class:I.groupZoneAdd}),n=_(this.doc,"select",{class:I.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});n.appendChild(_(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const t of this.columns())c.has(t.id)||!this.canGroup(t.id)||n.appendChild(_(this.doc,"option",{text:this.titleOf(t.id),attrs:{value:t.id}}));return this.off.push(X(n,"change",()=>{const t=n.value;t&&this.#o(t,this.groups().length)})),this.adderSelect=n,s.appendChild(n),s}#s(){for(const c of this.#e)c();this.#e.length=0;const l=this.props&&this.props.header;if(!(!l||!z(l.querySelectorAll)))for(const c of l.querySelectorAll("[data-col]")){const s=z(c.getAttribute)?c.getAttribute("data-col"):null;!s||!this.canGroup(s)||(z(c.setAttribute)&&c.setAttribute("draggable","true"),this.#e.push(X(c,"dragstart",n=>{this.dragging=s,n.dataTransfer&&z(n.dataTransfer.setData)&&n.dataTransfer.setData(w,s)})),this.#e.push(X(c,"dragend",()=>{this.dragging=null})))}}#l(l){const c=l&&l.dataTransfer;if(c&&z(c.getData)){const s=c.getData(w);if(s)return s}return null}#a(l){const c=this.chips&&z(this.chips.querySelector)?this.chips.querySelector(`[data-col="${H(l)}"]`):null;c&&z(c.focus)&&c.focus()}#u(){this.adderSelect&&z(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const l of this.#e)l();this.#e.length=0,super.destroy()}}}),Fe("packages/dom/src/ui/tooltip.js",function(e,K){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,H=K("packages/core/src/internal/util.js").isFunction;class U{root=null;init(g){this.doc=g.document,this.root=I(this.doc,"div",{class:`${$.tooltip}__text`}),this.update(g.content)}update(g){if(!this.root)return;const l=g==null?"":String(g);this.root.textContent!==l&&(this.root.textContent=l)}element(){return this.root}destroy(){this.root=null}}class z{root=null;component=null;timer=null;target=null;off=[];constructor(g){const l=g||{};this.doc=B(l),this.host=l.host||this.doc.body,this.delay=l.delay??400,this.hideDelay=l.hideDelay??0,this.components={text:U,...l.components||{}}}show(g){this.cancelTimer();const l=g.delay??this.delay;if(!l){this.showNow(g);return}this.timer=setTimeout(()=>{this.timer=null,this.showNow(g)},l)}showNow(g){const l=g.component||"text",c=typeof l=="function"?l:this.components[l]||U;return this.root||(this.root=I(this.doc,"div",{class:$.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==c?(this.component&&H(this.component.destroy)&&this.component.destroy(),X(this.root),this.component=new c,this.componentCtor=c,this.component.init({document:this.doc,content:g.content,...g.props||{}}),this.root.appendChild(this.component.element())):H(this.component.update)&&this.component.update(g.content),this.target=g.target||null,this.position(),this.root.setAttribute("data-open","true"),this.root}position(){if(!this.root||!this.target||!H(this.target.getBoundingClientRect))return;const g=this.target.getBoundingClientRect(),l=this.doc.defaultView||{};this.root.style.left=`${g.left+(l.scrollX||0)}px`,this.root.style.top=`${g.bottom+(l.scrollY||0)}px`}hide(){this.cancelTimer(),this.root&&(this.root.setAttribute("data-open","false"),this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.target=null)}cancelTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}attach(g,l,c){const s=()=>this.show({target:g,content:l(),...c||{}}),n=()=>this.hide(),t=[_(g,"mouseenter",s),_(g,"mouseleave",n),_(g,"focus",s),_(g,"blur",n)],r=()=>{for(const o of t)o()};return this.off.push(r),r}destroy(){this.hide();for(const g of this.off)g();this.off.length=0,this.component&&H(this.component.destroy)&&this.component.destroy(),this.component=null,this.root=null}}const w=z}),Fe("packages/dom/src/ui/pagination.js",function(e,K){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,H=K("packages/core/src/i18n/index.js").defaultMessages,z=K("packages/core/src/internal/util.js").isFunction;function w(l){const c=Math.max(1,Number(l.pageSize)||100),s=l.total==null?null:Math.max(0,Number(l.total)),n=s==null?null:Math.max(1,Math.ceil(s/c)),t=Math.max(0,n==null?Number(l.page)||0:Math.min(Number(l.page)||0,n-1)),r=s===0?0:t*c+1,o=s==null?(t+1)*c:Math.min(s,(t+1)*c);return{page:t,pageSize:c,pageCount:n,from:r,to:o,first:t===0,last:n==null?l.hasMore!==!0:t>=n-1,total:s}}class k{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(c){const s=c||{};this.doc=B(s),this.host=s.host||{},this.pageSize=Number(s.pageSize)||100;const n=Array.isArray(s.pageSizes)&&s.pageSizes.length?[...s.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!n.includes(this.pageSize)&&n.push(this.pageSize),this.pageSizes=n.sort((t,r)=>t-r),this.page=Number(s.page)||0,this.total=s.total===void 0?null:s.total,this.locale=s.locale,this.messages=s.messages||null,this.onChange=s.onChange||null,this.root=I(this.doc,"nav",{class:$.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(c,s){const n=this.messages;return(n&&typeof n.t=="function"?n:H).t(c,s)}element(){return this.root}model(){return w({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(c){c.total!==void 0&&(this.total=c.total),c.counting!==void 0&&(this.counting=c.counting===!0),c.hasMore!==void 0&&(this.hasMore=c.hasMore===!0),c.page!==void 0&&(this.page=Number(c.page)||0),this.paint()}goTo(c){const s=this.page;this.page=c;const n=this.model();return this.page=n.page,this.paint(),this.page!==s&&z(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize}),this.page}next(){return this.model().last?this.page:this.goTo(this.page+1)}previous(){return this.page===0?0:this.goTo(this.page-1)}last(){const c=this.model();return c.pageCount==null?this.page:this.goTo(c.pageCount-1)}setPageSize(c){const s=this.page*this.pageSize;this.pageSize=Math.max(1,Number(c)||1),this.page=Math.floor(s/this.pageSize),this.paint(),z(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const c=this.root;if(!c)return;for(const i of this.off)i();this.off.length=0,X(c);const s=this.model(),n=I(this.doc,"select",{class:`${$.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const i of this.pageSizes)n.appendChild(I(this.doc,"option",{text:String(i),attrs:{value:i}}));n.value=String(this.pageSize),this.off.push(_(n,"change",()=>this.setPageSize(Number(n.value)))),c.appendChild(n);const t=s.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:s.from,to:s.to}):this.t("pagination.summary",{from:s.from,to:s.to,total:s.total});c.appendChild(I(this.doc,"span",{class:`${$.pagination}__summary`,text:t}));const r=(i,m,d,h)=>{const a=I(this.doc,"button",{class:`${$.pagination}__button`,text:i,attrs:{type:"button","aria-label":h,disabled:d?"":null}});return d||this.off.push(_(a,"click",m)),a};c.appendChild(r("«",()=>this.goTo(0),s.first,this.t("pagination.first"))),c.appendChild(r("‹",()=>this.previous(),s.first,this.t("pagination.previous")));const o=I(this.doc,"span",{class:`${$.pagination}__page`});o.appendChild(I(this.doc,"span",{text:`${this.t("pagination.page")} `}));const f=I(this.doc,"input",{class:`${$.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":s.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:s.pageCount}),size:String(Math.max(2,String(s.pageCount??s.page+1).length))}});f.value=String(s.page+1);const u=()=>{const i=parseInt(String(f.value).trim(),10);if(!Number.isFinite(i)){f.value=String(this.model().page+1);return}this.goTo(i-1)};this.off.push(_(f,"keydown",i=>{i.key==="Enter"?(u(),i.preventDefault?.()):i.key==="Escape"?(f.value=String(this.model().page+1),f.blur?.()):i.stopPropagation?.()})),this.off.push(_(f,"blur",()=>u())),this.off.push(_(f,"focus",()=>f.select?.())),o.appendChild(f),s.pageCount!=null&&o.appendChild(I(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:s.pageCount})}`})),c.appendChild(o),c.appendChild(r("›",()=>this.next(),s.last,this.t("pagination.next"))),c.appendChild(r("»",()=>this.last(),s.last||s.pageCount==null,this.t("pagination.last")))}destroy(){for(const c of this.off)c();this.off.length=0,this.root=null}}const g=k}),Fe("packages/dom/src/ui/overlay.js",function(e,K){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,U=K("packages/core/src/i18n/index.js").defaultMessages;function z(s,n){const t=s&&s.grid&&s.grid.messages;return(t&&W(t.t)?t:U).t(n)}class w{root=null;init(n){this.doc=n.document,this.root=I(this.doc,"div",{class:`${$.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[I(this.doc,"span",{class:`${$.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),I(this.doc,"span",{class:`${$.overlay}__message`,text:n.message||z(n,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class k{root=null;init(n){this.doc=n.document,this.root=I(this.doc,"div",{class:`${$.overlay}__empty`,attrs:{role:"status"},children:[I(this.doc,"span",{class:`${$.overlay}__message`,text:n.message||z(n,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const g=Object.freeze({loading:w,empty:k});class l{root=null;slot=null;component=null;current=null;init(n){const t=n||{};this.doc=B(t),this.components={...g,...t.components||{}},this.root=I(this.doc,"div",{class:$.overlay,attrs:{"data-open":"false"}}),this.slot=I(this.doc,"div",{class:`${$.overlay}__slot`}),this.root.appendChild(this.slot),t.host&&t.host.appendChild(this.root)}element(){return this.root}show(n,t){const r=typeof n=="function"?n:this.components[n];return r?(this.hide(),this.component=new r,this.component.init({document:this.doc,message:t&&t.message,...t&&t.props||{}}),this.slot.appendChild(this.component.element()),this.current=typeof n=="string"?n:"custom",this.root.setAttribute("data-open","true"),this.root.setAttribute("data-overlay",this.current),this.component.element()):null}hide(){this.component&&W(this.component.destroy)&&this.component.destroy(),this.component=null,this.current=null,this.slot&&_(this.slot),this.root&&(this.root.setAttribute("data-open","false"),this.root.removeAttribute("data-overlay"))}showing(){return this.current}register(n,t){this.components[n]=t}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const c=l}),Fe("packages/dom/src/ui/index.js",function(e,K){"use strict";const Q=K("packages/dom/src/ui/statusbar.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return Q.StatusBar}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return Q.StatusPanel}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return Q.RowCountPanel}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return Q.SelectedCountPanel}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return Q.AggregationPanel}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return Q.ProgressPanel}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return Q.UpdatesPanel}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return Q.CommentsPanel}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return Q.statusPanels}}),Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return Q.aggregate}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return Q.formatCount}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return Q.formatNumber}});const $=K("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return $.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return $.resolveMenuItems}});const B=K("packages/dom/src/ui/toolpanel.js");Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return B.ToolPanel}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return B.ToolPanelBase}}),Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return B.ColumnsPanel}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return B.FiltersPanel}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return B.toolPanels}});const I=K("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return I.GroupByZone}});const _=K("packages/dom/src/ui/tooltip.js");Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return _.TooltipManager}}),Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return _.TextTooltip}});const X=K("packages/dom/src/ui/pagination.js");Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return X.Pagination}}),Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return X.pageModel}});const W=K("packages/dom/src/ui/overlay.js");Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return W.OverlayLayer}}),Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return W.LoadingOverlay}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return W.EmptyOverlay}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return W.overlays}})}),Fe("packages/dom/src/ui/celltooltip.js",function(e,K){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Q=K("packages/dom/src/editors/common.js"),$=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,X=K("packages/core/src/internal/util.js"),W=X.isFunction,H=X.warnOnce,z=K("packages/dom/src/cell/sanitise.js").sanitiseHtml,k=K("packages/dom/src/detailhost.js").insideDetail,l=K("packages/dom/src/renderer/renderer.js").displayIndexOf,c=K("packages/dom/src/renderer/viewport.js"),s=c.CLASS,n=c.NAMESPACE,r=K("packages/dom/src/themeof.js").carryTheme,o={tooltip:"lat-cell-tooltip",body:"lat-cell-tooltip__body",title:"lat-cell-tooltip__title",rows:"lat-cell-tooltip__rows",row:"lat-cell-tooltip__row",label:"lat-cell-tooltip__label",value:"lat-cell-tooltip__value",note:"lat-cell-tooltip__note"},f=400,u=140,i=6;let m=0;class d{#e;#t;#n;#r;#o=null;#i=null;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#f=null;#h=[];#p=!1;constructor(p){const b=p||{};this.#e=b.grid,this.#t=b.host,this.#n=b.viewport,this.#r=$(b),m+=1,this.#s=`lat-cell-tooltip-${m}`}mount(){const p=this.#n&&this.#n.root;if(!p||!W(p.addEventListener))return;const b=this.#e.on("cell:mouseover",y=>this.#w(y));W(b)&&this.#h.push(b);const j=this.#e.on("cell:mouseout",()=>this.#k());W(j)&&this.#h.push(j),this.#h.push(I(p,"focusin",y=>this.#S(y))),this.#h.push(I(p,"focusout",()=>this.#k())),this.#h.push(I(this.#r,"keydown",y=>this.#y(y),!0));const S=this.#r.defaultView;S&&W(S.addEventListener)&&this.#h.push(I(S,"scroll",()=>this.hide(),!0))}#m(){const p=W(this.#e.get)?this.#e.get("tooltip"):null,b=p&&typeof p=="object"?p:{},j=Number.isFinite(b.delay)&&b.delay>=0?Number(b.delay):f,S=b.maxWidth;return{delay:j,hideDelay:u,maxWidth:typeof S=="number"&&Number.isFinite(S)?`${S}px`:typeof S=="string"&&S?S:null}}#g(p){const b=p&&p.cell?p.cell.tooltip:null;return!b||typeof b!="object"||Array.isArray(b)||!W(b.render)&&!W(b.mount)?null:b}#b(p){if(!p||!W(p.closest))return null;const b=p.closest(`.${s.row}`);if(!b)return null;const j=l(b);if(j<0)return null;const S=this.#t.rowAt(j);if(!S)return null;const y=p.getAttribute("data-col");if(!y)return null;const v=this.#t.columns.get(y);return v?{row:S,key:S.key,index:j,colId:y,column:v,value:this.#t.cellValue?this.#t.cellValue(S,v):void 0,text:this.#t.cellText?this.#t.cellText(S,v):"",cell:p,grid:this.#e}:null}#w(p){const b=p&&p.target;if(!this.#g(p&&p.column)){this.#k();return}this.#O(b)}#S(p){const b=p&&p.target;if(!b||!W(b.closest)||k(b,this.#n.root))return;const j=b.closest(`.${s.cell}`);if(!j||j!==b){this.#k();return}const S=j.getAttribute("data-col"),y=S?this.#t.columns.get(S):null;if(!this.#g(y)){this.#k();return}this.#O(j)}#y(p){!p||p.key!=="Escape"||p.defaultPrevented||this.#l&&(W(p.preventDefault)&&p.preventDefault(),this.hide())}#O(p){if(this.#p||!p||(this.#x(),this.#l&&this.#a===p))return;this.#L();const{delay:b}=this.#m();if(!b){this.#M(p);return}this.#d=setTimeout(()=>{this.#d=null,this.#M(p)},b)}#k(){if(this.#L(),!this.#l||this.#f!==null)return;const{hideDelay:p}=this.#m();this.#f=setTimeout(()=>{this.#f=null,this.hide()},p)}#A(){if(this.#o)return this.#o;const p=this.#r,b=B(p,"div",{class:[n,o.tooltip],attrs:{id:this.#s,role:"tooltip","data-open":"false"}});this.#i=B(p,"div",{class:o.body}),b.appendChild(this.#i),this.#h.push(I(b,"mouseenter",()=>this.#x())),this.#h.push(I(b,"mouseleave",()=>this.#k()));const j=p.body;return j&&W(j.appendChild)&&j.appendChild(b),this.#o=b,b}#j(p,b){const j=this.#i;if(_(j),p==null||p==="")return!1;if(typeof p=="string")return j.textContent=p,!0;if(typeof p=="object"){if(typeof p.nodeType=="number")return j.appendChild(p),!0;const S=p;if(typeof S.html=="string")return j.innerHTML=z(S.html),!0;if(S.title!==void 0||S.rows!==void 0||S.note!==void 0)return this.#T(S),!0}return H(`tooltip-content:${b}`,`Column '${b}' cell.tooltip render returned a value that is not an element, a { title, rows, note } spec, a { html } wrapper or a string, so nothing was shown.`),!1}#T(p){const b=this.#r,j=this.#i,S=v=>v==null?"":String(v);p.title!==void 0&&p.title!==null&&p.title!==""&&j.appendChild(B(b,"div",{class:o.title,text:S(p.title)}));const y=Array.isArray(p.rows)?p.rows:[];if(y.length){const v=B(b,"div",{class:o.rows});for(const R of y){if(!R||typeof R!="object")continue;const O=B(b,"div",{class:o.row});O.appendChild(B(b,"span",{class:o.label,text:S(R.label)})),O.appendChild(B(b,"span",{class:o.value,text:S(R.value)})),v.appendChild(O)}j.appendChild(v)}p.note!==void 0&&p.note!==null&&p.note!==""&&j.appendChild(B(b,"div",{class:o.note,text:S(p.note)}))}#M(p){if(this.#p)return;const b=this.#b(p);if(!b){this.hide();return}const j=this.#g(b.column);if(!j){this.hide();return}this.hide();const S=this.#A();r(S,this.#n&&this.#n.root);let y;if(W(j.render))try{y=j.render(b)}catch(O){H(`tooltip-render:${b.colId}`,`Column '${b.colId}' cell.tooltip render threw; no tooltip was shown.`,O);return}const v=this.#j(y,b.colId);if(W(j.mount))try{j.mount(this.#i,b),this.#u=j}catch(O){H(`tooltip-mount:${b.colId}`,`Column '${b.colId}' cell.tooltip mount threw; the tooltip was closed.`,O),this.hide();return}else if(!v)return;const{maxWidth:R}=this.#m();R&&(S.style.maxWidth=R),this.#a=p,this.#l=!0,S.setAttribute("data-open","true"),this.#C(p),this.#E(p)}#C(p){if(!W(p.setAttribute))return;const b=W(p.getAttribute)?p.getAttribute("aria-describedby"):null;this.#c={cell:p,previous:b},p.setAttribute("aria-describedby",b?`${b} ${this.#s}`:this.#s)}#E(p){const b=this.#o;if(!b||!W(p.getBoundingClientRect))return;const j=this.#r.defaultView;if(!j)return;const S=p.getBoundingClientRect(),y=W(b.getBoundingClientRect)?b.getBoundingClientRect():{width:0,height:0},v=j.innerWidth||0,R=j.innerHeight||0,O=y.width||0,x=y.height||0;let C=S.bottom+i;const P=S.top-i-x;C+x>R-i&&P>=i&&(C=P),R&&(C=Math.max(i,Math.min(C,Math.max(i,R-x-i))));let F=S.left;v&&(F=Math.min(F,Math.max(i,v-O-i))),F=Math.max(i,F),b.style.left=`${Math.round(F)}px`,b.style.top=`${Math.round(C)}px`}hide(){if(this.#L(),this.#x(),!this.#l)return;if(this.#l=!1,this.#u&&W(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(b){H("tooltip-unmount","A cell.tooltip unmount threw while the tooltip was closing.",b)}this.#u=null,this.#i&&_(this.#i),this.#o&&this.#o.setAttribute("data-open","false");const p=this.#c;p&&W(p.cell.setAttribute)&&(p.previous?p.cell.setAttribute("aria-describedby",p.previous):W(p.cell.removeAttribute)&&p.cell.removeAttribute("aria-describedby")),this.#c=null,this.#a=null}#L(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#x(){this.#f!==null&&(clearTimeout(this.#f),this.#f=null)}destroy(){this.hide(),this.#p=!0;for(const p of this.#h)p();this.#h.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const h=d}),Fe("packages/dom/src/platform.js",function(e,K){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return Q}});function Q(){const $=globalThis.navigator,B=String($&&($.userAgentData?.platform||$.platform)||"");return/mac|iphone|ipad/i.test(B)}}),Fe("packages/dom/src/columnmenu.js",function(e,K){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"applyMenuLayer",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"resolveMenuChain",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return b}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/platform.js").macLike,W=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/dom/src/ui/contextmenu.js").ContextMenu,z=K("packages/core/src/compute/total.js"),w=z.aggregatesFor,k=z.totalLabel,g=10,l=150;function c(j,S){const y=(te,ne)=>(j&&j.messages?j.messages:W).t(te,ne),v=j.columns.get(S);if(!v)return[];const R=j.sort.get(),O=R.find(te=>te.col===S),x=v.layout&&v.layout.pin,C=j.state.get().group||[],P=C.includes(S);if(v.generated&&Array.isArray(v.groupedIds))return r(j,v,C);const F=!v.sort||v.sort.enabled!==!1,E=!v.filter||v.filter.enabled!==!1,D=[];F&&D.push({name:y("menu.sortAscending"),icon:"↑",disabled:O&&O.dir==="asc",action:()=>j.sort.set([{col:S,dir:"asc"}])},{name:y("menu.sortDescending"),icon:"↓",disabled:O&&O.dir==="desc",action:()=>j.sort.set([{col:S,dir:"desc"}])},{name:y("menu.clearSort"),disabled:!O,action:()=>j.sort.set(R.filter(te=>te.col!==S))},{separator:!0}),E&&D.push({name:y("menu.filterEllipsis"),action:()=>j.emit("column:filter:open",{colId:S})},{separator:!0}),D.push({name:y("menu.columnStatistics"),action:()=>j.emit("column:profile:open",{colId:S})},{separator:!0}),D.push({name:y("menu.pinColumn"),children:[{name:y("menu.pinStart"),disabled:x==="start",action:()=>j.columns.pin(S,"start")},{name:y("menu.pinEnd"),disabled:x==="end",action:()=>j.columns.pin(S,"end")},{name:y("menu.unpin"),disabled:!x,action:()=>j.columns.pin(S,null)}]});const N=!(v.layout&&(v.layout.movable===!1||v.layout.lockPosition)),M=!(v.layout&&v.layout.resizable===!1),A=te=>{const ne=j.columns.get(te);return Number(ne&&ne.layout&&ne.layout.width)||l},L=j.columns.visible().filter(te=>!te.generated).map(te=>te.id),G=L.indexOf(S);if(D.push({name:y("menu.sizeToFit"),action:()=>j.columns.autoSize(S)},{name:y("menu.sizeAllToFit"),action:()=>j.columns.fit()},{name:y("menu.width"),disabled:!M,children:[{name:y("menu.narrower"),disabled:!M,action:()=>j.columns.resize(S,Math.max(1,A(S)-g))},{name:y("menu.wider"),disabled:!M,action:()=>j.columns.resize(S,A(S)+g)},{name:y("menu.autosize"),disabled:!M,action:()=>j.columns.autoSize(S)}]},{separator:!0},{name:y("menu.moveColumn"),disabled:!N,children:[{name:y("menu.moveLeft"),disabled:!N||G<=0,action:()=>j.columns.move(S,Math.max(0,G-1))},{name:y("menu.moveRight"),disabled:!N||G<0||G>=L.length-1,action:()=>j.columns.move(S,Math.min(L.length-1,G+1))},{name:y("menu.moveToStart"),disabled:!N||G<=0,action:()=>j.columns.move(S,0)},{name:y("menu.moveToEnd"),disabled:!N||G<0||G>=L.length-1,action:()=>j.columns.move(S,L.length-1)}]},{separator:!0}),v.allowGroup!==!1&&D.push({name:y(P?"menu.ungroup":"menu.groupBy"),action:()=>j.columns.group(P?C.filter(te=>te!==S):[...C,S])}),C.length&&D.push({name:y("menu.expandAll"),action:()=>j.rows.expandAll()},{name:y("menu.collapseAll"),action:()=>j.rows.collapseAll()}),$(j.columns.groupColumns)){const te=v.groupPath||[],ne=te.length?te[te.length-1]:null,oe=[{name:y("columngroup.group"),disabled:L.length<2||G<0,action:()=>{const le=L[G+1]??L[G-1];if(!le)return;const ae=(j.columns.get(le)||{}).groupPath||[],se=ae.length?ae[ae.length-1]:null;se?j.columns.groupColumns([S],{groupId:se}):j.columns.groupColumns([S,le],{title:y("columngroup.newGroup")})}}];ne&&oe.push({name:y("columngroup.dissolve"),action:()=>j.columns.dissolveGroup(ne)}),D.push({separator:!0},...oe)}const q=j.state&&$(j.state.get)?j.state.get().pivot:null,Y=q&&q.columns||[],J=Y.includes(S);if(v.allowPivot!==!1&&D.push({name:y(J?"menu.unpivot":"menu.pivotBy"),action:()=>j.columns.pivot(J?Y.filter(te=>te!==S):[...Y,S])}),v.allowTotal!==!1)if($(j.get)&&j.get("aggregateChooser")===!0)D.push(s(j,v,y));else{const ne=!!v.total;D.push({name:y(ne?"menu.stopTotalling":"menu.totalColumn"),action:()=>j.columns.setTotal(S,ne?null:"sum")})}return D.push({name:y("menu.hideColumn"),disabled:v.layout&&v.layout.lockVisible===!0,action:()=>j.columns.hide(S)}),D}function s(j,S,y){const v=S.id,R=typeof S.total=="string"?S.total:null,O=[{name:y("menu.aggregateNone"),checked:!S.total,action:()=>j.columns.setTotal(v,null)},{separator:!0},...w(S).map(x=>({name:k(x),checked:R===x,action:()=>j.columns.setTotal(v,x)})),{separator:!0},n(j,S,y,"group",y("menu.aggregateGroup")),n(j,S,y,"grand",y("menu.aggregateGrand"))];return{name:y("menu.aggregate"),children:O}}function n(j,S,y,v,R){const O=S.id,x=v==="grand"?S.grandTotal:S.groupTotal,C=typeof x=="string"?x:null,P=[{name:y("menu.aggregateSame"),checked:x==null,action:()=>j.columns.setTotal(O,null,{scope:v})},{separator:!0},...w(S).map(F=>({name:k(F),checked:C===F,action:()=>j.columns.setTotal(O,F,{scope:v})}))];return{name:R,children:P}}function t(j,S){const y=(C,P)=>(j&&j.messages?j.messages:W).t(C,P),v=j.columns.get(S);if(!v)return[];const R=j.redaction,O=!!(R&&R.has(S)),x=[];return R&&(x.push({name:y(O?"menu.stopRedacting":"menu.redactColumn"),action:()=>R.toggle(S)}),(R.list().length>1||R.active&&!O)&&x.push({name:y("menu.stopRedactingAll"),action:()=>R.clear()}),x.push({separator:!0})),x.push({name:y("menu.hideColumn"),disabled:v.layout&&v.layout.lockVisible===!0,action:()=>j.columns.hide(S)}),x}function r(j,S,y){const v=(P,F)=>(j&&j.messages?j.messages:W).t(P,F),R=y[0],O=j.sort.get(),x=R?O.find(P=>P.col===R):null,C=[];R&&C.push({name:v("menu.sortGroupsAscending"),icon:"↑",disabled:x&&x.dir==="asc",action:()=>j.sort.set([{col:R,dir:"asc"}])},{name:v("menu.sortGroupsDescending"),icon:"↓",disabled:x&&x.dir==="desc",action:()=>j.sort.set([{col:R,dir:"desc"}])},{separator:!0},{name:v("menu.filterGroups"),action:()=>j.emit("column:filter:open",{colId:S.id})},{separator:!0}),C.push({name:v("menu.expandAll"),action:()=>j.rows.expandAll()},{name:v("menu.collapseAll"),action:()=>j.rows.collapseAll()},{separator:!0});for(const P of y){const F=j.columns.get(P);C.push({name:`Remove "${F&&F.title||P}" from grouping`,action:()=>j.columns.group(y.filter(E=>E!==P))})}return C.push({name:v("menu.clearGrouping"),disabled:!y.length,action:()=>j.columns.group([])}),C}function o(){const j=globalThis.navigator&&globalThis.navigator.clipboard;return!!(j&&typeof j.readText=="function")}function f(j){return $(j.get)&&j.get("edit")===!1?!1:(j.columns&&$(j.columns.visible)?j.columns.visible():[]).some(y=>{const v=y&&y.edit;return v?v.enabled===void 0||$(v.enabled)?!0:v.enabled!==!1:!1})}function u(j,S){if($(j.get)&&j.get("edit")===!1)return!1;const y=S&&S.edit;return y?y.enabled===void 0||$(y.enabled)?!0:y.enabled!==!1:!1}const i=new Set(["number","currency","percent","integer"]);function m(j){const S=$(j.get)?j.get("rangeChart"):void 0;return S?$(S)?{enabled:!0,handler:S}:S&&typeof S=="object"&&$(S.onChart)?{enabled:!0,handler:S.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function d(j){const S=j.selection&&$(j.selection.ranges)?j.selection.ranges():[];if(!Array.isArray(S)||!S.length)return null;const y=S[S.length-1],v=$(j.columns.visible)?j.columns.visible():[],R=new Set(v.filter(O=>O&&i.has(O.type)).map(O=>O.id));return(y.columns||[]).some(O=>R.has(O))?y:null}function h(j,S){const y=(Y,J)=>(j&&j.messages?j.messages:W).t(Y,J),{colId:v,row:R}=S,O=j.selection.keys().length,x=j.selection.cells().length,C=(j.state&&$(j.state.get)?j.state.get().group:null)||[],P=j.ranges||null,F=_()?"Cmd":"Ctrl",E=()=>x||O||0,D=Y=>j.columns&&$(j.columns.get)?j.columns.get(Y):null,N=$(j.selection.cells)?j.selection.cells():[],M=[...new Set(N.map(Y=>Y&&Y.colId).filter(Boolean))];!M.length&&v&&M.push(v);const A=M.length?M.some(Y=>u(j,D(Y))):f(j),L=v?u(j,D(v)):!1,G=m(j),q=G.enabled?d(j):null;return[{name:x>1?`Copy ${x} cells`:y("menu.copy"),shortcut:`${F}+C`,disabled:!E(),action:()=>P&&x?P.copy():j.export.clipboard({rows:O?"selected":"range"})},{name:y("menu.copyWithHeaders"),disabled:!E(),action:()=>j.export.clipboard({headers:!0,rows:O?"selected":"range"})},...v==null?[]:[{name:y("menu.paste"),shortcut:`${F}+V`,disabled:!P||!A||!o(),action:()=>P&&P.paste()},{separator:!0},{name:y("menu.clearCells",{count:x||1}),shortcut:"Delete",disabled:!P||!A||!x,action:()=>P&&P.clear()},{name:y("menu.fillDown"),shortcut:`${F}+D`,disabled:!P||!A||x<2,action:()=>P&&P.fillDown()}],...q&&G.handler?[{name:"Chart selection",action:()=>G.handler(j,q)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>j.export.csv({rows:"visible",download:!0})},{name:`Export ${O} selected row${O===1?"":"s"} to CSV`,disabled:!O,action:()=>j.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>j.export.excel({rows:"visible",download:!0})},{name:`Export ${O} selected row${O===1?"":"s"} to Excel`,disabled:!O,action:()=>j.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>j.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>j.export.print()},...j.importer&&$(j.importer.openFile)?[{name:y("menu.importCsv"),action:()=>j.importer.openFile()}]:[],{separator:!0},...C.length?[{name:y("menu.expandAll"),action:()=>j.rows.expandAll()},{name:y("menu.collapseAll"),action:()=>j.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!O,action:()=>j.selection.clear()},...$(j.get)&&j.get("rowDelete")===!0?[{name:y("menu.deleteRow",{count:O||1}),disabled:!O&&!R,action:()=>j.edit.deleteRows(O?void 0:R?R.key:void 0)}]:[],...v==null?[]:[{name:"Edit cell",disabled:!R||!v||!L,action:()=>R&&v&&j.edit.start(R.key,v)}]]}function a(j,S,y,v){if(j==null)return{items:S,spoke:!1,suppress:!1};if(j===!1)return{items:S,spoke:!0,suppress:!0};if(j===!0)return{items:S,spoke:!0,suppress:!1};if(Array.isArray(j))return{items:[...S,...j],spoke:!0,suppress:!1};if($(j)){const R=j(y,S);return{items:Array.isArray(R)?R:S,spoke:!0,suppress:!1}}return B(`menu-layer:${v}`,`${v} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof j}. Ignoring it.`),{items:S,spoke:!1,suppress:!1}}function p(j,S,y){let v=Array.isArray(j)?j:[],R=!1;for(const O of S){if(!O)continue;const x=a(O.layer,v,y,O.where);v=x.items,x.spoke&&(R=x.suppress)}return R?null:v}class b{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#s=null;constructor(S){this.#n=S.grid,this.#e=S.cellMenu!==!1,this.#t=S.headerMenu!==!1,this.#i=$(S.items)?S.items:null,this.#s=$(S.headerItems)?S.headerItems:null,this.#r=new U({document:S.document,host:S.host,ctx:{grid:S.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",S=>{const y=String(S.colId),v=this.#c(y,c(this.#n,y));v.length&&this.#r.show({items:v,ctx:this.#u(y),anchor:S.element,placement:"below",returnFocus:S.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",S=>{const y=String(S.colId),v=this.#c(y,t(this.#n,y));v.length&&this.#r.show({items:v,ctx:this.#u(y),x:S.x,y:S.y,returnFocus:S.element})})),this.#o.push(this.#n.on("cell:contextmenu",S=>{const y=S.event;this.#e&&y&&$(y.preventDefault)&&y.preventDefault();const v=this.#l(S),R=h(this.#n,v),O=p(R,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#a(v.column),where:`column '${v.colId}' contextMenu`}],v);!O||!O.length||(!this.#e&&y&&$(y.preventDefault)&&y.preventDefault(),this.#r.show({items:O,ctx:v,x:y?y.clientX:void 0,y:y?y.clientY:void 0}))}))}#l(S){const y=this.#n.columns,v=S.column||(S.colId!=null&&y&&$(y.get)?y.get(S.colId):void 0),R=S.row,O=this.#n.rows,x=S.key!==void 0?S.key:R?R.key:void 0;return{key:x,colId:S.colId,value:S.value!==void 0||x===void 0||S.colId==null?S.value:O&&$(O.value)?O.value(x,S.colId):void 0,row:R,data:R?R.data:void 0,column:v,index:S.index!==void 0?S.index:S.rowIndex,grid:this.#n}}#a(S){if(!(!S||S.contextMenu===void 0||S.contextMenu===null))return S.contextMenu}#u(S){return{colId:S,column:this.#n.columns.get(S),grid:this.#n}}#c(S,y){return this.#s?p(y,[{layer:this.#s,where:"columnMenu"}],this.#u(S))||[]:y}destroy(){for(const S of this.#o)S();this.#o=[],this.#r.destroy()}}}),Fe("packages/dom/src/shortcutshelp.js",function(e,K){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return k}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/renderer/keyboard.js"),X=_.groupedShortcuts,W=_.SHORTCUT_IDS,U=K("packages/dom/src/platform.js").macLike,z="lat-shortcuts",w='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class k{#e;#t;#n=null;#r=null;#o=[];constructor(l){this.#e=l.grid,this.#t=l.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#i(l,c){const s=this.#e;return(s&&s.messages?s.messages:I).t(l,c)}#s(l){const c=W[l.combo];if(!c)return l.meaning;const s=`shortcut.${c}`,n=this.#i(s);return n===s?l.meaning:n}mount(){const l=this.#t.viewport?.root;if(!l||!$(l.addEventListener))return;const c=s=>{if(this.open||s.key!=="?")return;const n=s.target,t=n&&n.tagName;t==="INPUT"||t==="TEXTAREA"||n&&n.isContentEditable||(s.preventDefault(),s.stopPropagation(),this.show())};l.addEventListener("keydown",c,!0),this.#o.push(()=>l.removeEventListener("keydown",c,!0))}show(){const l=this.#l();if(!l)return;const c=l.ownerDocument;this.#r=c&&c.activeElement,l.style.display="",$(l.focus)&&l.focus(),this.#e.emit?.("shortcuts:opened",{})}hide(){if(!this.#n)return;this.#n.style.display="none";const l=this.#r;this.#r=null,l&&$(l.focus)&&l.focus(),this.#e.emit?.("shortcuts:closed",{})}#l(){if(this.#n)return this.#n;const l=this.#t.viewport?.overlays,c=l?.ownerDocument;if(!l||!c?.createElement)return null;const s=c.createElement("div");s.className=z,s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("tabindex","-1");const n=`${z}-title`;s.setAttribute("aria-labelledby",n);const t=c.createElement("div");t.className=`${z}__head`;const r=c.createElement("h2");r.className=`${z}__title`,r.id=n,r.textContent=this.#i("shortcuts.title");const o=c.createElement("button");o.className=`${z}__close`,o.type="button",o.setAttribute("aria-label",this.#i("shortcuts.close")),o.textContent="×",t.appendChild(r),t.appendChild(o),s.appendChild(t);const f=c.createElement("div");f.className=`${z}__body`;for(const i of X())i.items.length&&f.appendChild(this.#a(c,i));s.appendChild(f);const u=c.createElement("p");return u.className=`${z}__hint`,u.textContent=this.#i("shortcuts.hint"),s.appendChild(u),l.appendChild(s),this.#n=s,this.#u(s,o),s}#a(l,c){const s=l.createElement("section");s.className=`${z}__group`;const n=l.createElement("h3");n.className=`${z}__group-title`,n.textContent=this.#i(c.messageKey),s.appendChild(n);const t=l.createElement("dl");t.className=`${z}__list`;const r=U();for(const o of c.items){const f=l.createElement("dt");f.className=`${z}__keys`,o.alternatives.forEach((i,m)=>{if(m>0){const d=l.createElement("span");d.className=`${z}__or`,d.textContent=this.#i("shortcuts.or"),f.appendChild(d)}i.forEach((d,h)=>{h>0&&f.appendChild(l.createTextNode("+"));const a=l.createElement("kbd");a.textContent=r&&d==="Ctrl"?this.#i("shortcuts.key.cmd"):d,f.appendChild(a)})});const u=l.createElement("dd");u.className=`${z}__meaning`,u.textContent=this.#s(o),t.appendChild(f),t.appendChild(u)}return s.appendChild(t),s}#u(l,c){const s=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.hide();return}if(t.key!=="Tab")return;const r=[...l.querySelectorAll(w)];if(!r.length){t.preventDefault();return}const o=r[0],f=r[r.length-1],u=l.ownerDocument.activeElement;t.shiftKey&&(u===o||u===l)?(t.preventDefault(),f.focus()):!t.shiftKey&&u===f&&(t.preventDefault(),o.focus())},n=t=>{t.preventDefault?.(),this.hide()};l.addEventListener("keydown",s),c.addEventListener("click",n),this.#o.push(()=>{l.removeEventListener("keydown",s),c.removeEventListener("click",n)})}destroy(){for(const l of this.#o)l();this.#o=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null}}}),Fe("packages/dom/src/rowreorder.js",function(e,K){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MANUAL_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return s}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/renderer.js").displayIndexOf,W="lat-rowdrag",H="lat-rowdrag-marker",U="lat-rowdrag-lifted",z="lat-manual-order",w=Object.freeze({sorted:"a11y.reorder.sorted",filtered:"a11y.reorder.filtered",grouped:"a11y.reorder.grouped","group-derived":"a11y.reorder.groupDerived","group-not-editable":"a11y.reorder.groupReadOnly",invalid:"a11y.reorder.invalid",vetoed:"a11y.reorder.vetoed"}),k=4,g=new Set;function l(n){if(!n)return null;const t=n===!0?{}:typeof n=="object"?n:null;return t?{send:t.send!==!1,receive:t.receive!==!1,mode:t.mode==="copy"?"copy":"move",group:typeof t.group=="string"?t.group:null}:null}function c(n){return n===!0?{column:null,manualOrder:!1,betweenGroups:!1}:!n||typeof n!="object"?null:{column:typeof n.column=="string"?n.column:null,manualOrder:n.manualOrder===!0,betweenGroups:n.betweenGroups===!0}}class s{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=[];constructor(t){this.#e=t.grid,this.#t=t.renderer,this.#n=t.document,this.#r=c(t.grid.get("rowReorder")),this.#o=l(t.grid.get("rowTransfer"))}get active(){return this.#r!==null||this.#o!==null}get draggable(){return this.#r!==null}get grid(){return this.#e}get root(){return this.#t.viewport?.root||null}accepts(t){if(!this.#o||!this.#o.receive)return!1;const r=t&&t.transfer;return!r||!r.send?!1:r.group===this.#o.group}get transfer(){return this.#o}#u(t,r){const o=this.#e;return(o&&o.messages?o.messages:I).t(t,r)}#c(t,r){const o=this.#t&&this.#t.announce;$(o)&&o.call(this.#t,t,r)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const t=this.#e.columns.visible().filter(r=>!r.generated);return t.length?t[0].id:null}paint(){if(!this.draggable)return;const t=this.#d(),r=this.#t.viewport?.root;if(!t||!r)return;const o=r.querySelectorAll(`.lat-cell[data-col="${t}"]`);for(const f of o){if(f.querySelector(`.${W}`))continue;const u=f.parentNode;if(u&&$(u.getAttribute)&&u.getAttribute("data-pinned"))continue;const i=this.#n.createElement("span");i.className=W,i.setAttribute("data-role","row-drag"),i.setAttribute("aria-hidden","true"),i.setAttribute("title",this.#u("a11y.reorder.grab")),i.textContent="⠿",f.insertBefore(i,f.firstChild||null)}this.#h(r,t)}#f(){const t=this.#e.rowOrder;return!!(t&&$(t.manual)&&t.manual())}#h(t,r){const o=this.#f();if($(t.setAttribute)&&(o?t.setAttribute("data-row-order","manual"):t.removeAttribute("data-row-order")),!this.#r||!this.#r.manualOrder)return;const f=t.querySelector(`.lat-header-cell[data-col="${r}"]`);if(!f)return;let u=f.querySelector(`.${z}`);u||(u=this.#n.createElement("button"),u.className=z,u.setAttribute("type","button"),u.setAttribute("data-role","manual-order"),u.setAttribute("tabindex","-1"),u.textContent=this.#u("rowOrder.button"),u.addEventListener("click",m=>{m.stopPropagation?.(),this.toggleManual()}),u.addEventListener("pointerdown",m=>m.stopPropagation?.()),f.insertBefore(u,f.firstChild||null)),u.setAttribute("aria-pressed",o?"true":"false");const i=this.#u(o?"rowOrder.exit":"rowOrder.enter");u.setAttribute("title",i),u.setAttribute("aria-label",i)}toggleManual(){const t=this.#e.rowOrder;if(!t)return;const r=this.#f()?t.exit():t.enter({origin:"user"}),o=f=>{f&&f.reason&&this.#c(this.#u(w[f.reason]||"a11y.reorder.refused"),{repeat:!0}),this.paint()};r&&$(r.then)?r.then(o):o(r)}mount(){if(!this.active)return;g.add(this);const t=this.#t.viewport?.root;if(!t||!$(t.addEventListener))return;const r=m=>this.#p(m),o=m=>this.#m(m),f=()=>this.#g(),u=m=>this.#T(m);if(t.addEventListener("pointerdown",r),t.addEventListener("keydown",u),$(this.#e.on)){let m=this.#f();this.#a.push(this.#e.on("state:changed",d=>{!d||!Array.isArray(d.sections)||!d.sections.includes("rowOrder")||this.#f()!==m&&(m=this.#f(),this.#c(this.#u(m?"a11y.rowOrder.entered":"a11y.rowOrder.exited"),{repeat:!0}))}))}const i=this.#n.defaultView||this.#n;i.addEventListener?.("pointermove",o),i.addEventListener?.("pointerup",f),this.#a.push(()=>{t.removeEventListener("pointerdown",r),t.removeEventListener("keydown",u),i.removeEventListener?.("pointermove",o),i.removeEventListener?.("pointerup",f)})}#p(t){const r=t.target;if(!r||!$(r.closest)||!r.closest('[data-role="row-drag"]'))return;const o=r.closest(".lat-row"),f=o?X(o):-1;if(f<0)return;const u=this.#e.rows.get(f);if(!u||u.group)return;const i=this.#L();if(i&&!(this.#o&&this.#o.send)){this.#c(this.#u(i),{repeat:!0});return}t.preventDefault?.(),this.#i={key:u.key,from:f,at:f,x:t.clientX,y:t.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#m(t){const r=this.#i;if(!r)return;if(!r.armed){if(Math.abs(t.clientX-r.x)+Math.abs(t.clientY-r.y)<k)return;r.armed=!0,this.#B(r),r.over=this,this.#e.emit("rowDrag:started",this.#b(r,this,r.from,r.key),"user")}this.#l&&this.#H(t.clientX,t.clientY);const o=this.#j(t.clientX,t.clientY);if(r.target=o,o!==this){this.#$(),o&&o.accepts(this)?(o.showDropTarget(t.clientX,t.clientY),r.hit=o.hitAt(t.clientX,t.clientY)):r.hit=null,this.#S(r,o),this.#y(r,o,r.hit?r.hit.at:null,r.hit?r.hit.overKey:null);return}const f=this.#x(t.clientX,t.clientY);if(this.#S(r,o),f<0){this.#y(r,this,null,null);return}r.at=f,this.#N(f);const u=this.#e.rows.get(f);this.#y(r,this,f,u?u.key:null)}#g(){const t=this.#i;this.#i=null,this.#$(),this.#U();for(const f of g)f.hideDropTarget();if(!t||(this.#O(t),!t.armed))return;const r=t.target;if(this.#e.emit("rowDrag:ended",this.#w(t),"user"),r&&r!==this){this.#A(t,r);return}if(t.at===t.from)return;const o=this.#L();if(o){this.#c(this.#u(o),{repeat:!0});return}this.#C(t.key,t.at)}#b(t,r,o,f){const u=this.#e.rows.byKey(t.key);return{key:t.key,data:u?u.data:null,over:r?r.grid:null,at:o,overKey:f}}#w(t){const r=t.target||null;if(r&&r!==this){if(!r.accepts(this))return{...this.#b(t,r,null,null),dropped:!1};const o=t.hit||{at:r.grid.rows.count(),overKey:null};return{...this.#b(t,r,o.at,o.overKey),dropped:!0}}if(r===this){const o=this.#e.rows.get(t.at);return{...this.#b(t,this,t.at,o?o.key:null),dropped:t.at!==t.from&&this.#L()===null}}return{...this.#b(t,null,null,null),dropped:!1}}#S(t,r){if(t.over===r)return;const o=t.over;t.over=r,o&&(this.#O(t),this.#e.emit("rowDrag:left",this.#b(t,o,null,null),"user"))}#y(t,r,o,f){t.pending={over:r,at:o,overKey:f},t.frame===null&&(t.frame=this.#k(()=>{t.frame=null;const u=t.pending;t.pending=null,!(!u||this.#i!==t)&&this.#e.emit("rowDrag:moved",this.#b(t,u.over,u.at,u.overKey),"user")}))}#O(t){t.pending=null,t.frame!==null&&(t.frame(),t.frame=null)}#k(t){const r=this.#n.defaultView||globalThis;if($(r.requestAnimationFrame)){const f=r.requestAnimationFrame(t);return()=>{$(r.cancelAnimationFrame)&&r.cancelAnimationFrame(f)}}const o=setTimeout(t,16);return()=>clearTimeout(o)}#A(t,r){if(!r.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const o=this.#e.rows.byKey(t.key);if(!o)return;const f=this.#o.mode,u=t.key,i=t.hit||{at:r.grid.rows.count(),overKey:null};let m=null;const d=r.receive(o.data,i.at,{overKey:i.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(u),onCancel:a=>{m=a}}),h=a=>{if(a!==!0){const p=a===!1?"a11y.transfer.refused":m==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(p),{repeat:!0});return}f==="move"?(this.#e.rows.apply({remove:[u]}),this.#e.emit("row:sent",{key:u,data:o.data,mode:f})):this.#e.emit("row:copied",{key:u,data:o.data,mode:f}),this.#c(this.#u(f==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};d&&$(d.then)?d.then(h):h(d)}receive(t,r,o={}){const f=this.#e,u=t&&typeof t=="object"?{...t}:t,i=o.overKey??null,m=o.source||null,d=$(o.onCancel)?o.onCancel:null,h=()=>{const S=f.rows.totalCount(),y=f.rows.apply({add:[u],at:Math.max(0,r||0)}),v=f.rows.totalCount()>S;return v&&f.emit("row:received",{data:u,at:r,overKey:i,rejected:y?.rejected||[]}),v},a=()=>{if(i!==null){const S=f.rows.get(r);if(!S||S.key!==i)return!1}else r=f.rows.count();return!$(o.revalidate)||o.revalidate()},p=$(f.rendererHost)?f.rendererHost():null;if(!p||!$(p.gateBefore))return h();const b=d?f.on("rowReceive:cancelled",S=>d(S.reason)):null,j=p.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:u,at:r,overKey:i,source:m,origin:"user"},h,a);return b&&(j&&$(j.then)?j.then(b,b):b()),j}hitAt(t,r){const o=this.#x(t,r);if(o<0)return{at:this.#e.rows.count(),overKey:null};const f=this.#e.rows.get(o);return{at:o,overKey:f?f.key:null}}showDropTarget(t,r){const o=this.root;o&&$(o.setAttribute)&&o.setAttribute("data-drop-target","")}hideDropTarget(){const t=this.root;t&&$(t.removeAttribute)&&t.removeAttribute("data-drop-target")}#j(t,r){const o=this.#n.elementFromPoint?this.#n.elementFromPoint(t,r):null,f=o&&$(o.closest)?o.closest(".lattice"):null;if(!f)return null;for(const u of g)if(u.root===f)return u;return null}#T(t){if(!t.altKey||!t.shiftKey)return;if(this.#r&&this.#r.manualOrder&&(t.code==="KeyM"||t.key==="M"||t.key==="m")){t.preventDefault?.(),t.stopPropagation?.(),this.toggleManual();return}const r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0;if(!r)return;const o=this.#n.activeElement,f=o&&$(o.closest)?o.closest(".lat-row"):null,u=f?X(f):-1;if(u<0)return;t.preventDefault?.(),t.stopPropagation?.();const i=this.#L();if(i){this.#c(this.#u(i),{repeat:!0});return}const m=this.#e.rows.get(u);!m||m.group||this.#C(m.key,this.#M(u,r))}#M(t,r){const o=this.#e;if(r>0||!$(o.rows.groupHeadings))return t+r;const f=new Set(o.rows.groupHeadings(t).map(i=>i.key));let u=t+r;for(;u>=0;){const i=o.rows.get(u);if(!i||!f.has(i.key))break;u+=r}return u<0?t:u}#C(t,r){const o=this.#e.rows.count(),f=Math.max(0,Math.min(o-1,r)),u=this.#e.rows.move(t,f,{origin:"user"});u&&$(u.then)?u.then(i=>this.#E(i,o)):this.#E(u,o)}#E(t,r){if(!t){this.#c(this.#u("a11y.reorder.vetoed"),{repeat:!0});return}if(!t.moved){if(!t.reason||t.reason==="unchanged")return;const o=t.reason==="vetoed"&&t.detail&&t.detail!=="prevented"?t.detail:null,f=o?this.#u("a11y.reorder.vetoedBecause",{reason:o}):this.#u(w[t.reason]||"a11y.reorder.refused");this.#c(f,{repeat:!0});return}if(Array.isArray(t.regrouped)&&t.regrouped.length){const o=t.regrouped.map(f=>String(f.to??"")).join(" / ");this.#c(this.#u("a11y.reorder.regrouped",{group:o}),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:t.to+1,total:r}),{repeat:!0})}#L(){const t=this.#e,r=this.#r||{manualOrder:!1,betweenGroups:!1};if(t.sort.get().length)return r.manualOrder?"a11y.reorder.sortedManual":"a11y.reorder.sorted";if((t.state.get().group||[]).length&&!this.#f()&&!r.betweenGroups)return"a11y.reorder.grouped";const o=t.filters.get();return o&&Object.keys(o).length?"a11y.reorder.filtered":null}#x(t,r){const o=this.#n.elementFromPoint?this.#n.elementFromPoint(t,r):null,f=o&&$(o.closest)?o.closest(".lat-row"):null;return!f||$(f.getAttribute)&&f.getAttribute("data-pinned")?-1:X(f)}#B(t){const r=this.root,o=r&&$(r.querySelector)?r.querySelector(`.lat-row[data-index="${t.from}"]`):null;o&&$(o.classList?.add)&&o.classList.add(U);const f=this.#n.body;if(!f||!$(f.appendChild))return;const u=this.#d(),i=u&&$(this.#e.rows?.text)&&this.#e.rows.text(t.key,u)||this.#u("a11y.reorder.grab"),m=r&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(r):null,d=(a,p)=>m&&m.getPropertyValue(a).trim()||p,h=this.#n.createElement("div");h.textContent=String(i),h.setAttribute("aria-hidden","true"),h.setAttribute("data-role","row-drag-ghost"),h.style.cssText=["position:fixed","z-index:2147483647","pointer-events:none","top:0","left:0","white-space:nowrap",`padding:${d("--lattice-space","4px")} calc(${d("--lattice-space","4px")} * 2)`,`border-radius:${d("--lattice-radius-sm",d("--lattice-radius","4px"))}`,`border:${d("--lattice-border-width","1px")} solid ${d("--lattice-border-strong","#0003")}`,`background:${d("--lattice-background","#fff")}`,`color:${d("--lattice-foreground","#000")}`,`box-shadow:${d("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${d("--lattice-font-size","13px")} ${d("--lattice-font-family","system-ui, sans-serif")}`].join(";"),f.appendChild(h),this.#l=h}#H(t,r){this.#l&&(this.#l.style.transform=`translate(${Math.round(t)+14}px, ${Math.round(r)+16}px)`)}#U(){this.#l&&(this.#l.parentNode&&this.#l.parentNode.removeChild(this.#l),this.#l=null);const t=this.root,r=t&&$(t.querySelectorAll)?t.querySelectorAll(`.${U}`):[];for(const o of r)o.classList.remove(U)}#N(t){const r=this.#t.viewport?.overlays;if(!r)return;this.#s||(this.#s=this.#n.createElement("div"),this.#s.className=H,r.appendChild(this.#s));const o=this.#t.viewport.root,f=o.querySelector(`.lat-row[data-index="${t}"]`)||o.querySelectorAll(".lat-row")[0];if(!f||!$(f.getBoundingClientRect))return;const u=f.getBoundingClientRect(),i=o.getBoundingClientRect(),m=this.#i&&t>this.#i.from;this.#s.style.display="",this.#s.style.top=`${Math.round((m?u.bottom:u.top)-i.top)}px`}#$(){this.#s&&(this.#s.style.display="none")}destroy(){g.delete(this);for(const t of this.#a)t();this.#a=[],this.#i&&this.#O(this.#i),this.#i=null,this.#U(),this.#s&&this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null}}}),Fe("packages/dom/src/alignedgrids.js",function(e,K){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isFunction,B=["column:resized","column:moved","column:visible","column:pinned"];function I(W){return(W||[]).map(H=>({id:H.id,width:H.width,flex:H.flex,hidden:H.hidden,pin:H.pin===void 0?null:H.pin}))}class _{#e=new Set;#t=new Map;#n=!1;add(H){if(!H||this.#e.has(H))return;this.#e.add(H);const U=[];for(const w of B)U.push(H.on(w,()=>this.#r(H)));U.push(H.on("scroll",w=>this.#i(H,w))),U.push(H.on("destroy",()=>this.remove(H))),this.#t.set(H,U);const[z]=this.#e;z!==H&&this.#o(H,I(z.columns.state()))}remove(H){const U=this.#t.get(H);if(U)for(const z of U)z();this.#t.delete(H),this.#e.delete(H)}get size(){return this.#e.size}destroy(){for(const H of[...this.#e])this.remove(H)}#r(H){if(this.#n)return;const U=I(H.columns.state());this.#n=!0;try{for(const z of this.#e)z!==H&&this.#o(z,U)}finally{this.#n=!1}}#o(H,U){if(!H.columns||!$(H.columns.apply))return;const z=new Map((H.columns.state()||[]).map(k=>[k.id,k])),w=[];for(const k of U){const g=z.get(k.id);g&&(w.push({...g,...k}),z.delete(k.id))}for(const k of z.values())w.push(k);H.columns.apply(w)}#i(H,U){if(this.#n)return;const z=U&&typeof U.left=="number"?U.left:null;if(z!==null){this.#n=!0;try{for(const w of this.#e)w!==H&&w.scroll?.to?.({left:z})}finally{this.#n=!1}}}}function X(W){const H=new _;for(const U of W||[])H.add(U);return H}}),Fe("packages/dom/src/columntagbar.js",function(e,K){"use strict";Object.defineProperty(e,"BAR_CLASS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveTagFilter",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"ColumnTagBar",{enumerable:!0,get:function(){return W}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-tagbar";function X(U){if(!U)return null;const z=U===!0?{}:typeof U=="object"?U:null;return z?{multiple:z.multiple===!0,label:typeof z.label=="string"?z.label:null}:null}class W{#e;#t;#n;#r=null;#o=null;#i=null;#s="\0";#l=[];constructor(z){this.#e=z.grid,this.#t=z.renderer,this.#n=z.document,this.#r=X(z.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#a(z,w){const k=this.#e;return(k&&k.messages?k.messages:I).t(z,w)}mount(){if(!this.active)return;const z=this.#t.viewport,w=z?.root;if(!w||!$(w.insertBefore))return;const k=this.#n.createElement("div");k.className=_,k.setAttribute("role","toolbar"),k.setAttribute("aria-label",this.#a("tags.label"));const g=this.#n.createElement("label");g.className=`${_}__label`,g.textContent=this.#r.label||this.#a("tags.label");const l=this.#n.createElement("select");l.className=`${_}__select`,this.#r.multiple&&l.setAttribute("multiple","");const c=`${_}-select-${Math.abs(H(String(w.className)))}`;l.id=c,g.setAttribute("for",c),k.appendChild(g),k.appendChild(l),w.insertBefore(k,z.header||w.firstChild),this.#o=k,this.#i=l;const s=()=>{const t=this.#r.multiple?[...l.selectedOptions||[]].map(r=>r.value).filter(Boolean):l.value?[l.value]:[];this.#e.columns.showTagged(t),this.#u(t)};l.addEventListener("change",s),this.#l.push(()=>l.removeEventListener("change",s));const n=this.#e.on("model:changed",()=>this.refresh());this.#l.push(n),this.refresh()}#u(z){const w=this.#t&&this.#t.announce;if(!$(w))return;const k=z.length?z.join(", "):this.#a("tags.all");w.call(this.#t,this.#a("tags.showing",{tag:k}))}refresh(){if(!this.#i||!this.#o)return;const z=this.#e.columns.tags();if(this.#o.style.display=z.length?"":"none",!z.length)return;const w=z.join("\0");if(w===this.#s)return;this.#s=w;const k=this.#e.columns.activeTags();if(this.#i.replaceChildren&&this.#i.replaceChildren(),!this.#r.multiple){const g=this.#n.createElement("option");g.value="",g.textContent=this.#a("tags.all"),this.#i.appendChild(g)}for(const g of z){const l=this.#n.createElement("option");l.value=g,l.textContent=g,k.includes(g)&&(l.selected=!0),this.#i.appendChild(l)}this.#r.multiple||(this.#i.value=k.length?k[0]:"")}destroy(){for(const z of this.#l)z();this.#l=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}function H(U){let z=0;for(let w=0;w<U.length;w++)z=z*31+U.charCodeAt(w)|0;return z}}),Fe("packages/dom/src/anomalychip.js",function(e,K){"use strict";Object.defineProperty(e,"CHIP_CLASS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveAnomalySummary",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"AnomalyChip",{enumerable:!0,get:function(){return U}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-anomaly-chip";function X(z){if(!z)return null;const w=z===!0?{}:typeof z=="object"?z:null;return w?{column:typeof w.column=="string"?w.column:null,label:typeof w.label=="string"?w.label:null}:null}function W(z){return z?typeof z=="string"?{kind:z}:typeof z=="object"?z:null:null}function H(z,w){return z?Array.isArray(z.conditions)?z.conditions.some(k=>H(k,w)):z.col===w&&z.op==="eq"&&z.value===!0:!1}class U{#e;#t;#n;#r=null;#o=null;#i=null;#s=[];#l=!1;#a=!1;#u=null;#c=0;#d=null;constructor(w){this.#e=w.grid,this.#t=w.renderer,this.#n=w.document,this.#r=X(w.grid.get("anomalySummary"))}get active(){return this.#r!==null}#f(w,k){const g=this.#e;return(g&&g.messages?g.messages:I).t(w,k)}#h(){const w=this.#r&&this.#r.column;let k=null;for(const g of this.#e.columns.all()){const l=W(g.shadow);if(!l||l.kind!=="anomalyFlag")continue;const c=l.of||g.field||g.id;if(w){if(g.id===w||c===w)return this.#d=g.id,g}else k||(k=g,this.#d=g.id)}return w?null:k}#p(){if(!this.#d||!$(this.#e.rows&&this.#e.rows.forEach))return 0;let w=0;try{this.#e.rows.forEach(k=>{!k||k.group||k.key==null||this.#e.rows.value(k.key,this.#d)===!0&&w++})}catch{return 0}return w}mount(){if(!this.active)return;const w=this.#t.viewport,k=w&&w.root;if(!k||!$(k.insertBefore))return;const g=this.#n.createElement("div");g.className=_,g.setAttribute("role","status");const l=this.#n.createElement("button");l.className=`${_}__button`,l.setAttribute("type","button"),l.setAttribute("aria-pressed","false"),g.appendChild(l),k.insertBefore(g,w.header||k.firstChild),this.#o=g,this.#i=l;const c=()=>this.toggle();l.addEventListener("click",c),this.#s.push(()=>l.removeEventListener("click",c));for(const s of["filter:changed","rows:changed","model:changed"])this.#s.push(this.#e.on(s,()=>{this.#a||this.refresh()}));this.refresh()}toggle(){this.#l?this.#g():this.#m()}#m(){if(!this.#d)return;this.#u=this.#e.filters.get();const w={col:this.#d,op:"eq",value:!0},k=this.#u?{op:"and",conditions:[this.#u,w]}:w;this.#l=!0,this.#a=!0;try{this.#e.filters.set(k)}finally{this.#a=!1}this.refresh()}#g(){this.#l=!1,this.#a=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#a=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#h()){this.#o.style.display="none";return}if(this.#l&&!H(this.#e.filters.get(),this.#d)&&(this.#l=!1,this.#u=null),this.#l){this.#b(this.#c,!0);return}const k=this.#p();if(this.#c=k,!k){this.#o.style.display="none";return}this.#b(k,!1)}#b(w,k){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",k?"true":"false"),this.#i.setAttribute("aria-pressed",k?"true":"false");const g=this.#r&&this.#r.label,l=k?this.#f("anomaly.chipActive",{count:w}):g||this.#f("anomaly.chip",{count:w});this.#i.textContent=l}destroy(){for(const w of this.#s)w();this.#s=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}}),Fe("packages/dom/src/rowform.js",function(e,K){"use strict";Object.defineProperty(e,"FORM_CLASS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return o}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,W=K("packages/core/src/model/rowkey.js").createRowKey,U=K("packages/dom/src/editors/index.js").createEditor,w=K("packages/dom/src/renderer/renderer.js").displayIndexOf,g=K("packages/dom/src/themeof.js").themeOf,l="lat-rowform",c='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function s(f){if(!f)return null;const u=f===!0?{}:typeof f=="object"?f:null;if(!u)return null;const i=$(u.load)?u.load:null,m=Array.isArray(u.fields)&&u.fields.length?u.fields:null;return{timeout:r(u.timeout),container:u.container??null,mode:u.container?"inline":u.mode==="dialog"?"dialog":"drawer",load:i,create:$(u.create)?u.create:null,fields:m,title:u.title??null,width:typeof u.width=="string"?u.width:null,trigger:u.trigger===!1?"none":"dblclick"}}function n(f,u){const i=$(f)?f():f;return i?typeof i=="string"?u&&$(u.querySelector)?u.querySelector(i):null:i&&$(i.appendChild)?i:null:null}const t=2e3;function r(f){return f===!1||f===0?0:typeof f!="number"||!Number.isFinite(f)||f<=0?t:f}class o{#e;#t;#n;#r;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];#f=null;#h=0;#p=null;#m=!1;#g=[];constructor(u){this.#e=u.grid,this.#t=u.renderer,this.#n=u.document,this.#r=u.registry||null,this.#o=s(u.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#b(u,i){const m=this.#e;return(m&&m.messages?m.messages:_).t(u,i)}mount(){if(!this.active)return;const u=this.#t.viewport?.root;if(!u||!$(u.addEventListener)||this.#o.trigger==="none")return;const i=m=>{const d=m.target;if(!d||!$(d.closest)||d.closest(".lat-editor-host, .lat-editor--popup"))return;const h=d.closest(".lat-row"),a=h?w(h):-1;if(a<0)return;const p=this.#e.rows.get(a);!p||p.group||p.detail||(m.preventDefault?.(),m.stopPropagation?.(),this.openRow(p.key))};u.addEventListener("dblclick",i,!0),this.#g.push(()=>u.removeEventListener("dblclick",i,!0))}openRow(u){const i=this.#e.rows.byKey(u);if(!i)return!1;const m=this.#A();if(!m)return!1;this.#a=i,this.#u=!1,this.#k(),this.#f=this.#n.activeElement,m.style.display="",this.#N(m),this.#T(i);const d=this.#o.load;if(!d)this.#H(i.data);else{this.#L();const h=++this.#h;this.#M(h,a=>{this.#x(new Error(`Loading the record timed out after ${a}ms`),u,"form.loadTimeout")}),Promise.resolve().then(()=>d({row:i,data:i.data,key:u,grid:this.#e})).then(a=>{h!==this.#h||!this.open||(this.#E(),this.#H(a||i.data))}).catch(a=>{h!==this.#h||!this.open||(this.#E(),this.#x(a,u))})}return $(m.focus)&&m.focus(),this.#e.emit("form:opened",{key:u,row:i}),!0}openNew(u){const i=this.#A();if(!i)return!1;this.#h+=1,this.#E(),this.#a=null,this.#u=!0,this.#k(),this.open||(this.#f=this.#n.activeElement),i.style.display="",this.#N(i);const m=i.querySelector(`.${l}__title`);return m&&(m.textContent=this.#b("form.newTitle")),this.#H(u&&typeof u=="object"?{...u}:{}),$(i.focus)&&i.focus(),this.#e.emit("form:opened",{key:null,row:null,created:!0}),!0}close(){if(!this.#i)return;this.#h+=1,this.#E(),this.#ge(),this.#i.style.display="none";const u=this.#a?this.#a.key:null;this.#a=null,this.#u=!1,this.#k();const i=this.#f;this.#f=null,i&&$(i.focus)&&i.focus(),this.#e.emit("form:closed",{key:u})}save(){if(!this.#a&&!this.#u||!this.#d.length||this.#u&&this.#l&&this.#l.disabled)return!1;const u=this.#a?this.#a.key:null,i={},m={},d=[],h=[];for(const a of this.#d){const p=$(a.editor.commit)?a.editor.commit():{ok:!0,value:void 0};if(!p.ok)return this.#_(a,p.message),!1;if(i[a.field]=p.value,a.readOnly){h.push(a.field);continue}const b=a.initial;Object.is(b,p.value)||(m[a.field]=p.value,a.colId?d.push({key:u,colId:a.colId,value:p.value}):h.push(a.field))}return this.#u?this.#w(i):(d.length&&this.#e.edit.setCells(d,"cell",{origin:"form"}),this.#e.emit("form:saved",{key:u,values:i,changed:m,unmapped:h}),this.close(),!0)}#w(u){const i=this.#d.filter(h=>!h.colId).map(h=>h.field),m=this.#o.create;if(!m)return this.#S(u)?(this.#y(u,u,i),!0):(B("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),!1);this.#k(),this.#C(!1);const d=++this.#h;return this.#M(d,h=>{this.#O(new Error(`Adding the record timed out after ${h}ms`),u,!0)}),Promise.resolve().then(()=>m(u)).then(h=>{if(!(d!==this.#h||!this.open)){if(this.#E(),!this.#S(h)){B("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),this.#O(new Error("rowForm.create answered with a row that carries no row key"),u,!1);return}this.#y(h,u,i)}}).catch(h=>{d!==this.#h||!this.open||(this.#E(),this.#O(h,u,!1))}),!0}#S(u){if(!u||typeof u!="object")return!1;const i=W(this.#e.get("rowKey"),{warn:!1});return!i||i.stable===!1?!1:$(i.keyEmpty)?!i.keyEmpty(u):!0}#y(u,i,m){const d=this.#e,h=d.rows.apply({add:[u]}),a=h&&Array.isArray(h.added)?h.added[0]:null;if(!a){this.#O(new Error("The new row could not be added"),i,!1);return}const p=a.key;d.emit("form:saved",{key:p,values:i,changed:i,unmapped:m,created:!0}),this.close();const b=d.get("selection");(typeof b=="string"?b!=="none":b&&typeof b=="object"&&b.mode!=="none")&&d.selection&&$(d.selection.set)&&d.selection.set([p]),d.scroll&&$(d.scroll.toRow)&&d.scroll.toRow(p)}#O(u,i,m){this.#C(!0),this.#k();const d=this.#n.createElement("div");d.className=`${l}__failure`;const h=this.#n.createElement("p");h.className=`${l}__note ${l}__note--error`,h.setAttribute("role","alert"),h.textContent=this.#b("form.createFailed");const a=this.#n.createElement("button");a.className=`${l}__retry`,a.type="button",a.textContent=this.#b("form.retry"),a.addEventListener("click",()=>this.save()),d.appendChild(h),d.appendChild(a),$(this.#s.insertBefore)?this.#s.insertBefore(d,this.#s.firstChild):this.#s.appendChild(d),this.#c=d,this.#e.emit("form:error",{key:null,error:u,timedOut:m,created:!0})}#k(){const u=this.#c;this.#c=null,u&&u.parentNode&&u.parentNode.removeChild(u)}#A(){if(this.#i)return this.#i;const u=this.#t.viewport?.overlays,i=this.#n||u?.ownerDocument;if(!i?.createElement)return null;const m=n(this.#o.container,i),d=m||u;if(!d)return null;this.#o.container&&!m&&B("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#m=!!m;const h=i.createElement("div"),a=this.#m?"lattice ":"";h.className=`${a}${l} ${l}--${this.#m?"inline":this.#o.mode}`,h.setAttribute("role",this.#m?"region":"dialog"),this.#m||h.setAttribute("aria-modal","true"),h.setAttribute("tabindex","-1"),this.#o.width&&h.style.setProperty("--lattice-rowform-width",this.#o.width);const p=`${l}-title`;h.setAttribute("aria-labelledby",p);const b=i.createElement("div");b.className=`${l}__head`;const j=i.createElement("h2");j.className=`${l}__title`,j.id=p,b.appendChild(j);const S=i.createElement("div");S.className=`${l}__body`;const y=i.createElement("div");y.className=`${l}__foot`;const v=i.createElement("button");v.className=`${l}__cancel`,v.type="button",v.textContent=this.#b("form.cancel");const R=i.createElement("button");return R.className=`${l}__save`,R.type="button",R.textContent=this.#b("form.save"),y.appendChild(v),y.appendChild(R),h.appendChild(b),h.appendChild(S),h.appendChild(y),d.appendChild(h),this.#i=h,this.#s=S,this.#l=R,this.#j(h,R,v),h}#j(u,i,m){const d=p=>{if(p.stopPropagation(),p.key==="Escape"){p.preventDefault(),this.close();return}if(p.key!=="Tab"||this.#m)return;const b=[...u.querySelectorAll(c)];if(!b.length){p.preventDefault();return}const j=b[0],S=b[b.length-1],y=u.ownerDocument.activeElement;p.shiftKey&&(y===j||y===u)?(p.preventDefault(),S.focus()):!p.shiftKey&&y===S&&(p.preventDefault(),j.focus())},h=p=>{p.preventDefault?.(),this.save()},a=p=>{p.preventDefault?.(),this.close()};u.addEventListener("keydown",d),i.addEventListener("click",h),m.addEventListener("click",a),this.#g.push(()=>{u.removeEventListener("keydown",d),i.removeEventListener("click",h),m.removeEventListener("click",a)})}#T(u){const i=this.#i.querySelector(`.${l}__title`);if(!i)return;const m=this.#o.title;$(m)?i.textContent=String(m({row:u,data:u.data})??""):typeof m=="string"?i.textContent=m:i.textContent=this.#b("form.title")}#M(u,i){this.#E();const m=this.#o.timeout;if(!m)return;const d=this.#n.defaultView||globalThis;$(d.setTimeout)&&(this.#p=d.setTimeout(()=>{this.#p=null,!(u!==this.#h||!this.open)&&(this.#h+=1,i(m))},m))}#C(u){this.#l&&(this.#l.disabled=!u,u?this.#l.removeAttribute("aria-disabled"):this.#l.setAttribute("aria-disabled","true"))}#E(){if(this.#p===null)return;const u=this.#n.defaultView||globalThis;$(u.clearTimeout)&&u.clearTimeout(this.#p),this.#p=null}#L(){this.#ge(),this.#C(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const u=this.#n.createElement("p");u.className=`${l}__note`,u.setAttribute("role","status"),u.textContent=this.#b("form.loading"),this.#s.appendChild(u)}#x(u,i,m="form.loadFailed"){this.#ge(),this.#C(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const d=this.#n.createElement("p");d.className=`${l}__note ${l}__note--error`,d.setAttribute("role","alert"),d.textContent=this.#b(m);const h=this.#n.createElement("button");h.className=`${l}__retry`,h.type="button",h.textContent=this.#b("form.retry"),h.addEventListener("click",()=>this.openRow(i)),this.#s.appendChild(d),this.#s.appendChild(h),this.#e.emit("form:error",{key:i,error:u,timedOut:m==="form.loadTimeout"})}#B(){return this.#o.fields?this.#o.fields.map(u=>typeof u=="string"?{field:u}:u):this.#e.columns.all().filter(u=>!u.generated&&u.field).map(u=>({field:u.field,label:u.title,colId:u.id}))}#H(u){this.#ge(),this.#C(!0),this.#s.replaceChildren&&this.#s.replaceChildren();const i=u&&typeof u=="object"?u:{};for(const m of this.#B()){const d=m.field;if(!d)continue;const h=m.colId?this.#e.columns.get(m.colId):this.#se(d),a=Object.hasOwn(i,d)?i[d]:null,p=this.#n.createElement("div");p.className=`${l}__field`;const b=this.#n.createElement("label");b.className=`${l}__label`,b.textContent=String(m.label??(h&&h.title)??d);const j=this.#n.createElement("div");j.className=`${l}__control`,p.appendChild(b),p.appendChild(j),this.#s.appendChild(p);const S={field:d,colId:h?h.id:null,editor:null,initial:a,opener:null,wrap:p,readOnly:!1},v=!!(h&&(h.computed||h.generated))?null:U({grid:this.#e,column:this.#re(m,h,d),colId:h?h.id:d,row:this.#a,data:i,value:a,text:a==null?"":String(a),locale:this.#e.get("locale"),props:m.props||h&&h.edit&&h.edit.props,lookup:m.lookup||h&&h.lookup,document:this.#n,cell:j,overlay:this.#$(),stop:()=>this.#Y(S)},this.#r);if(!v){S.readOnly=!0,S.colId=null,S.editor={commit:()=>({ok:!0,value:S.initial})},this.#U(j,h,a),this.#d.push(S);continue}S.editor=v;try{$(v.value)&&(S.initial=v.value())}catch{}if(this.#d.push(S),v.popup===!0)this.#z(j,S);else{const R=$(v.element)?v.element():null;R&&j.appendChild(R)}}this.#d.length||B("rowform:no-fields","rowForm has no fields to show; the form opened with no controls. Check rowForm.fields, or the grid's columns when fields is absent.")}#U(u,i,m){const d=this.#n.createElement("div");d.className=`${l}__static`,d.setAttribute("aria-readonly","true");let h="";try{const a=i&&i.dataType&&i.dataType.format;$(a)&&(h=a({value:m,column:i,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")}))}catch{h=""}(h===""||h==null)&&(h=m==null?"":String(m)),d.textContent=h,u.appendChild(d)}#N(u){if(!this.#m)return;const i=this.#t.viewport?.root;if(!(!i||!$(i.getAttribute)))for(const m of["data-theme","data-density","dir"]){const d=m==="data-theme"?g(i):i.getAttribute(m);d?u.setAttribute(m,d):$(u.removeAttribute)&&u.removeAttribute(m)}}#$(){return this.#m?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#z(u,i){const m=this.#n.createElement("button");m.className=`${l}__opener`,m.type="button",i.opener=m,this.#le(i);const d=()=>{$(i.editor.attached)&&i.editor.attached()};m.addEventListener("click",d),this.#g.push(()=>m.removeEventListener("click",d)),u.appendChild(m)}#_(u,i){const m=u.wrap;m&&$(m.scrollIntoView)&&m.scrollIntoView({block:"nearest"});const d=u.opener||($(u.editor.focusTarget)?u.editor.focusTarget():null);d&&$(d.focus)&&d.focus();const h=this.#t&&this.#t.announce;$(h)&&i&&h.call(this.#t,String(i))}#Y(u){if(!u.opener||!u.editor)return;const i=$(u.editor.popupHandle)?u.editor.popupHandle():null;i&&$(i.hide)&&i.hide(),this.#le(u),$(u.opener.focus)&&u.opener.focus()}#le(u){if(!u.opener)return;let i="";try{const d=u.colId?this.#e.columns.get(u.colId):null,h=d&&d.dataType&&d.dataType.format;$(h)&&(i=h({value:$(u.editor.value)?u.editor.value():null,column:d,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")})),(i===""||i==null)&&$(u.editor.toClipboard)&&(i=u.editor.toClipboard())}catch{i=""}const m=i===""||i==null;u.opener.textContent=m?this.#b("form.choose"):String(i),u.opener.classList.toggle(`${l}__opener--empty`,m)}#re(u,i,m){const d=u.editor||u.type||u.lookup||u.props,h={...i&&i.edit?i.edit:{},enabled:!0};return u.editor&&(h.editor=u.editor),u.props&&(h.props=u.props),i&&!d?{...i,edit:h}:{...i||{id:m,field:m},type:u.type||i&&i.type||"text",lookup:u.lookup||i&&i.lookup||void 0,edit:h}}#se(u){for(const i of this.#e.columns.all())if(!i.generated&&i.field===u)return i;return null}#ge(){for(const u of this.#d)$(u.editor.destroy)&&u.editor.destroy();this.#d=[]}destroy(){this.#h+=1,this.#E(),this.#ge();for(const u of this.#g)u();this.#g=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),Fe("packages/dom/src/toolpanelmount.js",function(e,K){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return C}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=K("packages/dom/src/ui/toolpanel.js"),_=I.ToolPanel,X=I.toolPanels,W=I.toolPanelTitles,H=I.toolPanelIcons,U=K("packages/dom/src/filters/index.js"),z=U.createFilter,w=U.filterFor,g=K("packages/dom/src/filters/text.js").TextFilter,l=K("packages/dom/src/filters/engineset.js"),c=l.EngineSetFilter,s=l.VALUE_LIMIT,n=K("packages/dom/src/editors/common.js"),t=n.CLS,r=n.documentFor,o=n.scannableRows,f=n.el,u=K("packages/dom/src/filtermenu.js"),i=u.mergeColumnFilter,m=u.branchFor,d=u.valueSource,h=u.isSetFilter,a=Object.freeze(["column:visible","column:moved","column:pinned","column:grouped","column:pivoted","filter:changed","model:changed","views:changed","sort:changed","history:changed","state:reset","cell:changed","formatting:changed"]);function p(P,F,E){const D=f(P,"div",{class:`${t.panel}__filterRefusal`});return D.appendChild(f(P,"div",{class:`${t.filter}__note`,text:E,attrs:{role:"note","data-warning":"filter:values-unsupported"}})),D.appendChild(F.element()),{get:()=>F.get(),set:N=>F.set(N),active:()=>F.active(),...$(F.clear)?{clear:()=>F.clear()}:{},destroy:()=>F.destroy(),element:()=>D}}function b(P){const{grid:F,container:E}=P||{};if(!F)throw new Error("[lattice] mountPanel needs a grid");if(!E||!E.appendChild)throw new Error("[lattice] mountPanel needs a container element");const D=$(P.panel)?P.panel:X[String(P.panel)];if(!D)throw new Error(`[lattice] unknown panel "${P.panel}"; known panels are ${Object.keys(X).join(", ")}`);const N=E.ownerDocument||r(E),M=x(F,N,P.announce),A=new D;A.init({document:N,host:M,grid:F,props:P.props||{}});const L=A.element();E.appendChild(L);const G=[];for(const q of a)$(F.on)&&G.push(F.on(q,()=>A.refresh()));return{element:L,refresh(){A.refresh()},destroy(){for(const q of G)q();G.length=0,$(A.destroy)&&A.destroy(),L&&L.parentNode&&L.parentNode.removeChild(L)}}}const j=260,S=30,y=`${t.panel}-dock`;function v(P,F,E){if(!P||!$(P.set))return;const D=m(E.filters.get(),F)||null,N=$(P.get)&&(!$(P.active)||P.active())&&P.get()||null;JSON.stringify(N)!==JSON.stringify(D)&&(D?P.set(D):$(P.clear)?P.clear():P.set(null))}function R(P,F){if(P==="insights"){const N=F&&$(F.get)?F.get("insights"):null;return{other:(N&&typeof N=="object"?N:{}).compareWith||null}}if(P!=="views")return{};const E=F&&$(F.get)?F.get("views"):null,D=E&&typeof E=="object"?E:{};return{allowSave:D.allowSave!==!1,showDiff:D.showDiff===!0,builtinTitle:D.builtinTitle,savedTitle:D.savedTitle}}function O(P){const F=P.pagination&&$(P.pagination.get)?P.pagination.get():null;return F&&Number.isFinite(F.total)?F.total:P.rows.count()}function x(P,F,E){const D=new Map;return{announce(N,M){$(E)&&E(N,M)},t(N,M){return P.messages.t(N,M)},grid:P,document:F,columns:()=>P.columns.all(),columnGroups:()=>P.state.get().columnGroups||[],groupColumns:(N,M)=>P.columns.groupColumns(N,M),ungroupColumn:N=>P.columns.ungroupColumn(N),renameGroup:(N,M)=>P.columns.renameGroup(N,M),dissolveGroup:N=>P.columns.dissolveGroup(N),showColumns:N=>P.columns.show(N),hideColumns:N=>P.columns.hide(N),groupBy:()=>P.state.get().group||[],setGroupBy:N=>P.columns.group(N),pivotBy:()=>(P.state.get().pivot||{}).columns||[],setPivotBy:N=>P.columns.pivot(N),valueColumns:()=>P.columns.all().filter(N=>N.total).map(N=>N.id),setValueColumns:N=>P.columns.totals(N),valueAggregation(N){const M=P.columns.get(N);return!M||!M.total?"sum":typeof M.total=="string"?M.total:"custom"},setValueAggregation(N,M){P.columns.setTotal(N,M)},quickFilter:()=>P.state.get().quick||"",setQuickFilter:N=>P.filters.quick(N),rowCount:()=>O(P),totalRowCount:()=>$(P.rows.totalCount)?P.rows.totalCount():P.rows.count(),formattableColumns:()=>P.columns.visible().filter(N=>!N.generated).map(N=>({id:N.id,title:String(N.title??N.id)})),formattingRules:N=>P.formatting.list(N),columnSamples:N=>{let M=N;if(!M||M==="*"){const G=P.columns.visible().find(q=>!q.generated);M=G?G.id:null}if(!M)return[];const A=[],L=new Set;for(const G of o(P)){const q=P.rows.value(G.key,M);if(q==null||q==="")continue;const Y=typeof q=="object"?A.length:q;if(!L.has(Y)&&(L.add(Y),A.push(q),A.length>=24))break}return A},profilableColumns:()=>P.columns.visible().filter(N=>!N.generated).map(N=>({id:N.id,title:String(N.title??N.id)})),columnProfile:N=>{const M=P.config().source;return((P.state.get().pivot||{}).columns||[]).length&&M&&typeof M=="object"&&$(M.aggregate)?null:P.statistics.profile(N)},columnProfileAsync:N=>P.statistics.profileAsync(N),reduceColumn:(N,M)=>P.statistics.reduce(N,M),columnCapability:N=>P.statistics.capability(N),regressionModel:N=>$(P.statistics.regressionModel)?P.statistics.regressionModel(N):null,insightsColumns:()=>P.columns.visible().filter(N=>!N.generated).map(N=>({id:N.id,title:String(N.title??N.id),type:N.type})),subsetVsPopulation:()=>P.statistics.subsetVsPopulation(),datasetVsDataset:N=>P.statistics.datasetVsDataset(N),compareGroups:(N,M)=>P.statistics.compareGroups(N,M),anomalies:N=>P.statistics.anomalies(N||{}),compareColumns:(N,M)=>{if(!N||!M||N===M)return null;const A=P.statistics.regression(N,M);return{n:A?A.n:0,pearson:P.statistics.correlation(N,M),spearman:P.statistics.spearman(N,M),kendall:P.statistics.kendall(N,M),covariance:P.statistics.covariance(N,M),slope:A?A.slope:null,intercept:A?A.intercept:null,r2:A?A.r2:null,stdError:A?A.stdError:null,weighted:P.statistics.weightedAverage(N,M)}},addRule:(N,M)=>P.formatting.add(N,M),removeRule:(N,M)=>P.formatting.remove(N,M),updateRule:(N,M,A)=>P.formatting.update(N,M,A),moveRule:(N,M,A)=>P.formatting.move(N,M,A),clearRules:N=>P.formatting.clear(N),views:()=>P.views.list(),activeId:()=>P.views.activeId,apply:N=>{P.views.apply(N)},saveAs:N=>P.views.save(N),rename:(N,M)=>P.views.rename(N,M),setDefault:N=>P.views.setDefault(N),clearDefault:()=>P.views.setDefault(null),remove:N=>P.views.remove(N),export:N=>P.views.export(N),diff:N=>P.views.diff(N),moveColumn(N,M,A){const L=P.columns.all().map(J=>J.id),G=L.indexOf(N),q=L.indexOf(M);if(G<0||q<0)return;let Y=A?q:q+1;G<Y&&(Y-=1),Y!==G&&P.columns.move(N,Y)},isFiltered(N){return m(P.filters.get(),N)!==null},clearFilter(N){P.filters.set(i(P.filters.get(),N,null));const M=D.get(N);M&&$(M.clear)?M.clear():M&&$(M.set)&&M.set(null)},clearAllFilters(){P.filters.set(null);for(const N of D.values())$(N.clear)?N.clear():$(N.set)&&N.set(null)},filterFor(N){if(D.has(N))return v(D.get(N),N,P),D.get(N);const M=P.columns.get(N);if(!M)return null;const A=M.filter&&M.filter.props&&M.filter.props.values,L=d(P),G=L?P.config().context??null:null,q=L?ne=>L.columnValues(N,{...ne||{},context:G}):null,Y={grid:P,column:M,colId:N,type:M.type,locale:P.get("locale"),props:{...M.filter&&M.filter.props,values:A||(M.lookup?void 0:L?()=>q({limit:s}).then(ne=>ne&&ne.supported?ne.values.map(oe=>oe.value):[]):()=>P.columns.distinct(N)),...L?{valueList:!1}:{}},lookup:M.lookup,document:F,value:ne=>P.rows.value(ne.row&&ne.row.key,N),rows:L?()=>[]:M.lookup?void 0:()=>o(P),changed:()=>{const oe=($(J.active)?J.active():!0)&&$(J.get)?J.get():null;P.filters.set(i(P.filters.get(),N,oe||null))},fetchValues:q};let J=null;const te=L&&!A&&!M.lookup?w(M):null;if(te&&h(te)){const ne=L.columnValuesRefusal(N);if(ne){const oe=new g;oe.init({...Y,props:{...Y.props,valueList:!1}}),J=p(F,oe,P.messages.t("filter.valuesUnsupported",{column:M.title||N})),B(`filter:values-unsupported:${N}`,`the filter on column "${N}" cannot list its values: ${ne}. It offers the text condition editor instead.`)}else J=new c,J.init(Y)}else J=z(Y);return J&&(v(J,N,P),D.set(N,J)),J},destroyFilters(){for(const N of D.values())$(N.destroy)&&N.destroy();D.clear()}}}class C{#e;#t;#n;#r;#o;#i=null;#s=[];#l="right";#a=null;#u=!1;#c=!1;constructor(F){this.#e=F.grid,this.#t=F.document,this.#n=F.root,this.#o=x(F.grid,F.document,F.announce);const D=(F.panels||["columns","filters"]).map(N=>X[N]?{name:N,title:W[N]?F.grid.messages.t(W[N]):N,icon:H[N]||N,Ctor:X[N],props:R(N,F.grid)}:(B(`toolpanel:${N}`,`unknown tool panel "${N}"`),null)).filter(Boolean);this.#l=F.side==="left"?"left":"right",this.#r=new _,this.#r.init({document:F.document,host:this.#o,grid:F.grid,panels:D,actions:F.actions,icons:F.icons,side:this.#l,openPanel:F.openPanel})}mount(){const F=this.#t.createElement("div");F.className=`${y} ${y}--${this.#l}`,F.appendChild(this.#r.element()),this.#n.appendChild(F),this.#i=F;const E=this.#r.show.bind(this.#r),D=this.#r.hide.bind(this.#r);this.#r.show=N=>{const M=E(N);return this.#h(),M},this.#r.hide=()=>{D(),this.#h()};for(const N of[...a,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#s.push(this.#e.on(N,()=>this.#r.refresh()));this.#s.push(this.#e.on("presentation:started",N=>{this.#u=!0;const M=N&&N.options&&Array.isArray(N.options.chrome)?N.options.chrome:[];this.#c=M.includes("toolPanel")})),this.#s.push(this.#e.on("presentation:ended",()=>{this.#u=!1,this.#c=!1})),this.#s.push(this.#e.on("toolpanel:focus",()=>this.open("columns"))),this.#s.push(this.#e.on("column:profile:open",N=>{const M=N&&N.colId,A=this.#r.panels.find(L=>L.name==="statistics");A&&M!=null&&(A.panel.column=String(M)),this.open("statistics")})),this.#h()}open(F){this.#r.show(F),this.#h()}close(){this.#r.hide(),this.#h()}toggle(F){this.#r.toggle(F),this.#h()}addAction(F){if(!(!F||!F.name)&&!this.#r.actions.some(E=>E.name===F.name)){if(this.#r.registerAction(F),this.#a&&!F.annotation){const E=this.#r.actions.find(D=>D.name===F.name);E&&this.#f(E.button)}else!this.#a&&F.annotation&&this.#u&&!this.#c&&this.#d();this.#h()}}removeAction(F){this.#r.removeAction(F)&&this.#h()}presentOnly(){return this.#a?!0:this.#r.actions.some(F=>F.annotation&&F.button)?(this.#d(),!0):!1}#d(){const F=this.#r;this.#a={hidden:[],reopen:F.openPanel||null},this.#a.reopen&&F.hide(),this.#f(F.body);for(const E of[...F.tabs?.children||[]])E!==F.actionGroup&&this.#f(E);for(const E of[...F.actionGroup?.children||[]]){const D=F.actions.find(N=>N.button===E);(!D||!D.annotation)&&this.#f(E)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#h()}presentRestore(){const F=this.#a;if(!F)return!1;this.#a=null;for(const E of F.hidden)E.el&&E.el.style&&(E.el.style.display=E.display);return F.reopen&&this.#r.show(F.reopen),this.#h(),!0}#f(F){if(!F||!F.style||!this.#a)return;const E=F.style.display||"";E!=="none"&&(F.style.display="none",this.#a.hidden.push({el:F,display:E}))}#h(){if(!this.#i)return;const F=!!this.#r.openPanel;this.#i.setAttribute("data-open",F?"true":"false"),this.#i.style.width=F?`${j}px`:"";const E=`${F?j:this.#p()}px`;this.#n.style.paddingLeft=this.#l==="left"?E:"",this.#n.style.paddingRight=this.#l==="left"?"":E,this.#n.style.setProperty("--lattice-dock-left",this.#l==="left"?E:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#l==="left"?"0px":E)}#p(){const F=this.#r&&$(this.#r.element)?this.#r.element().querySelector?.(`.${t.panel}__tabs`):null,E=F&&(F.offsetWidth||F.getBoundingClientRect?.().width)||0;return E>0?Math.ceil(E):S}destroy(){for(const F of this.#s)F();this.#s=[],this.#a=null,this.#o.destroyFilters(),this.#r.destroy(),this.#i&&this.#i.remove&&this.#i.remove(),this.#i=null,this.#n.style.paddingRight=""}}}),Fe("packages/dom/src/celledit.js",function(e,K){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/editors/index.js").createEditor,X=K("packages/dom/src/editors/common.js"),W=X.CLS,H=X.markInvalid,U=X.isEditable,w=K("packages/dom/src/detailhost.js").insideDetail,k=`${W.editor}-host`;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=-1;#u=[];#c=null;#d=!1;constructor(t){this.#e=t.grid,this.#t=t.document,this.#n=t.renderer,this.#r=t.registry||null,this.#o=t.cellLayer||null}mount(){this.#u.push(this.#e.on("cell:edit:start",m=>this.open(m))),this.#u.push(this.#e.on("cell:edit:end",()=>this.close()));const t=this.#n.viewport.root,r=this.#e.get("edit"),o=r&&typeof r=="object"&&r.start||"double",f=m=>{if(w(m.target,t))return;const d=l(m.target,j=>j.getAttribute&&j.getAttribute("data-col"));if(!d)return;const h=l(d,j=>j.getAttribute&&j.getAttribute("data-key"));if(!h)return;const a=this.#e.rows.byKey(h.getAttribute("data-key"));if(!a||a.group)return;const p=d.getAttribute("data-col"),b=this.#e.columns.get(p);!b||!b.edit||!b.edit.enabled||this.#e.edit.start(a.key,p)},u=o==="key"?null:o==="single"?"click":"dblclick";u&&(t.addEventListener(u,f),this.#u.push(()=>t.removeEventListener(u,f)));const i=m=>{!this.#i||!this.#l||this.#p(m.target)||this.commit()};this.#t.addEventListener("mousedown",i,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",i,!0))}get target(){return this.#l}open(t){this.close();const r=t.key||t.row&&t.row.key,o=t.colId;if(!r||!o)return;const f=this.#e.columns.get(o),u=this.#e.rows.byKey(r);if(!f||!u||!U({column:f,edit:f.edit,row:u,value:this.#e.rows.value(r,o),grid:this.#e}))return;const i=this.#w(r,o);if(this.#c=i,!i){B("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const m=this.#e.permissions,d=!!(m&&$(m.isSecret)&&m.isSecret(o)),h=_({grid:this.#e,column:f,colId:o,row:u,data:u.data,value:d?null:this.#e.rows.value(r,o),text:d?"":this.#e.rows.text(r,o),locale:this.#e.get("locale"),props:f.edit&&f.edit.props,lookup:f.lookup,document:this.#t,cell:i,overlay:this.#n.viewport.overlays,onCommit:b=>this.#h({value:b,key:r,colId:o}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:b=>{this.#d||this.#e.edit.stop(b)}},this.#r);if(!h){B(`celledit.noeditor:${o}`,`column "${o}" has no editor.`);return}this.#i=h,this.#s=i,this.#l={key:r,colId:o},this.#d=!1,this.#a=this.#b(i);const a=h.element();h.popup?(this.#n.viewport.overlays.appendChild(a),c(a,i,this.#n.viewport.root)):i.replaceChildren(a),i.classList.add(k),$(h.attached)&&h.attached(),s(a);const p=b=>this.#f(b);a.addEventListener("keydown",p),this.#u.push(()=>a.removeEventListener("keydown",p))}#f(t){const r=t.key;if(r!=="Enter"&&r!=="Tab"&&r!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),r==="Escape"){this.#e.edit.stop(!0);return}const o=r==="Enter"?this.#m(t.shiftKey?-1:1):this.#g(t.shiftKey?-1:1);this.commit()&&o&&this.#e.edit.start(o.key,o.colId)}#h(t){this.#d||(this.#d=!0,this.#e.edit.stop(!1,t))}commit(){if(!this.#i||!this.#l)return!1;if(this.#d)return!0;if($(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:r}=this.#l;if($(this.#i.value)){const o=this.#i.value();if($(this.#i.validate)){const f=this.#i.validate(o);if(f!==!0){if(H(this.#c,f),$(this.#i.focusTarget)){const u=this.#i.focusTarget();u&&$(u.focus)&&u.focus()}return!1}H(this.#c,null)}this.#h({value:o,key:t,colId:r})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#p(t){if(!t)return!1;const r=$(this.#i.element)?this.#i.element():null;if(r&&$(r.contains)&&r.contains(t))return!0;const o=this.#c;return!!(o&&$(o.contains)&&o.contains(t))}#m(t){if(!this.#l||this.#a<0)return null;for(let r=this.#a+t;r>=0&&r<this.#e.rows.count();r+=t){const o=this.#e.rows.get(r);if(o&&!o.group)return{key:o.key,colId:this.#l.colId}}return null}#g(t){if(!this.#l)return null;const r=this.#e.columns.visible(),o=r.findIndex(f=>f.id===this.#l.colId);for(let f=o+t;f>=0&&f<r.length;f+=t){const u=r[f];if(u.edit&&u.edit.enabled)return{key:this.#l.key,colId:u.id}}return null}#b(t){const r=l(t,f=>f.getAttribute&&f.getAttribute("data-index"));if(!r)return-1;const o=Number(r.getAttribute("data-index"));return Number.isFinite(o)?o:-1}#w(t,r){const o=this.#n.viewport.root;if(!o||!o.querySelectorAll)return null;for(const f of o.querySelectorAll(`[data-col="${r}"]`)){const u=l(f,i=>i.getAttribute&&i.getAttribute("data-key"));if(u&&u.getAttribute("data-key")===t)return f}return null}close(){this.#c&&H(this.#c,null);const t=this.#S();if(this.#i&&$(this.#i.destroy)&&this.#i.destroy(),this.#s){if(this.#s.classList.remove(k),this.#o&&$(this.#o.releaseCell)){const r=this.#l?this.#e.columns.get(this.#l.colId):null;this.#o.releaseCell(this.#s,r)}this.#s.replaceChildren&&this.#s.replaceChildren(),t&&this.#y(this.#s),this.#n.refresh({force:!0})}this.#i=null,this.#c=null,this.#s=null,this.#l=null,this.#a=-1,this.#d=!1}#S(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const r=this.#i&&$(this.#i.element)?this.#i.element():null,o=f=>!!f&&$(f.contains)&&f.contains(t);return o(r)||o(this.#s)}#y(t){const o=$(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;o&&$(o.focus)&&o.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function l(n,t){let r=n;for(;r;){if(t(r))return r;r=r.parentNode}return null}function c(n,t,r){if(!$(t.getBoundingClientRect))return;const o=t.getBoundingClientRect(),f=r.getBoundingClientRect();n.style.position="absolute",n.style.top=`${Math.round(o.top-f.top)}px`,n.style.minWidth=`${Math.round(o.width)}px`,n.style.left=`${Math.round(o.left-f.left)}px`;const u=n.offsetWidth||Math.round(o.width),i=Math.round(o.left-f.left)+u-Math.round(f.width);i>0&&(n.style.left=`${Math.max(0,Math.round(o.left-f.left)-i)}px`)}function s(n){const t=n.querySelector&&n.querySelector("input, select, textarea, [tabindex]")||n;$(t.focus)&&t.focus(),$(t.select)&&t.select()}}),Fe("packages/dom/src/editbar.js",function(e,K){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return U}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/editors/index.js").createEditor,H=`${K("packages/dom/src/editors/common.js").CLS.editor}-bar`;class U{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];constructor(w){this.#e=w.grid,this.#t=w.document,this.#n=w.root}mount(){const w=this.#t,k=w.createElement("div");k.className=H;const g=w.createElement("span");g.className=`${H}__ref`,g.textContent="";const l=w.createElement("div");l.className=`${H}__slot`;const c=w.createElement("span");c.className=`${H}__readonly`,k.appendChild(g),k.appendChild(l),this.#n.insertBefore(k,this.#n.firstChild),this.#r=k,this.#o=g,this.#i=l,this.#l=c;for(const s of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(s,n=>this.#h(n)))}bind(w,k){const g=this.#e.columns.get(k),l=w?this.#e.rows.byKey(w):null;this.#a=l&&g&&!l.group?{key:w,colId:k}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#f(),!this.#a){this.#o.textContent="";return}const{key:w,colId:k}=this.#a,g=this.#e.columns.get(k);if(!g)return;if(this.#o.textContent=g.title||k,!!!(g.edit&&g.edit.enabled)){this.#l.textContent=this.#e.rows.text(w,k),this.#i.appendChild(this.#l);return}const c=this.#e.rows.byKey(w);if(!c)return;const s=_({grid:this.#e,column:g,colId:k,row:c,data:c.data,value:this.#e.rows.value(w,k),text:this.#e.rows.text(w,k),locale:this.#e.get("locale"),props:g.edit&&g.edit.props,lookup:g.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:f=>f?this.cancel():this.commit(!0)});if(!s){B(`editbar.noeditor:${k}`,`column "${k}" has no editor.`),this.#l.textContent=this.#e.rows.text(w,k),this.#i.appendChild(this.#l);return}this.#s=s;const n=s.element();s.popup?(this.#l.textContent=this.#e.rows.text(w,k),this.#i.appendChild(this.#l)):this.#i.appendChild(n),$(s.attached)&&s.attached();const t=f=>this.#p(f),r=()=>{this.#u=!0},o=[n,this.#i];for(const f of o)f.addEventListener("keydown",t),f.addEventListener("input",r),f.addEventListener("change",r);this.#c=()=>{for(const f of o)f.removeEventListener("keydown",t),f.removeEventListener("input",r),f.removeEventListener("change",r)}}#f(){this.#c&&(this.#c(),this.#c=null),this.#s&&$(this.#s.destroy)&&this.#s.destroy(),this.#s=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#h(w){if(w&&w.colId&&(w.key||w.row&&w.row.key)){this.bind(w.key||w.row.key,w.colId);return}this.refresh()}#p(w){if(w.key==="Enter"){w.preventDefault(),this.commit();return}w.key==="Escape"&&(w.preventDefault(),this.cancel())}commit(w){if(!this.#a||!this.#u&&!w)return!1;const{key:k,colId:g}=this.#a;if(!this.#s||!$(this.#s.value))return!1;const l=this.#s.value();return this.#u=!1,this.#e.edit.start(k,g),this.#e.edit.stop(!1,{value:l,key:k,colId:g}),this.refresh(),!0}destroy(){this.#f();for(const w of this.#d)w();this.#d=[],this.#r&&$(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#a=null}}}),Fe("packages/dom/src/pastepreview.js",function(e,K){"use strict";Object.defineProperty(e,"PREVIEW_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"PastePreview",{enumerable:!0,get:function(){return z}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.clear,H="lat-pastepreview",U='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class z{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=[];constructor(k){this.#e=k.grid,this.#t=k.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(k,g){const l=this.#e;return(l&&l.messages?l.messages:I).t(k,g)}#d(k){const g=`paste.preview.reason.${k}`,l=this.#c(g);return l===g?k:l}#f(k){return k==null||k===""?"":String(k)}#h(k,g){const l=this.#e.columns&&$(this.#e.columns.get)?this.#e.columns.get(g):null;return`${l&&(l.title||l.headerName)||g} · ${k}`}show(k,g){const l=this.#w();if(!l)return!1;this.#l=g&&g.onConfirm,this.#a=g&&g.onCancel||null;const c=k&&k.changes||[],s=k&&k.rejected||[],n=c.filter(r=>r.changed);this.#p(n,s);const t=l.ownerDocument;return this.#s=t&&t.activeElement,l.style.display="",$(l.focus)&&l.focus(),this.#y(this.#c("a11y.paste.previewOpened",{count:n.length,changes:n.length,rejected:s.length}),{repeat:!0}),!0}#p(k,g){const l=this.#r.ownerDocument;W(this.#r);const c=X(l,"p",{class:`${H}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:k.length,changes:k.length,rejected:g.length})});if(this.#r.appendChild(c),!k.length&&!g.length){this.#r.appendChild(X(l,"p",{class:`${H}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!k.length;return}this.#o.disabled=!k.length,k.length&&(this.#r.appendChild(X(l,"h3",{class:`${H}__heading`,text:this.#c("paste.preview.changesHeading",{count:k.length})})),this.#r.appendChild(this.#m(l,k))),g.length&&(this.#r.appendChild(X(l,"h3",{class:`${H}__heading ${H}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:g.length})})),this.#r.appendChild(this.#g(l,g)))}#m(k,g){const l=X(k,"tr",{children:[X(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),X(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),c=g.map(s=>X(k,"tr",{children:[X(k,"th",{attrs:{scope:"row"},text:this.#h(s.key,s.colId)}),X(k,"td",{class:`${H}__old`,text:this.#f(s.oldValue)}),X(k,"td",{class:`${H}__new`,text:this.#f(s.newValue)})]}));return X(k,"table",{class:`${H}__table`,children:[X(k,"thead",{children:[l]}),X(k,"tbody",{children:c})]})}#g(k,g){const l=X(k,"tr",{children:[X(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),c=g.map(s=>X(k,"tr",{children:[X(k,"th",{attrs:{scope:"row"},text:this.#h(s.key,s.colId)}),X(k,"td",{class:`${H}__reason`,text:this.#d(s.reason)})]}));return X(k,"table",{class:`${H}__table ${H}__table--rejected`,children:[X(k,"thead",{children:[l]}),X(k,"tbody",{children:c})]})}confirm(){const k=this.#l;this.#b(),$(k)&&k()}cancel(){const k=this.#a;this.#b(),this.#y(this.#c("a11y.paste.cancelled"),{repeat:!0}),$(k)&&k()}#b(){if(!this.#n)return;this.#n.style.display="none",this.#l=null,this.#a=null;const k=this.#s;this.#s=null,k&&$(k.focus)&&k.focus()}#w(){if(this.#n)return this.#n;const k=this.#t.viewport&&this.#t.viewport.overlays,g=k&&k.ownerDocument;if(!k||!g||!$(g.createElement))return null;const l=`${H}-title`,c=X(g,"h2",{class:`${H}__title`,attrs:{id:l},text:this.#c("paste.preview.title")}),s=X(g,"div",{class:`${H}__body`}),n=X(g,"button",{class:`${H}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),t=X(g,"button",{class:`${H}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),r=X(g,"div",{class:`${H}__foot`,children:[t,n]}),o=X(g,"div",{class:H,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":l},children:[X(g,"div",{class:`${H}__head`,children:[c]}),s,r]});return k.appendChild(o),this.#n=o,this.#r=s,this.#o=n,this.#i=t,this.#S(o,n,t),o}#S(k,g,l){const c=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.cancel();return}if(t.key!=="Tab")return;const r=[...k.querySelectorAll(U)].filter(i=>!i.disabled);if(!r.length){t.preventDefault();return}const o=r[0],f=r[r.length-1],u=k.ownerDocument.activeElement;t.shiftKey&&(u===o||u===k)?(t.preventDefault(),f.focus()):!t.shiftKey&&u===f&&(t.preventDefault(),o.focus())},s=t=>{t&&$(t.preventDefault)&&t.preventDefault(),this.confirm()},n=t=>{t&&$(t.preventDefault)&&t.preventDefault(),this.cancel()};k.addEventListener("keydown",c),g.addEventListener("click",s),l.addEventListener("click",n),this.#u.push(()=>{k.removeEventListener("keydown",c),g.removeEventListener("click",s),l.removeEventListener("click",n)})}#y(k,g){const l=this.#t&&this.#t.announce;$(l)&&l.call(this.#t,k,g)}destroy(){for(const k of this.#u)k();this.#u=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null,this.#o=null,this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),Fe("packages/dom/src/rangeselect.js",function(e,K){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/core/src/model/selection.js"),X=_.extendSeries,W=_.resolveSelectionConfig,H=K("packages/dom/src/renderer/textentry.js"),U=H.isTextEntry,z=H.isFindBarControl,k=K("packages/dom/src/pastepreview.js").PastePreview,g=K("packages/dom/src/columnmenu.js"),l=g.chartableRange,c=g.rangeChartConfig,s="lat-cell--range",n="lat-cell--range-edge",t=Object.freeze({top:"lat-cell--range-top",right:"lat-cell--range-right",bottom:"lat-cell--range-bottom",left:"lat-cell--range-left"}),r=3;class o{#e;#t;#n;#r=!1;#o=[];#i=null;#s=null;#l=null;#a=null;#u=null;constructor(i){this.#e=i.grid,this.#t=i.renderer,this.#n=i.document,this.#a=i.preview||null}mount(){const i=this.#t.viewport.root,m=p=>this.#c(p),d=p=>this.#d(p),h=()=>this.#f(),a=p=>this.#h(p);i.addEventListener("pointerdown",m),this.#n.addEventListener("pointermove",d),this.#n.addEventListener("pointerup",h),i.addEventListener("keydown",a),this.#o.push(()=>{i.removeEventListener("pointerdown",m),this.#n.removeEventListener("pointermove",d),this.#n.removeEventListener("pointerup",h),i.removeEventListener("keydown",a)});for(const p of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(p,()=>this.paint()));this.paint()}#c(i){if(i.button!==0)return;const m=i.target;if(!m||!$(m.closest))return;if(this.#r=!1,m.closest('[data-role="fill-handle"]')){if(this.#E())return;this.#i={mode:"fill",fromX:i.clientX,fromY:i.clientY,armed:!0};return}if(m.closest('[data-role="row-drag"]'))return;const d=this.#$(m);if(!d)return;if(i.shiftKey&&this.#e.selection.corner()){const a=this.#C(d);this.#e.selection.extendRange(a.rowIndex,a.colId),this.#i={mode:"select",fromX:i.clientX,fromY:i.clientY,armed:!0};return}const h=this.#M(d);this.#u=h,this.#e.selection.startRange(h.rowIndex,h.colId,{additive:i.ctrlKey||i.metaKey}),this.#i={mode:"select",fromX:i.clientX,fromY:i.clientY,armed:!1}}#d(i){const m=this.#i;if(!m)return;if(!m.armed){if(Math.abs(i.clientX-m.fromX)+Math.abs(i.clientY-m.fromY)<r)return;m.armed=!0}const d=this.#z(i.clientX,i.clientY);if(!d)return;if(m.mode==="fill"){this.#l=d,this.paint();return}const h=this.#C(d);this.#e.selection.extendRange(h.rowIndex,h.colId)}#f(){const i=this.#i;if(this.#i=null,!!i){if(i.mode==="fill"&&this.#l){const m=this.#l;this.#l=null,this.fillTo(m.rowIndex)}this.#l=null,this.paint()}}#h(i){if(this.#B()||z(i.target)||U(i.target))return;const m=i.ctrlKey||i.metaKey,d=i.key;if(m&&(d==="c"||d==="C")){this.copy(),i.preventDefault();return}if(m&&(d==="v"||d==="V")){this.paste(),i.preventDefault();return}if(m&&(d==="d"||d==="D")){this.fillDown(),i.preventDefault();return}if(m&&!i.altKey&&(d==="z"||d==="Z"||d==="y"||d==="Y")){const O=this.#e.edit;if(!O||O.undoShortcuts===!1)return;const x=d==="y"||d==="Y"||i.shiftKey;this.#y(x)&&i.preventDefault();return}if(d==="Delete"||d==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),i.preventDefault();return}if(this.#e.edit&&this.#e.edit.clearOnDelete===!1)return;this.clear(),i.preventDefault();return}if(i.altKey&&d==="F1"){this.chartSelection()&&i.preventDefault();return}if(!i.shiftKey)return;const h={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[d];if(!h)return;if(m){const O=this.#N();if(!O)return;if(!this.#r){const E=this.#M(O);this.#u=E,this.#e.selection.startRange(E.rowIndex,E.colId,{additive:!0}),this.#r=!0}const x=this.#e.columns.visible().map(E=>E.id),C=x.indexOf(O.colId),P=this.#e.selection.corner()||{row:O.rowIndex,colId:O.colId},F=this.#C({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,P.row+h[0])),colId:x[Math.min(x.length-1,Math.max(0,(C<0?0:C)+h[1]))]});this.#e.selection.extendRange(F.rowIndex,F.colId),i.preventDefault();return}this.#r=!1;const a=this.#e.selection.corner(),p=this.#N(),b=a||p;if(!b)return;if(!a&&p){const O=this.#M(p);this.#u=O,this.#e.selection.startRange(O.rowIndex,O.colId)}const j=this.#e.columns.visible().map(O=>O.id),S=j.indexOf(b.colId??b.colId),y=j[Math.min(j.length-1,Math.max(0,S+h[1]))],v=Math.min(this.#e.rows.count()-1,Math.max(0,(a?a.row:p.rowIndex)+h[0])),R=this.#C({rowIndex:v,colId:y});this.#e.selection.extendRange(R.rowIndex,R.colId),i.preventDefault()}async copy(){const i=this.#e.export.rangeText();if(!i)return this.#e.selection.ranges().length>1&&this.#e.emit("clipboard:copy",{text:"",ok:!1,rows:"range",reason:"discontiguous"},"user"),!1;const m=globalThis.navigator&&globalThis.navigator.clipboard;if(!m||!$(m.writeText))return!1;try{return await m.writeText(i),this.#e.emit("clipboard:copy",{text:i,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:i,ok:!1,rows:"range"},"user"),!1}}async paste(){const i=globalThis.navigator&&globalThis.navigator.clipboard;if(!i||!$(i.readText))return 0;let m="";try{m=await i.readText()}catch{return 0}return this.pasteText(m)}pasteText(i){if(!i)return 0;const m=this.#e.selection.cells(),d=m.length?m[0]:this.#S();if(!d)return 0;const h=m.length>1?{rows:new Set(m.map(a=>a.key)).size,columns:new Set(m.map(a=>a.colId)).size}:void 0;if(this.#p()){const a=this.#e.edit.previewPaste(d,i,h);if(a.changes.length+a.rejected.length>1)return this.#m().show(a,{onConfirm:()=>this.#g(d,i,h)}),0}return this.#g(d,i,h)}#p(){const i=this.#e.edit;return!!(i&&i.pastePreview&&$(i.previewPaste))}#m(){return this.#a||(this.#a=new k({grid:this.#e,renderer:this.#t})),this.#a}#g(i,m,d){const h=this.#e.edit.pasteInto(i,m,d,{origin:"user"}),a=p=>this.#w(p?this.#b("a11y.range.written",{count:p}):this.#b("a11y.range.refused"),{repeat:!0});return h&&$(h.then)?h.then(a):a(h),h}#b(i,m){const d=this.#e;return(d&&d.messages?d.messages:I).t(i,m)}#w(i,m){const d=this.#t&&this.#t.announce;$(d)&&d.call(this.#t,i,m)}#S(){const i=this.#N();if(!i)return null;const m=this.#e.rows.get(i.rowIndex);return m?{key:m.key,colId:i.colId}:null}#y(i){const m=this.#e.history;return!(!m||!(i?m.canRedo():m.canUndo())||!(i?m.redo():m.undo()))}clear(){let i=this.#e.selection.cells();const m=this.#S(),d=this.#n&&this.#n.activeElement;if(!!(m&&d&&$(d.matches)&&d.matches('[data-col][tabindex="0"]'))&&!i.some(b=>b.key===m.key&&b.colId===m.colId)?i=[m]:i.length||(i=m?[m]:[]),!i.length)return 0;const a=this.#e.edit.setCells(i.map(b=>({key:b.key,colId:b.colId,value:null})),"cell",{origin:"user"}),p=b=>{b&&this.#w(this.#b("a11y.range.cleared",{count:b}),{repeat:!0})};return a&&$(a.then)?a.then(p):p(a),a}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const i=this.#e.selection.cells();if(i.length<2)return 0;const m=[...new Set(i.map(a=>a.key))];if(m.length<2)return 0;const d=m[0],h=[];for(const{key:a,colId:p}of i)a!==d&&h.push({key:a,colId:p,value:this.#e.rows.value(d,p)});return this.#e.edit.setCells(h,"cell",{origin:"user"})}chartSelection(){const i=c(this.#e);if(!i.handler)return!1;const m=l(this.#e);return m?(i.handler(this.#e,m),!0):!1}fillTo(i){if(this.#e.selection.ranges().length>1)return 0;const m=this.#e.selection.cells();if(!m.length)return 0;const d=[...new Set(m.map(y=>y.key))],h=[...new Set(m.map(y=>y.colId))],a=this.#U(d[d.length-1]);if(a<0||i<=a)return 0;const p=[];for(let y=a+1;y<=i;y++){const v=this.#e.rows.get(y);if(!v)break;p.push(v)}if(!p.length)return 0;const b=[];for(const y of h){const v=d.map(O=>this.#e.rows.value(O,y)),R=this.#O(v,p,y);for(let O=0;O<p.length;O++)b.push({key:p[O].key,colId:y,value:R[O]})}const j=this.#e.edit.setCells(b,"cell",{origin:"user"}),S=this.#e.selection.corner();return S&&this.#e.selection.extendRange(i,S.colId),j}#O(i,m,d){const h=this.#e.get("selection"),a=h&&typeof h=="object"?h.fill:void 0;if($(a)){const p=this.#e.columns.get(d),b=m.map(S=>({row:S,column:p})),j=a({source:i,target:b,direction:"down"});if(Array.isArray(j)&&j.length===m.length)return j}return X(i,m.length)}paint(){const i=this.#t.viewport.root;if(!i||!i.querySelectorAll)return;const m=this.#e.selection,d=m.ranges().length>0,h=this.#l;for(const a of i.querySelectorAll("[data-col]")){const p=a.getAttribute("data-col"),b=a.parentNode,j=a.getAttribute?a.getAttribute("data-index"):null,S=j!==null&&j!==""?j:b&&b.getAttribute?b.getAttribute("data-index"):null;if(S===null||S==="")continue;const y=Number(S);if(!Number.isFinite(y)||y<0)continue;const v=d&&m.inRange(y,p),R=!!h&&this.#k(y,p,h);a.classList.toggle(s,v||R);const O=v||R?this.#A(y,p,m):null;a.classList.toggle(n,!!O&&O.any);for(const[x,C]of Object.entries(t))a.classList.toggle(C,!!O&&O[x])}this.#j()}#k(i,m,d){const h=this.#e.selection.cells();if(!h.length||!new Set(h.map(b=>b.colId)).has(m))return!1;const p=this.#U([...new Set(h.map(b=>b.key))].pop());return i>p&&i<=d.rowIndex}#A(i,m,d){const h=this.#e.columns.visible().map(S=>S.id),a=h.indexOf(m),p=a>0?h[a-1]:null,b=a>=0&&a<h.length-1?h[a+1]:null,j={top:!d.inRange(i-1,m),bottom:!d.inRange(i+1,m),left:!p||!d.inRange(i,p),right:!b||!d.inRange(i,b)};return j.any=j.top||j.bottom||j.left||j.right,j}#j(){const i=this.#e.selection.corner(),m=this.#t.viewport.overlays;if(!m)return;if(!i||this.#x()===!1||this.#e.selection.ranges().length>1||this.#E()){this.#s&&(this.#s.style.display="none");return}const d=this.#_(i.row,i.colId);if(!d||!$(d.getBoundingClientRect)){this.#s&&(this.#s.style.display="none");return}this.#s||(this.#s=this.#n.createElement("div"),this.#s.className="lat-fill-handle",this.#s.setAttribute("data-role","fill-handle"),this.#s.setAttribute("title",this.#b("a11y.fillHandle")),m.appendChild(this.#s));const h=d.getBoundingClientRect(),a=this.#t.viewport.root.getBoundingClientRect();this.#s.style.display="";const b=this.#t.viewport.rtl===!0?h.left:h.right;this.#s.style.left=`${Math.round(b-a.left)-4}px`,this.#s.style.top=`${Math.round(h.bottom-a.top)-4}px`}#T(i){const m=this.#t;return!i||typeof m.spanAt!="function"?null:m.spanAt(i.rowIndex,i.colId)}#M(i){const m=this.#T(i);return m?{rowIndex:m.row,colId:m.columnId}:i}#C(i){const m=this.#T(i);if(!m)return i;const d=this.#u,h=!!d&&d.rowIndex>=m.row+m.rows,a=this.#L(),p=d?a.indexOf(d.colId):-1,b=p>=0&&p>=m.col+m.cols;return{rowIndex:h?m.row:m.row+m.rows-1,colId:b?m.columnId:m.endColumnId}}#E(){const i=this.#e.selection.corner();if(!i)return!1;const m=this.#T({rowIndex:i.row,colId:i.colId});return!!m&&(m.rows>1||m.cols>1)}#L(){const i=this.#e.columns;return i&&$(i.visible)?i.visible().map(m=>m.id):[]}#x(){return W(this.#e.get("selection")).fillHandle}#B(){const i=this.#t.viewport.root;return!!(i&&i.querySelector&&i.querySelector(".lat-editor-host, .lat-editor--popup"))}#H(){const i=this.#e.selection.cells();return i.length?i[0]:null}#U(i){for(let m=0;m<this.#e.rows.count();m++){const d=this.#e.rows.get(m);if(d&&d.key===i)return m}return-1}#N(){const i=this.#t.viewport.root,m=i&&i.querySelector?i.querySelector('[data-col][tabindex="0"]'):null;return m?this.#$(m):null}#$(i){if(!i||!$(i.closest))return null;const m=i.closest("[data-col]");if(!m||!m.classList.contains("lat-cell"))return null;const d=m.closest("[data-index]");if(!d)return null;const h=Number(d.getAttribute("data-index"));return!Number.isFinite(h)||h<0?null:{rowIndex:h,colId:m.getAttribute("data-col")}}#z(i,m){const d=this.#n.elementFromPoint?this.#n.elementFromPoint(i,m):null;return d?this.#$(d):null}#_(i,m){const d=this.#t.viewport.root;if(!d||!d.querySelectorAll)return null;for(const h of d.querySelectorAll(`[data-col="${m}"]`)){const a=h.closest?h.closest("[data-index]"):null;if(a&&Number(a.getAttribute("data-index"))===i)return h}return null}destroy(){for(const i of this.#o)i();this.#o=[],this.#s&&$(this.#s.remove)&&this.#s.remove(),this.#s=null,this.#i=null,this.#l=null,this.#a&&$(this.#a.destroy)&&this.#a.destroy(),this.#a=null}}const f=o}),Fe("packages/dom/src/importer.js",function(e,K){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return o}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/core/src/import/index.js"),X=_.parseDelimited,W=_.inferColumns,H=_.mapRecords,U=_.readXlsx,z=_.looksLikeXlsx,w=K("packages/dom/src/editors/common.js"),k=w.el,g=w.clear,l=w.on,s=K("packages/dom/src/renderer/textentry.js").isTextEntry,n="lat-import",t='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',r=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class o{#e;#t;#n;#r;#o=[];#i=null;#s=null;#l=null;#a=null;constructor(u){this.#e=u.grid,this.#t=u.renderer,this.#n=u.document;const i=u.settings&&typeof u.settings=="object"?u.settings:{};this.#r={file:i.file!==!1,drop:i.drop!==!1,paste:i.paste!==!1,mode:i.mode==="replace"?"replace":"append"},this.#u()}#u(){const u=this.#t&&this.#t.viewport?this.#t.viewport.root:null;u&&(this.#r.drop&&(this.#o.push(l(u,"dragover",i=>{i.dataTransfer&&[...i.dataTransfer.types||[]].includes("Files")&&(i.preventDefault(),u.classList.add("lat-import--dropzone"))})),this.#o.push(l(u,"dragleave",()=>u.classList.remove("lat-import--dropzone"))),this.#o.push(l(u,"drop",i=>{u.classList.remove("lat-import--dropzone");const m=i.dataTransfer&&i.dataTransfer.files&&i.dataTransfer.files[0];m&&(i.preventDefault(),this.#c(m))}))),this.#r.paste&&this.#o.push(l(u,"paste",i=>{if(s(i.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const m=i.clipboardData&&i.clipboardData.getData("text/plain");!m||!m.includes(`
57
57
  `)||(i.preventDefault(),this.fromText(m))})))}openFile(){const u=k(this.#n,"input",{attrs:{type:"file",accept:r}});u.style.display="none",this.#o.push(l(u,"change",()=>{const i=u.files&&u.files[0];i&&this.#c(i),u.parentNode&&u.parentNode.removeChild(u)})),this.#n.body.appendChild(u),u.click()}#c(u){if($(u.arrayBuffer)){u.arrayBuffer().then(m=>{const d=new Uint8Array(m);if(z(d)){this.fromXlsx(d,u.name);return}this.fromText(new TextDecoder().decode(d),u.name)});return}if($(u.text)){u.text().then(m=>this.fromText(m,u.name));return}const i=new this.#n.defaultView.FileReader;i.onload=()=>this.fromText(String(i.result||""),u.name),i.readAsText(u)}async fromXlsx(u,i){const{header:m,rows:d}=await U(u);if(!m.length)return;const h=W(m,d,{columns:this.#e.columns.all()}),a=d.filter(p=>p.length!==m.length).length;this.#l={rows:d,columns:h,delimiter:null,name:i,warnings:a?[`${a} row(s) do not have ${m.length} columns`]:[]},this.#d()}fromText(u,i){const{header:m,rows:d,delimiter:h}=X(u);if(!m.length)return;const a=W(m,d,{columns:this.#e.columns.all()}),p=d.filter(b=>b.length!==m.length).length;this.#l={rows:d,columns:a,delimiter:h,name:i,warnings:p?[`${p} row(s) do not have ${m.length} columns`]:[]},this.#d()}#d(){this.#i||this.#p(),this.#m(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const u=this.#i.querySelector(t);u&&$(u.focus)&&u.focus(),this.#f(this.#h("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#f(u,i){const m=this.#t&&this.#t.announce;$(m)&&m.call(this.#t,u,i)}#h(u,i){return(this.#e&&this.#e.messages?this.#e.messages:I).t(u,i)}#p(){const u=this.#n,i=k(u,"div",{class:n,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#h("import.title"),hidden:!0}}),m=k(u,"div",{class:`${n}__panel`});m.appendChild(k(u,"h2",{class:`${n}__title`,text:this.#h("import.title")})),this.#s=k(u,"div",{class:`${n}__body`}),m.appendChild(this.#s);const d=k(u,"div",{class:`${n}__footer`}),h=k(u,"button",{class:`${n}__cancel`,text:this.#h("import.cancel"),attrs:{type:"button"}}),a=k(u,"button",{class:`${n}__confirm`,text:this.#h("import.confirm"),attrs:{type:"button"}});this.#o.push(l(h,"click",()=>this.close())),this.#o.push(l(a,"click",()=>this.#g())),d.appendChild(h),d.appendChild(a),m.appendChild(d),i.appendChild(m),this.#o.push(l(i,"keydown",b=>{if(b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab")return;const j=[...i.querySelectorAll(t)].filter(v=>!v.hidden);if(!j.length)return;const S=j[0],y=j[j.length-1];b.shiftKey&&this.#n.activeElement===S?(b.preventDefault(),y.focus()):!b.shiftKey&&this.#n.activeElement===y&&(b.preventDefault(),S.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(i),this.#i=i}#m(){const u=this.#n,i=g(this.#s),{rows:m,columns:d,name:h,warnings:a}=this.#l;i.appendChild(k(u,"p",{class:`${n}__summary`,text:this.#h("import.summary",{count:m.length,name:h||this.#h("import.clipboard")})}));for(const v of a)i.appendChild(k(u,"p",{class:`${n}__warning`,text:v}));const p=this.#e.columns.all().map(v=>v.field||v.id).filter(Boolean),b=k(u,"table",{class:`${n}__map`}),j=k(u,"tr",{});for(const v of["import.colSource","import.colField","import.colType"])j.appendChild(k(u,"th",{text:this.#h(v)}));b.appendChild(j),d.forEach((v,R)=>{const O=k(u,"tr",{});O.appendChild(k(u,"td",{text:v.source}));const x=k(u,"select",{attrs:{"data-col":String(R),"aria-label":this.#h("import.mapLabel",{source:v.source})}});x.appendChild(k(u,"option",{text:this.#h("import.skip"),attrs:{value:""}}));for(const P of p)x.appendChild(k(u,"option",{text:P,attrs:{value:P,selected:P===v.field?!0:null}}));v.field&&!p.includes(v.field)&&x.appendChild(k(u,"option",{text:v.field,attrs:{value:v.field,selected:!0}}));const C=k(u,"td",{});C.appendChild(x),O.appendChild(C),O.appendChild(k(u,"td",{class:`${n}__type`,text:v.type})),b.appendChild(O)}),i.appendChild(b);const S=k(u,"div",{class:`${n}__mode`}),y=k(u,"select",{attrs:{"aria-label":this.#h("import.modeLabel"),"data-mode":"mode"}});y.appendChild(k(u,"option",{text:this.#h("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),y.appendChild(k(u,"option",{text:this.#h("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),S.appendChild(k(u,"label",{text:this.#h("import.modeLabel")})),S.appendChild(y),i.appendChild(S)}#g(){const{rows:u,columns:i}=this.#l;for(const p of this.#i.querySelectorAll("select[data-col]")){const b=Number(p.getAttribute("data-col"));i[b]&&p.value!==void 0&&p.value!==null&&(i[b].field=p.value)}const m=this.#i.querySelector("select[data-mode]"),d=m?m.value:void 0,h=d==="replace"||d==="append"?d:this.#r.mode,a=H(u,i);this.#e.import.apply(a,{mode:h}),this.close(),this.#f(this.#h("import.done",{count:a.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&$(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const u of this.#o)u();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),Fe("packages/dom/src/historybar.js",function(e,K){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,H=_.clear,U=_.documentFor,z="lat-history";class w{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(l,c){return(this.messages&&typeof this.messages.t=="function"?this.messages:I).t(l,c)}init(l){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||I;const c=l||{};if(this.doc=U(c),this.host=c.host||{},this.props=c.props||{},this.root=X(this.doc,"div",{class:["lattice-tokens",z],attrs:{role:"group","aria-label":this.t("history.title")}}),this.undoButton=this.#e("undo","Undo","↶"),this.redoButton=this.#e("redo","Redo","↷"),this.root.appendChild(this.undoButton),this.root.appendChild(this.redoButton),this.props.timeline!==!1){const s=X(this.doc,"button",{class:`${z}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(W(s,"click",()=>this.toggle())),this.root.appendChild(s),this.toggleButton=s,this.menu=X(this.doc,"div",{class:`${z}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(l,c,s){const n=X(this.doc,"button",{class:`${z}__${l}`,attrs:{type:"button"},children:[X(this.doc,"span",{class:`${z}__glyph`,text:s,attrs:{"aria-hidden":"true"}}),X(this.doc,"span",{class:`${z}__label`,text:c})]});return this.off.push(W(n,"click",()=>{const t=this.host[l];$(t)&&t(),this.refresh()})),n}element(){return this.root}refresh(){if(!this.root)return;const l=this.host,c=$(l.canUndo)?l.canUndo():!1,s=$(l.canRedo)?l.canRedo():!1,n=$(l.peek)?l.peek("undo"):null,t=$(l.peek)?l.peek("redo"):null;this.#t(this.undoButton,"undo",c,n),this.#t(this.redoButton,"redo",s,t),this.open&&this.#n()}#t(l,c,s,n){if(!l)return;l.disabled=!s;const t=c==="undo",r=this.t(t?"history.undo":"history.redo"),o=l.querySelector(`.${z}__label`);o&&(o.textContent=r);const f=n&&n.label?this.t("history.described",{action:r,label:n.label}):r;l.setAttribute("title",s?f:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),l.setAttribute("aria-label",s?f:this.t(t?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const l=this.menu;if(!l)return;H(l);const c=$(this.host.list)?this.host.list():[];if(!c.length){l.appendChild(X(this.doc,"p",{class:`${z}__empty`,text:this.t("history.empty")}));return}c.forEach((s,n)=>{const t=X(this.doc,"button",{class:`${z}__item`,attrs:{type:"button",role:"menuitem","data-type":s.type,"data-undone":s.undone?"true":null},children:[X(this.doc,"span",{class:`${z}__kind`,text:s.type}),X(this.doc,"span",{class:`${z}__text`,text:s.label||s.type})]});this.off.push(W(t,"click",()=>{const r=n+1;for(let o=0;o<r;o++)$(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),l.appendChild(t)})}destroy(){for(const l of this.off)l();this.off=[],this.root&&$(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const k=w}),Fe("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,X={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},W="lat-cell--changed",H="lat-cell--added-column";class U{#e;#t;#n=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){for(const g of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(g,()=>this.paint()));this.paint()}paint(){const g=this.#t.viewport.root;if(!g||!g.querySelectorAll)return;const l=this.#e.diff,c=l&&l.enabled;for(const s of g.querySelectorAll("[data-key]")){const n=s.getAttribute("data-key"),t=c?l.statusOf(n):"unchanged";for(const o of Object.values(X))s.classList.remove(o);c&&X[t]&&s.classList.add(X[t]),s.setAttribute("data-diff",c?t:"");const r=c&&t==="changed";for(const o of s.querySelectorAll("[data-col]")){const f=o.getAttribute("data-col");if(o.classList.remove(W,H),o.removeAttribute("data-before"),!r)continue;const u=l.cellStatus(n,f);if(u==="changed"){o.classList.add(W);const i=this.#r(l,n,f);i===null?o.removeAttribute("title"):(o.setAttribute("data-before",i),o.setAttribute("title",this.#o("diff.before",{value:i})))}else u==="added-column"&&o.classList.add(H)}}}#r(g,l,c){const s=this.#e,n=s&&s.columns,t=n&&$(n.get)?n.get(c):null,r=s&&s.permissions;if(t&&r&&$(r.isSecret)&&r.isSecret(t))return null;const o=g.before(l,c);if(o==null)return this.#o("diff.empty");if(!t||!$(t.formatValue))return String(o);const f=$(g.beforeRow)?g.beforeRow(l):void 0,i={...(s.rows&&$(s.rows.byKey)?s.rows.byKey(l):null)||{},data:f===void 0?{}:f};try{const m=t.formatValue(o,i,i.data);return m==null?"":String(m)}catch(m){return B(`diff-before-format:${c}`,`the formatter for column "${c}" threw while formatting a previous value, so the diff hover shows the raw one.`,m),String(o)}}#o(g,l){const c=this.#e;return(c&&c.messages?c.messages:_).t(g,l)}destroy(){for(const l of this.#n)l();this.#n=[];const g=this.#t.viewport.root;if(!(!g||!g.querySelectorAll)){for(const l of g.querySelectorAll("[data-key]")){for(const c of Object.values(X))l.classList.remove(c);l.removeAttribute("data-diff")}for(const l of g.querySelectorAll("[data-col]"))l.classList.remove(W,H),l.removeAttribute("data-before")}}}function z(k){return!!(k&&k.diff&&($(k.diff)||typeof k.diff=="object"))}const w=U}),Fe("packages/dom/src/highlightpaint.js",function(e,K){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--highlight",I="--lattice-cell-highlight";class _{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const H=()=>{this.#o=!1,this.paint()};$(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):$(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const U=this.#l();if(U){U.sweep();for(const z of H.querySelectorAll("[data-key]")){const w=z.getAttribute("data-key");for(const k of z.querySelectorAll("[data-col]")){const g=U.active?U.colourFor(w,k.getAttribute("data-col")):null;g?(k.classList.add(B),k.style.setProperty(I,g)):k.classList.contains(B)&&(k.classList.remove(B),k.style.removeProperty(I))}}this.#s(U)}}#s(H){this.#r!==null&&$(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const U=H.nextExpiry;if(!Number.isFinite(U)||!$(this.#i.setTimeout))return;const z=Math.max(0,U-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},z)}#l(){const H=this.#e.highlight;return H&&$(H.model)?H.model():null}destroy(){this.#r!==null&&$(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const U of this.#n)U();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const U of H.querySelectorAll(`.${B}`))U.classList.remove(B),U.style.removeProperty(I)}}const X=_}),Fe("packages/dom/src/findpaint.js",function(e,K){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--find",I="lat-cell--find-current";class _{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const H=()=>{this.#r=!1,this.paint()};$(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):$(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const U=this.#e.find;if(!U||!$(U.stateFor))return;const z=$(U.model)?U.model():null,w=!!z&&z.active;if(!w&&!this.#o)return;let k=!1;for(const g of H.querySelectorAll("[data-key]")){const l=g.getAttribute("data-key");for(const c of g.querySelectorAll("[data-col]")){const s=w?U.stateFor(l,c.getAttribute("data-col")):null;s?(k=!0,c.classList.add(B),c.classList.toggle(I,s==="current")):c.classList.contains(B)&&c.classList.remove(B,I)}}this.#o=k}destroy(){for(const U of this.#n)U();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll)){for(const U of H.querySelectorAll(`.${B}`))U.classList.remove(B,I);this.#o=!1}}}const X=_}),Fe("packages/dom/src/findbar.js",function(e,K){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/dom/src/editors/common.js"),$=Q.el,B=Q.on,_=K("packages/dom/src/renderer/textentry.js").isTextEntry,W=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,z="lat-find",w=12,k=120;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=!1;#p=!1;#m=null;#g=[];#b=null;#w=null;#S=!1;constructor(s){this.#e=s.grid,this.#t=s.renderer,this.#n=s.document||s.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=s.settings&&typeof s.settings=="object"?s.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(s,n){const t=this.#e;return(t&&t.messages&&U(t.messages.t)?t.messages:W).t(s,n)}mount(){const s=this.#O();if(!s)return;s.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),s.attachDriver({run:()=>this.#C()});const n=this.#t.viewport?.root;if(n&&U(n.addEventListener)&&this.#o.shortcut!==!1){const t=r=>{if(!(r.ctrlKey||r.metaKey)||r.altKey||r.shiftKey||r.key!=="f"&&r.key!=="F")return;const o=r.target;if(this.#s&&o===this.#s){r.preventDefault(),r.stopPropagation(),U(this.#s.select)&&this.#s.select();return}_(o)||(r.preventDefault(),r.stopPropagation(),this.show())};n.addEventListener("keydown",t,!0),this.#g.push(()=>n.removeEventListener("keydown",t,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#L())),this.#g.push(this.#e.on("columns:changed",()=>this.#A())),this.#g.push(this.#e.on("column:visible",()=>this.#A()))}show(s){const n=this.#k();if(!n)return;const t=n.style.display!=="none";n.style.display="",t||this.#y(),this.#O().setOpen(!0),s!=null&&(this.#s.value=String(s),this.#T()),this.#s.focus(),U(this.#s.select)&&this.#s.select(),this.#L()}hide(){this.#H();const s=this.#O();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#y()),s&&(s.clear(),s.setOpen(!1));const n=this.#t.viewport?.root;if(!n||!(this.#i&&this.#n&&this.#n.activeElement&&U(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const o=(U(n.querySelector)?n.querySelector('[tabindex="0"]'):null)||n;U(o.focus)&&o.focus()}search(){this.#T()}destroy(){this.#S=!0,this.#H();for(const n of this.#g)n();this.#g=[];const s=this.#O();s&&(s.attachUi(null),s.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#y(){const s=this.#t;s&&U(s.invalidate)&&s.invalidate("size")}#O(){const s=this.#e&&this.#e.find;return s&&U(s.model)?s.model():null}#k(){if(this.#i)return this.#i;const s=this.#t.viewport,n=s?.root,t=this.#n;if(!n||!t||!U(n.insertBefore))return null;const r=$(t,"div",{class:z,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=$(t,"input",{class:`${z}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=$(t,"span",{class:`${z}__count`,attrs:{"aria-hidden":"true"}}),this.#a=$(t,"span",{class:`${z}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=$(t,"span",{class:`${z}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const o=$(t,"button",{class:`${z}__nav ${z}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),f=$(t,"button",{class:`${z}__nav ${z}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=$(t,"button",{class:`${z}__toggle ${z}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=$(t,"button",{class:`${z}__toggle ${z}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#f=$(t,"select",{class:`${z}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const u=$(t,"button",{class:`${z}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),i=$(t,"div",{class:`${z}__options`,children:[this.#c,this.#d,this.#f]});for(const d of[this.#s,this.#l,this.#a,this.#u,o,f,u,i])r.appendChild(d);this.#g.push(B(this.#s,"input",()=>this.#j())),this.#g.push(B(o,"click",()=>this.#e.find.prev())),this.#g.push(B(f,"click",()=>this.#e.find.next())),this.#g.push(B(this.#c,"click",()=>{this.#h=!this.#h,this.#c.setAttribute("aria-pressed",String(this.#h)),this.#T()})),this.#g.push(B(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#T()})),this.#g.push(B(this.#f,"change",()=>{const d=this.#f.value;this.#m=d?String(d):null,this.#T()})),this.#g.push(B(u,"click",()=>this.hide()));const m=d=>{if(d.key==="Escape"){d.preventDefault(),d.stopPropagation(),this.hide();return}d.key==="Enter"&&d.target===this.#s&&(d.preventDefault(),d.stopPropagation(),this.#b!==null&&(this.#x(),this.#T()),d.shiftKey?this.#e.find.prev():this.#e.find.next())};return r.addEventListener("keydown",m),this.#g.push(()=>r.removeEventListener("keydown",m)),r.style.display="none",n.insertBefore(r,s.header||n.firstChild),this.#i=r,this.#A(),r}#A(){const s=this.#f;if(!s)return;const n=this.#n;for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild($(n,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,r=t&&U(t.visible)?t.visible():[];let o=!1;for(const f of r){if(!f||f.id===void 0)continue;const u=String(f.id);s.appendChild($(n,"option",{text:f.title||u,attrs:{value:u}})),u===this.#m&&(o=!0)}o||(this.#m=null),s.value=this.#m||""}#j(){const s=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):k;if(this.#x(),s===0||!U(this.#r.setTimeout)){this.#T();return}this.#b=this.#r.setTimeout(()=>{this.#b=null,this.#T()},s)}#T(){const s=this.#O();if(!s||this.#S)return;const n=this.#s?this.#s.value:"";if(!n){this.#B(),s.clear();return}s.begin(n,{caseSensitive:this.#h,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#M()}),this.#C()}#M(){const s=this.#t&&this.#t.window,n=s&&Number.isFinite(s.first)?s.first:0;return Math.max(0,n)}#C(){if(this.#w!==null||this.#S)return;const s=()=>{this.#w=null,this.#E()};U(this.#r.requestAnimationFrame)?this.#w=this.#r.requestAnimationFrame(s):U(this.#r.setTimeout)?this.#w=this.#r.setTimeout(s,0):s()}#E(){const s=this.#O();!s||this.#S||!s.active||(s.stale&&s.rescan({from:this.#M()}),!s.complete&&(s.step(w)||this.#C()))}#L(){if(!this.#i||this.#S)return;const s=this.#e.find.count(),n=this.#O().active;let t="",r="idle";n&&(s.total===0?(t=s.complete?this.t("find.none"):this.t("find.searching"),r=s.complete?"none":"searching"):(t=this.t(s.complete?"find.count":"find.countPartial",{current:s.current,total:s.total}),r=s.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",r);const o=n&&s.windowed;this.#a.textContent=o?this.t("find.loadedRows"):"",this.#a.style.display=o?"":"none",n?s.complete&&(this.#u.textContent=s.total===0?this.t(o?"a11y.find.noneLoaded":"a11y.find.none"):this.t(o?"a11y.find.countLoaded":"a11y.find.count",{current:s.current,count:s.total})):this.#u.textContent=""}#x(){this.#b!==null&&U(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null}#B(){this.#w!==null&&(U(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#w):U(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null)}#H(){this.#x(),this.#B()}}const l=g}),Fe("packages/dom/src/redactpaint.js",function(e,K){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const Q="lat-cell--redacted",$="lat-cell";class B{#e;#t;#n=[];constructor(X){this.#e=X.grid,this.#t=X.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const X=this.#t.viewport?.root;if(!X||!X.querySelectorAll)return;const W=this.#e.redaction;if(!W)return;const H=W.active;for(const U of X.querySelectorAll(`.${$}[data-col]`))H&&W.has(U.getAttribute("data-col"))?U.classList.add(Q):U.classList.contains(Q)&&U.classList.remove(Q)}destroy(){for(const X of this.#n)X();this.#n=[]}}const I=B}),Fe("packages/dom/src/validationpaint.js",function(e,K){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function I(W,H){let U=W;for(;U;){if(H(U))return U;U=U.parentNode}return null}class _{#e;#t;#n=[];constructor(H){this.#e=H.grid,this.#t=H.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const H of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(H,()=>this.paint()));this.paint()}#r(H){const U=I(H,z=>z.getAttribute&&z.getAttribute("data-key")!==null);return U?U.getAttribute("data-key"):null}paint(){const H=this.#e.validation;if(!H||!H.active)return;const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll))for(const z of U.querySelectorAll(`.${B}[data-col]`)){const w=z.getAttribute("data-col"),k=this.#r(z),g=k?H.errorFor(k,w):null;$(z,g?g.message:null)}}destroy(){for(const H of this.#n)H();this.#n=[]}}const X=_}),Fe("packages/dom/src/presentation.js",function(e,K){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/dom/src/renderer/textentry.js").isTextEntry,X=K("packages/dom/src/renderer/viewport.js").CLASS,W="lat-presenting",H="lat-presenting--changing",U="lat-presenting__progress",z="lat-cell--dimmed",w=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class k{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(c){this.#e=c.grid,this.#t=c.renderer,this.#n=c.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#h())),this.#r.push(this.#e.on("presentation:scale",()=>this.#h())),this.#r.push(this.#e.on("presentation:ended",()=>this.#f())),this.#r.push(this.#e.on("presentation:view",s=>this.#a(s))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&$(this.#n.watch)&&this.#r.push(this.#n.watch(s=>{s||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const c=this.#t.viewport?.root;if(c&&$(c.addEventListener)){const s=n=>this.#l(n);c.addEventListener("keydown",s),this.#r.push(()=>c.removeEventListener("keydown",s))}}#l(c){const s=this.#e.presentation;if(!s?.active)return;const n=c.ctrlKey||c.metaKey,t=c.key;if(t==="Escape"&&!this.#n){c.defaultPrevented||(s.stop(),c.preventDefault?.());return}if(n){t==="="||t==="+"?(s.nudge(1),c.preventDefault?.()):t==="-"||t==="_"?(s.nudge(-1),c.preventDefault?.()):t==="0"&&(s.setScale(1.5),c.preventDefault?.());return}if(!s.views.length||I(c.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(s.step(1),c.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(s.step(-1),c.preventDefault?.()):t==="Home"?(s.goTo(0),c.preventDefault?.()):t==="End"?(s.goTo(s.views.length-1),c.preventDefault?.()):(t==="r"||t==="R")&&(s.reset(),c.preventDefault?.())}#a(c){!c||!c.viewId||(this.#u(),this.#e.views?.apply?.(c.viewId),this.#c(c))}#u(){const c=this.#t.viewport?.root;c?.classList&&(c.classList.remove(H),c.offsetWidth,c.classList.add(H))}#c(c){const s=this.#t.viewport?.overlays;if(!s||!this.#e.presentation.views.length)return;const n=s.ownerDocument;if(!n?.createElement)return;if(!this.#i){const o=n.createElement("div");o.className=U,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),s.appendChild(o),this.#i=o}const t=this.#e.views?.get?.(c.viewId),r=t&&t.name?t.name:"";this.#i.textContent=r?`${r} · ${(c.index||0)+1} / ${c.count||0}`:`${(c.index||0)+1} / ${c.count||0}`}#d(){if(this.#o){this.#h();return}const c=!!(this.#n&&this.#n.active());this.#n&&!c&&this.#n.enter();const s=new Set(this.#e.presentation?.options?.chrome||[]),n=[];for(const r of w){if(s.has(r)||r==="toolPanel"&&this.#S())continue;const o=this.#y(r);o&&o.style&&o.style.display!=="none"&&(o.style.display="none",n.push(o))}const t=this.#b();t&&t.style&&t.style.display!=="none"&&this.#w(t)&&(t.style.display="none",n.push(t)),this.#o={maximised:c,hidden:n},this.#t.viewport?.root?.classList?.add(W),this.#h(),this.#m()}#f(){const c=this.#o;this.#o=null;const s=this.#t.viewport?.root;if(s?.classList?.remove(W),s?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),s?.classList?.remove(H),this.#p(),c){const n=this.#e.toolPanel;n&&$(n.presentRestore)&&n.presentRestore();for(const t of c.hidden)t.style.display="";this.#n&&!c.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#h(){const c=this.#t.viewport?.root;!c||!c.style||(c.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const c=this.#t.viewport?.root;if(!c?.querySelectorAll)return;const s=this.#e.presentation?.active?this.#e.presentation.spotlight:null,n=s&&s.keys.length?new Set(s.keys):null,t=s&&s.colIds.length?new Set(s.colIds):null;for(const r of c.querySelectorAll("[data-key]")){const o=!n||n.has(r.getAttribute("data-key"));for(const f of r.querySelectorAll("[data-col]"))!s||o&&(!t||t.has(f.getAttribute("data-col")))?f.classList.remove(z):f.classList.add(z)}}#m(){this.#g();const c=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(c)||c<=0||!this.#e.presentation.views.length)return;const s=this.#t.viewport?.root?.ownerDocument?.defaultView;s?.setInterval&&(this.#s=s.setInterval(()=>{const n=this.#e.presentation;n.active&&n.goTo(n.index>=n.views.length-1?0:n.index+1)},Math.max(1e3,c)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#b(){const c=this.#e.element;return!c||!$(c.querySelector)?null:c.querySelector(`.${X.statusBar}`)}#w(c){const s=c.children||[];for(const n of s)if(!n.style||n.style.display!=="none")return!1;return!0}#S(){const c=this.#e.toolPanel;return!!(c&&$(c.presentOnly)&&c.presentOnly())}#y(c){const s=this.#e.element;if(!s||!$(s.querySelector))return null;const n={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[c];return n?s.querySelector(n):null}destroy(){this.#o&&this.#f();for(const c of this.#r)c();this.#r=[]}}const g=k}),Fe("packages/dom/src/capture.js",function(e,K){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const $=K("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function I(U,z,w){const k=w.getComputedStyle(U),g=z.style;if(g)for(let l=0;l<k.length;l++){const c=k[l];B.has(c)||g.setProperty(c,k.getPropertyValue(c),k.getPropertyPriority(c))}}function _(U,z,w){if(I(U,z,w),U.tagName==="CANVAS"&&$(U.toDataURL))try{const l=U.toDataURL("image/png"),c=z.style;c&&(c.setProperty("background-image",`url(${l})`),c.setProperty("background-size","100% 100%"),c.setProperty("background-repeat","no-repeat"))}catch{}const k=U.children||[],g=z.children||[];for(let l=0;l<k.length&&l<g.length;l++)_(k[l],g[l],w)}function X(U,z){if(!U||U.startsWith("data:")||U.startsWith("blob:"))return!0;try{return new URL(U,z).origin===z}catch{return!0}}async function W(U,z={}){const w=U.ownerDocument,k=w?.defaultView;if(!k||typeof k.getComputedStyle!="function")throw new Error("capture needs a browser document");const g=U.getBoundingClientRect(),l=Math.max(1,Math.ceil(g.width)),c=Math.max(1,Math.ceil(g.height)),s=Math.max(.1,Number(z.scale)||2),n=k.location?.origin||"";for(const m of U.querySelectorAll("img")){const d=m.getAttribute("src")||"";if(!X(d,n))throw new Error(`capture refused: the image at ${d} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const t=U.cloneNode(!0);_(U,t,k),t.style.width=`${l}px`,t.style.height=`${c}px`,t.style.margin="0";const r=new k.XMLSerializer().serializeToString(t),o=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${c}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${r}</div></foreignObject></svg>`,f=new k.Image;await new Promise((m,d)=>{f.onload=()=>m(void 0),f.onerror=()=>d(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),f.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`});const u=w.createElement("canvas");u.width=Math.round(l*s),u.height=Math.round(c*s);const i=u.getContext("2d");if(!i)throw new Error("capture could not get a 2d context");return i.fillStyle=z.background||k.getComputedStyle(U).backgroundColor||"#ffffff",i.fillRect(0,0,u.width,u.height),i.drawImage(f,0,0,u.width,u.height),new Promise((m,d)=>{u.toBlob(h=>h?m({blob:h,width:u.width,height:u.height}):d(new Error("capture produced no image")),z.type||"image/png",z.quality)})}const H=W}),Fe("packages/dom/src/annotate.js",function(e,K){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.uid,I=Q.warnOnce,X=K("packages/dom/src/renderer/direction.js").signedX,W=Object.freeze(["pen","arrow","rect","highlight","erase"]),H=Object.freeze(["freehand","arrow","rect","highlight","text"]),U=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),z=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),w=14,k="system-ui, -apple-system, sans-serif";function g(h,a){if(!h||typeof h!="object")return null;const p=U[h.type];if(!p)return null;const b=typeof h.id=="string"&&h.id?h.id:B("mark"),j=Array.isArray(h.points)?h.points:[],S=[];for(const v of j){const R=Number(v&&v.x),O=Number(v&&v.y);Number.isFinite(R)&&Number.isFinite(O)&&S.push({x:R,y:O})}const y=typeof h.colour=="string"&&h.colour?h.colour:a;if(p==="text"){const v=typeof h.text=="string"?h.text:"";if(!S.length||!v)return null;const R={id:b,tool:p,colour:y,points:[S[0]],text:v,region:l(h.region)},O=Number(h.fontSize);return Number.isFinite(O)&&O>0&&(R.fontSize=O),typeof h.background=="string"&&h.background&&(R.background=h.background),R}return S.length<2?null:{id:b,tool:p,colour:y,points:S,region:l(h.region)}}function l(h){return h==="start"||h==="end"?h:"centre"}function c(h){const a={id:h.id,type:z[h.tool]||h.tool,colour:h.colour,points:h.points.map(p=>({x:p.x,y:p.y}))};return(h.region==="start"||h.region==="end")&&(a.region=h.region),h.tool==="text"&&(a.text=h.text,h.fontSize!==void 0&&(a.fontSize=h.fontSize),h.background!==void 0&&(a.background=h.background)),a}const s="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(h){return h==="arrow"||h==="rect"}function r(h,a){return{id:h,count:a,valueOf(){return this.count}}}const o=10;function f(h,a,p){const b=p.x-a.x,j=p.y-a.y,S=b*b+j*j;let y=S?((h.x-a.x)*b+(h.y-a.y)*j)/S:0;y=Math.max(0,Math.min(1,y));const v=a.x+y*b,R=a.y+y*j;return Math.hypot(h.x-v,h.y-R)}function u(h){const a=h.points;if(!a.length)return null;if(h.tool==="text"){const y=h.fontSize||w,v=(h.text||"").length*y*.6;return{x1:a[0].x,y1:a[0].y,x2:a[0].x+v,y2:a[0].y+y*1.2}}let p=1/0,b=1/0,j=-1/0,S=-1/0;for(const y of a)p=Math.min(p,y.x),b=Math.min(b,y.y),j=Math.max(j,y.x),S=Math.max(S,y.y);return{x1:p,y1:b,x2:j,y2:S}}function i(h,a){const p=u(h);if(!p)return 1/0;if(h.tool==="text"||h.tool==="rect"){if(a.x>=p.x1&&a.x<=p.x2&&a.y>=p.y1&&a.y<=p.y2)return 0;if(h.tool==="text")return 1/0}const b=h.points;if(h.tool==="rect"){const S=[{x:p.x1,y:p.y1},{x:p.x2,y:p.y1},{x:p.x2,y:p.y2},{x:p.x1,y:p.y2}];let y=1/0;for(let v=0;v<4;v++)y=Math.min(y,f(a,S[v],S[(v+1)%4]));return y}if(b.length===1)return Math.hypot(a.x-b[0].x,a.y-b[0].y);let j=1/0;for(let S=0;S<b.length-1;S++)j=Math.min(j,f(a,b[S],b[S+1]));return j}class m{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;#c=null;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#u=Array.isArray(a.seed)?a.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#m()})),this.#d(),this.#p(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(a){const p=g(a,this.#i);return p?(p.durable=!0,this.#s.push(p),this.#T(),this.redraw(),this.#E(),r(p.id,this.#s.length)):(I("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${H.join(", ")}) and at least two finite {x, y} points in content coordinates.`),r(null,this.#s.length))}list(){return this.#s.map(c)}remove(a){const p=this.#s.findIndex(b=>b.id===a);return p<0?(I("annotate.remove.unknown",`annotate.remove ignored an unknown id: "${a}".`),!1):(this.#s.splice(p,1),this.#c===a&&(this.#c=null),this.redraw(),this.#E(),!0)}replaceAll(a){const p=Array.isArray(a)?a:[];this.#s=p.map(b=>g(b,this.#i)).filter(Boolean);for(const b of this.#s)b.durable=!0;this.#s.length&&this.#T(),this.redraw(),this.#E()}#d(){const a=this.#t.viewport?.root;if(!a||!$(a.addEventListener))return;const p=b=>{if(!(!this.#o||!b)){if(b.key==="Escape"){this.use(null),b.preventDefault?.();return}if(this.#o==="erase"){if(b.key==="Tab"){this.#f(b);return}(b.key==="Delete"||b.key==="Backspace")&&this.#h(b)}}};a.addEventListener("keydown",p,!0),this.#a.push(()=>a.removeEventListener("keydown",p,!0))}#f(a){if(!this.#s.length){this.#x("a11y.annotate.noMarks");return}a.preventDefault?.();const p=this.#c?this.#s.findIndex(S=>S.id===this.#c):-1,b=a.shiftKey?-1:1,j=p<0?b>0?0:this.#s.length-1:(p+b+this.#s.length)%this.#s.length;this.#c=this.#s[j].id,this.redraw(),this.#x("a11y.annotate.focusedMark",{at:j+1,of:this.#s.length})}#h(a){if(!this.#c)return;a.preventDefault?.();const p=this.#c;this.remove(p),this.#x("a11y.annotate.erased")}#p(){const a=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!a||!$(a.matchMedia))return;let p=null;const b=()=>{const j=a.devicePixelRatio||1;let S;try{S=a.matchMedia(`(resolution: ${j}dppx)`)}catch{return}p=S;const y=()=>{this.redraw(),b()};$(S.addEventListener)?S.addEventListener("change",y,{once:!0}):$(S.addListener)&&S.addListener(y)};b(),this.#a.push(()=>{p=null})}use(a,p={}){const b=!!p.colour&&a===this.#o;p.colour&&(this.#i=String(p.colour));const j=a&&W.includes(a)?a:null;this.#o=j&&j===this.#o&&!b?null:j,this.#o!=="erase"&&(this.#c=null);const S=this.#o?this.#T():this.#n;return S&&(S.style.pointerEvents=this.#o?"auto":"none",S.style.cursor=this.#o?"crosshair":""),this.#E(),this.#o}undo(){const a=this.#s.pop();return a&&this.#c===a.id&&(this.#c=null),this.redraw(),this.#E(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#E())}#m(){const a=this.#s.filter(p=>p.durable);a.length!==this.#s.length&&(this.#s=a,this.redraw(),this.#E())}redraw(){!this.#n&&this.#s.length&&this.#T();const a=this.#n,p=this.#r;if(!a||!p)return;this.#M();const{left:b,top:j}=this.#j();p.clearRect(0,0,a.width,a.height);const S=this.#l?[...this.#s,this.#l]:this.#s;for(const y of["centre","start","end"]){const v=S.filter(R=>l(R.region)===y);if(v.length){p.save(),this.#g(p,y),p.translate((y==="centre"?-b:0)||0,-j||0);for(const R of v)this.#y(p,R),R.id===this.#c&&this.#k(p,R);p.restore()}}}#g(a,p="centre"){const b=this.#n,j=this.#t.viewport?.bodyViewport;if(!$(b?.getBoundingClientRect)||!$(j?.getBoundingClientRect))return;const S=b.getBoundingClientRect(),y=j.getBoundingClientRect();if(!y.width||!y.height)return;const v=this.#b(p,y);v&&(a.beginPath(),a.rect(v.left-S.left,y.top-S.top,v.width,y.height),a.clip())}#b(a,p){const b=O=>{if(!$(O?.getBoundingClientRect))return null;const x=O.getBoundingClientRect();return x&&x.width>0?{left:x.left,width:x.width}:null},j=b(this.#t.viewport?.bodyStart),S=b(this.#t.viewport?.bodyEnd);if(a==="start")return j;if(a==="end")return S;let y=p.left,v=p.left+p.width;const R=p.left+p.width/2;for(const O of[j,S]){if(!O)continue;const x=O.left+O.width;O.left+O.width/2<R?y=Math.max(y,x):v=Math.min(v,O.left)}return v>y?{left:y,width:v-y}:null}#w(a){for(const[p,b]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!$(b?.getBoundingClientRect))continue;const j=b.getBoundingClientRect();if(j&&j.width>0&&a>=j.left&&a<j.left+j.width)return p}return"centre"}#S(a){const p=this.#t.viewport?.bodyViewport;if(!$(p?.getBoundingClientRect))return!0;const b=p.getBoundingClientRect();return!b.width||!b.height?!0:a.clientX>=b.left&&a.clientX<=b.right&&a.clientY>=b.top&&a.clientY<=b.bottom}#y(a,p){const b=p.points;if(!b.length)return;const j=this.#e.presentation?.scale||1;a.lineWidth=(n[p.tool]||3)*j,a.strokeStyle=p.colour,a.fillStyle=p.colour,a.lineCap="round",a.lineJoin="round",a.globalAlpha=p.tool==="highlight"?.32:1;const S=b[0],y=b[b.length-1];if(p.tool==="text"){const v=(p.fontSize||w)*j;a.font=`${v}px ${k}`,a.textBaseline="top";const R=p.text||"";if(p.background){let O=R.length*v*.6;if(typeof a.measureText=="function"){const x=a.measureText(R);x&&Number.isFinite(x.width)&&(O=x.width)}a.fillStyle=p.background,a.fillRect(S.x-v*.15,S.y-v*.1,O+v*.3,v*1.2)}a.fillStyle=p.colour,a.fillText(R,S.x,S.y),a.globalAlpha=1;return}if(p.tool==="rect")a.strokeRect(S.x,S.y,y.x-S.x,y.y-S.y);else if(p.tool==="arrow")a.beginPath(),a.moveTo(S.x,S.y),a.lineTo(y.x,y.y),a.stroke(),this.#O(a,S,y,a.lineWidth);else{a.beginPath(),a.moveTo(S.x,S.y);for(let v=1;v<b.length;v++)a.lineTo(b[v].x,b[v].y);a.stroke()}a.globalAlpha=1}#O(a,p,b,j){const S=Math.atan2(b.y-p.y,b.x-p.x),y=Math.max(8,j*3);a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(b.x-y*Math.cos(S-Math.PI/7),b.y-y*Math.sin(S-Math.PI/7)),a.lineTo(b.x-y*Math.cos(S+Math.PI/7),b.y-y*Math.sin(S+Math.PI/7)),a.closePath(),a.fill()}#k(a,p){const b=u(p);if(!b||!$(a.strokeRect))return;const j=6;a.save(),a.setLineDash?.([4,3]),a.strokeStyle="#1a73e8",a.lineWidth=2,a.globalAlpha=1,a.strokeRect(b.x1-j,b.y1-j,b.x2-b.x1+j*2,b.y2-b.y1+j*2),a.restore()}#A(a,p){const b=this.#e.presentation?.scale||1,j=o*b;for(let S=this.#s.length-1;S>=0;S--){const y=this.#s[S];if(l(y.region)===p&&i(y,a)<=j)return y}return null}#j(){const a=$(this.#t.scrollPosition)?this.#t.scrollPosition():null,p=this.#t.viewport?.rtl===!0;return{left:X(a?.left||0,p),top:a?.top||0}}#T(){if(this.#n)return this.#n;const a=this.#t.viewport?.overlays,p=a?.ownerDocument;if(!a||!p?.createElement)return null;const b=p.createElement("canvas");return b.className=s,b.style.position="absolute",b.style.inset="0",b.style.pointerEvents="none",a.appendChild(b),this.#n=b,this.#r=b.getContext?b.getContext("2d"):null,this.#M(),this.#C(b),b}#M(){const a=this.#n,p=this.#t.viewport?.root;if(!a||!p?.getBoundingClientRect)return;const b=p.getBoundingClientRect(),S=a.ownerDocument?.defaultView?.devicePixelRatio||1,y=Math.max(1,Math.round(b.width*S)),v=Math.max(1,Math.round(b.height*S));a.width===y&&a.height===v||(a.width=y,a.height=v,a.style&&(a.style.width=`${Math.max(1,b.width)}px`,a.style.height=`${Math.max(1,b.height)}px`),this.#r?.setTransform(S,0,0,S,0,0))}#C(a){const p=(v,R="centre")=>{const O=a.getBoundingClientRect(),{left:x,top:C}=this.#j();return{x:v.clientX-O.left+(R==="centre"?x:0),y:v.clientY-O.top+C}},b=v=>{if(!this.#o||!this.#S(v))return;const R=this.#w(v.clientX);if(this.#o==="erase"){const O=this.#A(p(v,R),R);O&&(this.remove(O.id),this.#x("a11y.annotate.erased")),v.preventDefault?.();return}this.#l={id:B("mark"),tool:this.#o,colour:this.#i,points:[p(v,R)],region:R},a.setPointerCapture?.(v.pointerId),v.preventDefault?.()},j=v=>{if(!this.#l)return;const R=p(v,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(R),this.redraw()},S=v=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,a.releasePointerCapture?.(v.pointerId),this.redraw(),this.#E())},y=v=>{if(!this.#o)return;const R=this.#t.viewport?.bodyViewport;if(!R)return;let O=!1;v.deltaY&&typeof R.scrollTop=="number"&&(R.scrollTop+=v.deltaY,O=!0),v.deltaX&&typeof R.scrollLeft=="number"&&(R.scrollLeft+=v.deltaX,O=!0),O&&v.preventDefault?.()};a.addEventListener("pointerdown",b),a.addEventListener("pointermove",j),a.addEventListener("pointerup",S),a.addEventListener("pointercancel",S),a.addEventListener("wheel",y,{passive:!1}),this.#a.push(()=>{a.removeEventListener("pointerdown",b),a.removeEventListener("pointermove",j),a.removeEventListener("pointerup",S),a.removeEventListener("pointercancel",S),a.removeEventListener("wheel",y)})}#E(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#L(a,p){const b=this.#e.messages;return b&&$(b.t)?b.t(a,p):a}#x(a,p){this.#t.announce?.(this.#L(a,p),{repeat:!0})}destroy(){for(const a of this.#a)a();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const d=m}),Fe("packages/dom/src/timelinebar.js",function(e,K){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-timeline";function X(z){if(!Number.isFinite(z)||z<1e3)return"now";const w=Math.round(z/1e3);if(w<60)return`${w}s ago`;const k=Math.round(w/60);return k<60?`${k}m ago`:`${Math.round(k/60)}h ago`}function W(z,w){return Number.isFinite(z)?new Date(z).toLocaleTimeString(w||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class H{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=[];constructor(w){this.#e=w.grid,this.#t=w.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const w=this.#e.timeline,k=w.depth,g=w.position;this.#r.max=String(Math.max(1,k)),this.#r.value=String(Math.max(0,k-g)),this.#r.disabled=k===0;const l=w.at(),c=w.live;this.#o&&(this.#o.textContent=c?this.#l("timeline.live"):X(Date.now()-(l||Date.now())),this.#o.setAttribute("data-live",c?"true":"false")),this.#i&&(this.#i.textContent=k===0?this.#l("timeline.recording"):W(l,this.#e.get("locale"))),this.#n.setAttribute("data-live",c?"true":"false")}#l(w,k){const g=this.#e;return(g&&g.messages?g.messages:I).t(w,k)}#a(){if(this.#n)return;const w=this.#t.viewport?.overlays,k=w?.ownerDocument;if(!w||!k?.createElement)return;const g=k.createElement("div");g.className=_;const l=k.createElement("span");l.className=`${_}__ago`,l.setAttribute("role","status"),l.setAttribute("aria-live","polite");const c=k.createElement("input");c.className=`${_}__range`,c.type="range",c.min="0",c.step="1",c.setAttribute("aria-label",this.#l("timeline.scrub"));const s=k.createElement("span");s.className=`${_}__clock`;const n=k.createElement("button");n.className=`${_}__live`,n.type="button",n.textContent=this.#l("timeline.goLive"),n.setAttribute("aria-label",this.#l("timeline.returnToPresent")),g.appendChild(l),g.appendChild(c),g.appendChild(s),g.appendChild(n),w.appendChild(g),this.#n=g,this.#r=c,this.#o=l,this.#i=s;const t=()=>{const f=this.#e.timeline.depth;this.#e.timeline.seek(f-Number(c.value))};c.addEventListener("input",t);const r=()=>this.#e.timeline.toLive();n.addEventListener("click",r);const o=f=>f.stopPropagation();c.addEventListener("keydown",o),this.#s.push(()=>{c.removeEventListener("input",t),n.removeEventListener("click",r),c.removeEventListener("keydown",o)})}#u(){this.#n&&($(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const w of this.#s)w();this.#s=[],this.#u()}}const U=H}),Fe("packages/dom/src/commentpaint.js",function(e,K){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/direction.js").isRtlElement,W="lat-comment-mark",H="lat-cell--commented",U="lat-cell--commented-open";class z{#e;#t;#n=[];#r=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#s(),this.paint()}paint(){const g=this.#e.comments;if(!g||!g.enabled)return;const l=this.#t.viewport?.root;if(!l||!l.querySelectorAll)return;const c=[];for(const s of l.querySelectorAll("[data-key]")){const n=s.getAttribute("data-key");if(n){c.push(n);for(const t of s.querySelectorAll("[data-col]")){const r=t.getAttribute("data-col"),o=g.at(n,r),f=!!(o&&o.count);t.classList.toggle(H,f),t.classList.toggle(U,f&&o.unresolved>0),this.#i(t,o,r)}}}(c.length!==this.#r.length||c.some((s,n)=>s!==this.#r[n]))&&(this.#r=c,g.request(c))}#o(g,l){const c=this.#e;return(c&&c.messages?c.messages:I).t(g,l)}#i(g,l,c){if(!l||!l.count){g.hasAttribute("aria-description")&&g.removeAttribute("aria-description");return}const s=l.count,n=l.unresolved,t=this.#o("count.comments",{count:s});g.setAttribute("aria-description",n>0?this.#o("comments.someUnresolved",{comments:t,unresolved:n}):this.#o("comments.allResolved",{comments:t}))}#s(){const g=this.#t.viewport?.root;if(!g||!$(g.addEventListener))return;const l=s=>{const n=this.#e.comments;if(!n||!n.enabled)return;const t=s.target&&$(s.target.closest)?s.target.closest("[data-col]"):null;if(!t||!t.classList.contains(H)||!this.#l(t,s))return;const r=t.closest("[data-key]"),o=r&&r.getAttribute("data-key");o&&(s.stopPropagation(),s.preventDefault(),n.open(o,t.getAttribute("data-col")))},c=s=>{const n=this.#e.comments;if(!n||!n.enabled||!s.altKey||s.key!=="m"&&s.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&$(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const r=t.closest("[data-key]"),o=r&&r.getAttribute("data-key");o&&(s.preventDefault(),s.stopPropagation(),n.open(o,t.getAttribute("data-col")))};g.addEventListener("click",l,!0),g.addEventListener("keydown",c,!0),this.#n.push(()=>{g.removeEventListener("click",l,!0),g.removeEventListener("keydown",c,!0)})}#l(g,l){if(!$(g.getBoundingClientRect))return!1;const c=g.getBoundingClientRect(),s=Math.max(14,Math.min(24,c.height*.6));return(X(g)?l.clientX<=c.left+s:l.clientX>=c.right-s)&&l.clientY<=c.top+s}destroy(){for(const g of this.#n)g();this.#n=[]}}const w=z}),Fe("packages/dom/src/presencepaint.js",function(e,K){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/presence.js").CURSOR_LABEL_MS,U="lat-presence";class z{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=null;constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){const g=this.#e.presence;if(!(!g||!g.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const l of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(l,c=>this.#l(l,c)));this.#a(),this.paint()}}#l(g,l){if(this.#f(),g==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const s=l&&l.peer;s&&(this.#r.textContent=this.#h(g==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:s.name}))}#a(){const g=this.#t.viewport?.overlays,l=g?.ownerDocument;if(!g||!l?.createElement)return;const c=this.#e.get("presence")||{},s=l.createElement("span");if(s.className=`${U}__live`,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),g.appendChild(s),this.#r=s,c.roster===!1)return;const n=l.createElement("div");n.className=U,c.roster&&c.roster.side==="start"&&n.setAttribute("data-side","start"),n.style.pointerEvents="auto",g.appendChild(n),this.#n=n}paint(){const g=this.#e.presence,l=this.#t.viewport?.root;if(!g||!g.enabled||!l?.querySelectorAll)return;this.#d(l);const c=g.peers(),s=[...c].sort((n,t)=>n.at-t.at);for(const n of s)for(const t of n.ranges||[])for(const r of t.rowIds||[])for(const o of t.columns||[])this.#c(l,r,o,n,"range");for(const n of s)n.cursor&&this.#c(l,n.cursor.rowId,n.cursor.colId,n,"cursor");for(const n of s)n.editing&&this.#c(l,n.editing.rowId,n.editing.colId,n,"edit");this.#f(),this.#u(c)}#u(g){if(this.#s!==null)return;const l=g.filter(n=>n.cursorFresh);if(!l.length)return;const s=Math.max(...l.map(n=>n.cursorAt||0))+H-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,s))}#c(g,l,c,s,n){const t=g.querySelector(`[data-key="${X(l)}"]`),r=t&&t.querySelector(`[data-col="${X(c)}"]`);r&&(r.setAttribute("data-presence",n),r.style.setProperty("--lat-peer",s.colour),r.setAttribute("data-peer-name",s.name),r.setAttribute("data-peer-initial",s.initials||(s.name||"?").slice(0,1).toUpperCase()),s.idle?r.setAttribute("data-peer-idle","true"):r.removeAttribute("data-peer-idle"),n==="cursor"&&s.cursorFresh&&r.setAttribute("data-peer-fresh","true"),this.#o.add(`${l}${c}`))}#d(g){if(this.#o.size){for(const l of g.querySelectorAll("[data-presence]"))l.removeAttribute("data-presence"),l.removeAttribute("data-peer-name"),l.removeAttribute("data-peer-initial"),l.removeAttribute("data-peer-fresh"),l.removeAttribute("data-peer-idle"),l.style.removeProperty("--lat-peer");this.#o.clear()}}#f(){if(!this.#n)return;const g=this.#n.ownerDocument,l=this.#e.presence.peers();if(this.#n.textContent="",!l.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const s of l){const n=g.createElement("button");n.className=`${U}__peer`,n.type="button",n.style.setProperty("--lat-peer",s.colour),n.toggleAttribute("data-idle",!!s.idle),n.toggleAttribute("data-hidden",!!s.hidden);let t="presence.peer";s.hidden?t="presence.peerHidden":s.idle&&(t="presence.peerIdle"),n.setAttribute("aria-label",this.#h(t,{name:s.name}));const r=g.createElement("span");r.className=`${U}__dot`,r.setAttribute("aria-hidden","true"),r.textContent=s.initials||(s.name||"?").slice(0,1).toUpperCase(),n.appendChild(r);const o=g.createElement("span");o.className=`${U}__name`,o.textContent=s.name,n.appendChild(o),n.addEventListener("click",()=>this.#e.presence.jumpTo(s.id)),this.#n.appendChild(n)}const c=l.filter(s=>s.hidden).length;if(c){const s=g.createElement("span");s.className=`${U}__hidden`,s.textContent=this.#h("presence.hidden",{count:c}),this.#n.appendChild(s)}}announceRefusal(g){if(!this.#r)return;const l=g&&g.name?g.name:this.#h("presence.someoneElse");this.#r.textContent=this.#h("a11y.presence.refused",{name:l})}#h(g,l){const c=this.#e;return(c&&c.messages?c.messages:I).t(g,l)}destroy(){for(const l of this.#i)l();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const g=this.#t.viewport?.root;g?.querySelectorAll&&this.#d(g),this.#n&&$(this.#n.remove)&&this.#n.remove(),this.#r&&$(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const w=z}),Fe("packages/dom/src/commentpanel.js",function(e,K){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/comments.js").parseCellKey,U="lat-comments",z=/^(https?:|mailto:)/i,w='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function k(s,n){if(!Number.isFinite(s))return"";const t=Math.max(0,Math.round((n-s)/1e3));if(t<60)return"just now";const r=Math.round(t/60);if(r<60)return`${r}m ago`;const o=Math.round(r/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function g(s,n,t,r){n.textContent="";const o=String(t??"");if(!r){n.textContent=o;return}const f=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let u=0,i=f.exec(o);for(;i;){i.index>u&&n.appendChild(s.createTextNode(o.slice(u,i.index)));const m=i[0];if(m.startsWith("*")){const d=s.createElement("em");d.textContent=m.slice(1,-1),n.appendChild(d)}else if(m.startsWith("`")){const d=s.createElement("code");d.textContent=m.slice(1,-1),n.appendChild(d)}else{const d=m.indexOf("]("),h=m.slice(1,d),a=m.slice(d+2,-1);if(z.test(a)){const p=s.createElement("a");p.href=a,p.textContent=h,p.rel="noopener noreferrer",p.target="_blank",n.appendChild(p)}else n.appendChild(s.createTextNode(h))}u=i.index+m.length,i=f.exec(o)}u<o.length&&n.appendChild(s.createTextNode(o.slice(u)))}class l{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(n){this.#e=n.grid,this.#t=n.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",n=>this.#a(n))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#w(),this.#y()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(n){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#f(n.rowId,n.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#w(),this.#y(),this.#o&&$(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const n=this.#s;this.#s=null,n&&$(n.focus)&&n.focus()}#c(){const n=this.#e.comments.openKey;if(!n)return;const{rowId:t}=H(n);this.#e.rows.byKey(t)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(n){if(!this.#r)return;const r=this.#r.ownerDocument.createElement("p");r.className=`${U}__note`,r.setAttribute("role","status"),r.textContent=n,this.#r.appendChild(r)}#f(n,t){const r=this.#t.viewport?.root;if(!r||!r.querySelector)return null;const o=r.querySelector(`[data-key="${X(n)}"]`);return o?o.querySelector(`[data-col="${t}"]`):null}#h(n,t){const r=this.#e;return(r&&r.messages?r.messages:I).t(n,t)}#p(n){const t=n.createElement("div");t.className=U,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#h("comments.panel"));const r=n.createElement("header");r.className=`${U}__head`;const o=n.createElement("div");o.className=`${U}__title`,r.appendChild(o);const f=n.createElement("button");f.className=`${U}__resolve`,f.type="button",r.appendChild(f);const u=n.createElement("button");u.className=`${U}__close`,u.type="button",u.setAttribute("aria-label",this.#h("comments.close")),u.textContent="×",r.appendChild(u);const i=n.createElement("div");i.className=`${U}__list`,i.setAttribute("role","log"),i.setAttribute("aria-live","polite");const m=n.createElement("form");m.className=`${U}__composer`;const d=n.createElement("textarea");d.className=`${U}__input`,d.rows=2,d.setAttribute("aria-label",this.#h("comments.write"));const h=n.createElement("button");h.className=`${U}__send`,h.type="submit",h.textContent=this.#h("comments.post"),m.appendChild(d),m.appendChild(h),t.appendChild(r),t.appendChild(i),t.appendChild(m),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=i,this.#o=d,this.#m=o,this.#g=f;const a=S=>{S.preventDefault();const y=String(d.value||"").trim();y&&(d.value="",this.#e.comments.add(y))},p=()=>this.#e.comments.close(),b=()=>{this.#b()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},j=S=>{if(S.stopPropagation(),S.key==="Escape"){S.preventDefault(),this.#e.comments.close();return}if(S.key!=="Tab")return;const y=[...t.querySelectorAll(w)].filter(x=>x.offsetParent!==null||x===d);if(!y.length)return;const v=y[0],R=y[y.length-1],O=t.ownerDocument.activeElement;S.shiftKey&&O===v?(S.preventDefault(),R.focus()):!S.shiftKey&&O===R&&(S.preventDefault(),v.focus())};m.addEventListener("submit",a),u.addEventListener("click",p),f.addEventListener("click",b),t.addEventListener("keydown",j),this.#l.push(()=>{m.removeEventListener("submit",a),u.removeEventListener("click",p),f.removeEventListener("click",b),t.removeEventListener("keydown",j)})}#m=null;#g=null;#b(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#w(){const n=this.#e.comments;if(!this.#n||!n.openKey)return;const t=this.#n.ownerDocument,r=this.#e.get("comments")||{},o=Date.now(),f=n.openKey,{rowId:u,field:i}=H(f),m=this.#e.columns.get(i),d=this.#e.rows.byKey(u),h=$(r.rowLabel)&&d?r.rowLabel(d):u;if(this.#m.textContent=this.#h("comments.cellTitle",{column:m&&(m.title??m.id)||i,row:h}),this.#g.textContent=this.#b()>0?this.#h("comments.resolve"):this.#h("comments.reopen"),this.#r.textContent="",n.loading){this.#d(this.#h("comments.loading"));return}const a=n.thread||[];if(!a.length){this.#d(this.#h("comments.empty"));return}const p=d&&m?m.getValue(d.data,d):void 0;for(const b of a)this.#r.appendChild(this.#S(t,b,o,p,r))}#S(n,t,r,o,f){const u=n.createElement("article");u.className=`${U}__item`,t.pending&&u.setAttribute("data-pending","true"),t.resolved&&u.setAttribute("data-resolved","true");const i=n.createElement("div");i.className=`${U}__meta`;const m=n.createElement("span");m.className=`${U}__author`,m.textContent=t.author&&(t.author.name||t.author.initials)||this.#h("comments.unknownAuthor"),i.appendChild(m);const d=n.createElement("time");d.className=`${U}__time`;const h=k(t.at,r);d.textContent=t.edited?this.#h("comments.edited",{time:h}):h,i.appendChild(d),u.appendChild(i);const a=n.createElement("div");if(a.className=`${U}__body`,g(n,a,t.body,!!f.markdown),u.appendChild(a),t.value!==void 0&&!Object.is(t.value,o)){const j=n.createElement("p");j.className=`${U}__moved`,j.textContent=this.#h("comments.valueMoved",{was:String(t.value),now:String(o)}),u.appendChild(j)}const p=t.can||{},b=j=>p[j]!==!1;if(b("edit")||b("delete")){const j=n.createElement("div");if(j.className=`${U}__actions`,b("delete")){const S=n.createElement("button");S.type="button",S.className=`${U}__action`,S.textContent=this.#h("comments.delete"),S.addEventListener("click",()=>this.#e.comments.remove(t.id)),j.appendChild(S)}u.appendChild(j)}return u}#y(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const t=this.#e.comments.openKey,{rowId:r,field:o}=H(t),f=this.#f(r,o)||this.#i,u=this.#t.viewport?.root;if(!f||!u||!$(f.getBoundingClientRect))return;const i=f.getBoundingClientRect(),m=u.getBoundingClientRect(),d=this.#n.getBoundingClientRect();let h=i.bottom-m.top+4;h+d.height>m.height&&i.top-m.top>d.height&&(h=i.top-m.top-d.height-4);let a=i.left-m.left;a+d.width>m.width&&(a=Math.max(0,m.width-d.width-4)),this.#n.style.top=`${Math.max(0,h)}px`,this.#n.style.left=`${Math.max(0,a)}px`;const p=i.bottom<m.top||i.top>m.bottom;this.#n.toggleAttribute("data-offscreen",p)}destroy(){for(const n of this.#l)n();this.#l=[],this.#n&&$(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const c=l}),Fe("packages/dom/src/watermark.js",function(e,K){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,H="lat-watermark",U="https://www.latticegrid.dev",z=["br","bl","tl","tr"],w=4e3;class k{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(c){this.#e=c.grid,this.#t=c.document,this.#n=c.element,this.#i=c.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),$(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const c=this.#e.licence&&this.#e.licence.ready;c&&$(c.then)&&c.then(()=>this.refresh(),()=>this.refresh())}refresh(){const c=this.#d();c&&!this.#r?(this.#f(),this.#u()):!c&&this.#r&&(this.#h(),this.#c())}#a(){const c=this.#i;if(!c||!$(c.matchMedia))return!1;try{return!!c.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),$(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#h();return}this.#s=(this.#s+1)%z.length,this.#h(),this.#f(),this.#u()},w)))}#c(){this.#l!==null&&$(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const c=this.#e.licence;return!!(c&&$(c.watermark)&&c.watermark())}#f(){const c=this.grid&&this.grid.messages?this.grid.messages:I,s=X(this.#t,"a",{class:`${H}__link`,text:c.t("licence.watermark"),attrs:{href:U,target:"_blank",rel:"noopener noreferrer"}}),n=X(this.#t,"span",{class:`${H}__free`,text:c.t("licence.watermark.free")});this.#r=X(this.#t,"div",{class:`${H} ${H}--${z[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[s,n]}),this.#o.push(W(this.#r,"pointerdown",t=>{$(t.stopPropagation)&&t.stopPropagation()})),this.#n&&$(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#h(){this.#r&&$(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const c of this.#o)c();this.#o=[],this.#h()}}const g=k}),Fe("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.isFunction,I=K("packages/dom/src/editors/common.js"),_=I.el,X=I.on,H=K("packages/dom/src/themeof.js").themeOf,U="lat-maximised",z={position:"fixed",top:"0px",left:"0px",right:"0px",bottom:"0px",width:"auto",height:"auto",minWidth:"0px",minHeight:"0px",maxWidth:"none",maxHeight:"none",margin:"0px",zIndex:"2147483000"},w="lat-maximised-host",k="lat-maximise-placeholder";class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(s){this.#e=s.element,this.#t=s.document,this.#n=B(s.onChange)?s.onChange:null,this.#r=B(s.captureScroll)?s.captureScroll:null,this.#o=B(s.restoreScroll)?s.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const s=this.#e.parentNode;if(!s||!this.#t.body)return $("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=_(this.#t,"div",{class:k}),this.#i.style.visibility="hidden";const n=this.#e.offsetWidth,t=this.#e.offsetHeight;n&&(this.#i.style.width=`${n}px`),t&&(this.#i.style.height=`${t}px`);const r=this.#r?this.#r():null,o=B(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?H(s):null;o&&(this.#e.setAttribute("data-theme",o),this.#u=!0),s.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[f,u]of Object.entries(z))this.#a[f]=this.#e.style[f]||"",this.#e.style[f]=u;return this.#c=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(U),this.#t.body.classList&&this.#t.body.classList.add(w),r&&this.#o&&this.#o(r),this.#s=X(this.#t,"keydown",f=>this.#f(f)),this.#h(),!0}exit(){if(!this.active())return!1;const s=this.#r?this.#r():null,n=this.#i,t=n.parentNode;if(t&&B(t.insertBefore)&&this.#d(()=>t.insertBefore(this.#e,n)),B(n.remove)&&n.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[r,o]of Object.entries(this.#a))this.#e.style[r]=o;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(U),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(w),s&&this.#o&&this.#o(s),this.#s&&this.#s(),this.#s=null,this.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(s){const n=this.#t.activeElement,t=n&&n!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(n)?n:null;s(),t&&B(t.focus)&&t.focus()}#f(s){!s||s.key!=="Escape"||s.defaultPrevented||this.exit()}#h(){this.#n&&this.#n();for(const s of this.#l)s(this.active())}watch(s){return B(s)?(this.#l.add(s),()=>this.#l.delete(s)):()=>{}}destroy(){this.exit()}}const l=g}),Fe("packages/dom/src/promptbar.js",function(e,K){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),$=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,z=K("packages/core/src/ai/schema.js"),w=z.describeGrid,k=z.promptText,g=K("packages/core/src/ai/intent.js"),l=g.applyPlan,c=g.buildPrompt,s=g.planIntent,n="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=null;#p=null;#m=null;#g=null;#b="idle";#w=0;#S=!1;#y=[];t(u,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(u,i)}init(u={}){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||W,this.#e=$(u),this.#t=u.grid||null,this.#n=U(u.ask)?u.ask:null,this.#r=u.schemaOptions||{},this.#o=u.context,this.#i={onPlan:U(u.onPlan)?u.onPlan:null,onApply:U(u.onApply)?u.onApply:null,onError:U(u.onError)?u.onError:null},this.#s=B(this.#e,"div",{class:n,attrs:{"data-state":"idle",role:"search"}}),this.#O(u)}element(){return this.#s}refresh(){this.#S||!this.#s||this.#b!=="busy"&&this.#T()}destroy(){this.#S=!0,this.#w++;for(const u of this.#y)u();this.#y.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#f=null,this.#h=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(u){if(this.#S||this.#b==="busy")return null;const i=String(u??(this.#l&&this.#l.value)??"").trim();if(!i)return null;if(!this.#n)return this.#C("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const m=++this.#w;this.#k("busy"),this.#M("Thinking…");let d;try{const h=w(this.#t,this.#r),a=k(h);if(d=await this.#n({prompt:i,schema:h,schemaText:a,message:c(i,a),context:this.#o}),this.#S||m!==this.#w)return null;const p=s(d,h);return this.#A(p),p}catch(h){return this.#S||m!==this.#w||(this.#i.onError&&this.#i.onError(h),this.#C(h instanceof Error?h.message:String(h))),null}}apply(){const u=this.#g;if(this.#S||!u||!u.ok)return null;const i=this.#t?.ai,m=U(i?.apply)?i.apply(u):l(u,this.#t);return this.#i.onApply&&this.#i.onApply(m,u),this.#T(),this.#l&&(this.#l.value=""),m.failed.length?this.#C(`Applied ${m.applied.length}; ${m.failed.map(d=>`${d.type} failed: ${d.reason}`).join("; ")}`):this.#M(`Applied: ${u.describe()}`),m}discard(){this.#S||(this.#T(),this.#M("Discarded."))}#O(u){const i=this.#e,m=B(i,"div",{class:`${n}__row`});this.#l=B(i,"input",{class:`${n}__input`,attrs:{type:"text",placeholder:u.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":u.label||"Ask about this grid",autocomplete:"off"}}),this.#y.push(I(this.#l,"keydown",h=>{const a=h&&h.key;a==="Enter"?(U(h.preventDefault)&&h.preventDefault(),this.ask()):a==="Escape"&&this.#g&&(U(h.preventDefault)&&h.preventDefault(),this.discard())})),m.appendChild(this.#l),this.#a=B(i,"button",{class:`${n}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#y.push(I(this.#a,"click",()=>{this.ask()})),m.appendChild(this.#a),this.#s.appendChild(m),this.#u=B(i,"div",{class:`${n}__preview`,attrs:{hidden:!0}}),this.#c=B(i,"p",{class:`${n}__summary`}),this.#d=B(i,"ul",{class:`${n}__notes`});const d=B(i,"div",{class:`${n}__buttons`});this.#f=B(i,"button",{class:`${n}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#h=B(i,"button",{class:`${n}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#y.push(I(this.#f,"click",()=>{this.apply()})),this.#y.push(I(this.#h,"click",()=>{this.discard()})),d.appendChild(this.#f),d.appendChild(this.#h),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(d),this.#s.appendChild(this.#u),this.#p=B(i,"p",{class:`${n}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(i,"p",{class:`${n}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#k(u){if(this.#b=u,!this.#s)return;this.#s.setAttribute("data-state",u);const i=u==="busy";r(this.#l,i),r(this.#a,i),this.#a&&(this.#a.textContent=this.t(i?"prompt.asking":"prompt.ask")),o(this.#u,u!=="preview"),o(this.#m,u!=="error")}#A(u){const i=u;if(this.#i.onPlan&&this.#i.onPlan(u),!i.ok){this.#g=null;const m=i.rejected.length?i.rejected.map(d=>d.reason).join("; "):"nothing to do";this.#C(`I could not turn that into a change: ${m}`);return}this.#g=u,this.#M(""),this.#c&&(this.#c.textContent=i.describe()),this.#j(i.rejected),this.#k("preview")}#j(u){const i=this.#d;if(i){_(i),o(i,!u.length);for(const m of u.slice(0,6))i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:m.reason}));u.length>6&&i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:this.t("prompt.moreNotes",{count:u.length-6})}))}}#T(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&_(this.#d),this.#k("idle")}#M(u){this.#p&&(this.#p.textContent=u)}#C(u){this.#g=null,this.#M(""),this.#m&&(this.#m.textContent=u),this.#k("error")}}function r(f,u){f&&(f.disabled=u,u?f.setAttribute("disabled",""):f.removeAttribute("disabled"))}function o(f,u){f&&(f.hidden=u,u?f.setAttribute("hidden",""):f.removeAttribute("hidden"))}}),Fe("packages/dom/src/stat.js",function(e,K){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.isObject,I=Q.warnOnce,X=K("packages/core/src/source/derive.js").reduceValues,H=K("packages/core/src/source/memory.js").isPipelineSettle,z=K("packages/core/src/i18n/index.js").defaultMessages,k=K("packages/dom/src/cell/icons.js").renderIconInto,g={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},l="unknown",c=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),s=Object.freeze({direction:"flat",change:null,percent:null});function n(a,p){if(!Number.isFinite(a)||!Number.isFinite(p))return s;const b=a-p,j=b>0?"up":b<0?"down":"flat",S=p===0?null:b/Math.abs(p)*100;return{direction:j,change:b,percent:S}}function t(a,p){return a==="flat"||p==="neither"?"flat":a===p?"good":"bad"}function r(a,p,b=null){if($(p)){const O=p(a,b);return O==="good"||O==="warn"||O==="bad"?O:null}if(!B(p))return null;const j=typeof a=="number"&&Number.isFinite(a)?a:null;if(j===null)return null;const S=Number.isFinite(Number(p.good))?Number(p.good):null,y=Number.isFinite(Number(p.warn))?Number(p.warn):null,v=String(p.direction||"up")==="down",R=O=>v?j<=O:j>=O;return S!==null&&R(S)?"good":y!==null&&R(y)?"warn":S===null&&y===null?null:"bad"}function o(a){return!($(a.value)||a.value!==void 0&&!B(a.value))}function f(a){return!a||!a.rows||!$(a.rows.totalCount)?!0:a.rows.totalCount()>0}function u(a){const p=B(a)?a:{},b=p.grid||null,j=d(p.container,b);if(!j)return I("stat.container","createStat needs a `container`: an element or a selector."),h();const S=j.ownerDocument||(typeof document>"u"?null:document);if(!S)return I("stat.document","createStat needs a document; it draws DOM."),h();const y=S.createElement("div");y.className=["lattice",g.root,p.class].filter(Boolean).join(" "),y.setAttribute("role","group");const v=S.createElement("div");v.className=g.title;const R=S.createElement("div");R.className=g.value;const O=S.createElement("div");O.className=g.interval;const x=S.createElement("div");x.className=g.delta;const C=S.createElement("div");C.className=g.footer;const P=S.createElement("div");if(P.className=g.note,P.hidden=!0,p.icon!=null&&p.icon!==""){const te=S.createElement("span");te.className=g.icon,te.setAttribute("aria-hidden","true"),k(te,p.icon,`stat:${p.title||"stat"}`),y.appendChild(te);const ne=S.createElement("div");ne.className=g.body,ne.appendChild(v),ne.appendChild(R),ne.appendChild(P),ne.appendChild(O),ne.appendChild(x),ne.appendChild(C),y.appendChild(ne)}else y.appendChild(v),y.appendChild(R),y.appendChild(P),y.appendChild(O),y.appendChild(x),y.appendChild(C);j.appendChild(y);let E=null;const D=[];let N=!1;function M(){if($(p.value))return p.value(b);if(p.value!==void 0&&!B(p.value))return p.value;const te=B(p.value)?p.value:p,ne=te.of,oe=te.fn||"sum",le=te.show;return b?oe==="count"?L().length:ne?le?G(String(ne),String(oe),String(le)):A()==="filtered"&&b.statistics&&$(b.statistics.reduce)?b.statistics.reduce(String(ne),String(oe)):X(L().map(ae=>m(ae,String(ne))),String(oe)):null:null}function A(){return String(p.scope||"filtered")}function L(){if(!b||!b.rows)return[];const te=A();if(te==="all"){const oe=[];return $(b.rows.forEachAll)&&b.rows.forEachAll(le=>{le.group||oe.push(i(le))}),oe}if(te==="selected")return(b.selection&&$(b.selection.rows)?b.selection.rows():[]).filter(Boolean).map(i);const ne=[];return $(b.rows.forEach)&&b.rows.forEach(oe=>{oe.group||ne.push(i(oe))}),ne}function G(te,ne,oe){if(ne!=="min"&&ne!=="max")return I(`stat.show.${ne}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${ne}" reduces to a value that no single row holds, so there is no row to report from.`),null;let le=null,ae=null;for(const se of L()){const ee=Number(m(se,te));Number.isFinite(ee)&&(le===null||(ne==="max"?ee>le:ee<le))&&(le=ee,ae=se)}return ae===null?null:m(ae,oe)}function q(te){if($(p.format))return String(p.format(te,b));if(te==null)return p.empty??"—";const ne=B(p.value)?p.value:p,oe=ne.show||ne.of;if((ne.show?!0:c.has(String(ne.fn||"sum")))&&b&&oe&&$(b.columns?.get)){const ae=b.columns.get(String(oe));if(ae&&$(ae.formatValue))return ae.formatValue(te)}return typeof te=="number"?Number.isInteger(te)?String(te):te.toFixed(p.decimals??2):String(te)}function Y(te){return te?(b&&b.messages||z).t(`stat.tone.${te}`):""}function J(){if(N)return;const te=M(),ne=o(p)&&!!b&&!f(b),oe=ne?null:te,le=$(p.baseline)?p.baseline(b):p.baseline;E=oe,v.textContent=p.title??"",v.hidden=!p.title,R.textContent=q(oe),P.hidden=!ne,ne&&(P.textContent=b.messages.t("stat.noData"));const ae=ne||le===void 0||le===null?s:n(typeof oe=="number"?oe:null,Number(le)),se=t(ae.direction,p.goodWhen||"up");if(x.hidden=ae.change===null,ae.change!==null){const he=ae.direction==="up"?"↑":ae.direction==="down"?"↓":"→",me=ae.percent===null?q(Math.abs(ae.change)):`${Math.abs(ae.percent).toFixed(1)}%`;x.textContent=`${he} ${me}`,x.setAttribute("data-tone",se),x.setAttribute("data-direction",ae.direction)}const ee=$(p.interval)?p.interval(oe,b):null,ie=!!ee&&Number.isFinite(ee.lower)&&Number.isFinite(ee.upper);O.hidden=!ie,ie&&(O.textContent=`${q(ee.lower)} – ${q(ee.upper)}`,Number.isFinite(ee.confidence)&&O.setAttribute("title",`${Math.round(ee.confidence*100)}%`));const ce=ne?l:p.bands?r(oe,p.bands,b):null;ce?y.setAttribute("data-tone",ce):y.removeAttribute("data-tone"),C.textContent=$(p.footer)?String(p.footer(oe,b)):p.footer??"",C.hidden=!C.textContent,y.setAttribute("aria-label",[p.title,R.textContent,ne?P.textContent:"",ie?O.textContent:"",ae.change===null?"":x.textContent,ae.change===null?"":Y(se),C.textContent].filter(Boolean).join(", "))}if(b&&$(b.on)&&p.live!==!1)for(const te of["rows:changed","filter:changed","selection:changed","model:changed"]){const ne=oe=>{te==="model:changed"&&!H(oe)||J()};b.on(te,ne),D.push(()=>$(b.off)&&b.off(te,ne))}return J(),{element:()=>y,value:()=>E,refresh:J,destroy(){N=!0;for(const te of D)try{te()}catch{}D.length=0,y.remove()}}}function i(a){return B(a)&&"data"in a?a.data:a}function m(a,p){if(!B(a))return;if(!p.includes("."))return a[p];let b=a;for(const j of p.split(".")){if(!B(b))return;b=b[j]}return b}function d(a,p){if(a&&typeof a=="object")return a;if(typeof a!="string")return null;const b=p&&p.element&&p.element.ownerDocument||(typeof document>"u"?null:document);return b?b.querySelector(a):null}function h(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),Fe("packages/dom/src/kpistrip.js",function(e,K){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isObject,I=K("packages/dom/src/stat.js").createStat,_={band:"lat-kpi-strip"};class X{#e;#t;#n;#r=null;#o=[];constructor({grid:H,document:U,kpis:z}){this.#e=H,this.#t=U,this.#n=Array.isArray(z)?z.filter($):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const U=this.#t.createElement("div");U.className=`lattice ${_.band}`,U.setAttribute("role","group"),U.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=U;for(const z of this.#n){const w=I({...z,grid:this.#e,container:U});this.#o.push(w)}}destroy(){for(const H of this.#o)try{H.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),Fe("packages/dom/src/createGrid.js",function(e,K){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return Ct}});const $=K("packages/core/src/index.js").createHeadlessGrid,I=K("packages/core/src/defaults.js").applyDefaults,X=K("packages/core/src/export/download.js").downloadBlob,W=K("packages/core/src/internal/util.js"),H=W.fail,U=W.isFunction,z=W.warnOnce,k=K("packages/dom/src/localviews.js").createLocalViewStorage,l=K("packages/dom/src/renderer/index.js").DomRenderer,s=K("packages/dom/src/cell/index.js").createCellLayer,n=K("packages/dom/src/cell/icons.js"),t=n.icon,r=n.iconNames,f=K("packages/dom/src/editors/index.js").editors,i=K("packages/dom/src/filters/index.js").filters,m=K("packages/dom/src/ui/index.js"),d=m.StatusBar,h=m.TooltipManager,a=m.Pagination,p=m.GroupByZone,j=K("packages/dom/src/ui/celltooltip.js").CellTooltips,y=K("packages/dom/src/filtermenu.js").FilterMenu,R=K("packages/dom/src/columnmenu.js").ColumnMenu,x=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=K("packages/dom/src/rowreorder.js").RowReorder,E=K("packages/dom/src/alignedgrids.js").AlignedGrids,N=K("packages/dom/src/columntagbar.js").ColumnTagBar,A=K("packages/dom/src/anomalychip.js").AnomalyChip,G=K("packages/dom/src/rowform.js").RowForm,q=K("packages/dom/src/toolpanelmount.js"),Y=q.ToolPanelDock,J=q.panelHost,ne=K("packages/dom/src/celledit.js").CellEditController,le=K("packages/dom/src/editbar.js").EditBar,se=K("packages/dom/src/rangeselect.js").RangeController,ie=K("packages/core/src/model/selection.js").resolveSelectionConfig,he=K("packages/dom/src/importer.js").ImportController,Ee=K("packages/dom/src/historybar.js").HistoryBar,je=K("packages/dom/src/diffpaint.js").DiffPainter,we=K("packages/dom/src/detailhost.js").DetailHost,Ne=K("packages/dom/src/highlightpaint.js").HighlightPainter,Ve=K("packages/dom/src/findpaint.js").FindPainter,Ae=K("packages/dom/src/findbar.js").FindBar,Ze=K("packages/dom/src/redactpaint.js").RedactionPainter,at=K("packages/dom/src/validationpaint.js").ValidationPainter,mt=K("packages/dom/src/presentation.js").PresentationController,At=K("packages/dom/src/capture.js").captureElement,Tt=K("packages/dom/src/annotate.js").AnnotationLayer,Bt=K("packages/dom/src/timelinebar.js").TimelineBar,nt=K("packages/dom/src/commentpaint.js").CommentPainter,Se=K("packages/dom/src/presencepaint.js").PresencePainter,Ie=K("packages/dom/src/commentpanel.js").CommentPanel,Xe=K("packages/dom/src/watermark.js").Watermark,be=K("packages/dom/src/maximise.js").Maximiser,Ce=K("packages/dom/src/promptbar.js").PromptBar,Be=K("packages/dom/src/kpistrip.js").KpiStrip;function _e(Ke,dt,rt){const ut=dt==="redo"?"toolbar.redo":"toolbar.undo";return!rt||!rt.label?Ke(ut):Ke(dt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:rt.label})}const ke=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Te=2e3;function ze(Ke,dt,rt,ut){const kt=dt.annotate===!0?He(Ke,ut):[];if(dt.actions===!1)return[];if(dt.actions===void 0&&dt.side!=="left")return kt;const Nt=Array.isArray(dt.actions)?dt.actions:ke,gt=(Dt,tn)=>Ke.messages.t(Dt,tn),Mt={undo:{name:"undo",title:()=>_e(gt,"undo",Ke.history.peek("undo")),icon:"undo",run:()=>Ke.history.undo(),enabled:()=>Ke.history.canUndo()},redo:{name:"redo",title:()=>_e(gt,"redo",Ke.history.peek("redo")),icon:"redo",run:()=>Ke.history.redo(),enabled:()=>Ke.history.canRedo()},export:{name:"export",title:()=>gt("toolbar.exportCsv"),icon:"download",run:()=>Ke.export.csv({download:!0,fileName:dt.exportName})},excel:{name:"excel",title:()=>gt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ke.export.excel({download:!0,fileName:dt.exportName})},clipboard:{name:"clipboard",title:()=>gt("toolbar.clipboard"),icon:"copy",run:()=>Ke.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>gt("toolbar.print"),icon:"print",run:()=>Ke.export.print()},pause:{name:"pause",title:()=>{if(!Ke.updates.paused)return gt("toolbar.pause");const Dt=Ke.updates.stats().pending;return Dt?gt("toolbar.applyHeld",{count:Dt}):gt("toolbar.resume")},icon:()=>Ke.updates.paused?"play":"pause",run:()=>Ke.updates.paused?Ke.updates.resume():Ke.updates.pause()},restore:{name:"restore",title:()=>gt("toolbar.restoreView"),icon:"restore",run:()=>Ke.state.reset(),enabled:()=>Ke.state.modified()},maximise:{name:"maximise",title:()=>gt(rt&&rt.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>rt&&rt.active()?"minimise":"maximise",run:()=>rt.toggle()}};return rt||delete Mt.maximise,Nt.map(Dt=>Dt==="-"?{name:"-",separator:!0}:typeof Dt=="string"?Mt[Dt]:!Dt||typeof Dt!="object"||!Dt.name?null:{...Dt,run:U(Dt.run)?()=>Dt.run({grid:Ke,keys:Ke.selection&&U(Ke.selection.keys)?Ke.selection.keys():[],cells:Ke.selection&&U(Ke.selection.cells)?Ke.selection.cells():[]}):void 0}).filter(Boolean).concat(kt)}function He(Ke,dt){const rt={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},ut=(Nt,gt)=>Ke.messages.t(Nt,gt),kt=["pen","arrow","rect","highlight","erase"].map(Nt=>({name:Nt,title:()=>ut(`toolbar.annotate.${Nt}`),icon:rt[Nt],run:()=>Ke.annotate?.use(Nt),active:()=>Ke.annotate?.tool===Nt,annotation:!0}));return kt.push(Qe(Ke,ut,dt)),kt}function Qe(Ke,dt,rt){return{name:"clearAll",title:()=>dt("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(Ke.annotate?.count||0)>0,annotation:!0,run:()=>it(Ke,dt,rt)}}function it(Ke,dt,rt){const ut=Ke.toolPanel;if(!ut)return;const kt=gt=>rt?.announce?.(dt(gt),{repeat:!0});ut.removeAction("clearAll");const Nt=()=>{ut.removeAction("clearAllConfirm"),ut.removeAction("clearAllKeep"),ut.addAction(Qe(Ke,dt,rt))};ut.addAction({name:"clearAllConfirm",title:()=>dt("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{Ke.annotate?.clear(),Nt(),kt("a11y.annotate.cleared")}}),ut.addAction({name:"clearAllKeep",title:()=>dt("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>Nt()}),kt("a11y.annotate.confirmClear")}const st=["pen","arrow","rect","highlight","erase","clearAll"];function ot(Ke){let dt=null,rt=null;return Ke.on("source:error",ut=>{const kt=ut&&ut.error;rt=String(kt&&kt.message||"").replace(/^\[lattice\]\s*/,"")||(Ke.messages?Ke.messages.t("overlay.error"):"Something went wrong")}),Ke.on("rows:changed",()=>{rt=null}),{loadError:()=>rt,rowCount:()=>{if(U(Ke.rows.matchCount))return Ke.rows.matchCount();const ut=Ke.pagination&&U(Ke.pagination.get)?Ke.pagination.get():null;return ut&&Number.isFinite(ut.total)?ut.total:Ke.rows.count()},totalRowCount:()=>U(Ke.rows.totalCount)?Ke.rows.totalCount():Ke.rows.count(),selectedAcrossSource:()=>{dt||(dt=U(Ke.rendererHost)?Ke.rendererHost():{});const ut=U(dt.selectionSummary)?dt.selectionSummary():null;return ut&&ut.predicate?{count:ut.count}:null},selectedCount:()=>{const ut=Ke.selection&&Ke.selection.keys?Ke.selection.keys():null;return ut?ut.length:0},rangeValues:()=>{const ut=Ke.selection;return!ut||!U(ut.cells)?[]:ut.cells().map(({key:kt,colId:Nt})=>Ke.rows.value(kt,Nt))},hiddenUnresolved:()=>U(Ke.comments&&Ke.comments.hiddenUnresolved)?Ke.comments.hiddenUnresolved():0,progress:()=>U(Ke.source&&Ke.source.progress)?Ke.source.progress():null,updateStats:()=>Ke.updates?Ke.updates.stats():null}}function bt(Ke,dt){for(const[rt,ut]of Object.entries(f||{}))Ke.register("editor",rt,ut);for(const[rt,ut]of Object.entries(i||{}))Ke.register("filter",rt,ut);for(const[rt,ut]of Object.entries(dt.components||{}))Ke.register("component",rt,ut);for(const[rt,ut]of Object.entries(dt.pipes||{}))Ke.register("pipe",rt,ut);for(const[rt,ut]of Object.entries(dt.totalFns||{}))Ke.register("totalFn",rt,ut)}function vt(Ke,dt,rt,ut,kt,Nt){const gt=[],Mt=dt.viewport;let Dt=null;if(rt.maximise!==!1&&(Dt=new be({element:Nt,document:ut,onChange:()=>dt.invalidate("all"),captureScroll:()=>dt.scrollState(),restoreScroll:lt=>dt.restoreScroll(lt)}),Ke.maximise=Dt,gt.push(()=>Dt.destroy())),rt.statusBar){const lt=typeof rt.statusBar=="object"?rt.statusBar:{},wt=new d;wt.init({document:ut,host:ot(Ke),panels:lt.panels,registry:lt.registry,locale:Ke.get("locale"),messages:Ke.messages}),Mt.statusBar.appendChild(wt.element());const Rt=()=>{const sn=Mt.statusBar.offsetHeight||Mt.statusBar.getBoundingClientRect?.().height||0;Mt.root.style.setProperty("--lattice-status-height",`${Math.ceil(sn)}px`)},Ht=()=>{wt.refresh(),Rt()},Kt=["rows:changed","model:changed","source:error","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(sn=>Ke.on(sn,Ht));Ht(),Rt(),gt.push(()=>{for(const sn of Kt)sn();Mt.root.style.removeProperty("--lattice-status-height"),wt.destroy?.()})}const tn=ie(rt.selection);if(tn.ranges){const lt=new se({grid:Ke,renderer:dt,document:ut});lt.mount(),Ke.ranges=lt,gt.push(()=>lt.destroy())}if(rt.import){const lt=new he({grid:Ke,renderer:dt,document:ut,settings:typeof rt.import=="object"?rt.import:{}});Ke.importer=lt,gt.push(()=>lt.destroy())}if(rt.historyBar){const lt=typeof rt.historyBar=="object"?rt.historyBar.element:null,wt=new Ee;wt.init({document:ut,host:{undo:()=>Ke.history.undo(),redo:()=>Ke.history.redo(),canUndo:()=>Ke.history.canUndo(),canRedo:()=>Ke.history.canRedo(),peek:Ht=>Ke.history.peek(Ht),list:()=>Ke.history.list()},props:typeof rt.historyBar=="object"?rt.historyBar:{}}),(lt||Mt.root).appendChild(wt.element());const Rt=[Ke.on("history:changed",()=>wt.refresh())];Ke.historyBar=wt,gt.push(()=>{for(const Ht of Rt)Ht();wt.destroy()})}if(rt.diff){const lt=new je({grid:Ke,renderer:dt});lt.mount(),Ke.diffPainter=lt,gt.push(()=>lt.destroy())}if(rt.ai&&U(rt.ai.ask)){const lt=new Ce;lt.init({document:ut,grid:Ke,ask:rt.ai.ask,schemaOptions:rt.ai.schemaOptions,context:rt.ai.context,placeholder:rt.ai.placeholder});const wt=rt.ai.element||Mt.root;wt===Mt.root?wt.insertBefore(lt.element(),wt.firstChild):wt.appendChild(lt.element()),Ke.promptBar=lt,gt.push(()=>lt.destroy())}if(rt.groupPanel){const lt=typeof rt.groupPanel=="object"?rt.groupPanel:{},wt=new p;wt.init({document:ut,grid:Ke,host:J(Ke,ut,(Rt,Ht)=>dt.announce?.(Rt,Ht)),props:{header:Mt.header,hint:lt.hint}}),Mt.root.insertBefore(wt.element(),Mt.header),Ke.groupPanel=wt;for(const Rt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])U(Ke.on)&&gt.push(Ke.on(Rt,()=>wt.refresh()));gt.push(()=>wt.destroy())}if(rt.kpis){const lt=new Be({grid:Ke,document:ut,kpis:rt.kpis});lt.active&&(lt.mount(),Mt.root.insertBefore(lt.element(),Mt.header),Ke.kpiStrip=lt,gt.push(()=>lt.destroy()))}if(rt.toolPanel){const lt=typeof rt.toolPanel=="object"?rt.toolPanel:{},wt=new Y({grid:Ke,document:ut,root:Mt.root,panels:lt.panels,openPanel:lt.openPanel,side:lt.side,icons:lt.icons,actions:ze(Ke,lt,Dt,dt),announce:(Rt,Ht)=>dt.announce?.(Rt,Ht)});wt.mount(),Ke.toolPanel=wt,gt.push(()=>wt.destroy()),lt.annotate===void 0&&(gt.push(Ke.on("presentation:started",()=>{for(const Rt of He(Ke,dt))wt.addAction(Rt)})),gt.push(Ke.on("presentation:ended",()=>{for(const Rt of st)wt.removeAction(Rt)})))}if(!!rt.pagination&&(()=>{const lt=typeof rt.pagination=="object"?rt.pagination:{};return Ke.pagination.set({pageSize:Number(lt.pageSize)||100}),Ke.pagination.get().pageSize>0})()){const lt=typeof rt.pagination=="object"?rt.pagination:{},wt=new a;wt.init({document:ut,pageSize:lt.pageSize,pageSizes:lt.pageSizes,page:lt.page,total:lt.total,locale:Ke.get("locale"),messages:Ke.messages,onChange:({page:Kt,pageSize:sn})=>Ke.pagination.set({page:Kt,pageSize:sn})});const Rt=()=>{const Kt=Ke.pagination.get();wt.total=Kt.total,wt.counting=Kt.counting===!0,wt.hasMore=Kt.total==null&&Kt.pageCount>Kt.page+1,wt.page=Kt.page,wt.paint()};Ke.pagination.set({pageSize:wt.pageSize}),Rt();const Ht=["rows:changed","filter:changed","model:changed"].map(Kt=>Ke.on(Kt,Rt));Mt.statusBar.appendChild(wt.element()),gt.push(()=>{for(const Kt of Ht)Kt();wt.destroy?.()})}if(rt.edit!==!1)if(rt.editBar){const lt=new le({grid:Ke,document:ut,root:Mt.root});lt.mount(),Ke.editBar=lt,gt.push(()=>lt.destroy())}else{const lt=new ne({grid:Ke,document:ut,renderer:dt,registry:kt,cellLayer:dt.cellLayer});lt.mount(),gt.push(()=>lt.destroy())}const dn=new y({grid:Ke,document:ut,layer:Mt.overlays,registry:kt});dn.mount(),gt.push(()=>dn.destroy());const qt=new R({grid:Ke,document:ut,host:Mt.root,cellMenu:rt.contextMenu!==!1,headerMenu:rt.columnMenu!==!1,items:U(rt.contextMenu)?rt.contextMenu:void 0,headerItems:U(rt.columnMenu)?rt.columnMenu:void 0});if(qt.mount(),gt.push(()=>qt.destroy()),Array.isArray(rt.alignedGrids)&&rt.alignedGrids.length){const lt=new E;lt.add(Ke);for(const wt of rt.alignedGrids)wt&&wt!==Ke&&lt.add(wt);gt.push(()=>lt.destroy())}const _t=new G({grid:Ke,renderer:dt,document:ut,registry:kt});_t.active&&(_t.mount(),gt.push(()=>_t.destroy())),Object.defineProperty(Ke,"form",{configurable:!0,value:Object.freeze({open(lt){return _t.active?_t.openRow(lt):!1},openNew(lt){return _t.active?_t.openNew(lt):(z("rowform:off","grid.form.openNew() was called on a grid with no row form (rowForm is off, or no renderer is attached); nothing opened."),!1)},close(){_t.active&&_t.close()},save(){return _t.active?_t.save():!1},isOpen(){return _t.active?_t.open:!1}})}),gt.push(()=>{delete Ke.form}),Object.defineProperty(Ke,"icons",{configurable:!0,value:Object.freeze({get(lt){const wt=t(lt);return wt?{viewBox:wt.viewBox,paths:wt.paths.slice(),paint:wt.paint==="stroke"?"stroke":"fill"}:null},names(){return r()}})}),gt.push(()=>{delete Ke.icons});const Et=new N({grid:Ke,renderer:dt,document:ut});Et.active&&(Et.mount(),gt.push(()=>Et.destroy()));const xt=new A({grid:Ke,renderer:dt,document:ut});xt.active&&(xt.mount(),gt.push(()=>xt.destroy()));const Ut=new P({grid:Ke,renderer:dt,document:ut});if(Ut.active){Ut.mount(),Ut.paint();const lt=Ke.on("render:done",()=>Ut.paint());gt.push(()=>{lt(),Ut.destroy()})}if(rt.shortcuts!==!1){const lt=new x({grid:Ke,renderer:dt});lt.mount(),gt.push(()=>lt.destroy())}const Wt=new Ne({grid:Ke,renderer:dt,window:ut.defaultView||void 0});Wt.mount(),gt.push(()=>Wt.destroy());const Qt=new Ve({grid:Ke,renderer:dt,window:ut.defaultView||void 0});if(Qt.mount(),gt.push(()=>Qt.destroy()),rt.find!==!1){const lt=new Ae({grid:Ke,renderer:dt,document:ut,settings:rt.find});lt.mount(),gt.push(()=>lt.destroy())}const Yt=new Ze({grid:Ke,renderer:dt});Yt.mount(),gt.push(()=>Yt.destroy());const Jt=new at({grid:Ke,renderer:dt});Jt.mount(),gt.push(()=>Jt.destroy());const rn=new mt({grid:Ke,renderer:dt,maximiser:Dt});rn.mount(),gt.push(()=>rn.destroy());const en=new Bt({grid:Ke,renderer:dt});en.mount(),gt.push(()=>en.destroy()),rt.environment||Ke.set("environment",()=>({userAgent:typeof navigator=="object"&&navigator?navigator.userAgent:void 0,hardwareConcurrency:typeof navigator=="object"&&navigator?navigator.hardwareConcurrency:void 0,devicePixelRatio:typeof window=="object"&&window?window.devicePixelRatio:void 0,viewport:typeof window=="object"&&window?{width:window.innerWidth,height:window.innerHeight}:void 0,crossOriginIsolated:typeof globalThis.crossOriginIsolated=="boolean"?globalThis.crossOriginIsolated:void 0}));let cn=null;for(const[lt,wt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])gt.push(Ke.on(lt,()=>{cn=wt}));gt.push(Ke.on("render:done",lt=>{Ke.diagnostics.render(cn||lt.cause,lt.phases),cn=null}));const ln=ut.defaultView;if(ln&&U(ln.requestAnimationFrame)){let lt=ln.requestAnimationFrame(function wt(Rt){Ke.diagnostics.frame(Rt),lt=ln.requestAnimationFrame(wt)});gt.push(()=>{U(ln.cancelAnimationFrame)&&ln.cancelAnimationFrame(lt)})}const yn=new Se({grid:Ke,renderer:dt});if(yn.mount(),gt.push(()=>yn.destroy()),gt.push(Ke.on("presence:lockRefused",lt=>yn.announceRefusal(lt.peer))),Ke.presence&&Ke.presence.enabled){for(const Rt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])gt.push(Ke.on(Rt,()=>Ke.presence.publish()));let lt="";gt.push(Ke.on("render:done",()=>{const Rt=dt.focusState&&dt.focusState(),Ht=Rt?`${Rt.rowKey}${Rt.colId}`:"";Ht!==lt&&(lt=Ht,Ke.presence.publish())}));const wt=Nt.ownerDocument;if(wt&&U(wt.addEventListener)){const Rt=()=>Ke.presence.setPaused(wt.visibilityState==="hidden");wt.addEventListener("visibilitychange",Rt),Rt(),gt.push(()=>wt.removeEventListener("visibilitychange",Rt))}}const bn=new nt({grid:Ke,renderer:dt});bn.mount(),gt.push(()=>bn.destroy());const wn=new Ie({grid:Ke,renderer:dt});wn.mount(),gt.push(()=>wn.destroy()),gt.push(Ke.on("facet:computed",()=>dt.refreshHeader?.())),tn&&tn.headerCheckbox===!0&&gt.push(Ke.on("selection:changed",()=>dt.refreshHeader?.())),gt.push(Ke.on("facet:expanded",()=>dt.invalidate("columns"))),gt.push(Ke.on("model:changed",()=>dt.invalidate("rows")));const Zt=(lt,wt)=>dt.announce?.(lt,wt),fn=Ke.messages,Gt=(lt,wt)=>fn.t(lt,wt),gn=lt=>Gt("count.rows",{count:lt});gt.push(Ke.on("sort:changed",()=>{const lt=Ke.sort.get();if(!lt.length){Zt(Gt("a11y.sort.cleared"));return}const wt=lt.map(Rt=>{const Ht=Ke.columns.get(Rt.col);return Gt("a11y.sort.column",{column:Ht&&Ht.title||Rt.col,direction:Gt(Rt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Zt(Gt("a11y.sort.by",{columns:fn.list(wt)}))})),gt.push(Ke.on("filter:changed",()=>{const lt=Ke.rows.matchCount?Ke.rows.matchCount():Ke.rows.count();if(lt===null)return;const wt=Ke.rows.totalCount?Ke.rows.totalCount():lt;Zt(lt===wt?Gt("a11y.filter.cleared",{rows:gn(wt)}):Gt("a11y.filter.applied",{shown:gn(lt),total:gn(wt)}))})),gt.push(Ke.on("selection:changed",()=>{const lt=Ke.selection.keys().length;Zt(lt===0?Gt("a11y.selection.cleared"):Gt("a11y.selection.count",{count:lt}))})),gt.push(Ke.on("group:toggled",lt=>{const wt=Ke.rows.byKey?Ke.rows.byKey(lt.key):null,Rt=(wt&&(wt.groupLabel??wt.groupValue))??lt.key;Zt(Gt(lt.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Rt,rows:gn(Ke.rows.count())}))})),gt.push(Ke.on("column:grouped",lt=>{const wt=Array.isArray(lt.columns)?lt.columns:[];if(!wt.length){Zt(Gt("a11y.group.cleared"));return}const Rt=wt.map(Ht=>{const Kt=Ke.columns.get(Ht);return Kt&&Kt.title||Ht});Zt(Gt("a11y.group.by",{columns:fn.list(Rt)}))})),gt.push(Ke.on("page:changed",lt=>{const wt=Number(lt.size)||0,Rt=Number(lt.total)||0,Ht=wt>0?Math.max(1,Math.ceil(Rt/wt)):1;Zt(Gt("a11y.page.position",{page:(Number(lt.page)||0)+1,pages:Ht}))}));let on={added:0,removed:0},Xt=null;const Ln=()=>{Xt=null;const lt=[];on.added&&lt.push(Gt("count.rowsAdded",{count:on.added})),on.removed&&lt.push(Gt("count.rowsRemoved",{count:on.removed})),on={added:0,removed:0},lt.length&&Zt(fn.list(lt))};gt.push(Ke.on("rows:changed",lt=>{if(!lt||typeof lt.added!="number")return;const wt=Number(lt.added)||0,Rt=Number(lt.removed)||0;!wt&&!Rt||(on.added+=wt,on.removed+=Rt,Xt||(Xt=setTimeout(Ln,Te)))})),gt.push(()=>{Xt&&clearTimeout(Xt)}),gt.push(Ke.on("rows:paused",()=>{Xt&&(clearTimeout(Xt),Xt=null),on={added:0,removed:0},Zt(Gt("a11y.updates.paused"),{repeat:!0})})),gt.push(Ke.on("rows:resumed",()=>Zt(Gt("a11y.updates.resumed"),{repeat:!0})));let hn={count:0,first:null},pn=null;const Cn=()=>{pn=null;const{count:lt,first:wt}=hn;if(hn={count:0,first:null},!lt||!wt)return;const Rt=Ke.columns.get(wt.colId),Ht=Rt&&Rt.title||wt.colId,Kt=wt.reason?Gt("a11y.edit.reason",{reason:wt.reason}):"";if(lt===1){const sn=wt.restored===void 0||wt.restored===null||wt.restored===""?Gt("value.empty"):String(wt.restored);Zt(Gt("a11y.edit.refusedOne",{column:Ht,value:sn,reason:Kt}),{repeat:!0});return}Zt(Gt("a11y.edit.refusedMany",{count:lt,reason:Kt}),{repeat:!0})};gt.push(Ke.on("cell:reverted",lt=>{!lt||!lt.applied||(hn.count+=1,hn.first||(hn.first=lt),pn||(pn=setTimeout(Cn,150)))})),gt.push(()=>{pn&&clearTimeout(pn)}),gt.push(Ke.on("history:applied",lt=>{const wt=!!(lt&&lt.direction==="redo"),Rt=lt&&lt.step&&lt.step.label;Zt(Rt?Gt(wt?"a11y.history.redo":"a11y.history.undo",{label:Rt}):Gt(wt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const vn=new Tt({grid:Ke,renderer:dt,seed:rt.state&&Array.isArray(rt.state.annotations)?rt.state.annotations:null});vn.mount(),gt.push(()=>vn.destroy()),Ke.annotate=vn,Ke.capture=async(lt={})=>{const{blob:wt,width:Rt,height:Ht}=await At(dt.viewport.root,lt);return(lt.download===!0||lt.download!==!1&&lt.fileName)&&X(wt,lt.fileName||`${Ke.get("exportName")||"grid"}.png`),Ke.emit("presentation:captured",{width:Rt,height:Ht,bytes:wt.size,mimeType:wt.type,fileName:lt.fileName||null},"api"),wt};const En=new Xe({grid:Ke,document:ut,element:Mt.overlays,window:ut.defaultView||void 0});En.mount(),gt.push(()=>En.destroy());const Fn=new h({grid:Ke,document:ut,element:Mt.overlays});Fn.mount?.(),gt.push(()=>Fn.destroy?.());const Tn=new j({grid:Ke,host:Ke.rendererHost(),viewport:Mt,document:ut});return Tn.mount(),gt.push(()=>Tn.destroy()),gt}function pt(Ke){const dt=[],rt=ut=>{if(ut&&(ut.__lattice&&dt.push(ut),ut.children))for(const kt of ut.children)rt(kt)};return rt(Ke),dt}function Ct(Ke,dt={}){(!Ke||typeof Ke!="object"||!("appendChild"in Ke))&&H("createGrid needs a host element as its first argument."),dt=I(dt);const rt=Ke.ownerDocument||(typeof document<"u"?document:null);rt||H("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const ut=rt.documentElement&&rt.documentElement.lang,kt=!dt.licence&&U(rt.querySelector)?rt.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Nt={...dt};if(!dt.locale&&ut&&(Nt.locale=ut),kt&&(Nt.licence=kt),dt.views&&dt.views.local)if(dt.views.storage)z("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const qt=dt.views.local===!0?{}:dt.views.local;Nt.views={...dt.views,storage:k(qt)}}const gt=$(Nt),Mt=gt.rendererHost();Mt.document=rt,bt(Mt.registry,dt),Mt.cellLayer=s(Mt),Mt.detailHost=new we({grid:gt,document:Ke.ownerDocument||globalThis.document,createGrid:(qt,_t)=>Ct(qt,_t)});const Dt=new l(Ke,Mt),tn=gt.on("detail:toggled",()=>{Mt.detailHost.syncTarget(),Mt.detailHost.prune()}),mn=gt.on("config:changed",qt=>{qt&&qt.key==="detail"&&Mt.detailHost.reconfigure()});gt.on("destroy",()=>{tn(),mn(),Mt.detailHost.destroy()}),Mt.detailHost.syncTarget(),gt.attachRenderer(Dt),Dt.mount();const an=vt(gt,Dt,dt,rt,Mt.registry,Ke),dn=gt.destroy.bind(gt);return gt.destroy=()=>{for(const qt of an)try{qt()}catch{}Ke.__lattice===gt&&(Ke.__lattice=null),dn()},Ke.__lattice=gt,gt}}),Fe("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HYDRATE_CONFIG_ATTR",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"hydrateInto",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return h}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=K("packages/core/src/columns/datatypes.js"),_=I.BUILTIN_TYPES,X=I.parseNumberText,H=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,z=K("packages/core/src/format/boolean.js").toTriState,w=K("packages/core/src/format/date.js"),k=w.toIsoDate,g=w.toIsoDateTime,c=K("packages/dom/src/createGrid.js").createGrid,s=new Set([...Object.keys(_),...Object.keys(H)]);function n(a,p){for(const b of a.children)if(b.tagName===p.toUpperCase())return b;return null}function t(a,p){const b=[];for(const j of a.children)j.tagName===p.toUpperCase()&&b.push(j);return b}function r(a,p){const b=$(a.getAttribute)?a.getAttribute("data-field"):null;return b||String(a.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${p}`}function o(a){const p=a.trim();if(p==="")return null;if(p==="true"||p==="false")return p==="true";const b=Number(p);return Number.isFinite(b)&&p!==""?b:p}function f(a,p){return p==="text"?a===""?null:a:p==="boolean"?z(a):p==="number"?X(a):p==="date"||p==="dateString"?k(a):p==="datetime"?g(a):o(a)}function u(a){const p=n(a,"thead"),b=n(p||a,"tr"),S=(b?t(b,"th").length?t(b,"th"):t(b,"td"):[]).map((O,x)=>{const C=r(O,x),P={id:C,field:C,title:String(O.textContent||"").trim()||C},F=$(O.getAttribute)?O.getAttribute("data-type"):null;F&&(s.has(F)?P.type=F:B(`hydrate.unknownType:${F}`,`data-type "${F}" on column "${C}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const E=$(O.getAttribute)?O.getAttribute("data-format"):null;return E&&(P.format=E),P}),y=n(a,"tbody"),R=(y?t(y,"tr"):t(a,"tr").filter(O=>O!==b)).map((O,x)=>{const C=t(O,"td"),F={__row:($(O.getAttribute)?O.getAttribute("data-id"):null)||`row${x}`};return S.forEach((E,D)=>{F[E.field]=C[D]?E.type?f(String(C[D].textContent||""),E.type):o(String(C[D].textContent||"")):null}),F});return{columns:S,rows:R}}function i(a,p){if(p===void 0)return a;if(p!==null&&typeof p=="object"&&!Array.isArray(p)&&Array.isArray(p.only))return p.only;if(!Array.isArray(p))return p;const b=new Map;for(const S of p)if(S&&typeof S=="object"){const y=S.id??S.field;y!=null&&b.set(y,S)}const j=a.map(S=>{const y=b.get(S.id)??b.get(S.field);return y===void 0?S:{...S,...y}});for(const[S,y]of b)a.some(v=>v.id===S||v.field===S)||j.push({...y});return j}const m="data-lattice-hydrate-config";function d(a,p,b={}){const{columns:j,rows:S}=u(p);return c(a,{rowKey:"__row",...b,columns:i(j,b.columns),rows:b.rows!==void 0?b.rows:S})}function h(a,p={}){const b=a.ownerDocument.createElement("div");b.setAttribute("data-lattice-hydrated",""),a.removeAttribute("data-lattice-grid"),b.__latticeTable=a;try{b.setAttribute(m,JSON.stringify(p))}catch{b.setAttribute(m,"{}")}return a.parentNode.insertBefore(b,a),a.parentNode.removeChild(a),d(b,a,p)}}),Fe("packages/dom/src/autoinit.js",function(e,K){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return z}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/dom/src/createGrid.js").createGrid,X=K("packages/dom/src/hydrate.js").hydrateTable;function W(w,k){const g=[];return $(w.hasAttribute)&&w.hasAttribute(k)&&g.push(w),$(w.querySelectorAll)&&g.push(...w.querySelectorAll(`[${k}]`)),g}function H(w){const k=w.parentNode;if(!k||!k.children)return null;const g=[...k.children],l=g.indexOf(w),c=[g[l+1],g[l-1]];for(const s of c)if(s&&s.tagName==="SCRIPT"&&$(s.getAttribute)&&s.hasAttribute("data-lattice-config"))return s;return null}function U(w){const k=H(w);if(!k)return{};try{return JSON.parse(k.textContent||"{}")}catch(g){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",g),{}}}function z(w){const k=w||(typeof document<"u"?document:null);if(!k)return[];const g=[];for(const l of W(k,"data-lattice-grid")){if(l.__lattice)continue;const c=U(l);g.push(l.tagName==="TABLE"?X(l,c):I(l,c))}return g}}),Fe("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const Q=K("packages/dom/src/createGrid.js"),$=Q.createGrid,B=K("packages/dom/src/hydrate.js"),I=B.hydrateTable,_=K("packages/dom/src/autoinit.js"),X=_.autoInit,W=K("packages/dom/src/localviews.js"),H=W.createLocalViewStorage,U=K("packages/core/src/index.js"),z=U.createHeadlessGrid,w=U.registerModules,k=U.setLicence,g=U.version,l=U.getVersion,c=U.serialiseState,s=U.restoreState,n=U.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return Q.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return Q.gridElementsWithin}});const t=K("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return t.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return B.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return B.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return _.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return W.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return W.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return U.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return U.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return U.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return U.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return U.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return U.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return U.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return U.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return U.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return U.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return U.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return U.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return U.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return U.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return U.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return U.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return U.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return U.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return U.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return U.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return U.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return U.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return U.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return U.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return U.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return U.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return U.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return U.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return U.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return U.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return U.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return U.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return U.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return U.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return U.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return U.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return U.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return U.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return U.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return U.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return U.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return U.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return U.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return U.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return U.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return U.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return U.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return U.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return U.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return U.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return U.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return U.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return U.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return U.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return U.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return U.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return U.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return U.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return U.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return U.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return U.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return U.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return U.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return U.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return U.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return U.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return U.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return U.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return U.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return U.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return U.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return U.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return U.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return U.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return U.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return U.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return U.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return U.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return U.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return U.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return U.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return U.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return U.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return U.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return U.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return U.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return U.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return U.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return U.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return U.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return U.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return U.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return U.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return U.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return U.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return U.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return U.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return U.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return U.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return U.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return U.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return U.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return U.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return U.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return U.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return U.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return U.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return U.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return U.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return U.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return U.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return U.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return U.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return U.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return U.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return U.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return U.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return U.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return U.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return U.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return U.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return U.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return U.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return U.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return U.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return U.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return U.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return U.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return U.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return U.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return U.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return U.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return U.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return U.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return U.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return U.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return U.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return U.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return U.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return U.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return U.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return U.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return U.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return U.VERSION}});const r=K("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return r.DomRenderer}});const o=K("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return o.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return o.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return o.branchFor}});const f=K("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return f.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return f.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return f.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return f.autoGroupMenuItems}});const u=K("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return u.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return u.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return u.layoutState}});const i=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return i.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return i.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return i.mountPanel}});const m=K("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return m.CellEditController}});const d=K("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return d.EditBar}});const h=K("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return h.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return h.HISTORY_CLS}});const a=K("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return a.DiffPainter}});const p=K("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return p.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return p.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return p.summariseDiff}});const b=K("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return b.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return b.PROMPT_CLASS}});const j=K("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return j.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return j.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return j.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return j.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return j.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return j.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return j.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return j.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return j.sanitiseHtml}});const S=K("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return S.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return S.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return S.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return S.BaseEditor}});const y=K("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return y.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return y.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return y.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return y.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return y.ConditionFilter}});const v=K("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return v.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return v.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return v.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return v.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return v.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return v.OverlayLayer}});const R=K("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return R.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return R.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return R.licenceState}});const O=Object.freeze({createGrid:$,createHeadlessGrid:z,defaults:n,registerModules:w,setLicence:k,version:g,autoInit:X,hydrateTable:I,serialiseState:c,restoreState:s,createLocalViewStorage:H}),x=O}),Fe("packages/modules/shared/adapter.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"handlerName",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"CONFIG_KEY_ALIASES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"aliasConfigKey",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isHandlerProp",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"partition",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createGridController",{enumerable:!0,get:function(){return z}});const Q=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","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","validation:failed","validation:cleared","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"]),$=Object.freeze({sort:(w,k)=>w.sort.set(k||[]),filters:(w,k)=>w.filters.set(k||null),quickFilter:(w,k)=>{if(k&&typeof k=="object"){w.filters.quick(k.text||"",{mode:k.mode});return}w.filters.quick(typeof k=="string"?k:"")},selectedKeys:(w,k)=>w.selection.set(Array.isArray(k)?k:[])});function B(w){return`on${String(w).split(":").map(g=>g.charAt(0).toUpperCase()+g.slice(1)).join("")}`}function I(w){return String(w).replace(/:/g,"-")}const _=Object.freeze({"row-key":"rowKey","row-height":"rowHeight","header-height":"headerHeight","auto-height":"autoHeight"});function X(w){return Object.hasOwn(_,w)?_[w]:w}const W=Object.freeze(Object.fromEntries(Q.map(w=>[B(w),w])));function H(w){return Object.hasOwn(W,w)}function U(w){const k={},g={},l={};for(const[c,s]of Object.entries(w||{})){if(H(c)){l[c]=s;continue}if(Object.hasOwn($,c)){g[c]=s;continue}k[c]=s}return{config:k,imperative:g,handlers:l}}function z(w){const k=w.createGrid;if(typeof k!="function")throw new TypeError("createGridController needs createGrid; pass it in from the grid package.");const g=U(w.props||{}),l=k(w.element,{...g.config});let c=g.handlers,s=g.config,n={};const t=f=>{if(!f||typeof f.type!="string")return;const u=c[B(f.type)];typeof u=="function"&&u(f)},r=l.on("*",t);for(const[f,u]of Object.entries(g.imperative))u!==void 0&&($[f](l,u),n[f]=u);let o=!1;return{grid:l,update(f){if(o)return;const u=U(f||{});c=u.handlers;const i={};for(const[m,d]of Object.entries(u.config))Object.is(s[m],d)||(i[m]=d);for(const m of Object.keys(s))Object.hasOwn(u.config,m)||(i[m]=void 0);Object.keys(i).length&&l.setAll(i),s=u.config;for(const[m,d]of Object.entries($)){const h=u.imperative[m];Object.is(n[m],h)||h===void 0&&!Object.hasOwn(n,m)||(d(l,h),n[m]=h)}},destroy(){o||(o=!0,r(),l.destroy())}}}}),Fe("packages/modules/react/viewers.js",function(e,K){"use strict";Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"VIEWER_BULK_UPDATE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"partitionViewerProps",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return U}});const $=K("packages/core/src/internal/util.js").warnOnce,B=Object.freeze({kpi:Object.freeze(["tile:click","tile:dblclick","tile:contextmenu","node:toggle","change","tile:status"]),kanban:Object.freeze(["card:click","card:dblclick","card:contextmenu","card:move","card:reverted","card:confirmed","selection:changed","column:collapse","card:add","drag:start","drag:end","swimlane:collapse","swimlane:reorder","column:reorder","filter:changed","sprint:changed","epic:changed","card:expand","card:drill","card:edit","card:sla","beforeMove","beforeAdd","beforeEdit","beforeLaneReorder","beforeColumnReorder","beforeColumnChange","move:cancelled","add:cancelled","edit:cancelled","laneReorder:cancelled","columnReorder:cancelled","columnChange:cancelled"]),tabs:Object.freeze(["beforeTabChange","tab:changed","tabChange:cancelled"]),calendar:Object.freeze(["card:click","card:dblclick","card:contextmenu","card:mount","range:change","beforeMove","card:move"]),chart:Object.freeze(["click","hover","leave","draw","legend"]),gantt:Object.freeze(["schedule","error"]),layout:Object.freeze(["layout:changed","window:moved","window:resized","window:closed","beforeWindowClose","windowClose:cancelled"]),router:Object.freeze(["metrics","fields:changed"])}),I=Object.freeze({kpi:Object.freeze({rows:(z,w)=>z.setRows(Array.isArray(w)?w:[])}),kanban:Object.freeze({rows:(z,w)=>z.setRows(Array.isArray(w)?w:[]),quickFilter:(z,w)=>z.setQuickFilter(typeof w=="string"?w:""),sprint:(z,w)=>z.setSprint(w),epic:(z,w)=>z.setEpic(w),loading:(z,w)=>z.setLoading(!!w),error:(z,w)=>z.setError(w??null)}),gantt:Object.freeze({tasks:(z,w)=>z.setTasks(Array.isArray(w)?w:[]),dependencies:(z,w)=>z.setDependencies(Array.isArray(w)?w:[])}),tabs:Object.freeze({active:(z,w)=>{typeof w=="string"&&z.activate(w)}}),calendar:Object.freeze({rows:(z,w)=>z.setRows(Array.isArray(w)?w:[]),view:(z,w)=>z.setView(w),date:(z,w)=>z.goTo(w),move:(z,w,k)=>z.move(w,k)}),chart:Object.freeze({}),layout:Object.freeze({})}),_=Object.freeze({chart:"update"});function X(z){return`on${String(z).split(":").map(k=>k.charAt(0).toUpperCase()+k.slice(1)).join("")}`}const W=Object.freeze(Object.fromEntries(Object.entries(B).map(([z,w])=>[z,Object.freeze(Object.fromEntries(w.map(k=>[X(k),k])))])));function H(z,w){const k=W[z]||{},g=I[z]||{},l={},c={},s={};for(const[n,t]of Object.entries(w||{})){if(Object.hasOwn(k,n)){s[n]=t;continue}if(Object.hasOwn(g,n)){c[n]=t,l[n]=t;continue}l[n]=t}return{config:l,live:c,handlers:s}}function U(z){const w=String(z.viewer),k=z.mount,g=z.name||w;if(typeof k!="function")throw new TypeError(`createViewerController needs a mount factory for "${w}"; pass the module's own factory in, e.g. { createKPI } from lattice-grid/modules/kpi.`);const l=H(w,z.props||{}),c=k(z.element,{...l.config});if(!c||typeof c!="object")throw new TypeError(`the ${g} factory returned no instance; nothing can be driven.`);let s=l.handlers,n=l.config;const t={...l.live},r=[];if(typeof c.on=="function")for(const i of B[w]||[]){const m=X(i),d=c.on(i,h=>{const a=s[m];typeof a=="function"&&a(h)});typeof d=="function"&&r.push(d)}const o=_[w],f=I[w]||{};let u=!1;return{instance:c,update(i){if(u)return;const m=H(w,i||{});s=m.handlers;const d={};for(const[a,p]of Object.entries(m.config))Object.is(n[a],p)||(d[a]=p);if(n=m.config,!Object.keys(d).length)return;const h=[];for(const a of Object.keys(d)){const p=f[a];if(p){p(c,d[a]),t[a]=d[a];continue}o&&typeof c[o]=="function"||h.push(a)}if(o&&typeof c[o]=="function"){const a={};for(const p of Object.keys(d))f[p]||(a[p]=d[p]);Object.keys(a).length&&c[o](a)}h.length&&$(`react.viewer.${w}.mountOnly.${h.join(".")}`,`${g}: ${h.map(a=>`\`${a}\``).join(", ")} changed, but ${g} takes ${h.length===1?"it":"them"} only when the viewer is created. Nothing was applied and the viewer was NOT rebuilt — rebuilding it silently would throw away scroll position, selection and expansion. Give the component a \`key\` that changes when this must take effect, so the rebuild is yours and visible, or drive the instance through the ref.`)},destroy(){if(!u){u=!0;for(const i of r)try{i()}catch{}r.length=0,typeof c.destroy=="function"&&c.destroy()}}}}}),Fe("packages/modules/webcomponent/controller.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"ELEMENT_STYLE_ID",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"coerceAttribute",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"injectElementStyle",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return s}});const $=K("packages/core/src/internal/util.js").warnOnce,B="lattice-",I="lattice-grid-element-styles",_=Object.freeze({theme:"theme",density:"density",locale:"locale","row-key":"rowKey","row-height":"rowHeight","header-height":"headerHeight","auto-height":"autoHeight","filter-row":"filterRow",selection:"selection",rows:"rows",columns:"columns"}),X=new Set(["rowHeight","headerHeight"]),W=new Set(["autoHeight","filterRow"]),H=new Set(["rows","columns"]);function U(){return Object.keys(_)}function z(n){return B+String(n).replace(/:/g,"-")}function w(n,t){if(W.has(n))return t!==null&&t!=="false";if(t!==null){if(X.has(n)){const r=Number(t);return Number.isFinite(r)?r:void 0}if(H.has(n))try{return JSON.parse(t)}catch{return}return t}}function k(n){if(!n||!n.createElement||n.getElementById&&n.getElementById(I))return;const t=n.createElement("style");t.setAttribute("id",I),t.appendChild(n.createTextNode(`lattice-grid{display:block}
58
58
  `));const r=n.head||n.documentElement||null;r&&r.appendChild(t)}const g=new Set(["quickFilter","quickFilterText","sort","filters","selectedKeys"]);function l(n,t,r){let o;if(t==="quickFilter"||t==="quickFilterText"){if(!n.filters||typeof n.filters.quick!="function")return c(t);o=()=>n.filters.quick(r==null?"":String(r))}else if(t==="sort"){if(!n.sort||typeof n.sort.set!="function")return c(t);o=()=>n.sort.set(Array.isArray(r)?r:[])}else if(t==="filters"){if(!n.filters||typeof n.filters.set!="function")return c(t);o=()=>n.filters.set(r??{})}else{if(!n.selection||typeof n.selection.set!="function")return c(t);o=()=>n.selection.set(Array.isArray(r)?r:[])}o()}function c(n){$(`webcomponent.write:${n}`,`<lattice-grid>: \`${n}\` could not be written to the grid (it has no API for it), so it had no effect.`)}class s{#e;#t;#n=null;#r={};#o=null;#i=!1;#s=!1;constructor(t,r){this.#e=t,this.#t=r.createGrid}get grid(){return!this.#n&&this.#s&&this.settleCreate(),this.#n}get teardownPending(){return this.#i}config(){return{...this.#r}}configure(t){if(!(!t||typeof t!="object"))for(const[r,o]of Object.entries(t))this.#l(r,o)}attributeChanged(t,r){const o=_[t];if(!o)return;const f=w(o,r);f===void 0&&!W.has(o)||this.#l(o,f)}connect(){this.#i=!1,this.#s=!0,!this.#n&&queueMicrotask(()=>this.settleCreate())}settleCreate(){if(!this.#s||this.#n)return;k(this.#e.ownerDocument||null);const t={},r=[];for(const[f,u]of Object.entries(this.#r))g.has(f)&&f!=="quickFilterText"?r.push([f,u]):t[f]=u;const o=this.#t(this.#e,t);this.#n=o;for(const[f,u]of r)l(o,f,u);this.#a(o)}disconnect(){this.#s=!1,this.#n&&(this.#i=!0,queueMicrotask(()=>this.settleTeardown()))}settleTeardown(){this.#i&&(this.#i=!1,this.destroy())}destroy(){this.#o&&(this.#o(),this.#o=null);const t=this.#n;this.#n=null,t&&typeof t.destroy=="function"&&t.destroy()}#l(t,r){if(this.#r[t]=r,!!this.#n){if(g.has(t)){l(this.#n,t,r);return}typeof this.#n.set=="function"&&this.#n.set(t,r)}}#a(t){!t||typeof t.on!="function"||(this.#o=t.on("*",r=>{const o=this.#e;if(!o||typeof o.dispatchEvent!="function")return;const f={...r};delete f.grid,o.dispatchEvent(this.#u(z(r.type),f))}))}#u(t,r){const o=globalThis.CustomEvent;return typeof o=="function"?new o(t,{detail:r,bubbles:!0,composed:!0}):{type:t,detail:r,bubbles:!0,composed:!0}}}}),Fe("packages/modules/webcomponent/styles.js",function(e,K){"use strict";Object.defineProperty(e,"constructableStyleSheets",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isLatticeStyleNode",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"sheetText",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"latticeStyleNodes",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"adoptIntoHostRoot",{enumerable:!0,get:function(){return g}});const Q=Symbol.for("lattice.webcomponent.styleMirror"),$=/--lattice-|\.lat-/,B=new WeakMap,I=new WeakMap;function _(){const l=globalThis.CSSStyleSheet;if(typeof l!="function")return!1;try{return typeof new l().replaceSync=="function"}catch{return!1}}function X(l){if(!l||typeof l.getAttribute!="function")return!1;const c=String(l.tagName||"").toLowerCase();if(c!=="style"&&c!=="link"||c==="link"&&!String(l.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("stylesheet"))return!1;const s=String(l.getAttribute("id")||"");if(s.startsWith("lattice")||s.startsWith("lat-")||l.hasAttribute&&l.hasAttribute("data-lattice"))return!0;if(c==="link"){const n=String(l.getAttribute("href")||"");return/lattice/i.test(n)?!0:$.test(W(l))}return $.test(String(l.textContent||""))}function W(l){if(String(l&&l.tagName||"").toLowerCase()==="style")return String(l.textContent||"");try{const s=l&&l.sheet;if(!s||!s.cssRules)return"";let n="";for(const t of s.cssRules)n+=`${t.cssText}
59
- `;return n}catch{return""}}function H(l,c){const s=B.get(l);if(s)return s.sheet;const n=W(l);if(!n)return null;const t=c.CSSStyleSheet,r=new t;try{r.replaceSync(n)}catch{return null}r[Q]=!0;let o=null;const f=c.MutationObserver;return typeof f=="function"&&String(l.tagName).toLowerCase()==="style"&&(o=new f(()=>{try{r.replaceSync(String(l.textContent||""))}catch{}}),o.observe(l,{childList:!0,characterData:!0,subtree:!0})),B.set(l,{sheet:r,stop:()=>o&&o.disconnect()}),r}function U(l){return l?l.nodeType===9?l:l.ownerDocument||globalThis.document||null:globalThis.document||null}function z(l){const c=l||globalThis.document;return!c||typeof c.querySelectorAll!="function"?[]:[...c.querySelectorAll("style,link[rel]")].filter(X)}function w(l={}){if(!_())return[];const c=l.document||globalThis.document,s=c&&c.defaultView||globalThis,n=[];for(const t of z(c)){const r=H(t,s);r&&!n.includes(r)&&n.push(r)}return n}function k(l,c={}){const s=()=>{};if(!l||typeof l!="object")return s;const n=c.document||U(l);if(!n)return s;const t=n.defaultView||globalThis;let r=I.get(l);r||(r=new Map,I.set(l,r));const o=[],f=_(),u=a=>{if(r.has(a))return;const p=f?H(a,t):null;if(p){r.set(a,p);const j=l.adoptedStyleSheets||[];j.includes(p)||(l.adoptedStyleSheets=[...j,p]);return}if(String(a.tagName).toLowerCase()!=="link"||typeof l.appendChild!="function")return;const b=n.createElement("link");b.setAttribute("rel","stylesheet"),b.setAttribute("href",a.getAttribute("href")||""),b.setAttribute("data-lattice","adopted"),l.appendChild(b),o.push(b),r.set(a,b)};for(const a of z(n))u(a);let i=null;const m=t.MutationObserver,d=n.head||n.documentElement;typeof m=="function"&&d&&(i=new m(a=>{for(const p of a)for(const b of p.addedNodes||[])X(b)&&u(b)}),i.observe(d,{childList:!0}));let h=!1;return()=>{if(h)return;h=!0,i&&i.disconnect();const a=l.adoptedStyleSheets||[],p=new Set([...r.values()]);l.adoptedStyleSheets=a.filter(b=>!p.has(b));for(const b of o)b.parentNode&&b.parentNode.removeChild(b);r.clear()}}function g(l){if(!l||typeof l.getRootNode!="function"||typeof l.getAttribute=="function"&&String(l.getAttribute("lattice-styles")||"")==="off")return null;const c=l.getRootNode();return!c||c.nodeType!==11||!c.host?null:k(c)}}),Fe("packages/modules/webcomponent/elements.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_GRID_NAME",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DEFAULT_TAG_PREFIX",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VIEWER_ALIASES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"VIEWER_BINDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"coerceElementAttribute",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"attributeConfig",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createElementScope",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"scopeFor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"applyPredicates",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"upgradeProperty",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"installProperty",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"harvestProperties",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"createLatticeCalendarElement",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"gridElementClass",{enumerable:!0,get:function(){return le}});const $=K("packages/core/src/internal/util.js").warnOnce,I=K("packages/modules/shared/adapter.js").aliasConfigKey,_=K("packages/modules/react/viewers.js"),X=_.VIEWER_EVENTS,W=_.viewerHandlerName,H=_.createViewerController,U=K("packages/modules/webcomponent/controller.js"),z=U.GridElementController,w=U.observedAttributeNames,k=U.domEventName,g=U.ATTRIBUTE_CONFIG,c=K("packages/modules/webcomponent/styles.js").adoptIntoHostRoot,s="default",n="lattice-",t=Object.freeze({grid:"grid",kpi:"kpi",chart:"chart",kanban:"kanban",calendar:"calendar",gantt:"gantt",layout:"layout",tabs:"tabs",router:"router"}),r=Object.freeze({chart:ae=>{if("data"in ae){const se=ae.data;delete ae.data,se!=null&&ae.rows===void 0&&(ae.rows=se)}if("stacked"in ae){const se=ae.stacked;delete ae.stacked,se!=null&&ae.stack===void 0&&(ae.stack=se)}if("horizontal"in ae){const se=ae.horizontal;delete ae.horizontal,se&&ae.type==="bar"&&(ae.type="horizontalBar")}},kanban:ae=>{if(!("titleProperty"in ae))return;const se=ae.titleProperty;if(delete ae.titleProperty,typeof se!="string"||!se)return;const ee=ae.card&&typeof ae.card=="object"?ae.card:null;ee&&ee.title!==void 0||(ae.card={title:se,...ee||{}})},gantt:ae=>{if(!("scale"in ae))return;const se=ae.scale;if(delete ae.scale,se==null||se==="")return;const ee=ae.render&&typeof ae.render=="object"?{...ae.render}:{};ee.zoom===void 0&&(ee.zoom=se),ae.render=ee}}),o=Object.freeze({kpi:Object.freeze({label:"lattice-kpi",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["tiles","rows","columns"]),scalars:Object.freeze(["rowKey","locale"])}),chart:Object.freeze({label:"lattice-chart",requires:Object.freeze(["grid"]),fromContext:"grid",properties:Object.freeze(["shapes","series","data"]),scalars:Object.freeze(["type","x","y","value","label","lon","lat","labels","stacked","horizontal","scheme","subtitle","footnote","tooltip","legend"])}),kanban:Object.freeze({label:"lattice-kanban",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["rows","columns","card"]),scalars:Object.freeze(["rowKey","columnProperty","titleProperty","pointsProperty","orderProperty","swimlaneProperty","sprintProperty","epicProperty","swimlanes","virtualize"])}),calendar:Object.freeze({label:"lattice-calendar",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["rows","card","header","colorMap","labels","renderCard"]),scalars:Object.freeze(["rowKey","view","date","startProperty","endProperty","allDayProperty","firstDay","locale","timeZone","colorProperty","eventOrder","dayMaxEvents","readonly","ariaLabel"])}),gantt:Object.freeze({label:"lattice-gantt",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tasks","dependencies","resources","calendar","columns"]),scalars:Object.freeze(["rowKey","scale","projectStart","autoSchedule"])}),layout:Object.freeze({label:"lattice-layout",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["windows"]),scalars:Object.freeze(["columns","rows","compact","columnWidth","rowHeight","gap","overflowX","overflowY"])}),tabs:Object.freeze({label:"lattice-tabs",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tabs"]),scalars:Object.freeze(["lazy"])})}),f=new Set(["grid-name","lattice-styles","name","route","route-options","id","class","style","slot"]),u=new Set(["role","tabindex","hidden","part","exportparts","lang","dir","title-id","is"]),i=Symbol.for("lattice.webcomponent.routerScope"),m=new WeakMap;function d(ae){if(ae==null)return;if(ae===""||ae==="true")return!0;if(ae==="false")return!1;const se=String(ae).trim();if(se.startsWith("[")||se.startsWith("{"))try{return JSON.parse(se)}catch{return ae}return se!==""&&Number.isFinite(Number(se))?Number(se):ae}function h(ae,se){const ee={},ie=ae&&typeof ae.getAttributeNames=="function"?ae.getAttributeNames():[];for(const ce of ie){if(f.has(ce)||u.has(ce)||se&&se.has(ce)||ce.startsWith("data-")||ce.startsWith("aria-"))continue;const he=d(ae.getAttribute(ce));he!==void 0&&(ee[a(ce)]=he)}return ee}function a(ae){const se=I(ae);return se!==ae||!ae.includes("-")?se:ae.replace(/-([a-z0-9])/g,(ee,ie)=>ie.toUpperCase())}function p(ae){return ae&&typeof ae.getAttributeNames=="function"?ae.getAttributeNames():[]}function b(ae){const se=[];for(const ee of p(ae))f.has(ee)||u.has(ee)||ee.startsWith("data-")||ee.startsWith("aria-")||se.push(a(ee));return se}function j(){const ae=new Map,se=new Set;return{publish(ee,ie){const ce=ee||s;ie?ae.set(ce,ie):ae.delete(ce);for(const he of[...se])he()},get(ee){return ae.get(ee||s)||null},names(){return[...ae.keys()]},subscribe(ee){return se.add(ee),()=>{se.delete(ee)}}}}function S(ae={}){const se=typeof ae.createDataRouter=="function"?ae.createDataRouter:null;let ee=null,ie=!1;return{grids:j(),get router(){return ee},attach(he,me,Ee){ie||!se||(ee||(ee=se(ae.config||{})),ee.attach(he,me,Ee||{}))},detach(he){if(!(ie||!ee))try{ee.detach(he)}catch{}},destroy(){ie=!0;const he=ee;ee=null,he&&he.destroy()}}}function y(ae){let se=ae&&ae.parentNode||null;for(;se;){if(se[i])return se[i];se=se.parentNode||se.host||null}const ie=(ae&&typeof ae.getRootNode=="function"?ae.getRootNode():ae&&ae.ownerDocument||null)||globalThis.document||globalThis;let ce=m.get(ie);return ce||(ce=S(),m.set(ie,ce)),ce}function v(ae,se,ee){const ie=se&&typeof se=="object"?se:{},ce=ee&&typeof ee=="object"?ee:{};for(const[he,me]of Object.entries(ie))Object.is(ce[he],me)||ae.filters.where(he,typeof me=="function"?me:null);for(const he of Object.keys(ce))Object.hasOwn(ie,he)||ae.filters.where(he,null)}function R(ae,se){if(!Object.hasOwn(ae,se))return;const ee=ae[se];delete ae[se],ae[se]=ee}const O=new Set(["instance","config","grid","gridName","router"]);function x(ae,se){let ee=Object.getPrototypeOf(ae);for(;ee;){const ie=Object.getOwnPropertyDescriptor(ee,se);if(ie)return typeof ie.get=="function";ee=Object.getPrototypeOf(ee)}return!1}function C(ae,se){if(!se||O.has(se)||se.startsWith("__"))return;const ee=Object.getOwnPropertyDescriptor(ae,se);if(ee&&typeof ee.get=="function")return;if(x(ae,se)){ee&&R(ae,se);return}const ie=ee?ee.value:void 0;ee&&delete ae[se],Object.defineProperty(ae,se,{get(){return this.__props[se]},set(ce){this.__write(se,ce)},configurable:!0,enumerable:!0}),ee&&(ae[se]=ie)}function P(ae){let se=!1;for(const ee of Object.getOwnPropertyNames(ae)){if(ee.startsWith("__")||O.has(ee))continue;const ie=Object.getOwnPropertyDescriptor(ae,ee);!ie||typeof ie.get=="function"||!ie.enumerable||(C(ae,ee),se=!0)}return se}function F(ae,se,ee){if(!ae||typeof ae.dispatchEvent!="function")return;const ie=globalThis.CustomEvent,ce={detail:ee,bubbles:!0,composed:!0};ae.dispatchEvent(typeof ie=="function"?new ie(se,ce):{type:se,...ce})}function E(ae){const se=ae.viewer,ee=o[se],ie=ae.label||ee.label,ce=ae.mount,he=X[se]||[];class me extends ae.Base{__props={};__controller=null;__builtAgainst=null;__connected=!1;__teardownPending=!1;__release=[];__queued=!1;__wired=!1;__scope=null;__ownAttributes=new Set;constructor(){super();for(const ge of["config","grid","gridName",...ee.properties,...ee.scalars])R(this,ge);P(this)}get instance(){return this.__controller?this.__controller.instance:null}move(ge,je){const pe=this.instance;return pe&&typeof pe.move=="function"?pe.move(ge,je):Promise.resolve(!1)}get grid(){return this.__props.grid}set grid(ge){this.__write("grid",ge)}get gridName(){const ge=this.__props.gridName;if(typeof ge=="string")return ge;const je=typeof this.getAttribute=="function"?this.getAttribute("grid-name"):null;return je===null?void 0:je}set gridName(ge){this.__write("gridName",ge)}get config(){return{...this.__props}}set config(ge){if(!(!ge||typeof ge!="object")){for(const[je,pe]of Object.entries(ge))this.__props[je]=pe;this.__schedule()}}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__wired){this.__wired=!0;const ge=c(this);ge&&this.__release.push(ge);const je=y(this);this.__scope=je,ee.fromContext&&this.__release.push(je.grids.subscribe(()=>this.__settle()));const pe=globalThis.MutationObserver;if(typeof pe=="function"){const we=new pe(()=>this.__settle());we.observe(this,{attributes:!0}),this.__release.push(()=>we.disconnect())}}P(this);for(const ge of b(this))C(this,ge);this.__schedule()}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()))}__settleTeardown(){if(this.__teardownPending){this.__teardownPending=!1,this.__wired=!1,this.__scope=null;for(const ge of this.__release.splice(0))try{ge()}catch{}this.__tearDown()}}__write(ge,je){this.__props[ge]=je,this.__schedule()}__schedule(){this.__queued||(this.__queued=!0,queueMicrotask(()=>{this.__queued=!1,this.__settle()}))}__boundGrid(){if(!ee.fromContext)return null;if(this.__props.grid!==void 0)return this.__props.grid||null;const ge=this.__scope;return ge?ge.grids.get(this.gridName):null}__resolve(){const ge={...h(this,this.__ownAttributes),...this.__props};if(delete ge.gridName,ee.fromContext){const pe=this.__boundGrid();pe?ge[ee.fromContext]=pe:delete ge[ee.fromContext]}const je=r[se];je&&je(ge);for(const pe of he)ge[W(pe)]=we=>F(this,k(pe),we);return ge}__settle(){if(!this.__connected)return;P(this);const ge=this.__resolve(),je=ee.fromContext&&ge[ee.fromContext]||null;if(this.__controller&&!Object.is(this.__builtAgainst,je)&&this.__tearDown(),!this.__controller){for(const we of ee.requires)if(ge[we]===void 0||ge[we]===null)return;if(ee.fromContext&&!je&&ge.rows===void 0)return;const pe=new Set(p(this));this.__controller=H({viewer:se,mount:ce,element:this,props:ge,name:ie});for(const we of p(this))pe.has(we)||this.__ownAttributes.add(we);this.__builtAgainst=je,F(this,"ready",{instance:this.__controller.instance});return}this.__controller.update(ge)}__tearDown(){const ge=this.__controller;this.__controller=null,this.__builtAgainst=null,ge&&(F(this,"destroyed",{instance:ge.instance}),ge.destroy())}}for(const Ee of[...ee.properties,...ee.scalars])Ee in ae.Base.prototype||Object.defineProperty(me.prototype,Ee,{get(){return this.__props[Ee]},set(ge){this.__write(Ee,ge)},configurable:!0,enumerable:!0});return me}function D(ae,se,ee){if(typeof ae!="function")throw new TypeError(`${se} needs ${ee}: ${se}({ ${ee} }).`)}function N(){const ae=globalThis.HTMLElement;return typeof ae=="function"?ae:null}function M(ae){D(ae&&ae.createKPI,"createLatticeKPIElement","createKPI");const se=N();return se?E({viewer:"kpi",Base:se,mount:(ee,ie)=>ae.createKPI(ee,ie)}):null}function A(ae){D(ae&&ae.createChart,"createLatticeChartElement","createChart");const se=N();return se?E({viewer:"chart",Base:se,mount:(ee,ie)=>ae.createChart({...ie,container:ee})}):null}function L(ae){D(ae&&ae.createKanban,"createLatticeKanbanElement","createKanban");const se=N();return se?E({viewer:"kanban",Base:se,mount:(ee,ie)=>ae.createKanban(ee,ie)}):null}function G(ae){D(ae&&ae.createCalendar,"createLatticeCalendarElement","createCalendar");const se=N();return se?E({viewer:"calendar",Base:se,mount:(ee,ie)=>ae.createCalendar(ee,ie)}):null}function q(ae){D(ae&&ae.createGantt,"createLatticeGanttElement","createGantt");const se=N();return se?E({viewer:"gantt",Base:se,mount:(ee,ie)=>ae.createGantt({...ie,element:ee})}):null}function Y(ae){D(ae&&ae.createLayout,"createLatticeLayoutElement","createLayout");const se=N();return se?E({viewer:"layout",Base:se,mount:(ee,ie)=>ae.createLayout(ee,ie)}):null}function J(ae){D(ae&&ae.createTabs,"createLatticeTabsElement","createTabs");const se=N();return se?E({viewer:"tabs",Base:se,mount:(ie,ce)=>{const he=new Map,me=typeof ie.querySelectorAll=="function"?[...ie.querySelectorAll("template[data-tab]")]:[];for(const je of me)je.parentNode===ie&&he.set(je.getAttribute("data-tab"),je);const ge=(Array.isArray(ce.tabs)&&ce.tabs.length?ce.tabs:[...he.keys()].map(je=>({id:je,label:he.get(je).getAttribute("data-label")||je}))).map(je=>{const pe=je,we=he.get(pe.id);return we?{...pe,view:ye=>{const Ne=we.content.cloneNode(!0),$e=[...Ne.childNodes];return ye.appendChild(Ne),{destroy(){for(const Ve of $e)Ve.parentNode&&Ve.parentNode.removeChild(Ve)}}}}:pe});return ae.createTabs(ie,{...ce,tabs:ge,createGrid:ae.createGrid||(()=>{throw new Error('[lattice] <lattice-tabs>: a tab has neither a <template data-tab="…"> nor a createGrid to build it with. Give the tab a template, or pass createGrid into createLatticeTabsElement.')})})}}):null}function te(ae){D(ae&&ae.createDataRouter,"createLatticeRouterElement","createDataRouter");const se=N();if(!se)return null;class ee extends se{__scope=null;__config={};constructor(){super(),R(this,"config")}get config(){return{...this.__config}}set config(ce){!ce||typeof ce!="object"||(this.__config={...this.__config,...ce},this.__scope&&this.__scope.router&&$("webcomponent.router.mountOnly.config","[lattice] <lattice-router>: `config` changed after the router was built. Nothing was applied and the router was NOT rebuilt — rebuilding it would detach every grid and drop every row it holds. Replace the <lattice-router> element itself when a genuinely different router is wanted."))}get router(){return this.__scope?this.__scope.router:null}get instance(){return this.router}connectedCallback(){if(this.__scope)return;const ce=h(this);this.__scope=S({createDataRouter:ae.createDataRouter,config:{...ce,...this.__config}}),this[i]=this.__scope}disconnectedCallback(){const ce=this.__scope;if(this.__scope=null,this[i]=null,!ce)return;const he=ce.router;ce.destroy(),he&&F(this,"destroyed",{instance:he})}}return ee}function ne(ae={}){const se={},ee=(ie,ce,he)=>{if(typeof ce!="function")return;const me=he();me&&(se[ie]=me)};return ee("LatticeGridElement",ae.createGrid,()=>le(ae.createGrid)),ee("LatticeKPIElement",ae.createKPI,()=>M({createKPI:ae.createKPI})),ee("LatticeChartElement",ae.createChart,()=>A({createChart:ae.createChart})),ee("LatticeKanbanElement",ae.createKanban,()=>L({createKanban:ae.createKanban})),ee("LatticeCalendarElement",ae.createCalendar,()=>G({createCalendar:ae.createCalendar})),ee("LatticeGanttElement",ae.createGantt,()=>q({createGantt:ae.createGantt})),ee("LatticeLayoutElement",ae.createLayout,()=>Y({createLayout:ae.createLayout})),ee("LatticeTabsElement",ae.createTabs,()=>J({createTabs:ae.createTabs,createGrid:ae.createGrid})),ee("LatticeRouterElement",ae.createDataRouter,()=>te({createDataRouter:ae.createDataRouter})),se}function oe(ae={}){const se=globalThis.customElements,ee={};if(!se||typeof se.define!="function")return ee;const ie=typeof ae.prefix=="string"?ae.prefix:n,ce=ne(ae),he={LatticeGridElement:t.grid,LatticeKPIElement:t.kpi,LatticeChartElement:t.chart,LatticeKanbanElement:t.kanban,LatticeCalendarElement:t.calendar,LatticeGanttElement:t.gantt,LatticeLayoutElement:t.layout,LatticeTabsElement:t.tabs,LatticeRouterElement:t.router};for(const[me,Ee]of Object.entries(ce)){const ge=ie+he[me],je=se.get?se.get(ge):void 0;if(je){ee[ge]=je;continue}se.define(ge,Ee),ee[ge]=Ee}return ee}function le(ae){const se=N();if(!se)return null;class ee extends se{static get observedAttributes(){return w()}__connected=!1;__teardownPending=!1;__published=!1;__publishedAs=s;__scope=null;__predicates=void 0;__rowUpdates=void 0;__release=[];constructor(){super(),this.__controller=new z(this,{createGrid:ae});for(const ce of["rows","columns","config","predicates","rowUpdates",...Object.values(g)])R(this,ce)}get grid(){return this.__controller.grid}get instance(){return this.__controller.grid}get rows(){return this.__controller.config().rows}set rows(ce){this.__controller.configure({rows:ce})}get columns(){return this.__controller.config().columns}set columns(ce){this.__controller.configure({columns:ce})}get config(){return this.__controller.config()}set config(ce){this.__controller.configure(ce)}get predicates(){return this.__predicates}set predicates(ce){const he=this.__published?this.__controller.grid:null;he&&v(he,ce,this.__predicates),this.__predicates=ce}get rowUpdates(){return this.__rowUpdates}set rowUpdates(ce){if(Object.is(ce,this.__rowUpdates))return;this.__rowUpdates=ce;const he=this.__published?this.__controller.grid:null;he&&ce&&he.rows.apply(ce)}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__scope){const ce=c(this);ce&&this.__release.push(ce),this.__scope=y(this)}this.__controller.connect(),queueMicrotask(()=>this.__publish())}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()),this.__controller.disconnect())}attributeChangedCallback(ce,he,me){this.__controller.attributeChanged(ce,me)}__publish(){if(!this.__connected||this.__published)return;const ce=this.__controller.grid;if(!ce)return;this.__published=!0,this.__predicates&&v(ce,this.__predicates,{});const he=typeof this.getAttribute=="function"?this.getAttribute("name"):null;this.__publishedAs=he||s;const me=this.__scope;me&&me.grids.publish(this.__publishedAs,ce);const Ee=typeof this.getAttribute=="function"?this.getAttribute("route"):null;if(me&&Ee!==null){const ge=this.getAttribute("route-options");me.attach(ce,d(Ee),ge===null?{}:d(ge))}this.__rowUpdates&&ce.rows.apply(this.__rowUpdates),F(this,"grid-ready",{grid:ce})}__settleTeardown(){if(!this.__teardownPending)return;this.__teardownPending=!1;const ce=this.__controller.grid,he=this.__scope;this.__scope=null,this.__published=!1;for(const me of this.__release.splice(0))try{me()}catch{}ce&&he&&(F(this,"grid-destroyed",{grid:ce}),he.detach(ce),he.grids.publish(this.__publishedAs,null)),this.__controller.settleTeardown()}}for(const ie of Object.values(g))Object.getOwnPropertyDescriptor(ee.prototype,ie)||ie in se.prototype||Object.defineProperty(ee.prototype,ie,{get(){return this.__controller.config()[ie]},set(ce){this.__controller.configure({[ie]:ce})},configurable:!0,enumerable:!0});return ee}}),Fe("packages/modules/webcomponent/index.js",function(e,K){"use strict";Object.defineProperty(e,"TAG_NAME",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createLatticeGridElement",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"defineLatticeGrid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const Q=K("packages/dom/src/index.js"),$=Q.createGrid,B=K("packages/modules/webcomponent/elements.js"),I=B.gridElementClass,_=K("packages/modules/webcomponent/controller.js");Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return _.GridElementController}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return _.observedAttributeNames}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return _.domEventName}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return _.ATTRIBUTE_CONFIG}}),Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return _.EVENT_PREFIX}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return B.createLatticeElements}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return B.defineLatticeElements}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return B.ELEMENT_TAGS}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return B.createLatticeKPIElement}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return B.createLatticeChartElement}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return B.createLatticeKanbanElement}}),Object.defineProperty(e,"createLatticeCalendarElement",{enumerable:!0,get:function(){return B.createLatticeCalendarElement}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return B.createLatticeGanttElement}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return B.createLatticeLayoutElement}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return B.createLatticeTabsElement}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return B.createLatticeRouterElement}});const X=K("packages/modules/webcomponent/styles.js");Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return X.adoptLatticeStyles}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return X.latticeStyleSheets}});const W=K("packages/modules/react/viewers.js");Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return W.VIEWER_EVENTS}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return W.VIEWER_APPLY}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return W.viewerHandlerName}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return W.createViewerController}});const H=K("packages/modules/shared/adapter.js");Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return H.EVENT_NAMES}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return H.dashedName}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return Q.createCurrencyType}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return Q.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return Q.registerUnitSystem}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return Q.createStat}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return Q.createHeadlessGrid}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return Q.duckdbAdapter}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return Q.createPushdownSource}});const U="lattice-grid";function z(g=$){return I(g)}function w(g={}){const l=globalThis.customElements,c=g.tagName||U;if(!l||typeof l.define!="function")return null;const s=l.get?l.get(c):void 0;if(s)return s;const n=z(g.createGrid||$);return n?(l.define(c,n),n):null}w();const k=w});try{Kn("packages/worker/src/inline.js").setWorkerSource('(function(Ot){"use strict";var ct=Object.create(null),lt=Object.create(null);function Ce(o,me){ct[o]=me}function at(o){var me=lt[o];if(me)return me;var ae=Object.create(null);lt[o]=ae;var he=ct[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(ae,at),ae}Ce("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return Se}});const ae="1.86.4";async function he(){return ae}const W="1.86.4",U=new Set,_=2e3;function Z(D){if(U.add(D),U.size>_){const x=U.values().next().value;x!==void 0&&U.delete(x)}}const E=[],z=500;function re(D,x,fe){E.push({key:D,level:x,message:fe.map(p=>typeof p=="string"?p:Y(p)).join(" "),at:Date.now()}),E.length>z&&E.shift()}function Y(D){if(D instanceof Error)return D.message;try{return JSON.stringify(D)}catch{return String(D)}}function se(){return E.map(D=>({...D}))}function te(D){if(D.length===0||typeof D[0]!="string")return D;const x=D[0].replace(/^\\[lattice\\]\\s*/,"");return x===D[0]?D:[x,...D.slice(1)]}function H(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"warn",fe),console.warn("[lattice]",...fe)}function T(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"info",fe),console.info("[lattice]",...fe)}function V(){U.clear(),E.length=0}function ne(D,x){const fe=new Error(`[lattice] ${D}`);throw x!==void 0&&(fe.cause=x),fe}function R(D,x){D||ne(x)}const j=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(D){return D!==null&&typeof D=="object"&&!Array.isArray(D)}function a(D){return typeof D=="function"}function s(D){return D==null}function h(D){return D==null||D===""}function u(D){return typeof D!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(D))?!0:!!(D.prototype&&Object.getOwnPropertyNames(D.prototype).length>1)}const t=new Map;function l(D){let x=t.get(D);if(x)return x;if(!D.includes("."))x=fe=>fe?.[D];else{const fe=D.split("."),p=fe.length;x=Q=>{let X=Q;for(let ce=0;ce<p;ce++){if(X==null)return;X=X[fe[ce]]}return X}}return t.set(D,x),x}const m=new Map;function e(D){let x=m.get(D);if(x)return x;if(!D.includes("."))x=(fe,p)=>{fe!=null&&(fe[D]=p)};else{const fe=D.split("."),p=fe.length-1;x=(Q,X)=>{let ce=Q;for(let le=0;le<p;le++){if(ce==null)return;const ge=fe[le];ce[ge]==null&&(ce[ge]={}),ce=ce[ge]}ce!=null&&(ce[fe[p]]=X)}}return m.set(D,x),x}function d(D,x){return l(x)(D)}function f(D,x,fe){e(x)(D,fe)}function r(D){return D?(D.includes(".")?D.slice(D.lastIndexOf(".")+1):D).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(/^./,fe=>fe.toUpperCase()):""}const n={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"};function c(D){const x=D==null?"":String(D);return/[&<>"\']/.test(x)?x.replace(/[&<>"\']/g,fe=>n[fe]):x}function g(D){return String(D).replace(/\\w\\S*/g,x=>x[0].toUpperCase()+x.slice(1).toLowerCase())}function A(D,x,fe){if(D!==void 0)return D===!0?{enabled:!0,...fe}:D===!1?{enabled:!1}:i(D)?D:{[x]:D,enabled:!0}}function P(D){return D==null?[]:Array.isArray(D)?D:[D]}const q=Object.freeze(new Set(["__proto__","constructor","prototype"]));function L(D,x){if(!i(D))return i(x)?{...x}:x;if(!i(x))return x===void 0?D:x;const fe={...D};for(const p of Object.keys(x)){if(q.has(p))continue;const Q=x[p];Q!==void 0&&(fe[p]=i(Q)&&i(fe[p])?L(fe[p],Q):Q)}return fe}function v(D,x){if(!i(D)||!i(x)||D===x)return x;const fe=Object.create(Object.getPrototypeOf(D));return Object.assign(fe,D,x),fe}class G{#t;#e=new Map;#n;constructor(x=256,fe=null){this.#t=x,this.#n=fe}get size(){return this.#e.size}get max(){return this.#t}set max(x){this.#t=x,this.#r()}has(x){return this.#e.has(x)}get(x){const fe=this.#e;if(!fe.has(x))return;const p=fe.get(x);return fe.delete(x),fe.set(x,p),p}peek(x){return this.#e.get(x)}set(x,fe){const p=this.#e;return p.has(x)&&p.delete(x),p.set(x,fe),this.#r(),fe}delete(x){const fe=this.#e.get(x);return this.#e.delete(x)&&this.#n&&this.#n(fe,x),fe}clear(){if(this.#n)for(const[x,fe]of this.#e)this.#n(fe,x);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const x=this.#e;for(;x.size>this.#t;){const fe=x.keys().next().value,p=x.get(fe);x.delete(fe),this.#n&&this.#n(p,fe)}}}const S=new Map;function N(D,x){const fe=`${D||""}|${x?JSON.stringify(x):""}`;let p=S.get(fe);return p||(p=new Intl.Collator(D||void 0,{numeric:!0,sensitivity:"variant",...x}),S.set(fe,p)),p}function I(D,x){if(D===x)return 0;if(D==null)return 1;if(x==null)return-1;if(typeof D=="number"&&typeof x=="number")return Number.isNaN(D)?Number.isNaN(x)?0:1:Number.isNaN(x)||D<x?-1:D>x?1:0;const fe=String(D),p=String(x);return fe<p?-1:fe>p?1:0}function K(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const B=typeof requestAnimationFrame=="function";function ee(D){return B?requestAnimationFrame(D):setTimeout(()=>D(K()),16)}function J(D){D!=null&&(B?cancelAnimationFrame(D):clearTimeout(D))}function ue(D){let x=null,fe=null;const p=()=>{x=null;const X=fe;fe=null,D(...X||[])},Q=(...X)=>{fe=X,x===null&&(x=ee(p))};return Q.cancel=()=>{J(x),x=null,fe=null},Q.flush=()=>{x!==null&&(J(x),p())},Q}function de(D,x){let fe=null,p=null;const Q=()=>{if(fe=null,p===null)return;const le=p;p=null,D(...le),X()},X=()=>{fe=setTimeout(Q,x),typeof fe?.unref=="function"&&fe.unref()},ce=(...le)=>{fe===null?(D(...le),X()):(p=le,clearTimeout(fe),X())};return ce.flush=()=>{if(fe!==null&&clearTimeout(fe),fe=null,p===null)return;const le=p;p=null,D(...le)},ce.cancel=()=>{fe!==null&&clearTimeout(fe),fe=null,p=null},ce.pending=()=>fe!==null||p!==null,ce}function Oe(D,x=50){return typeof requestIdleCallback=="function"?requestIdleCallback(D,{timeout:x}):setTimeout(()=>D({timeRemaining:()=>0,didTimeout:!0}),1)}let Ae=0;function Se(D="l"){return`${D}${(++Ae).toString(36)}`}}),Ce("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.isFunction,U=1,_=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),Z=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),E=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function z(a){if(a==null)return null;const s=a.presence;return{id:a.id,kind:a.kind,nullable:!!a.nullable,values:a.values??null,presence:s?s.words??s:null,presenceBits:s?s.size??(s.words??s).length*8:0,dict:a.dict?re(a.dict):null,offsets:a.offsets??null,version:a.version??0}}function re(a){return Array.isArray(a)?a:W(a.values)?a.values():[]}function Y(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=z(a[h]);return s}class se{#t;#e;constructor(s,h){this.#t=s,this.#e=h}get words(){return this.#t}get size(){return this.#e}get(s){return(this.#t[s>>>3]&1<<(s&7))!==0}count(){const s=this.#t;let h=0;for(let u=0;u<s.length;u++){let t=s[u];for(;t;)t&=t-1,h++}return h}}class te{#t;#e=null;#n=0;#r=new Map;constructor(s){this.#t=s||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(s){if(this.#e===null){this.#e=new Map;for(let t=0;t<this.#t.length;t++)this.#e.set(this.#t[t],t)}const h=this.#e.get(s);if(h!==void 0)return h;const u=this.#t.length;return this.#t.push(s),this.#e.set(s,u),this.#n++,u}valueOf(s){return this.#t[s]}values(){return this.#t}ranks(s){const h=s||"",u=this.#r.get(h);if(u&&u.version===this.#n)return u.ranks;const t=this.#t.length,l=new Uint32Array(t);for(let r=0;r<t;r++)l[r]=r;const m=he(s).compare,e=this.#t,d=Array.from(l).sort((r,n)=>{const c=e[r],g=e[n];return c===g?0:c==null?1:g==null?-1:m(String(c),String(g))}),f=new Uint32Array(t);for(let r=0;r<d.length;r++)f[d[r]]=r;return this.#r.set(h,{version:this.#n,ranks:f}),f}}function H(a){if(a==null)return null;const s=a.presence?new se(a.presence,a.presenceBits||a.presence.length*8):null,h=a.dict?new te(a.dict):null,u=a.values,t=a.offsets??null,l=a.kind,m=e=>{if(s&&!s.get(e))return null;switch(l){case"dictionary":return h?h.valueOf(u[e]):u[e];case"bitset":return(u[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],f=t[e+1],r=new Array(f-d);for(let n=d;n<f;n++)r[n-d]=h?h.valueOf(u[n]):u[n];return r}default:return u[e]}};return{id:a.id,kind:l,nullable:a.nullable,values:u,presence:s,dict:h,offsets:t,get:m,version:a.version}}function T(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=H(a[h]);return s}function V(){const a=[],s=[];return{mask(h){for(let u=0;u<a.length;u++)if(a[u].length>=h){const t=a.splice(u,1)[0].subarray(0,h);return t.fill(0),t}return new Uint8Array(h)},indices(h){for(let u=0;u<s.length;u++)if(s[u].length>=h)return s.splice(u,1)[0].subarray(0,h);return new Uint32Array(h)},release(h){h&&(h instanceof Uint8Array?a.push(h):h instanceof Uint32Array&&s.push(h))},clear(){a.length=0,s.length=0}}}function ne(a){if(!ArrayBuffer.isView(a))return!1;const s=a.buffer;return s?typeof SharedArrayBuffer>"u"||!(s instanceof SharedArrayBuffer):!1}function R(a,s=[]){const h=u=>{if(!ne(u))return;const t=u.buffer;s.includes(t)||s.push(t)};if(a==null)return s;if(ArrayBuffer.isView(a))return h(a),s;if(Array.isArray(a)){for(const u of a)h(u);return s}if(typeof a=="object")for(const u of Object.keys(a)){const t=a[u];if(Array.isArray(t))for(const l of t)h(l);else h(t)}return s}function j(a,s=0){if(a==null)return!0;const h=typeof a;if(h==="function"||h==="symbol")return!1;if(h!=="object"||s>4||ArrayBuffer.isView(a)||a instanceof ArrayBuffer||a instanceof Date)return!0;if(Array.isArray(a)){for(const u of a)if(!j(u,s+1))return!1;return!0}for(const u of Object.keys(a))if(!j(a[u],s+1))return!1;return!0}function i(a,s=new Set){if(!a||typeof a!="object")return s;const h=a;typeof h.col=="string"&&s.add(h.col);const u=h.conditions;if(Array.isArray(u))for(const t of u)i(t,s);return s}}),Ce("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const ae=8;class he{static#t=new Uint8Array(256);static{for(let U=1;U<256;U++)he.#t[U]=he.#t[U>>1]+(U&1)}#e;#n;constructor(U=0){const _=Math.max(0,U|0);this.#n=_,this.#e=new Uint8Array(Math.ceil(_/ae))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(U){return U<0||U>=this.#n?0:this.#e[U>>3]>>(U&7)&1}set(U){return U>=0&&U<this.#n&&(this.#e[U>>3]|=1<<(U&7)),this}clear(U){return U>=0&&U<this.#n&&(this.#e[U>>3]&=~(1<<(U&7))),this}assign(U,_){return _?this.set(U):this.clear(U)}fill(U=!1){return this.#e.fill(U?255:0),U&&this.#r(),this}grow(U){const _=Math.max(0,U|0);if(_<=this.#n)return this;const Z=Math.ceil(_/ae);if(Z>this.#e.length){const E=new Uint8Array(Z);E.set(this.#e),this.#e=E}return this.#n=_,this}count(){const U=this.#e,_=he.#t;let Z=0;for(let E=0;E<U.length;E++)Z+=_[U[E]];return Z}and(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]&=_[z];for(let z=E;z<Z.length;z++)Z[z]=0;return this}or(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]|=_[z];return this}not(){const U=this.#e;for(let _=0;_<U.length;_++)U[_]=~U[_]&255;return this.#r(),this}clone(){const U=new he(this.#n);return U.words.set(this.#e.subarray(0,U.words.length)),U}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const U=this.#n&7;if(U===0)return;const _=this.#n>>3;_<this.#e.length&&(this.#e[_]&=(1<<U)-1)}static from(U){const _=Array.isArray(U)?U:Array.from(U),Z=new he(_.length);for(let E=0;E<_.length;E++)_[E]&&Z.set(E);return Z}}}),Ce("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return U}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare;class U{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(Z=[]){this.#t=[];for(let E=0;E<Z.length;E++){const z=Z[E];this.#e.has(z)||(this.#e.set(z,this.#t.length),this.#t.push(z))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let Z=this.#t.length*8;for(let E=0;E<this.#t.length;E++){const z=this.#t[E];typeof z=="string"&&(Z+=z.length*2),Z+=16}return Z}codeOf(Z){const E=this.#e.get(Z);if(E!==void 0)return E;const z=this.#t.length;return this.#t.push(Z),this.#e.set(Z,z),this.#n++,z}lookup(Z){const E=this.#e.get(Z);return E===void 0?-1:E}has(Z){return this.#e.has(Z)}valueOf(Z){return this.#t[Z]}values(){return this.#t}ranks(Z){const E=Z||"";if(this.#r&&this.#i===this.#n&&this.#s===E)return this.#r;const z=this.#t.length,re=new Array(z);for(let H=0;H<z;H++)re[H]=H;const Y=he(Z).compare,se=this.#t;re.sort((H,T)=>this.#h(se[H],se[T],Y));const te=new Uint32Array(z);for(let H=0;H<z;H++)te[re[H]]=H;return this.#r=te,this.#i=this.#n,this.#s=E,te}#h(Z,E,z){return typeof Z=="string"&&typeof E=="string"?z(Z,E):W(Z,E)}}}),Ce("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return ae}});class ae{#t;#e;#n=0;#r=0;constructor(W={}){const U=Math.max(1,W.rows??16),_=Math.max(1,W.values??U);this.#t=new Int32Array(_),this.#e=new Uint32Array(U+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(W){return W<0||W>=this.#n?0:this.#e[W+1]-this.#e[W]}at(W){return W<0||W>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[W],this.#e[W+1])}has(W,U){if(W<0||W>=this.#n)return!1;const _=this.#t,Z=this.#e[W+1];for(let E=this.#e[W];E<Z;E++)if(_[E]===U)return!0;return!1}hasAny(W,U){for(let _=0;_<U.length;_++)if(this.has(W,U[_]))return!0;return!1}hasAll(W,U){for(let _=0;_<U.length;_++)if(!this.has(W,U[_]))return!1;return!0}hasNone(W,U){return!this.hasAny(W,U)}push(W){const U=this.#n,_=W.length;this.#i(U+1),this.#s(this.#r+_);const Z=this.#r;for(let E=0;E<_;E++)this.#t[Z+E]=W[E]|0;return this.#r+=_,this.#n=U+1,this.#e[U]=Z,this.#e[U+1]=this.#r,U}write(W,U){if(W===this.#n){this.push(U);return}if(W<0||W>this.#n)return;const _=this.#e[W],Z=this.#e[W+1],E=U.length;if(Z-_===E){for(let z=0;z<E;z++)this.#t[_+z]=U[z]|0;return}this.#h(W,U)}compact(W,U,_){const Z=this.#t,E=this.#e,z=this.#n,re=new Int32Array(Math.max(1,this.#r)),Y=new Uint32Array(U+1);let se=0;for(let te=0;te<z;te++){if(W[te]===_)continue;const H=E[te],T=E[te+1];Y[W[te]]=se;for(let V=H;V<T;V++)re[se++]=Z[V];Y[W[te]+1]=se}this.#t=re,this.#e=Y,this.#n=U,this.#r=se}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(W){if(W+1<=this.#e.length)return;let U=this.#e.length-1;for(;U<W;)U=U*2||16;const _=new Uint32Array(U+1);_.set(this.#e),this.#e=_}#s(W){if(W<=this.#t.length)return;let U=this.#t.length;for(;U<W;)U=U*2||16;const _=new Int32Array(U);_.set(this.#t),this.#t=_}#h(W,U){const _=this.#t,Z=this.#e,E=this.#n,z=U.length-(Z[W+1]-Z[W]),re=new Int32Array(Math.max(1,this.#r+z)),Y=new Uint32Array(Z.length);let se=0;for(let te=0;te<E;te++){if(Y[te]=se,te===W)for(let H=0;H<U.length;H++)re[se++]=U[H]|0;else for(let H=Z[te];H<Z[te+1];H++)re[se++]=_[H];Y[te+1]=se}this.#t=re,this.#e=Y,this.#r=se}}}),Ce("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return j}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare,U=ae.warnOnce;function _(i){const a=new Uint32Array(i);for(let s=0;s<i;s++)a[s]=s;return a}function Z(i,a){if(a&&typeof a.count=="number")return a.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const s=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):s?i.kind==="bitset"?typeof s.size=="number"?s.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(U(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${s.length*8}`),s.length*8):s.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const E=new WeakMap;function z(i){const a=i.constructor;if(!a)return"unknown";const s=E.get(a);if(s)return s;let h="unknown";try{let u=null;typeof a.from=="function"?u=a.from([!1,!0]):(u=new a(8),u.set(1));const t=u&&u.words;t&&t.length&&(t[0]===2?h="lsb":t[0]===64&&(h="msb"))}catch{h="unknown"}return E.set(a,h),h}function re(i){if(!i)return()=>0;const a=i instanceof Uint8Array?i:i.words;if(a instanceof Uint8Array){const s=i instanceof Uint8Array?"lsb":z(i);if(s==="lsb")return h=>a[h>>>3]>>>(h&7)&1;if(s==="msb")return h=>a[h>>>3]>>>7-(h&7)&1}return typeof i.get=="function"?s=>i.get(s)?1:0:()=>0}function Y(i){return!i||!i.presence?null:re(i.presence)}function se(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function te(i,a){return i?typeof i.valueOf=="function"?i.valueOf(a):typeof i.values=="function"?i.values()[a]:null:null}function H(i,a){const s=i.offsets,h=i.values;if(!s||!h)return[];const u=s[a],t=s[a+1];if(!(t>u))return[];const l=i.dict,m=new Array(t-u);for(let e=u;e<t;e++)m[e-u]=l?te(l,h[e]):h[e];return m}function T(i){if(!i)return()=>{};const a=i.values,s=Y(i),h=i.kind;if(h==="dictionary"){const u=i.dict;return s?t=>s(t)?te(u,a[t]):null:t=>te(u,a[t])}if(h==="bitset"){const u=re(a);return s?t=>s(t)?u(t)===1:null:t=>u(t)===1}if(h==="multi")return s?u=>s(u)?H(i,u):null:u=>H(i,u);if(!a&&typeof i.get=="function"){const u=i.get.bind(i);return t=>{const l=u(t);return l===void 0?null:l}}return s?u=>{if(!s(u))return null;const t=a[u];return t===void 0?null:t}:u=>{const t=a[u];return t===void 0?null:t}}function V(i,a){if(i<a)return-1;if(i>a)return 1;if(i===a){const u=Object.is(i,-0),t=Object.is(a,-0);return u===t?0:u?-1:1}const s=Number.isNaN(i),h=Number.isNaN(a);return s&&h?0:s?1:-1}function ne(i){const a=he(i);return(s,h)=>{if(s===h)return 0;const u=typeof s,t=typeof h;if(u==="string"&&t==="string")return a.compare(s,h);if(u==="number"&&t==="number")return V(s,h);if(u==="boolean"&&t==="boolean")return s===h?0:s?1:-1;if(s instanceof Date||h instanceof Date){const l=s instanceof Date?s.getTime():Number(s),m=h instanceof Date?h.getTime():Number(h);return V(l,m)}return W(s,h)}}function R(i,a){if(i&&typeof i.ranks=="function")return i.ranks(a);const s=i&&typeof i.values=="function"?i.values():[],h=s.length,u=ne(a),t=new Array(h);for(let m=0;m<h;m++)t[m]=m;t.sort((m,e)=>u(s[m],s[e])||m-e);const l=new Uint32Array(h);for(let m=0;m<h;m++)l[t[m]]=m;return l}function j(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Ce("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return v}});const ae=me("packages/core/src/compute/handle.js"),he=ae.bitReader,W=ae.dictRanks,U=ae.dictSize,_=ae.identity,Z=ae.isMissing,E=ae.presenceReader,z=ae.rowCount,re=ae.valueComparator,Y=ae.valueReader,se=new Uint32Array(0),te=new ArrayBuffer(8),H=new Float64Array(te),T=new Uint32Array(te),V=(H[0]=-1,(T[1]&2147483648)!==0?1:0),ne=V===1?0:1;function R(S,N){H[0]=S;let I=T[V],K=T[ne];(I&2147483648)!==0?(I=~I>>>0,K=~K>>>0):I=(I^2147483648)>>>0,N[0]=K,N[1]=I}function j(S,N,I,K){if(K<2)return S;const B=new Uint32Array(256*8);for(let D=0;D<K;D++){const x=N[D],fe=I[D];B[x&255]++,B[256+(x>>>8&255)]++,B[512+(x>>>16&255)]++,B[768+(x>>>24&255)]++,B[1024+(fe&255)]++,B[1280+(fe>>>8&255)]++,B[1536+(fe>>>16&255)]++,B[1792+(fe>>>24&255)]++}let ee=S,J=N,ue=I,de=new Uint32Array(K),Oe=new Uint32Array(K),Ae=new Uint32Array(K);const Se=new Uint32Array(256);for(let D=0;D<8;D++){const x=D<<8,fe=(D&3)<<3,p=D>=4;let Q=!1;for(let le=0;le<256;le++)if(B[x+le]===K){Q=!0;break}if(Q)continue;let X=0;for(let le=0;le<256;le++)Se[le]=X,X+=B[x+le];for(let le=0;le<K;le++){const ge=J[le],Me=ue[le],be=(p?Me:ge)>>>fe&255,ye=Se[be]++;de[ye]=ee[le],Oe[ye]=ge,Ae[ye]=Me}let ce=ee;ee=de,de=ce,ce=J,J=Oe,Oe=ce,ce=ue,ue=Ae,Ae=ce}return ee}function i(S,N,I){if(I<2)return S;const K=new Uint32Array(256*4);for(let Oe=0;Oe<I;Oe++){const Ae=N[Oe];K[Ae&255]++,K[256+(Ae>>>8&255)]++,K[512+(Ae>>>16&255)]++,K[768+(Ae>>>24&255)]++}let B=S,ee=N,J=new Uint32Array(I),ue=new Uint32Array(I);const de=new Uint32Array(256);for(let Oe=0;Oe<4;Oe++){const Ae=Oe<<8,Se=Oe<<3;let D=!1;for(let p=0;p<256;p++)if(K[Ae+p]===I){D=!0;break}if(D)continue;let x=0;for(let p=0;p<256;p++)de[p]=x,x+=K[Ae+p];for(let p=0;p<I;p++){const Q=ee[p],X=de[Q>>>Se&255]++;J[X]=B[p],ue[X]=Q}let fe=B;B=J,J=fe,fe=ee,ee=ue,ue=fe}return B}function a(S,N,I,K){const B=new Uint32Array(K+1);for(let ue=0;ue<I;ue++)B[N[ue]]++;let ee=0;for(let ue=0;ue<=K;ue++){const de=B[ue];B[ue]=ee,ee+=de}const J=new Uint32Array(I);for(let ue=0;ue<I;ue++)J[B[N[ue]]++]=S[ue];return J}function s(S,N,I,K){return I<2?S:K<=65536||K<=I*2?a(S,N,I,K):i(S,N,I)}function h(S,N){return S.length===N&&S.byteOffset===0?S:Uint32Array.prototype.slice.call(S,0,N)}function u(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=new Uint32Array(B),J=new Uint32Array(B),ue=new Uint32Array(B),de=new Uint32Array(B),Oe=new Uint32Array(2);let Ae=0,Se=0;for(let fe=0;fe<B;fe++){const p=K[fe],Q=S[p];if(Number.isNaN(Q)){de[Se++]=p;continue}R(Q,Oe),I?(J[Ae]=~Oe[0]>>>0,ue[Ae]=~Oe[1]>>>0):(J[Ae]=Oe[0],ue[Ae]=Oe[1]),ee[Ae++]=p}const D=j(ee.subarray(0,Ae),J.subarray(0,Ae),ue.subarray(0,Ae),Ae);if(Se===0)return h(D,Ae);const x=new Uint32Array(B);return x.set(D.subarray(0,Ae),0),x.set(de.subarray(0,Se),Ae),x}function t(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=Uint32Array.from(K),J=new Uint32Array(B);for(let ue=0;ue<B;ue++){const de=(S[ee[ue]]^2147483648)>>>0;J[ue]=I?~de>>>0:de}return h(i(ee,J,B),B)}function l(S,N,I={}){const K=N||_(z(S,I)),B=K.length;if(B<2)return Uint32Array.from(K);const ee=W(S.dict,I.locale),J=S.values,ue=E(S),de=Math.max(U(S.dict),ee.length),Oe=de,Ae=Uint32Array.from(K),Se=new Uint32Array(B),D=!!I.descending;for(let x=0;x<B;x++){const fe=Ae[x];let p=ue&&ue(fe)===0?Oe:ee[J[fe]];p===void 0&&(p=Oe),Se[x]=D?Oe-p:p}return h(s(Ae,Se,B,de+1),B)}function m(S,N,I){const K=N.length;let B=Uint32Array.from(N);if(K<2)return B;let ee=new Uint32Array(K);for(let J=1;J<K;J<<=1){for(let de=0;de<K;de+=J<<1){const Oe=Math.min(de+J,K),Ae=Math.min(de+(J<<1),K);let Se=de,D=Oe,x=de;for(;Se<Oe&&D<Ae;)ee[x++]=I(S[B[Se]],S[B[D]])<=0?B[Se++]:B[D++];for(;Se<Oe;)ee[x++]=B[Se++];for(;D<Ae;)ee[x++]=B[D++]}const ue=B;B=ee,ee=ue}return B}function e(S,N,I){const K=he(S.values),B=N.length,ee=new Uint32Array(B),J=I?1:0;let ue=0;for(let de=0;de<B;de++)K(N[de])===J&&(ee[ue++]=N[de]);for(let de=0;de<B;de++)K(N[de])!==J&&(ee[ue++]=N[de]);return ee}function d(S,N){const I=S.values,K=S.kind;if((K==="object"||K===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!S.presence)return I;const ee=Y(S),J=new Array(z(S)||0);for(let ue=0;ue<N.length;ue++){const de=N[ue];J[de]=ee(de)}return J}function f(S,N){for(let I=0;I<N.length;I++)if(typeof S[N[I]]!="string")return!1;return!0}function r(S,N,I,K,B){const ee=S.length,J=Uint32Array.from(S);if(ee<2||K<1)return J;const ue=new Uint32Array(ee),de=K-1;for(let Oe=0;Oe<ee;Oe++){const Ae=I[N[Oe]];ue[Oe]=B?de-Ae:Ae}return h(s(J,ue,ee,K),ee)}function n(S,N,I){const K=re(I),B=new Array(N);for(let J=0;J<N;J++)B[J]=J;B.sort((J,ue)=>K(S[J],S[ue])||J-ue);const ee=new Uint32Array(N);for(let J=0;J<N;J++)ee[B[J]]=J;return ee}function c(S,N,I){const K=N.length,B=new Map,ee=[],J=new Uint32Array(K);for(let Oe=0;Oe<K;Oe++){const Ae=S[N[Oe]];let Se=B.get(Ae);Se===void 0&&(Se=ee.length,B.set(Ae,Se),ee.push(Ae)),J[Oe]=Se}const ue=ee.length,de=n(ee,ue,I.locale);return r(N,J,de,ue,!!I.descending)}function g(S,N,I){const K=d(S,N);if(N.length>=2&&f(K,N)){const J=S.stringRank;return J&&J.version===S.version&&J.usable(N,K,I.locale)?J.sort(N,I):c(K,N,I)}const B=re(I.locale),ee=I.descending?(J,ue)=>B(ue,J):B;return m(K,N,ee)}function A(S,N,I){const K=d(S,N),B=I.compare,J=!!I.descending?(ue,de)=>-B(ue,de,void 0,void 0,!0):(ue,de)=>B(ue,de,void 0,void 0,!1);return m(K,N,J)}function P(S,N){const I=N.length,K=E(S),B=S.values,ee=S.kind==="float64"&&!!B,J=S.kind==="object"||S.kind==="multi"||S.kind===void 0;if(!K&&!ee&&!J)return{present:N,absent:se};const ue=new Uint32Array(I),de=new Uint32Array(I);let Oe=0,Ae=0;if(K&&ee)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1&&!Number.isNaN(B[D])?ue[Oe++]=D:de[Ae++]=D}else if(ee&&!K)for(let Se=0;Se<I;Se++){const D=N[Se];Number.isNaN(B[D])?de[Ae++]=D:ue[Oe++]=D}else if(K&&!J)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1?ue[Oe++]=D:de[Ae++]=D}else{const Se=Y(S);for(let D=0;D<I;D++){const x=N[D];Z(Se(x))?de[Ae++]=x:ue[Oe++]=x}}return Ae===0?{present:N,absent:se}:{present:ue.subarray(0,Oe),absent:de.subarray(0,Ae)}}function q(S,N,I){if(N.length===0)return S;const K=new Uint32Array(S.length+N.length);return I?(K.set(N,0),K.set(S,N.length)):(K.set(S,0),K.set(N,S.length)),K}function L(S,N,I={}){const K=N||_(z(S,I));if(!S||K.length<2)return Uint32Array.from(K);const{present:B,absent:ee}=P(S,K);if(B.length===0)return Uint32Array.from(K);const J=!!I.descending;let ue;if(typeof I.compare=="function")ue=A(S,B,I);else switch(S.kind){case"float64":ue=u(S.values,B,J);break;case"int32":ue=t(S.values,B,J);break;case"dictionary":ue=l(S,B,I);break;case"bitset":ue=e(S,B,J);break;default:ue=g(S,B,I);break}return q(ue,ee,!!I.nullsFirst)}function v(S,N,I,K={}){const B=N||[],ee=B.length&&(B[0].handle||G(S,B[0].col))||S&&S[0];let J=I||_(z(ee,K));for(let ue=B.length-1;ue>=0;ue--){const de=B[ue],Oe=de.handle||G(S,de.col)||S&&S[ue];Oe&&(J=L(Oe,J,{descending:de.descending!==void 0?!!de.descending:de.dir==="desc",nullsFirst:!!de.nullsFirst,locale:de.locale!==void 0?de.locale:K.locale,compare:de.compare}))}return J instanceof Uint32Array?J:Uint32Array.from(J)}function G(S,N){if(!(!S||N===void 0)){for(let I=0;I<S.length;I++)if(S[I]&&S[I].id===N)return S[I]}}}),Ce("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return _}});const ae=me("packages/core/src/compute/sort.js"),he=ae.collateStringRanks,W=ae.rankSortStrings,U=1e5;class _{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(E=U){this.#h=E>0?E:U,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(E){this.#s=E}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let E=this.#n.byteLength;const z=this.#t;for(let re=0;re<z.length;re++)E+=z[re].length*2+24;return E}#a(E,z){const re=this.#e.get(E);if(re!==void 0)return re;if(this.#u)return-1;if(z&&this.#t.length>=this.#h)return this.#u=!0,-1;const Y=this.#t.length;return this.#t.push(E),this.#e.set(E,Y),this.#i++,Y}build(E,z){const re=z|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let Y=0;Y<re;Y++){const se=E[Y],te=typeof se=="string"?this.#a(se,!1):-1;this.#n[Y]=te<0?0:te}this.#r=re}append(E,z,re){const Y=(z|0)+(re|0);if(Y>this.#n.length){const se=new Uint32Array(Y);se.set(this.#n.subarray(0,this.#r)),this.#n=se}for(let se=z|0;se<Y;se++){const te=E[se],H=typeof te=="string"?this.#a(te,!0):-1;this.#n[se]=H<0?0:H}this.#r=Math.max(this.#r,Y)}ranks(E){const z=E||"";if(this.#o&&this.#c===this.#i&&this.#l===z)return this.#o;const re=he(this.#t,this.#t.length,E);return this.#o=re,this.#c=this.#i,this.#l=z,re}usable(E,z,re){if(this.#u||this.#t.length===0)return!1;const Y=this.#n,se=this.#t,te=this.#r;for(let H=0;H<E.length;H++){const T=E[H];if(T>=te||se[Y[T]]!==z[T])return!1}return!0}sort(E,z){const re=this.ranks(z.locale),Y=this.#t.length,se=E.length,te=new Uint32Array(se),H=this.#n;for(let T=0;T<se;T++)te[T]=H[E[T]];return W(E,te,re,Y,!!z.descending)}}}),Ce("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ColumnHandle",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"ColumnStore",{enumerable:!0,get:function(){return l}});const ae=me("packages/core/src/internal/util.js"),he=ae.warnOnce,W=ae.isFunction,U=ae.pathGetter,Z=me("packages/core/src/store/bitset.js").Bitset,z=me("packages/core/src/store/dictionary.js").Dictionary,Y=me("packages/core/src/store/multivalue.js").MultiValue,te=me("packages/core/src/store/stringrank.js").StringRankIndex,H=4294967295,T=1024,V=5e3,ne=.2,R=new Set(["float64","int32","bitset","dictionary","object","multi"]);function j(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function a(m){const e=i(m);return Number.isFinite(e)?e|0:0}function s(m){return j(m)?[]:Array.isArray(m)?m:[m]}function h(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=m.dict.valueOf(d[r]);return f}default:return m.buf[e]}}function u(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],f=m.offsets[e+1],r=m.table||[],n=new Array(f-d);for(let c=d;c<f;c++)n[c-d]=r[m.values[c]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const f=R.has(e.kind)?e.kind:"object";e.kind&&!R.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=f,this.#e=f,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=W(e.read)?e.read:U(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const f=new te(this.#S());return f.build(e,d),f.version=this.#f,this.#d=f,this.#k=this.#f,f.capped?null:f}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=this.#a.valueOf(d[r]);return f}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,f){if(this.#g||f<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,c=this.#m;let g=!1;switch(this.#e){case"float64":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]);if(typeof q=="number"){n&&c.set(d+P),A[d+P]=q;continue}const L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?NaN:i(q)}break}case"int32":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?0:a(q)}break}case"bitset":{const A=this.#c;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A.assign(d+P,!L&&!!q)}break}case"dictionary":{const A=this.#o,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0),A[d+q]=v?0:P.codeOf(L)}break}case"multi":{const A=this.#l,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0);const G=s(L),S=new Array(G.length);for(let N=0;N<G.length;N++)S[N]=P.codeOf(G[N]);A.write(d+q,S)}break}default:{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?null:q}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,f),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,f){if(this.#g||f<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<f;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<f;g++)r.set(d+g);const c=e.kind===this.#e;if(c&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(c&&this.#e==="bitset"){const g=e.values;for(let A=0;A<f;A++)this.#c.assign(d+A,(g[A>>3]&1<<(A&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],A=new Uint32Array(g.length);for(let v=0;v<g.length;v++)A[v]=this.#a.codeOf(g[v]);const P=e.values,q=this.#o,L=r;for(let v=0;v<f;v++){if(L&&(n&&(n[v>>3]&1<<(v&7))===0)){q[d+v]=0;continue}q[d+v]=A[P[v]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],A=new Uint32Array(g.length);for(let L=0;L<g.length;L++)A[L]=this.#a.codeOf(g[L]);const P=e.values,q=e.offsets;for(let L=0;L<f;L++){const v=q[L],G=q[L+1],S=new Array(G-v);for(let N=v;N<G;N++)S[N-v]=A[P[N]]??0;this.#l.write(d+L,S)}this.#f++;return}for(let g=0;g<f;g++){const A=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,A?null:u(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const f=new Array(d);for(let r=0;r<d;r++)f[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,f[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!R.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},f=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<f;n++){const c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?null:h(d,n))}return this.#j(),this.#f++,!0}compact(e,d,f){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[c,g]of r)e[c]!==H&&n.set(e[c],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==H&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=f;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,f,H);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new Z(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new z(this.#h??[]);break;case"multi":this.#l=new Y({rows:d,values:d}),this.#a=this.#a??new z(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new Z(d)),this.#p=d}#A(e,d){const f=j(d);switch(this.#r?this.#m.assign(e,!f):f&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=f?NaN:i(d);break;case"int32":this.#o[e]=f?0:a(d);break;case"bitset":this.#c.assign(e,!f&&!!d);break;case"dictionary":this.#o[e]=f?0:this.#a.codeOf(d);break;case"multi":{const r=s(d),n=new Array(r.length);for(let c=0;c<r.length;c++)n[c]=this.#a.codeOf(r[c]);this.#l.write(e,n);break}default:this.#o[e]=f?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),f=this.#r?new Z(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,f&&!j(n)&&f.set(r)}return this.#O={version:this.#f,values:d,presence:f},this.#O}}class l{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new Z(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??T),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??V:0,this.#w=d.compactRatio??ne;const f={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,f);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const f=e.length|0;if(f===0)return{from:d,to:d};if(this.#l)for(let n=0;n<f;n++)this.#r[d+n]=e[n];if(this.#i=d+f,this.#h+=f,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,f);return{from:d,to:this.#i}}appendPacked(e,d){const f=this.#i;if(this.#b||!e)return{from:f,to:f};const r=e.count|0;if(r===0)return{from:f,to:f};if(this.#l&&d)for(let c=0;c<r;c++)this.#r[f+c]=d[c];this.#i=f+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const c of e.columns)n.set(c.id,c);for(const c of this.#n){const g=n.get(c.id);g?c.appendPacked(g,f,r):c.grow(this.#s)}return{from:f,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const f=this.#e.get(e);return f?f.get(d):void 0}set(e,d,f){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,f)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,f=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)f[n]=this.#o.get(n)===1?H:r++;for(const n of this.#n)n.compact(f,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)f[c]!==H&&(n[f[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new Z(Math.max(this.#s,r)),f}column(e){return this.#e.get(e)}columns(){return this.#n.slice()}liveIndices(){const e=new Uint32Array(this.#h);if(this.#u===0){for(let f=0;f<this.#i;f++)e[f]=f;return e}let d=0;for(let f=0;f<this.#i;f++)this.#o.get(f)===0&&(e[d++]=f);return e}convert(e,d){const f=this.#e.get(e);return f?f.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const f of this.#n)f.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const f of this.#n)d[f.id]=f.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Ce("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.now,W=ae.nextFrame,U=ae.infoOnce,_=ae.warnOnce,Z=ae.isFunction,E=ae.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,Y=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function se(j,i={}){if(i.multi)return"multi";if(j.length===0)return"object";let a=0,s=0,h=0,u=0,t=0;for(let m=0;m<j.length;m++){const e=j[m];typeof e=="number"?a++:typeof e=="boolean"?s++:typeof e=="string"?h++:e instanceof Date?u++:Array.isArray(e)&&t++}const l=j.length;return a===l?"float64":s===l?"bitset":u===l?"float64":h===l?"text":t===l?"multi":"object"}function te(j,i,a){return i<=0||j<a*i?"dictionary":"object"}function H(j,i,a){const s=new Map,h=new Map;for(const c of j){if(c.computed)continue;const g=Z(c.read)?c.read:E(c.field||c.id);h.set(c.id,g),s.set(c.id,g)}const u=i?.order??[],t=i?.fns??{},l=i?.deps??{},m=i?.wrapDeps??null,e=u.filter(c=>Z(t[c])),d=e.some(c=>l[c]==="*");let f=new WeakMap;const r=c=>{const g={};if(d)for(const[A,P]of h)g[A]=P(c);for(const A of e){const P=l[A];let q;if(P==="*")q=g;else{q={};const L=P||[];for(let v=0;v<L.length;v++){const G=L[v];q[G]=G in g?g[G]:h.get(G)?.(c)}}g[A]=t[A](m?m(q,A):q,{data:c,row:null,column:null,grid:null,context:a})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=f.get(c);return g===void 0&&(g=r(c),f.set(c,g)),g};for(const c of e)s.set(c,g=>n(g)[c]);return{readers:s,reset(){f=new WeakMap}}}class T{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,a){this.spec=i,this.read=a,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class V{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,a={},s={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...Y,...s};const h=a.columns??[];this.#r=H(h,a.computed??null,a.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(h,a.computed??null),this.#n=new re(this.#e.map(u=>({id:u.spec.id,kind:u.kind,nullable:u.nullable,read:u.read,dictionary:u.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=he(),{chunkMs:a,chunkRows:s}=this.#s,h=this.#t.length;do{const u=Math.min(this.#i+s,h);this.#n.append(this.#t.slice(this.#i,u)),this.#a(this.#i,u),this.#i=u,this.#r.reset(),this.#w(!1)}while(this.#i<h&&he()-i<a);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:h}),this.#i>=h?(this.#w(!0),this.#h=!0,!1):!0}cancel(){this.#u=!0}result(){return{store:this.#n,schema:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#d(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#u}}#l(i,a){const s=this.#t,h=Math.min(this.#s.sampleSize,s.length),u=this.#s.dictionaryRatio,t=a?.pure instanceof Set?a.pure:new Set(a?.pure??a?.order??[]);for(const l of i){if(!l||!l.id)continue;if(l.computed&&(l.pure===!1||a&&!t.has(l.id))){_(`ingest.impure.${l.id}`,`column "${l.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(l.id)??(Z(l.read)?l.read:E(l.field||l.id)),e=new T(l,m);if(l.kind)e.kind=l.kind,e.reason="declared by the caller";else if(l.dictionary)e.kind=l.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<h&&d.length<this.#s.sampleSize;r++){const n=m(s[r]);n!=null&&d.push(n)}e.inferred=!0;const f=se(d,{multi:l.multi});if(f==="text"){const r=new Set(d).size;e.kind=te(r,d.length,u),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=f,e.reason=`inferred from ${d.length} sampled values`,f==="object"&&d.length&&U(`ingest.mixed.${l.id}`,`column "${l.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(d))}this.#e.push(e)}}#a(i,a){const s=this.#t;for(const h of this.#e){if(!h.candidate||!h.distinct)continue;const u=h.distinct;for(let t=i;t<a;t++){const l=h.read(s[t]);l!=null&&u.add(l)}}}#d(i){if(i.distinct)return i.distinct.size;const a=this.#n.column(i.spec.id);return a?.dict?a.dict.size:0}#w(i){const a=this.#s.dictionaryRatio,s=this.#t.length;for(const h of this.#e){if(!h.candidate)continue;const u=this.#d(h);if(h.kind==="dictionary"&&u>=a*s){const t=this.#n.column(h.spec.id);h.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(h.spec.id,"object"),h.kind="object",h.change="demoted",h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}if(h.kind==="object"&&u>=a*s){h.candidate=!1,h.distinct=null,h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}i&&h.kind==="object"&&u<a*s&&(this.#n.convert(h.spec.id,"dictionary"),h.kind="dictionary",h.change=h.change==="demoted"?null:"promoted",h.reason=`${u} distinct values is below ${a*100}% of ${s} rows`,h.distinct=null),i&&(h.candidate=!1)}}}async function ne(j,i={},a={}){const s=new V(j,i,a),h=a.scheduler?.frame??W;for(;s.slice();)await new Promise(u=>{h(u)});return s.result()}function R(j,i={},a={}){const s=new V(j,i,{...a,chunkMs:1/0});for(;s.slice(););return s.result()}}),Ce("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return V}});const he=me("packages/core/src/internal/util.js").pathGetter,W=me("packages/core/src/store/ingest.js"),U=W.inferKind,_=W.decideText,Z=W.INGEST_DEFAULTS,z=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function Y(ne){if(!Array.isArray(ne)||ne.length===0)return!1;for(const R of ne)if(!R||typeof R.id!="string"||typeof R.field!="string"||R.field===""||R.kind&&!re.has(R.kind))return!1;return!0}function se(ne){const R=z(ne);return Number.isFinite(R)?R|0:0}function te(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}function H(ne,R,j,i){if(ne.kind)return ne.kind;const a=[];for(let u=0;u<R.length&&a.length<Z.sampleSize;u++){const t=R[u];t!=null&&a.push(t)}const s=U(a,{multi:ne.multi});if(s!=="text")return s;const h=new Set(a).size;return _(h,a.length,i)}function T(ne,R,j={}){const i=R.length|0,a=j.dictionaryRatio??Z.dictionaryRatio,s=[];for(const h of ne){const u=he(h.field||h.id),t=h.nullable!==!1,l=new Array(i);for(let r=0;r<i;r++){const n=u(R[r]);l[r]=n===void 0?null:n}const m=H(h,l,i,a),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let f;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?NaN:z(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?0:se(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),!g&&c&&(r[n>>3]|=1<<(n&7))}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],c=new Map;for(let g=0;g<i;g++){const A=l[g];if(A===null){r[g]=0;continue}d(g);let P=c.get(A);P===void 0&&(P=n.length,n.push(A),c.set(A,P)),r[g]=P}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,c=new Uint32Array(i+1),g=[];for(let A=0;A<i;A++){const P=l[A];c[A]=g.length,P===null||d(A);const L=te(P);for(let v=0;v<L.length;v++){const G=L[v];let S=n.get(G);S===void 0&&(S=r.length,r.push(G),n.set(G,S)),g.push(S)}}c[i]=g.length,f={id:h.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:c,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const c=l[n];c!==null&&d(n),r[n]=c}f={id:h.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}s.push(f)}return{count:i,columns:s}}function V(ne){const R=[];if(!ne||!Array.isArray(ne.columns))return R;const j=i=>{ArrayBuffer.isView(i)&&i.buffer&&!R.includes(i.buffer)&&R.push(i.buffer)};for(const i of ne.columns)j(i.values),j(i.presence),j(i.offsets);return R}}),Ce("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return _}});function ae(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function he(Z){return!!Z&&typeof Z.compare!="function"}function W(Z){if(!Z)return!0;for(let E=0;E<Z.length;E++)if(!he(Z[E]))return!1;return!0}function U(Z,E){const z=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,re=Z.locale!==void 0?Z.locale:E;return{col:z,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:ae(re)}}function _(Z,E){const z=Z||[],re=new Array(z.length);for(let Y=0;Y<z.length;Y++)re[Y]=U(z[Y],E);return re}}),Ce("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.isNil,W=ae.warnOnce,U=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(j){const i=[];let a=0,s="";const h=()=>{s&&(i.push({token:null,text:s}),s="")};for(;a<j.length;){const u=j[a];if(u==="\'"){if(j[a+1]==="\'"){s+="\'",a+=2;continue}const l=j.indexOf("\'",a+1);if(l===-1){s+=j.slice(a+1),a=j.length;continue}s+=j.slice(a+1,l),a=l+1;continue}const t=U.find(l=>j.startsWith(l,a));if(t){h(),i.push({token:t,text:t}),a+=t.length;continue}/[A-Za-z]/.test(u)&&W(`date.pattern.token:${u}`,`the date pattern "${j}" contains \'${u}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${U.join(" ")}.`),s+=u,a+=1}return h(),i}const Z=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function E(j){if(he(j)||j==="")return null;if(j instanceof Date)return Number.isNaN(j.getTime())?null:j;if(typeof j=="number")return Number.isNaN(j)?null:new Date(j);if(typeof j=="string"){const i=Z.exec(j.trim());if(i){const[,s,h,u,t="0",l="0",m="0"]=i;return new Date(+s,+h-1,+u,+t,+l,+m)}const a=new Date(j);return Number.isNaN(a.getTime())?null:a}return null}function z(j,i){return String(j).padStart(i,"0")}function re(j){if(!j)return s=>({year:s.getFullYear(),month:s.getMonth()+1,day:s.getDate(),hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),ms:s.getMilliseconds(),weekday:s.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:j,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),a={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return s=>{const h={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:s.getMilliseconds(),weekday:0};for(const u of i.formatToParts(s))switch(u.type){case"year":h.year=Number(u.value);break;case"month":h.month=Number(u.value);break;case"day":h.day=Number(u.value);break;case"hour":h.hour=Number(u.value)%24;break;case"minute":h.minute=Number(u.value);break;case"second":h.second=Number(u.value);break;case"weekday":h.weekday=a[u.value]??0;break;default:break}return h}}function Y(j,i,a){const s=_(j),h=re(a),u=new Set(s.filter(d=>d.token).map(d=>d.token)),t=u.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:a}):null,l=u.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:a}):null,m=u.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:a}):null,e=u.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:a}):null;return d=>{const f=h(d);let r="";for(const n of s){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=z(f.year,4);break;case"yy":r+=z(f.year%100,2);break;case"MMMM":r+=l.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=z(f.month,2);break;case"M":r+=String(f.month);break;case"dd":r+=z(f.day,2);break;case"d":r+=String(f.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=z(f.hour,2);break;case"H":r+=String(f.hour);break;case"hh":r+=z(f.hour%12===0?12:f.hour%12,2);break;case"h":r+=String(f.hour%12===0?12:f.hour%12);break;case"mm":r+=z(f.minute,2);break;case"m":r+=String(f.minute);break;case"ss":r+=z(f.second,2);break;case"s":r+=String(f.second);break;case"SSS":r+=z(f.ms,3);break;case"a":r+=f.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const se=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function te(j,i){const a=j||{},s=a.locale||i||void 0,h=a.nullDisplay??"",u=a.timeZone;let t;if(a.pattern)t=Y(a.pattern,s,u);else if(a.dateStyle||a.timeStyle){const f={timeZone:u};a.dateStyle&&(f.dateStyle=a.dateStyle),a.timeStyle&&(f.timeStyle=a.timeStyle);const r=new Intl.DateTimeFormat(s,f);t=n=>r.format(n)}else{const f=new Intl.DateTimeFormat(s,{dateStyle:"medium",timeZone:u});t=r=>f.format(r)}const l=a.relative?new Intl.RelativeTimeFormat(s,{numeric:"auto"}):null,e=(typeof a.relative=="object"&&a.relative?a.relative.threshold??7:7)*24*36e5,d=(f,r)=>{const n=E(f);if(!n)return h;if(l){const c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[A,P]of se)if(Math.abs(g)>=P||A==="second")return l.format(Math.round(g/P),A)}}return t(n)};return d.spec=a,d}function H(j){if(he(j)||j==="")return null;if(typeof j=="string"){const s=/^(\\d{4}-\\d{2}-\\d{2})/.exec(j.trim());if(s)return s[1];const h=E(j);return h?H(h):null}const i=E(j);if(!i)return null;const a=s=>String(s).padStart(2,"0");return`${i.getFullYear()}-${a(i.getMonth()+1)}-${a(i.getDate())}`}function T(j,i){if(he(j)||j==="")return null;if(typeof j=="string"){const s=j.trim();if(V.test(s)){const t=E(s);return t?ne(t,i):null}const h=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(s);if(h){const[,t,l,m,e]=h;return`${t}T${l}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(s))return`${s}T00:00`;const u=E(s);return u?T(u):null}const a=E(j);return a?ne(a,i):null}const V=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ne(j,i){const a=t=>String(t).padStart(2,"0");if(i)try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(j).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),l=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${l}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const s=`${j.getFullYear()}-${a(j.getMonth()+1)}-${a(j.getDate())}`,h=j.getSeconds(),u=`${a(j.getHours())}:${a(j.getMinutes())}${h?`:${a(h)}`:""}`;return`${s}T${u}`}function R(j,i){const a=he(j)||j===""?null:String(j),s=he(i)||i===""?null:String(i);return a===null?s===null?0:1:s===null||a<s?-1:a>s?1:0}}),Ce("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"wallMs",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return fe}});const ae=me("packages/core/src/internal/util.js"),he=ae.isBlank,W=ae.toArray,U=ae.warnOnce,_=me("packages/core/src/format/date.js"),Z=_.toDate,E=_.toIsoDate,z=me("packages/core/src/compute/handle.js"),re=z.bitReader,Y=z.dictSize,se=z.dictValue,te=z.presenceReader,H=z.valueComparator,T=z.valueReader,V=/^\\d{4}-\\d{2}-\\d{2}$/,ne="\\0null\\0";function R(p,Q){const X=p&&p.pool;if(X){const ce=X.mask||X.acquireMask||X.acquire||X.take;if(typeof ce=="function"){const le=ce.call(X,Q);if(le&&le.length>=Q)return le}}return new Uint8Array(Q)}function j(p,Q){const X=p&&p.pool;if(!X||!Q)return;const ce=X.release||X.releaseMask||X.free||X.recycle;typeof ce=="function"&&ce.call(X,Q)}function i(p,Q,X){return p.fill(X,0,Q),p}function a(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,Q){if(p==null)return p;if(Q==="number")return typeof p=="number"?p:Number(p);if(Q==="date"||Q==="dateString"){const X=E(p);return X===null?h(p):X}return Q==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function h(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function u(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function t(p,Q){const X=typeof p=="string"?p:String(p);return Q?X:X.toLowerCase()}function l(p,Q){return p==null?ne:typeof p=="string"?Q?p:p.toLowerCase():p instanceof Date?p.getTime():p}function m(p,Q,X){const ce=new Set;for(const le of W(p)){const ge=s(le,X);ce.add(l(ge,Q)),typeof ge=="string"&&ge!==""&&Number.isFinite(Number(ge))?ce.add(Number(ge)):typeof ge=="number"&&Number.isFinite(ge)&&ce.add(l(String(ge),Q))}return ce}function e(p,Q,X){if(p==null||Q===null||Q===void 0)return p==null&&Q==null;const ce=typeof p,le=typeof Q;return ce==="string"&&le==="string"?X?p===Q:p.toLowerCase()===Q.toLowerCase():p instanceof Date||Q instanceof Date?h(p)===h(Q):ce==="number"&&le==="number"?p===Q||Number.isNaN(p)&&Number.isNaN(Q):ce==="number"&&le==="string"?p===Number(Q):ce==="string"&&le==="number"?Number(p)===Q:ce==="boolean"||le==="boolean"?p===Q:Array.isArray(p)&&Array.isArray(Q)?p.length===Q.length&&p.every((ge,Me)=>e(ge,Q[Me],X)):p===Q}function d(p,Q){try{if(p instanceof RegExp){const X=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,Q||X.includes("i")?X:`${X}i`)}return new RegExp(String(p),Q?"":"i")}catch(X){return U(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,X),null}}function f(p,Q){if(p&&p.type==="datetime"&&r.has(p.op))return P(p,Q);const X=q(p,Q),ce=p&&p.type;return ce!=="date"&&ce!=="dateString"?X:le=>X(typeof le=="string"&&V.test(le)?le:E(le)??le)}const r=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),n=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3})\\d*)?)?)?$/,c=new Map;function g(p,Q){let X=c.get(Q);if(X===void 0){try{X=new Intl.DateTimeFormat("en-CA",{timeZone:Q,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{X=null}c.set(Q,X)}if(!X)return null;const ce={};for(const le of X.formatToParts(p))le.type!=="literal"&&(ce[le.type]=le.value);return ce}function A(p,Q){if(p==null||p==="")return null;if(typeof p=="string"){const ge=n.exec(p.trim());if(ge)return Date.UTC(+ge[1],+ge[2]-1,+ge[3],+(ge[4]||0),+(ge[5]||0),+(ge[6]||0),+(ge[7]||"0").padEnd(3,"0"))}const X=Z(p);if(!X)return null;const ce=X.getUTCMilliseconds(),le=Q?g(X,Q):null;return le?Date.UTC(+le.year,+le.month-1,+le.day,le.hour==="24"?0:+le.hour,+le.minute,+le.second,ce):Date.UTC(X.getFullYear(),X.getMonth(),X.getDate(),X.getHours(),X.getMinutes(),X.getSeconds(),ce)}function P(p,Q){const X=typeof p.timeZone=="string"&&p.timeZone?p.timeZone:void 0,ce=Me=>A(Me,X),le=Array.isArray(p.value)?p.value.map(ce):ce(p.value),ge=q({...p,type:"number",value:le},Q);return Me=>ge(A(Me))}function q(p,Q){const X=p&&p.op,ce=!!(p&&p.caseSensitive),le=p&&p.type,ge=H(Q),Me=be=>ye=>!be(ye);switch(X){case"eq":{const be=s(p.value,le);return ye=>e(ye,be,ce)}case"ne":{const be=s(p.value,le);return ye=>!e(ye,be,ce)}case"lt":case"lte":case"gt":case"gte":{const be=s(p.value,le);if(a(be))return()=>!1;const ye=X==="lt"?-1:X==="lte"?0:X==="gt"?1:2;return Re=>{if(a(Re))return!1;const Ne=ge(Re,be);return ye===-1?Ne<0:ye===0?Ne<=0:ye===1?Ne>0:Ne>=0}}case"between":case"notBetween":{const be=W(p.value),ye=s(be[0],le),Re=s(be[1],le),Ne=p.bounds||"[]",Ee=Ne.charAt(0)!=="(",Be=Ne.charAt(1)!==")";if(a(ye)||a(Re))return X==="between"?()=>!1:()=>!0;const ze=We=>{if(a(We))return!1;const Xe=ge(We,ye),Ye=ge(We,Re);return(Ee?Xe>=0:Xe>0)&&(Be?Ye<=0:Ye<0)};return X==="between"?ze:Me(ze)}case"in":case"notIn":{const be=m(p.value,ce,le),ye=Re=>be.has(l(Re,ce));return X==="in"?ye:Me(ye)}case"contains":case"notContains":{const be=t(s(p.value,le),ce),ye=Re=>Re==null?!1:t(Re,ce).includes(be);return X==="contains"?ye:Me(ye)}case"startsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).startsWith(be)}case"endsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).endsWith(be)}case"matches":{const be=d(p.value,ce);return be?ye=>ye==null?!1:be.test(String(ye)):()=>!1}case"blank":return be=>he(be)||Array.isArray(be)&&be.length===0;case"notBlank":return be=>!(he(be)||Array.isArray(be)&&be.length===0);case"containsAny":case"containsNone":{const be=m(p.value,ce,le),ye=Re=>{const Ne=Re==null?[]:W(Re);for(let Ee=0;Ee<Ne.length;Ee++)if(be.has(l(Ne[Ee],ce)))return!0;return!1};return X==="containsAny"?ye:Me(ye)}case"containsAll":{const be=W(p.value).map(ye=>l(s(ye,le),ce));return ye=>{const Re=ye==null?[]:W(ye);if(be.length===0)return!0;const Ne=new Set(Re.map(Ee=>l(Ee,ce)));for(let Ee=0;Ee<be.length;Ee++)if(!Ne.has(be[Ee]))return!1;return!0}}default:{const be=fe(X);return be?be.compile(p.value):(U(`op:${String(X)}`,`unknown filter operator "${String(X)}"; the condition is refused rather than matching every row`),()=>!1)}}}function L(p,Q,X){return f(Q,X)(p)}const v=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),G=new Set(["containsAny","containsAll","containsNone"]);function S(p,Q,X){const ce=p&&p.op,le=v[ce]||ce,ge=f({...p,op:le,type:Q.type},X),Me=Q.items,be=ye=>{const Re=Me(ye);if(!Re)return!1;for(let Ne=0;Ne<Re.length;Ne++)if(ge(Re[Ne]))return!0;return!1};return v[ce]?ye=>!be(ye):be}function N(p,Q,X,ce){const le=te(p);if(le){const be=Q?1:0;for(let ye=0;ye<ce;ye++)X[ye]=le(ye)===be?1:0;return X}const ge=p.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return i(X,ce,Q?1:0);const Me=T(p);for(let be=0;be<ce;be++){const ye=Me(be),Re=he(ye)||Array.isArray(ye)&&ye.length===0;X[be]=Re===Q?0:1}return X}function I(p,Q,X,ce){const le=p.dict,ge=Y(le),Me=new Uint8Array(ge);for(let Ne=0;Ne<ge;Ne++)Me[Ne]=Q(se(le,Ne))?1:0;const be=p.values,ye=te(p);if(!ye){for(let Ne=0;Ne<ce;Ne++)X[Ne]=Me[be[Ne]];return X}const Re=Q(null)?1:0;for(let Ne=0;Ne<ce;Ne++)X[Ne]=ye(Ne)===1?Me[be[Ne]]:Re;return X}function K(p,Q,X,ce){const le=re(p.values),ge=Q(!0)?1:0,Me=Q(!1)?1:0,be=te(p);if(!be){for(let Re=0;Re<ce;Re++)X[Re]=le(Re)===1?ge:Me;return X}const ye=Q(null)?1:0;for(let Re=0;Re<ce;Re++)X[Re]=be(Re)===0?ye:le(Re)===1?ge:Me;return X}function B(p,Q,X,ce,le){const ge=p.values,Me=Q.type,be=Q.op;let ye=!0;switch(be){case"eq":case"ne":{const Ne=u(s(Q.value,Me)),Ee=typeof Q.value=="number"&&Number.isNaN(Q.value),Be=be==="ne"?1:0;if(Ee)for(let ze=0;ze<le;ze++)ce[ze]=(Number.isNaN(ge[ze])?1:0)^Be;else for(let ze=0;ze<le;ze++)ce[ze]=(ge[ze]===Ne?1:0)^Be;break}case"lt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<Ne?1:0;break}case"lte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<=Ne?1:0;break}case"gt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>Ne?1:0;break}case"gte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>=Ne?1:0;break}case"between":case"notBetween":{const Ne=W(Q.value),Ee=u(s(Ne[0],Me)),Be=u(s(Ne[1],Me)),ze=Q.bounds||"[]",We=ze.charAt(0)!=="(",Xe=ze.charAt(1)!==")",Ye=be==="notBetween"?1:0;if(We&&Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<=Be?1:0)^Ye;else if(We)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<Be?1:0)^Ye;else if(Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<=Be?1:0)^Ye;else for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<Be?1:0)^Ye;break}case"in":case"notIn":{const Ne=new Set;for(const Be of W(Q.value)){const ze=u(s(Be,Me));Number.isNaN(ze)||Ne.add(ze)}const Ee=be==="notIn"?1:0;for(let Be=0;Be<le;Be++)ce[Be]=(Ne.has(ge[Be])?1:0)^Ee;break}default:ye=!1;break}if(!ye)return!1;const Re=te(p);if(Re){const Ne=X(null)?1:0;for(let Ee=0;Ee<le;Ee++)Re(Ee)===0&&(ce[Ee]=Ne)}return!0}function ee(p,Q,X,ce){const le=T(p);for(let ge=0;ge<ce;ge++)X[ge]=Q(le(ge))?1:0;return X}function J(p,Q,X){const ce=Q.count|0,le=X||R(Q,ce);if(!p)return i(le,ce,1);const ge=typeof Q.handle=="function"?Q.handle(p.col):void 0,Me=typeof Q.custom=="function"?Q.custom:null;if(!ge){if(Me){for(let Ne=0;Ne<ce;Ne++)le[Ne]=Me(p,Ne)?1:0;return le}return U(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),i(le,ce,0)}const be=p.op;if(be==="blank"||be==="notBlank")return N(ge,be==="notBlank",le,ce);const ye=typeof Q.itemwise=="function"?Q.itemwise(p.col):null;if(ye&&!fe(be)&&!G.has(be))return ee(ge,S(p,ye,Q.locale),le,ce);const Re=f(p,Q.locale);switch(ge.kind){case"dictionary":return I(ge,Re,le,ce);case"bitset":return K(ge,Re,le,ce);case"float64":case"int32":return B(ge,p,Re,le,ce)?le:ee(ge,Re,le,ce);default:return ee(ge,Re,le,ce)}}function ue(p,Q,X){if(!p)return i(R(Q,X),X,1);if(Array.isArray(p.conditions)){const ce=p.conditions.filter(Me=>Me!=null),le=p.op==="or"?"or":p.op==="not"?"not":"and";if(ce.length===0)return i(R(Q,X),X,1);const ge=ue(ce[0],Q,X);for(let Me=1;Me<ce.length;Me++){const be=ue(ce[Me],Q,X);if(le==="or")for(let ye=0;ye<X;ye++)ge[ye]|=be[ye];else for(let ye=0;ye<X;ye++)ge[ye]&=be[ye];j(Q,be)}if(le==="not")for(let Me=0;Me<X;Me++)ge[Me]^=1;return ge}return J(p,Q,R(Q,X))}function de(p,Q){return ue(p,Q,Q.count|0)}function Oe(p,Q){if(!p||!Q)return p||null;const X=p;if(Array.isArray(X.conditions)){if((X.op==="or"?"or":X.op==="not"?"not":"and")!=="and")return Ae(X,Q)?null:p;const le=[];for(const ge of X.conditions){const Me=Oe(ge,Q);Me&&le.push(Me)}return le.length?{...X,op:"and",conditions:le}:null}return X.col===Q?null:p}function Ae(p,Q){if(!p||typeof p!="object")return!1;const X=p;if(X.col===Q)return!0;if(Array.isArray(X.conditions)){for(const ce of X.conditions)if(Ae(ce,Q))return!0}return!1}function Se(p,Q,X){if(X&&X.length>=Q){let Me=0;for(let be=0;be<Q;be++)p[be]&&(X[Me++]=be);return X.subarray(0,Me)}let ce=0;for(let Me=0;Me<Q;Me++)ce+=p[Me]?1:0;const le=new Uint32Array(ce);let ge=0;for(let Me=0;Me<Q;Me++)p[Me]&&(le[ge++]=Me);return le}const D=new Map;function x(p){if(!(!p||typeof p!="object"))for(const[Q,X]of Object.entries(p))X&&typeof X.compile=="function"&&D.set(Q,X)}function fe(p){return typeof p=="string"?D.get(p):void 0}}),Ce("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return te}});const ae=me("packages/core/src/compute/handle.js"),he=ae.dictSize,W=ae.identity,U=ae.presenceReader,_=ae.rowCount,Z=ae.valueReader,E="",z="\\0",re=1<<20;function Y(H,T,V,ne){const R=H.length,j=H.map(t=>Z(t)),i=Array.isArray(ne)&&ne.some(Boolean),a=i?j.map((t,l)=>ne[l]?m=>ne[l](t(m)):t):j;if(!i&&R>0&&H.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=H.map(m=>he(m.dict)+1);let l=1;for(let m=0;m<R;m++)l*=t[m];if(l<=Number.MAX_SAFE_INTEGER){const m=H.map(r=>r.values),e=H.map(r=>U(r)),d=r=>{let n=0;for(let c=0;c<R;c++){const g=e[c],A=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+A}return n},f=new Float64Array(V);for(let r=0;r<V;r++)f[r]=d(T[r]);return{packed:f,strings:null,product:l,readers:a,keyOf:d}}}const h=t=>{let l="";for(let m=0;m<R;m++){const e=a[m](t);l+=(m===0?"":E)+(e==null?z:String(e))}return l},u=new Array(V);for(let t=0;t<V;t++)u[t]=h(T[t]);return{packed:null,strings:u,product:1/0,readers:a,keyOf:h}}function se(H,T,V,ne){const R=new Uint32Array(ne+1);for(let s=0;s<V;s++)R[T[s]+1]++;for(let s=0;s<ne;s++)R[s+1]+=R[s];const j=new Uint32Array(V),i=R.slice(0,ne);for(let s=0;s<V;s++)j[i[T[s]]++]=H[s];const a=new Array(ne);for(let s=0;s<ne;s++)a[s]=j.subarray(R[s],R[s+1]);return a}function te(H,T,V={}){const ne=H||[],R=T||W(_(ne[0],V)),j=R.length;if(ne.length===0||j===0)return{keys:[],buckets:[]};const{packed:i,strings:a,product:s,readers:h}=Y(ne,R,j,V.project),u=new Uint32Array(j);let t=0,l=null;if(i&&s<=Math.max(1024,Math.min(re,j*4))){const f=s,r=new Int32Array(f).fill(-1);for(let n=0;n<j;n++)r[i[n]]=0;for(let n=0;n<f;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<j;n++)u[n]=r[i[n]];l=new Float64Array(t);for(let n=0;n<f;n++)r[n]>=0&&(l[r[n]]=n)}else if(i){const f=new Map;for(let r=0;r<j;r++){const n=i[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}l=new Float64Array(t);for(const[r,n]of f)l[n]=r}else{const f=new Map;for(let r=0;r<j;r++){const n=a[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}}const m=se(R,u,j,t),e=new Array(t);for(let f=0;f<t;f++){const r=m[f][0],n=new Array(h.length);for(let c=0;c<h.length;c++)n[c]=h[c](r);e[f]=n}const d={keys:e,buckets:m};return l&&(d.packed=l),d}}),Ce("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=ae.dictSize,_=ae.dictValue,Z=Object.freeze(["equal","quantile","log"]),E=Object.freeze(["hour","day","week","month","quarter","year"]),z=20,re=50,Y=1e4;function se(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const A=c&&c.base;if(A==="date"||A==="datetime"||A==="time"||A==="dateString")return"date";switch(n.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return A==="number"?"numeric":A==="boolean"?"boolean":A==="text"?"category":"none"}}function te(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return P=>c[P];const A=W(n);return P=>H(A(P))}function H(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const c=Number(n);if(Number.isFinite(c))return c;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function T(n,c,g,A=re){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:U(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const P=W(n),q=c?c.length:g,L=new Set;for(let v=0;v<q;v++){const G=P(c?c[v]:v);if(G!=null&&(L.add(G),L.size>A))return{cardinality:L.size,exact:!1}}return{cardinality:L.size,exact:!0}}const V=36e5,ne=864e5;function R(n,c=z){const g=Number.isFinite(n)&&n>0?n:0,A=Math.max(1,c)*2;return g/V<=A?"hour":g/ne<=A?"day":g/(7*ne)<=A?"week":g/(30*ne)<=A?"month":g/(91*ne)<=A?"quarter":"year"}function j(n,c){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(c){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const A=(g.getDay()+6)%7;return g.setDate(g.getDate()-A),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,c){const g=new Date(n);switch(c){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function a(n,c,g){const A=te(n),P=he(n),q=c?c.length:g;let L=1/0,v=-1/0,G=0,S=0;for(let N=0;N<q;N++){const I=c?c[N]:N;if(P&&!P(I)){G++;continue}const K=A(I);if(!Number.isFinite(K)){G++;continue}K<L&&(L=K),K>v&&(v=K),S++}return{min:L,max:v,nulls:G,finite:S}}function s(n,c,g,A){const P=te(n),q=he(n),L=c?c.length:g,v=L>A?L/A:1,G=[];for(let N=0;N<L;N+=v){const I=c?c[Math.floor(N)]:Math.floor(N);if(q&&!q(I))continue;const K=P(I);Number.isFinite(K)&&G.push(K)}const S=Float64Array.from(G);return S.sort(),S}function h(n,c,g,A={}){const P=A.kind||se(n,A.type);return P==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:P==="boolean"?u(n,c,g):P==="category"?t(n,c,g,A):l(n,c,g,P,A)}function u(n,c,g){const A=he(n);let P=0;if(A){const L=c?c.length:g;for(let v=0;v<L;v++)A(c?c[v]:v)||P++}const q=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&q.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:q}}function t(n,c,g,A){const P=A.cardinalityLimit??re,{cardinality:q}=T(n,c,g,P);if(q>P&&(A.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:q};const L=W(n),v=c?c.length:g,G=new Map;let S=0;for(let ee=0;ee<v;ee++){const J=L(c?c[ee]:ee);if(J==null||J===""){S++;continue}if(Array.isArray(J)){if(!J.length){S++;continue}for(const ue of J)G.set(ue,(G.get(ue)||0)+1);continue}G.set(J,(G.get(J)||0)+1)}let N=[...G.entries()];A.order==="alpha"?N.sort((ee,J)=>String(ee[0]).localeCompare(String(J[0]))):N.sort((ee,J)=>J[1]-ee[1]);let I=0,K=0;if(N.length>P){K=N.length-P;for(let ee=P;ee<N.length;ee++)I+=N[ee][1];N=N.slice(0,P)}const B=N.map(([ee])=>({value:ee,label:String(ee)}));return I>0&&B.push({remainder:!0,label:`Other (${K} values)`}),S>0&&B.push({null:!0,label:"Empty"}),{kind:"category",buckets:B,cardinality:q}}function l(n,c,g,A,P){const{min:q,max:L,nulls:v,finite:G}=a(n,c,g);if(!G)return{kind:A,buckets:v?[{null:!0,label:"Empty"}]:[],empty:!0};const S=Math.max(1,Math.floor(P.buckets||z));let N=[];if(A==="date"){const K=E.includes(P.granularity)?P.granularity:R(L-q,S);let B=j(q,K);for(;B<=L&&N.length<4096;){const ee=i(B,K);if(!(ee>B))break;N.push({from:B,to:ee}),B=ee}return{kind:A,buckets:m(N,v),granularity:K}}const I=Z.includes(P.strategy)?P.strategy:"equal";if(I==="quantile"){const K=s(n,c,g,Y);if(K.length){const B=[K[0]];for(let ee=1;ee<S;ee++){const J=K[Math.min(K.length-1,Math.floor(ee/S*K.length))];J>B[B.length-1]&&B.push(J)}B.push(L);for(let ee=0;ee<B.length-1;ee++)N.push({from:B[ee],to:B[ee+1]})}}else if(I==="log"&&q>0){const K=Math.log10(q),ee=(Math.log10(L)-K)/S||1;for(let J=0;J<S;J++)N.push({from:10**(K+J*ee),to:10**(K+(J+1)*ee)})}if(!N.length){const K=(L-q)/S||1;for(let B=0;B<S;B++)N.push({from:q+B*K,to:q+(B+1)*K})}return N[N.length-1].to=L,{kind:A,buckets:m(N,v),strategy:I,min:q,max:L}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,A,P){const q=A&&A.buckets||[],L=P&&P.length>=q.length?P.subarray(0,q.length):new Uint32Array(q.length);if(L.fill(0),!n||!q.length)return L;const v=q.length-1,G=!!q[v]&&q[v].null===!0,S=c?c.length:g;if(A.kind==="boolean"){const ee=W(n);for(let J=0;J<S;J++){const ue=ee(c?c[J]:J);if(ue==null){G&&L[v]++;continue}L[ue?1:0]++}return L}if(A.kind==="category"){const ee=new Map;for(let de=0;de<q.length;de++)!q[de].null&&!q[de].remainder&&ee.set(q[de].value,de);const J=q.findIndex(de=>de.remainder),ue=W(n);for(let de=0;de<S;de++){const Oe=ue(c?c[de]:de);if(Oe==null||Oe===""){G&&L[v]++;continue}if(Array.isArray(Oe)){if(!Oe.length){G&&L[v]++;continue}for(const Se of Oe){const D=ee.get(Se);D!==void 0?L[D]++:J>=0&&L[J]++}continue}const Ae=ee.get(Oe);Ae!==void 0?L[Ae]++:J>=0&&L[J]++}return L}const N=G?q.length-1:q.length,I=new Float64Array(N+1);for(let ee=0;ee<N;ee++)I[ee]=q[ee].from;I[N]=N?q[N-1].to:0;const K=te(n),B=he(n);for(let ee=0;ee<S;ee++){const J=c?c[ee]:ee;if(B&&!B(J)){G&&L[v]++;continue}const ue=K(J);if(!Number.isFinite(ue)){G&&L[v]++;continue}const de=d(I,N,ue);de>=0&&L[de]++}return L}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let A=0,P=c-1;for(;A<P;){const q=A+P+1>>>1;g>=n[q]?A=q:P=q-1}return A}function f(n,c,g,A={}){const P=A.bounds||h(n,A.boundsIndices??c,g,A);return{bounds:P,counts:e(n,c,g,P)}}const r=f}),Ce("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ne}});const ae=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,W=1e-300;function U(R){if(R<.5)return Math.log(Math.PI/Math.sin(Math.PI*R))-U(1-R);const j=R-1;let i=.9999999999998099;const a=j+7.5;for(let s=0;s<ae.length;s++)i+=ae[s]/(j+s+1);return .5*Math.log(2*Math.PI)+(j+.5)*Math.log(a)-a+Math.log(i)}function _(R,j,i){const a=R+j,s=R+1,h=R-1;let u=1,t=1-a*i/s;Math.abs(t)<W&&(t=W),t=1/t;let l=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(j-m)*i/((h+e)*(R+e));t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t,l*=t*u,d=-(R+m)*(a+m)*i/((R+e)*(s+e)),t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t;const f=t*u;if(l*=f,Math.abs(f-1)<he)break}return l}function Z(R,j,i){if(!(R>0)||!(j>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const a=Math.exp(U(R+j)-U(R)-U(j)+R*Math.log(i)+j*Math.log(1-i));return i<(R+1)/(R+j+2)?a*_(R,j,i)/R:1-a*_(j,R,1-i)/j}function E(R){if(!(R>0)||!(R<1))return R===0?-1/0:R===1?1/0:Number.NaN;const j=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],a=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],s=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],h=.02425;let u,t,l;R<h?(u=Math.sqrt(-2*Math.log(R)),l=(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1)):R<=1-h?(u=R-.5,t=u*u,l=(((((j[0]*t+j[1])*t+j[2])*t+j[3])*t+j[4])*t+j[5])*u/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(u=Math.sqrt(-2*Math.log(1-R)),l=-(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1));const e=(.5*z(-l/Math.SQRT2)-R)*Math.sqrt(2*Math.PI)*Math.exp(l*l/2);return l-e/(1+l*e/2)}function z(R){const j=Math.abs(R),i=2/(2+j),a=4*i-2,s=[-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 h=0,u=0,t;for(let m=s.length-1;m>0;m--)t=u,u=a*u-h+s[m],h=t;const l=i*Math.exp(-j*j+.5*(s[0]+a*u)-h);return R>=0?l:2-l}function re(R){return .5*z(-R/Math.SQRT2)}function Y(R,j){if(!(j>0)||!Number.isFinite(R))return Number.NaN;const i=.5*Z(j/2,.5,j/(j+R*R));return R>0?1-i:i}function se(R,j){if(!(R>0)||!(R<1)||!(j>0))return Number.NaN;if(j>1e7)return E(R);let i=-1e4,a=1e4,s=E(R);const h=U(j/2)+U(.5)-U((j+1)/2);for(let u=0;u<60;u++){const t=Y(s,j);t<R?i=s:a=s;const l=Math.exp(-((j+1)/2)*Math.log(1+s*s/j)-h)/Math.sqrt(j),m=l>0?(t-R)/l:0;if(Math.abs(m)<1e-12)break;const e=s-m;if(s=e>i&&e<a&&Number.isFinite(e)?e:(i+a)/2,a-i<1e-12)break}return s}function te(R,j){let i=R,a=1/R,s=a;for(let h=0;h<300&&(i+=1,s*=j/i,a+=s,!(Math.abs(s)<Math.abs(a)*he));h++);return a*Math.exp(-j+R*Math.log(j)-U(R))}function H(R,j){let i=j+1-R,a=1/W,s=1/i,h=s;for(let u=1;u<=300;u++){const t=-u*(u-R);i+=2,s=t*s+i,Math.abs(s)<W&&(s=W),a=i+t/a,Math.abs(a)<W&&(a=W),s=1/s;const l=s*a;if(h*=l,Math.abs(l-1)<he)break}return Math.exp(-j+R*Math.log(j)-U(R))*h}function T(R,j){return!(R>0)||!(j>=0)||!Number.isFinite(j)?Number.NaN:j===0?0:j<R+1?te(R,j):1-H(R,j)}function V(R,j){return j>0?T(j/2,R/2):Number.NaN}function ne(R,j){const i=V(R,j);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Ce("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return Z}});function ae(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++)for(let se=0;se<=Y;se++){let te=E[Y][se];for(let H=0;H<se;H++)te-=re[Y][H]*re[se][H];if(Y===se){if(!(te>0))return null;re[Y][se]=Math.sqrt(te)}else re[Y][se]=te/re[se][se]}return re}function he(E,z){const re=E.length,Y=new Array(re).fill(0);for(let te=0;te<re;te++){let H=z[te];for(let T=0;T<te;T++)H-=E[te][T]*Y[T];Y[te]=H/E[te][te]}const se=new Array(re).fill(0);for(let te=re-1;te>=0;te--){let H=Y[te];for(let T=te+1;T<re;T++)H-=E[T][te]*se[T];se[te]=H/E[te][te]}return se}function W(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++){const se=new Array(z).fill(0);se[Y]=1;const te=he(E,se);for(let H=0;H<z;H++)re[H][Y]=te[H]}return re}function U(E,z,re){const Y=E.length,se=Y?E[0].length:0,te=Array.from({length:se},()=>new Array(se).fill(0)),H=new Array(se).fill(0);for(let T=0;T<Y;T++){const V=re?re[T]:1,ne=E[T];for(let R=0;R<se;R++){const j=V*ne[R];H[R]+=j*z[T];for(let i=R;i<se;i++)te[R][i]+=j*ne[i]}}for(let T=0;T<se;T++)for(let V=0;V<T;V++)te[T][V]=te[V][T];return{xtwx:te,xtwy:H}}function _(E,z){return E.map(re=>re.reduce((Y,se,te)=>Y+se*z[te],0))}function Z(E,z){let re=0;for(let Y=0;Y<E.length;Y++){let se=0;for(let te=0;te<E.length;te++)se+=z[Y][te]*E[te];re+=E[Y]*se}return re}}),Ce("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return te}});class ae{#t=0;#e=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.#t}add(T){if(!Number.isFinite(T))return;this.#t++;const V=T-this.#e;this.#e+=V/this.#t,this.#n+=V*(T-this.#e)}merge(T){if(T.#t===0)return;if(this.#t===0){this.#t=T.#t,this.#e=T.#e,this.#n=T.#n;return}const V=this.#t+T.#t,ne=T.#e-this.#e;this.#e+=ne*(T.#t/V),this.#n+=T.#n+ne*ne*(this.#t*T.#t/V),this.#t=V}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const T=this.variance();return T===null?null:Math.sqrt(T)}stddevP(){const T=this.varianceP();return T===null?null:Math.sqrt(T)}}class he{#t=[];#e=0;#n;#r;constructor(T,V=Math.random){if(!(T>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(T),this.#r=V}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.#e}get size(){return this.#t.length}add(T){if(!Number.isFinite(T))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(T);return}const V=Math.floor(this.#r()*this.#e);V<this.#n&&(this.#t[V]=T)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let T=0;for(const V of this.#t)T+=V;return T/this.#t.length}quantile(T){const V=this.#t.length;if(!V)return null;const ne=this.#t.slice().sort((a,s)=>a-s);if(V===1)return ne[0];const R=(V-1)*Math.min(1,Math.max(0,T)),j=Math.floor(R),i=Math.ceil(R);return j===i?ne[j]:ne[j]+(R-j)*(ne[i]-ne[j])}}function W(H){return H^=H>>>16,H=Math.imul(H,2246822507),H^=H>>>13,H=Math.imul(H,3266489909),H^=H>>>15,H>>>0}function U(H){if(typeof H=="number"){const ne=new DataView(new ArrayBuffer(8));return ne.setFloat64(0,H===0?0:H),W(ne.getUint32(0)^ne.getUint32(4))}const T=typeof H=="string"?H:String(H);let V=2166136261;for(let ne=0;ne<T.length;ne++)V^=T.charCodeAt(ne),V=Math.imul(V,16777619);return W(V)}class _{#t;#e;#n;constructor(T=14){const V=Math.floor(T);if(V<4||V>16)throw new RangeError("HLL precision must be 4..16");this.#t=V,this.#e=1<<V,this.#n=new Uint8Array(this.#e)}static errorBoundFor(T=14){const V=1<<Math.floor(T),ne=1.04/Math.sqrt(V);return Object.freeze({kind:"probabilistic",metric:"relative",value:ne,statement:`distinct count within ~${(ne*100).toFixed(2)}% relative standard error (m=${V} buckets)`})}errorBound(){return _.errorBoundFor(this.#t)}add(T){const V=U(T),ne=V&this.#e-1,R=V>>>this.#t|1<<32-this.#t;let j=1,i=R;for(;(i&1)===0;)j++,i>>>=1;j>this.#n[ne]&&(this.#n[ne]=j)}count(){const T=this.#e,V=32-this.#t,ne=new Float64Array(V+2);for(let i=0;i<T;i++)ne[this.#n[i]]++;let R=T*z(1-ne[V+1]/T);for(let i=V;i>=1;i--)R=.5*(R+ne[i]);R+=T*E(ne[0]/T);const j=Z*T*T/R;return Math.round(j)}}const Z=.5/Math.log(2);function E(H){if(H===1)return 1/0;let T=1,V=H,ne;do H*=H,ne=V,V+=H*T,T+=T;while(V!==ne);return V}function z(H){if(H===0||H===1)return 0;let T=1,V=1-H,ne;do H=Math.sqrt(H),ne=V,T*=.5,V-=(1-H)**2*T;while(V!==ne);return V/3}class re{#t=new Map;#e;#n=0;constructor(T){if(!(T>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(T)}errorBoundFor(T){const V=T/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:V,statement:`each count overestimates the truth by at most N/m = ${V.toFixed(2)} (N=${T}, m=${this.#e})`})}get seen(){return this.#n}add(T){this.#n++;const V=this.#t.get(T);if(V){V.count++;return}if(this.#t.size<this.#e){this.#t.set(T,{count:1,error:0});return}let ne,R=1/0;for(const[j,i]of this.#t)i.count<R&&(R=i.count,ne=j);this.#t.delete(ne),this.#t.set(T,{count:R+1,error:R})}top(T=this.#e){return[...this.#t.entries()].map(([ne,R])=>({item:ne,count:R.count,error:R.error})).sort((ne,R)=>R.count-ne.count).slice(0,Math.max(0,Math.floor(T)))}}class Y{#t;#e=[[]];#n=0;#r;#i;constructor(T=200,V=Math.random){this.#t=Math.max(8,Math.floor(T)),this.#r=V,this.#i=2/3}static errorBoundFor(T=200){const V=1/Math.max(8,Math.floor(T));return Object.freeze({kind:"probabilistic",metric:"rank",value:V,statement:`queried quantile\'s true rank within ~${(V*100).toFixed(2)}% of N of the requested rank (k=${T})`})}errorBound(){return Y.errorBoundFor(this.#t)}get count(){return this.#n}#s(T){const ne=this.#e.length-1-T,R=Math.ceil(this.#t*this.#i**ne);return Math.max(2,R)}add(T){Number.isFinite(T)&&(this.#n++,this.#e[0].push(T),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(T){const V=this.#e[T];V.sort((j,i)=>j-i),T+1>=this.#e.length&&this.#e.push([]);const ne=this.#e[T+1],R=this.#r()<.5?0:1;for(let j=R;j<V.length;j+=2)ne.push(V[j]);this.#e[T]=[];for(let j=0;j<this.#e.length;j++)if(this.#e[j].length>=this.#s(j)){this.#h(j);return}}#u(){const T=[];for(let V=0;V<this.#e.length;V++){const ne=1<<V;for(const R of this.#e[V])T.push({v:R,w:ne})}return T}quantile(T){const V=this.#u();if(!V.length)return null;V.sort((i,a)=>i.v-a.v);let ne=0;for(const i of V)ne+=i.w;const R=Math.min(1,Math.max(0,T))*ne;let j=0;for(const i of V)if(j+=i.w,j>=R)return i.v;return V[V.length-1].v}rank(T){let V=0;for(let ne=0;ne<this.#e.length;ne++){const R=1<<ne;for(const j of this.#e[ne])j<=T&&(V+=R)}return V}}const se=Object.freeze({distinct:_.errorBoundFor(14),median:Y.errorBoundFor(200),p25:Y.errorBoundFor(200),p75:Y.errorBoundFor(200),p90:Y.errorBoundFor(200),p95:Y.errorBoundFor(200),p99:Y.errorBoundFor(200),iqr:Y.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"})}),te={Welford:ae,Reservoir:he,HyperLogLog:_,SpaceSaving:re,KLL:Y,hash32:U,SKETCH_BOUNDS:se}}),Ce("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=me("packages/core/src/compute/special.js"),_=U.studentTQuantile,Z=U.studentT,E=U.normalQuantile,z=U.normalCdf,re=U.chiSquareUpperTail,Y=me("packages/core/src/compute/linalg.js"),se=Y.cholesky,te=Y.choleskySolve,H=Y.choleskyInverse,T=Y.normalEquations,V=Y.quadForm,R=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,j=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"}),a=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 s(b){const k=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(a,b)?a[b]:null;return{stat:b,exact:k,approximate:y}}function h(b,k){const y=k.length,w=new Float64Array(y);let O=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const F=b.values,C=he(b);for(let ie=0;ie<y;ie++){const oe=k[ie];if(C&&C(oe)!==1)continue;const ke=F[oe];Number.isNaN(ke)||(w[O++]=ke)}return w.subarray(0,O)}const $=W(b);for(let F=0;F<y;F++){const C=$(k[F]);if(C==null||C==="")continue;const ie=typeof C=="number"?C:Number(C);Number.isFinite(ie)&&(w[O++]=ie)}return w.subarray(0,O)}function u(b,k){const y=new Map,w=W(b);let O=0;for(let $=0;$<k.length;$++){const F=w(k[$]);if(F==null||F===""||typeof F=="number"&&Number.isNaN(F))continue;const C=typeof F=="object"?String(F):F;y.set(C,(y.get(C)||0)+1),O++}const M=[...y.values()].sort(($,F)=>F-$);return{counts:M,total:O,distinct:M.length}}function t(b){return b.total>0?b.counts.map(k=>k/b.total):[]}function l(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))w+=O*O;return w}function m(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w}function e(b,k){const y=u(b,k);if(!y.total||y.distinct<2)return y.total?1:null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w/Math.log2(y.distinct)}function d(b,k,y=3){const w=u(b,k);if(!w.total)return null;const O=Math.max(1,Math.floor(y));let M=0;for(let $=0;$<Math.min(O,w.counts.length);$++)M+=w.counts[$];return M/w.total}function f(b,k){const y=h(b,k),w=y.length;if(!w)return null;const O=y.slice().sort();if(O[0]<0)return null;let M=0,$=0;for(let F=0;F<w;F++)M+=O[F],$+=(F+1)*O[F];return M===0?0:2*$/(w*M)-(w+1)/w}function r(b){let k=0,y=0,w=0;for(let O=0;O<b.length;O++){const M=b[O];k++;const $=M-y;y+=$/k,w+=$*(M-y)}return{n:k,mean:y,m2:w}}function n(b,k){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const w=(y-1)*Math.min(1,Math.max(0,k)),O=Math.floor(w),M=Math.ceil(w);return O===M?b[O]:b[O]+(w-O)*(b[M]-b[O])}function c(b,k){if(!b.length)return NaN;const y=b.slice().sort();return n(y,k)}function g(b,k){const y=W(b);let w=0,O=0,M=0;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=String(F).toUpperCase();C==="PASS"?w++:C==="FAIL"?O++:C==="WARN"&&M++}return{pass:w+M,fail:O,warn:M,judged:w+M+O}}const A=Object.freeze({hhi:(b,k)=>l(b,k),entropy:(b,k)=>m(b,k),evenness:(b,k)=>e(b,k),top3Share:(b,k)=>d(b,k,3),top10Share:(b,k)=>d(b,k,10),gini:(b,k)=>f(b,k),trimmedMean:(b,k)=>G(h(b,k),.1),winsorizedMean:(b,k)=>S(h(b,k),.1),robustOutliers:(b,k)=>N(h(b,k),3.5),jarqueBera:(b,k)=>I(h(b,k)),variance:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?w/(y-1):null},varianceP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?w/y:null},stddev:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?Math.sqrt(w/(y-1)):null},stddevP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?Math.sqrt(w/y):null},median:(b,k)=>{const y=h(b,k);return y.length?c(y,.5):null},p25:(b,k)=>{const y=h(b,k);return y.length?c(y,.25):null},p75:(b,k)=>{const y=h(b,k);return y.length?c(y,.75):null},p90:(b,k)=>{const y=h(b,k);return y.length?c(y,.9):null},p95:(b,k)=>{const y=h(b,k);return y.length?c(y,.95):null},p99:(b,k)=>{const y=h(b,k);return y.length?c(y,.99):null},iqr:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=y.slice().sort();return n(w,.75)-n(w,.25)},mad:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=c(y,.5),O=new Float64Array(y.length);for(let M=0;M<y.length;M++)O[M]=Math.abs(y[M]-w);return c(O,.5)},range:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=1/0,O=-1/0;for(let M=0;M<y.length;M++)y[M]<w&&(w=y[M]),y[M]>O&&(O=y[M]);return O-w},distinct:(b,k)=>{const y=W(b),w=new Set;for(let O=0;O<k.length;O++){const M=y(k[O]);M==null||M===""||w.add(M instanceof Date?M.getTime():M)}return w.size},mode:(b,k)=>{const y=W(b),w=new Map;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=F instanceof Date?F.getTime():F;w.set(C,(w.get(C)||0)+1)}let O=null,M=1;for(const[$,F]of w)F>M&&(M=F,O=$);return O},skewness:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<3||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let C=0;C<y.length;C++)F+=((y[C]-O)/$)**3;return w/((w-1)*(w-2))*F},kurtosis:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<4||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let oe=0;oe<y.length;oe++)F+=((y[oe]-O)/$)**4;const C=w*(w+1)/((w-1)*(w-2)*(w-3)),ie=3*(w-1)**2/((w-2)*(w-3));return C*F-ie},geomean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]<=0)return null;w+=Math.log(y[O])}return Math.exp(w/y.length)},harmean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]===0)return null;w+=1/y[O]}return y.length/w},sumSquares:(b,k)=>{const y=h(b,k);let w=0;for(let O=0;O<y.length;O++)w+=y[O]*y[O];return w},passRate:(b,k)=>{const{pass:y,judged:w}=g(b,k);return w?y/w:null},failureCount:(b,k)=>g(b,k).fail}),P=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 q(b,k,y){const w=W(b),O=W(k);let M=0,$=0;for(let F=0;F<y.length;F++){const C=y[F],ie=Number(w(C)),oe=Number(O(C));!Number.isFinite(ie)||!Number.isFinite(oe)||(M+=ie*oe,$+=oe)}return $===0?null:M/$}function L(b,k,y){const w=W(b);let O=null,M=y?-1/0:1/0;for(let $=0;$<k.length;$++){const F=k[$],C=Number(w(F));Number.isFinite(C)&&(y?C>M:C<M)&&(M=C,O=F)}return O}function v(b,k,y){const w=W(b),O=W(k);let M=0,$=0,F=0,C=0,ie=0,oe=0;for(let pe=0;pe<y.length;pe++){const ve=y[pe],Le=Number(w(ve)),we=Number(O(ve));!Number.isFinite(Le)||!Number.isFinite(we)||(M++,$+=Le,F+=we,C+=Le*Le,ie+=we*we,oe+=Le*we)}if(M<2)return null;const ke=M*oe-$*F,je=Math.sqrt((M*C-$*$)*(M*ie-F*F));if(je===0)return null;const Pe=ke/je;return Math.max(-1,Math.min(1,Pe))}function G(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((F,C)=>F-C),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w.slice(O,y-O);if(!M.length)return n(w,.5);let $=0;for(const F of M)$+=F;return $/M.length}function S(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w[O],$=w[y-1-O];let F=0;for(const C of w)F+=Math.min($,Math.max(M,C));return F/y}function N(b,k=3.5){if(!b.length)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=n(w,.5),M=w.map(C=>Math.abs(C-O)).sort((C,ie)=>C-ie),$=n(M,.5);if($===0)return null;let F=0;for(const C of w)Math.abs(.6745*(C-O)/$)>k&&F++;return F}function I(b){const k=b.length;if(k<8)return null;let y=0;for(const C of b)y+=C;y/=k;let w=0,O=0,M=0;for(const C of b){const ie=C-y;w+=ie*ie,O+=ie*ie*ie,M+=ie*ie*ie*ie}if(w/=k,O/=k,M/=k,w===0)return null;const $=O/w**1.5,F=M/(w*w)-3;return k/6*($*$+F*F/4)}function K(b,k,y){const w=[];let O=0;for(let C=0;C<b.length;C++){const ie=Number(b[C]),oe=Number(k[C]);!Number.isFinite(ie)||!Number.isFinite(oe)||oe<=0||(w.push([ie,oe]),O+=oe)}if(!w.length||O<=0)return null;if(w.sort((C,ie)=>C[0]-ie[0]),w.length===1)return w[0][0];const M=[];let $=0;for(const[,C]of w)M.push(($+C/2)/O),$+=C;const F=Math.max(0,Math.min(1,y));if(F<=M[0])return w[0][0];if(F>=M[M.length-1])return w[w.length-1][0];for(let C=1;C<M.length;C++){if(F>M[C])continue;const ie=M[C]-M[C-1],oe=ie>0?(F-M[C-1])/ie:0;return w[C-1][0]+(w[C][0]-w[C-1][0])*oe}return w[w.length-1][0]}function B(b,k,y){const w=W(b),O=W(k),M=new Float64Array(y.length),$=new Float64Array(y.length);let F=0;for(let C=0;C<y.length;C++){const ie=y[C],oe=Number(w(ie)),ke=Number(O(ie));!Number.isFinite(oe)||!Number.isFinite(ke)||(M[F]=oe,$[F]=ke,F++)}return{xs:M.subarray(0,F),ys:$.subarray(0,F),n:F}}function ee(b,k,y,w=!1){const{xs:O,ys:M,n:$}=B(b,k,y);if($<2)return null;let F=0,C=0;for(let oe=0;oe<$;oe++)F+=O[oe],C+=M[oe];F/=$,C/=$;let ie=0;for(let oe=0;oe<$;oe++)ie+=(O[oe]-F)*(M[oe]-C);return ie/(w?$:$-1)}function J(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;let $=0,F=0;for(let Le=0;Le<M;Le++)$+=w[Le],F+=O[Le];$/=M,F/=M;let C=0,ie=0,oe=0;for(let Le=0;Le<M;Le++){const we=w[Le]-$,De=O[Le]-F;C+=we*we,ie+=we*De,oe+=De*De}if(C===0)return null;const ke=ie/C,je=F-ke*$,Pe=oe===0?1:Math.max(0,Math.min(1,ie*ie/(C*oe))),pe=Math.max(0,oe-ke*ie),ve=M>2?Math.sqrt(pe/(M-2)/C):0;return{slope:ke,intercept:je,r2:Pe,stdError:ve,n:M}}const ue=new Set(["ols","wls","robust"]),de=new Set(["quantile"]),Oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),Ae=1.345;function Se(b,k,y){const{xtwx:w,xtwy:O}=T(b,k,y),M=se(w);if(!M)return null;const $=te(M,O),F=H(M),C=D(b,$),ie=k.map((oe,ke)=>oe-C[ke]);return{beta:$,cov:F,fitted:C,residuals:ie}}function D(b,k){return b.map(y=>y.reduce((w,O,M)=>w+O*k[M],0))}function x(b,k){const y=b.length,w=b.map(ie=>ie[k]),O=b.map(ie=>[1,...ie.filter((oe,ke)=>ke!==k)]),M=Se(O,w,null);if(!M)return 1;const $=w.reduce((ie,oe)=>ie+oe,0)/y;let F=0,C=0;for(let ie=0;ie<y;ie++)F+=M.residuals[ie]**2,C+=(w[ie]-$)**2;return C===0?1:Math.max(0,Math.min(1,1-F/C))}function fe(b){const k=[...b].sort((O,M)=>O-M),y=p(k),w=b.map(O=>Math.abs(O-y)).sort((O,M)=>O-M);return p(w)/.6745}function p(b){const k=b.length;if(!k)return 0;const y=Math.floor(k/2);return k%2?b[y]:(b[y-1]+b[y])/2}function Q(b,k,y={}){const w=y.method||"ols";if(Oe.has(w))throw new Error(`[lattice] regression method "${w}" is out of scope; use ols, wls or robust.`);if(de.has(w))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ue.has(w))throw new Error(`[lattice] unknown regression method "${w}"; use ols, wls or robust.`);const O=Array.isArray(k)?k.length:0,M=O&&Array.isArray(b[0])?b[0].length:0,$=M+1;if(!(O>$))return null;for(let Te=0;Te<O;Te++){if(!Number.isFinite(k[Te])||!Array.isArray(b[Te])||b[Te].length!==M)return null;for(let Fe=0;Fe<M;Fe++)if(!Number.isFinite(b[Te][Fe]))return null}let F=null;if(w==="wls"){if(F=y.weights,!Array.isArray(F)||F.length!==O)return null;for(let Te=0;Te<O;Te++)if(!(F[Te]>0)||!Number.isFinite(F[Te]))return null}const C=b.map(Te=>[1,...Te]);let ie,oe=null;if(w==="robust"){if(ie=Se(C,k,null),!ie)return null;for(let Te=0;Te<50;Te++){const Fe=fe(ie.residuals);if(!(Fe>0))break;const Ue=ie.residuals.map(Ge=>{const xe=Math.abs(Ge/Fe);return xe<=Ae?1:Ae/xe}),qe=Se(C,k,Ue);if(!qe)return null;const Je=qe.beta.reduce((Ge,xe,it)=>Math.max(Ge,Math.abs(xe-ie.beta[it])),0);if(ie=qe,oe=Ue,Je<1e-10)break}}else if(ie=Se(C,k,F),!ie)return null;const ke=w==="robust"?oe:F,{beta:je,cov:Pe,fitted:pe,residuals:ve}=ie;let Le=0,we=0,De=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Le+=Fe*ve[Te]**2,we+=Fe,De+=Fe*k[Te]}const $e=De/we;let Ke=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Ke+=Fe*(k[Te]-$e)**2}const He=O-$,Qe=Le/He,Ve=Ke===0?1:Math.max(0,Math.min(1,1-Le/Ke)),ut=1-(1-Ve)*(O-1)/He,nt=Array.isArray(y.names)&&y.names.length===M?y.names:b[0].map((Te,Fe)=>`x${Fe+1}`),Ze=tt(y.confidence),rt=He>0?_(1-(1-Ze)/2,He):1/0,Lt=je.map((Te,Fe)=>{const Ue=Math.sqrt(Math.max(0,Qe*Pe[Fe][Fe])),qe=Ue>0?Te/Ue:Te===0?0:1/0,Je=Number.isFinite(qe)?2*(1-Z(Math.abs(qe),He)):0,Ge=Number.isFinite(rt)?rt*Ue:null;return{name:Fe===0?"(intercept)":nt[Fe-1],estimate:Te,stdError:Ue,t:qe,p:Math.max(0,Math.min(1,Je)),lower:Ge===null?null:Te-Ge,upper:Ge===null?null:Te+Ge}}),bt=new Array(O),yt=new Array(O);for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1,Ue=Math.max(0,Math.min(1,Fe*V(C[Te],Pe)));bt[Te]=Ue;const qe=(1-Ue)**2;yt[Te]=qe>0&&Qe>0?ve[Te]**2/($*Qe)*(Ue/qe):null}const Ft=b[0].map((Te,Fe)=>{if(M<2)return 1;const Ue=x(b,Fe);return Ue>=1?1/0:1/(1-Ue)});let pt=null;{const Te=ve.map(Ue=>Ue*Ue),Fe=Se(C,Te,null);if(Fe){const Ue=Te.reduce((et,Ct)=>et+Ct,0)/O;let qe=0,Je=0;for(let et=0;et<O;et++)qe+=Fe.residuals[et]**2,Je+=(Te[et]-Ue)**2;const Ge=Je===0?0:Math.max(0,Math.min(1,1-qe/Je)),xe=O*Ge,it=re(xe,M);pt={statistic:xe,df:M,p:it,heteroscedastic:it<.05}}}let wt=null;if(M===1){const Te=b.map((Fe,Ue)=>Ue).sort((Fe,Ue)=>b[Fe][0]-b[Ue][0]);wt={confidence:Ze,points:Te.map(Fe=>{const Ue=C[Fe],qe=Math.sqrt(Math.max(0,Qe*V(Ue,Pe)));return{x:b[Fe][0],yhat:pe[Fe],lower:pe[Fe]-rt*qe,upper:pe[Fe]+rt*qe}})}}return{method:w,coefficients:Lt,r2:Ve,adjR2:ut,n:O,df:He,sigma2:Qe,fitted:pe,residuals:ve,leverage:bt,cooksD:yt,vif:Ft,heteroscedasticity:pt,band:wt,weights:ke?[...ke]:null}}function X(b){const k=b.length,y=Array.from({length:k},(M,$)=>$).sort((M,$)=>b[M]-b[$]),w=new Float64Array(k);let O=0;for(;O<k;){let M=O;for(;M+1<k&&b[y[M+1]]===b[y[O]];)M++;const $=(O+M)/2+1;for(let F=O;F<=M;F++)w[y[F]]=$;O=M+1}return w}const ce=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function le(b){const k=[.01,.05,.1],y=[ce["1%"],ce["5%"],ce["10%"]];if(b<=y[0]){const M=(Math.log(k[1])-Math.log(k[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(k[0])+M*(b-y[0]))))}if(b>=y[2]){const M=(Math.log(k[2])-Math.log(k[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(k[2])+M*(b-y[2]))))}const w=b<y[1]?0:1,O=(b-y[w])/(y[w+1]-y[w]);return Math.exp(Math.log(k[w])+O*(Math.log(k[w+1])-Math.log(k[w])))}function ge(b,k,y,w){const O=y-w,M=w+3,$=new Array(O),F=new Array(O);let C=!0,ie=w;for(let pe=0;pe<O;pe++){const ve=w+pe,Le=new Float64Array(M);Le[0]=1,Le[1]=pe+1,Le[2]=b[ve];for(let we=1;we<=w;we++)Le[2+we]=k[ve-we];for(let we=1;we<M;we++)Number.isFinite(Le[we])||(ie=Math.min(ie,we-3));$[pe]=Le,F[pe]=k[ve],Number.isFinite(F[pe])||(C=!1)}if(!C)return 0;const{xtwx:oe,xtwy:ke}=T($,F,null);let je=0,Pe=1/0;for(let pe=0;pe<=ie;pe++){const ve=pe+3;if(!(O>ve))continue;const Le=new Array(ve);for(let Ve=0;Ve<ve;Ve++)Le[Ve]=oe[Ve].slice(0,ve);const we=se(Le);if(!we)continue;const De=te(we,ke.slice(0,ve));let $e=0;for(let Ve=0;Ve<O;Ve++){const ut=$[Ve];let nt=0;for(let Ze=0;Ze<ve;Ze++)nt+=ut[Ze]*De[Ze];$e+=(F[Ve]-nt)**2}const He=$e/(O-ve)*(O-ve);if(!(He>0))continue;const Qe=O*Math.log(He/O)+2*ve;Qe<Pe&&(Pe=Qe,je=pe)}return je}function Me(b,k={}){const y=[];for(let Pe=0;Pe<b.length;Pe++){const pe=Number(b[Pe]);Number.isFinite(pe)&&y.push(pe)}const w=y.length,O=w-1;if(w<8||O<6)return null;const M=new Array(O);for(let Pe=0;Pe<O;Pe++)M[Pe]=y[Pe+1]-y[Pe];let $=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.ceil(12*(w/100)**.25);$=Math.max(0,Math.min($,Math.floor((O-5)/2)));const F=(Pe,pe)=>{const ve=[],Le=[];for(let we=pe;we<O;we++){const De=[we-pe+1,y[we]];for(let $e=1;$e<=Pe;$e++)De.push(M[we-$e]);ve.push(De),Le.push(M[we])}return Q(ve,Le,{method:"ols"})},C=ge(y,M,O,$),ie=F(C,C);if(!ie||!ie.coefficients[2])return null;const oe=ie.coefficients[2].t,ke=le(oe),je=oe<ce["5%"];return{statistic:oe,usedLag:C,nobs:O-C,criticalValues:{...ce},pValue:ke,pApproximate:!0,stationary:je,verdict:je?"stationary":"non-stationary",regression:"ct"}}function be(b,k={}){const y=[];for(let je=0;je<b.length;je++){const Pe=Number(b[je]);Number.isFinite(Pe)&&y.push(Pe)}const w=y.length;if(w<3)return null;let O=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.min(10,w-1);O=Math.max(1,Math.min(O,w-1));let M=0;for(const je of y)M+=je;M/=w;const $=y.map(je=>je-M);let F=0;for(const je of $)F+=je*je;F/=w;const C=new Array(O+1).fill(0);C[0]=1;for(let je=1;je<=O;je++){let Pe=0;for(let pe=je;pe<w;pe++)Pe+=$[pe]*$[pe-je];C[je]=F>0?Pe/w/F:0}const ie=new Array(O+1).fill(0);ie[0]=1;let oe=[];for(let je=1;je<=O;je++){let Pe=C[je];for(let we=1;we<je;we++)Pe-=oe[we-1]*C[je-we];let pe=1;for(let we=1;we<je;we++)pe-=oe[we-1]*C[we];const ve=pe!==0?Pe/pe:0,Le=new Array(je);for(let we=1;we<je;we++)Le[we-1]=oe[we-1]-ve*oe[je-1-we];Le[je-1]=ve,ie[je]=ve,oe=Le}const ke=1.96/Math.sqrt(w);return{acf:C,pacf:ie,bounds:{upper:ke,lower:-ke},n:w,nlags:O,approximate:!0}}function ye(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;const $=X(w),F=X(O);let C=0,ie=0;for(let Pe=0;Pe<M;Pe++)C+=$[Pe],ie+=F[Pe];C/=M,ie/=M;let oe=0,ke=0,je=0;for(let Pe=0;Pe<M;Pe++){const pe=$[Pe]-C,ve=F[Pe]-ie;oe+=pe*ve,ke+=pe*pe,je+=ve*ve}return ke===0||je===0?null:Math.max(-1,Math.min(1,oe/Math.sqrt(ke*je)))}function Re(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2||M>j)return null;let $=0,F=0,C=0,ie=0;for(let je=0;je<M;je++)for(let Pe=je+1;Pe<M;Pe++){const pe=Math.sign(w[je]-w[Pe]),ve=Math.sign(O[je]-O[Pe]),Le=pe*ve;Le>0?$++:Le<0?F++:pe===0&&ve===0||(pe===0?C++:ie++)}const oe=$+F+ie,ke=$+F+C;return oe===0||ke===0?null:($-F)/Math.sqrt(oe*ke)}function Ne(b,k={}){const y=b.length;if(y<2)return null;const w=b[0],O=b[y-1],M=[];for(let we=1;we<y;we++){const De=b[we-1];De!==0&&M.push((b[we]-De)/Math.abs(De))}let $=null;if(M.length>1){let we=0;for(const $e of M)we+=$e;we/=M.length;let De=0;for(const $e of M)De+=($e-we)**2;$=Math.sqrt(De/(M.length-1))}const F=Number(k.periodsPerYear)>0?Number(k.periodsPerYear):null;let C=b[0],ie=0,oe=0,ke=0,je=0;for(let we=1;we<y;we++){if(b[we]>C){C=b[we],ie=we;continue}if(C<=0)continue;const De=(C-b[we])/C;De>oe&&(oe=De,ke=ie,je=we)}let Pe=null;if(y>2){let we=0;for(let Ke=0;Ke<y;Ke++)we+=b[Ke];we/=y;let De=0,$e=0;for(let Ke=0;Ke<y;Ke++){const He=b[Ke]-we;$e+=He*He,Ke>0&&(De+=He*(b[Ke-1]-we))}Pe=$e>0?De/$e:null}let pe=0,ve=0;for(const we of M)we>0?pe++:we<0&&ve++;let Le=null;if(w>0&&O>0){const we=(O/w)**(1/(y-1))-1;Le=F?(1+we)**F-1:we}return{n:y,first:w,last:O,change:O-w,changePercent:w===0?null:(O-w)/Math.abs(w)*100,volatility:$,annualisedVolatility:$!==null&&F?$*Math.sqrt(F):null,growth:Le,maxDrawdown:oe,maxDrawdownFrom:ke,maxDrawdownTo:je,autocorrelation:Pe,upDays:pe,downDays:ve}}const Ee=1.128,Be=3.267;function ze(b){const k=b.length;if(k<2)return null;const y=[];for(let O=1;O<k;O++)y.push(Math.abs(b[O]-b[O-1]));const w=y.reduce((O,M)=>O+M,0)/y.length;return{ranges:y,centre:w,upper:Be*w,lower:0}}function We(b){const k=b.length;if(k<2)return null;let y=0;for(let O=1;O<k;O++)y+=Math.abs(b[O]-b[O-1]);const w=y/(k-1);return{sigma:w/Ee,meanRange:w}}function Xe(b,k){const y=b.length;if(y<2||!k)return null;const w=Number.isFinite(Number(k.lower))?Number(k.lower):null,O=Number.isFinite(Number(k.upper))?Number(k.upper):null;if(w===null&&O===null)return null;let M=0;for(let pe=0;pe<y;pe++)M+=b[pe];M/=y;let $=0;for(let pe=0;pe<y;pe++)$+=(b[pe]-M)**2;const F=Math.sqrt($/(y-1)),C=We(b),ie=C?C.sigma:null,oe=pe=>{if(!pe||pe<=0)return{index:null,k:null};const Le=w!==null&&O!==null?(O-w)/(6*pe):null,we=O!==null?(O-M)/(3*pe):1/0,De=w!==null?(M-w)/(3*pe):1/0;return{index:Le,k:Math.min(we,De)}},ke=oe(ie),je=oe(F);let Pe=0;for(let pe=0;pe<y;pe++){if(w!==null&&b[pe]<w){Pe++;continue}O!==null&&b[pe]>O&&Pe++}return{n:y,mean:M,lower:w,upper:O,target:Number.isFinite(Number(k.target))?Number(k.target):null,sigmaWithin:ie,sigmaOverall:F,cp:ke.index,cpk:ke.k,pp:je.index,ppk:je.k,outOfSpec:Pe,defectRate:y?Pe/y:null}}function Ye(b){const k=b.length;if(k<2)return null;const y=We(b);if(!y||!(y.sigma>0))return null;let w=0;for(let O=0;O<k;O++)w+=b[O];return w/=k,{centre:w,sigma:y.sigma,upper:w+3*y.sigma,lower:w-3*y.sigma}}function Ie(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=F=>(b[F]-w)/O,$=[];for(let F=0;F<y;F++){if(Math.abs(M(F))>3&&$.push({index:F,rule:1,description:"beyond three sigma"}),F>=2)for(const C of[1,-1]){let ie=0;for(let oe=F-2;oe<=F;oe++)M(oe)*C>2&&ie++;if(ie>=2){$.push({index:F,rule:2,description:"two of three past two sigma"});break}}if(F>=4)for(const C of[1,-1]){let ie=0;for(let oe=F-4;oe<=F;oe++)M(oe)*C>1&&ie++;if(ie>=4){$.push({index:F,rule:3,description:"four of five past one sigma"});break}}if(F>=7)for(const C of[1,-1]){let ie=!0;for(let oe=F-7;oe<=F;oe++)if(M(oe)*C<=0){ie=!1;break}if(ie){$.push({index:F,rule:4,description:"eight in a row on one side"});break}}}return $}function ft(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=C=>(b[C]-w)/O,$=(C,ie,oe,ke)=>{for(const je of[1,-1]){let Pe=0;for(let pe=C;pe<=ie;pe++)M(pe)*je>oe&&Pe++;if(Pe>=ke)return!0}return!1},F=[];for(let C=0;C<y;C++){if(Math.abs(M(C))>3&&F.push({index:C,rule:1,description:"beyond three sigma"}),C>=8)for(const ie of[1,-1]){let oe=!0;for(let ke=C-8;ke<=C;ke++)if(M(ke)*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:2,description:"nine in a row on one side"});break}}if(C>=5)for(const ie of[1,-1]){let oe=!0;for(let ke=C-4;ke<=C;ke++)if((b[ke]-b[ke-1])*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:3,description:ie>0?"six rising":"six falling"});break}}if(C>=13){let ie=!0;for(let oe=C-12;oe<=C;oe++){const ke=b[oe]-b[oe-1],je=b[oe+1<=C?oe+1:oe]-b[oe];if(oe+1>C)break;if(ke===0||je===0||ke>0==je>0){ie=!1;break}}ie&&F.push({index:C,rule:4,description:"fourteen alternating"})}if(C>=2&&$(C-2,C,2,2)&&F.push({index:C,rule:5,description:"two of three past two sigma"}),C>=4&&$(C-4,C,1,4)&&F.push({index:C,rule:6,description:"four of five past one sigma"}),C>=14){let ie=!0;for(let oe=C-14;oe<=C;oe++)if(Math.abs(M(oe))>=1){ie=!1;break}ie&&F.push({index:C,rule:7,description:"fifteen within one sigma"})}if(C>=7){let ie=!0;for(let oe=C-7;oe<=C;oe++)if(Math.abs(M(oe))<=1){ie=!1;break}ie&&F.push({index:C,rule:8,description:"eight beyond one sigma"})}}return F}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,k,y="westernElectric"){return String(y)==="nelson"?ft(b,k):Ie(b,k)}function Mt(b,k,y){let w=0;for(let O=0;O<b.length;O++)(b[O]<k||b[O]>y)&&w++;return w}function Pt(b,k,y,w=20){const O=b.length;if(!O)return[];const M=b[0],$=b[O-1];if($===M)return[{from:M,to:$,count:O}];const F=y-k,C=1.5*F;let ie=F>0?Math.max(M,k-C):M,oe=F>0?Math.min($,y+C):$;oe>ie||(ie=M,oe=$);const ke=F>0?2*F/Math.cbrt(O):(oe-ie)/(Math.ceil(Math.log2(O))+1),je=ke>0?Math.min(w,Math.max(1,Math.ceil((oe-ie)/ke))):1,Pe=(oe-ie)/je,pe=[];for(let ve=0;ve<je;ve++)pe.push({from:ie+ve*Pe,to:ie+(ve+1)*Pe,count:0});for(let ve=0;ve<O;ve++){const Le=Math.min(je-1,Math.max(0,Math.floor((b[ve]-ie)/Pe)));pe[Le].count++}return pe[0].from=M,pe[je-1].to=$,pe}const _e=.95;function tt(b){const k=Number(b);return Number.isFinite(k)&&k>0&&k<1?k:_e}function Nt(b,k=_e){const y=b.length;if(y<2)return null;let w=0;for(let oe=0;oe<y;oe++)w+=b[oe];const O=w/y;let M=0;for(let oe=0;oe<y;oe++){const ke=b[oe]-O;M+=ke*ke}const $=Math.sqrt(M/(y-1)),F=tt(k),ie=_(1-(1-F)/2,y-1)*$/Math.sqrt(y);return{mean:O,lower:O-ie,upper:O+ie,margin:ie,n:y,confidence:F}}function St(b,k,y=_e){const w=Number(b),O=Number(k);if(!(O>0)||!(w>=0)||w>O)return null;const M=tt(y),$=E(1-(1-M)/2),F=w/O,C=$*$,ie=1+C/O,oe=(F+C/(2*O))/ie,ke=$/ie*Math.sqrt(F*(1-F)/O+C/(4*O*O));return{proportion:F,lower:Math.max(0,oe-ke),upper:Math.min(1,oe+ke),n:O,confidence:M}}function vt(b,k=_e){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=tt(k),O=_(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-O,upper:b.slope+O,margin:O,confidence:y}}function Tt(b,k,y=_e){const w=Number(b),O=Number(k);if(!Number.isFinite(w)||!(O>1))return null;const M=tt(y),F=E(1-(1-M)/2)*Math.sqrt(1/(9*O)+w*w/(2*(O-1)));return{index:w,lower:w-F,upper:w+F,margin:F,n:O,confidence:M}}function ht(b,k){return!b||!(b.sd>0)||!Number.isFinite(k)||!Number.isFinite(b.mean)?null:(k-b.mean)/b.sd}function dt(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*z(Math.abs(b)/2)-1)):0}function ot(b,k){const y=new Map,w=W(b);let O=0;for(let M=0;M<k.length;M++){const $=w(k[M]);if($==null||$===""||typeof $=="number"&&Number.isNaN($))continue;const F=$ instanceof Date?$.getTime():typeof $=="object"?String($):$;y.set(F,(y.get(F)||0)+1),O++}return{map:y,total:O}}function mt(b,k,y,w){if(!(k>0)||!(w>0))return null;let O=0;const M=new Set(b.keys());for(const $ of y.keys())M.add($);for(const $ of M){const F=(b.get($)||0)/k,C=(y.get($)||0)/w;O+=Math.abs(F-C)}return O/2}const st=10;function Et(b,k,y){if(y&&y.numeric){const F=h(b,k),{n:C,mean:ie}=r(F),oe=C>0?ht({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:oe,distance:oe===null?0:dt(oe),direction:oe===null?0:Math.sign(oe),subsetN:C,populationN:y.n||0,reliable:C>=st}}const{map:O,total:M}=ot(b,k),$=mt(O,M,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:$,distance:$===null?0:$,direction:0,subsetN:M,populationN:y.total||0,reliable:M>=st}}function gt(b,k){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=W(b);let w=0,O=0;for(let M=0;M<k.length&&w<200;M++){const $=y(k[M]);if($==null||$==="")continue;if($ instanceof Date)return!1;w++;const F=typeof $=="number"?$:Number($);Number.isFinite(F)&&O++}return w===0?!1:O/w>=.9}function Rt(b,k){if(gt(b,k)){const O=h(b,k),{n:M,mean:$,m2:F}=r(O);return{numeric:!0,mean:$,sd:M>0?Math.sqrt(F/M):0,n:M}}const{map:y,total:w}=ot(b,k);return{numeric:!1,map:y,total:w}}}),Ce("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return f}});const ae=me("packages/core/src/internal/util.js"),he=ae.isFunction,W=ae.warnOnce,U=me("packages/core/src/compute/handle.js"),_=U.presenceReader,Z=U.valueComparator,E=U.valueReader,z=me("packages/core/src/compute/statistics.js"),re=z.STAT_FNS,Y=z.STAT_LABELS;function se(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function te(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++){const v=P[n[L]];Number.isNaN(v)||(g+=v)}return g}for(let L=0;L<c;L++){const v=n[L];if(q(v)===1){const G=P[v];Number.isNaN(G)||(g+=G)}}return g}const A=E(r);for(let P=0;P<c;P++){const q=s(A(n[P]));q!==null&&(g+=q)}return g}te.kernel=!0;function H(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++)Number.isNaN(P[n[L]])||g++;return g}for(let L=0;L<c;L++){const v=n[L];q(v)===1&&!Number.isNaN(P[v])&&g++}return g}const A=E(r);for(let P=0;P<c;P++){const q=A(n[P]);q!=null&&!(typeof q=="number"&&Number.isNaN(q))&&g++}return g}H.kernel=!0;function T(r,n){return n.length}T.kernel=!0;function V(r,n){const c=H(r,n);return c===0?null:te(r,n)/c}V.kernel=!0;function ne(r,n,c,g){const A=n.length;if(se(r)){const v=r.values,G=_(r);let S=null;if(!G){for(let N=0;N<A;N++){const I=v[n[N]];Number.isNaN(I)||(S===null||(c<0?I<S:I>S))&&(S=I)}return S}for(let N=0;N<A;N++){const I=n[N];if(G(I)===0)continue;const K=v[I];Number.isNaN(K)||(S===null||(c<0?K<S:K>S))&&(S=K)}return S}const P=E(r),q=Z(g);let L=null;for(let v=0;v<A;v++){const G=P(n[v]);G==null||typeof G=="number"&&Number.isNaN(G)||(L===null||(c<0?q(G,L)<0:q(G,L)>0))&&(L=G)}return L}function R(r,n,c){return ne(r,n,-1,c&&c.locale)}R.kernel=!0;function j(r,n,c){return ne(r,n,1,c&&c.locale)}j.kernel=!0;function i(r,n){return n.length===0?null:E(r)(n[0])}i.kernel=!0;function a(r,n){return n.length===0?null:E(r)(n[n.length-1])}a.kernel=!0;function s(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isNaN(n)?null:n}const h={sum:te,min:R,max:j,avg:V,count:T,first:i,last:a,countValues:H,...re},u=Object.freeze({...Y,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function t(r){return r?typeof r=="string"?u[r]||r:"Total":""}const l=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const c=l.filter(g=>g in h);for(const g of Object.keys(h))c.includes(g)||c.push(g);return c}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const c=E(r),g=[];for(let A=0;A<n.length;A++){const P=c(n[A]);P!=null&&g.push(P)}return g}function f(r,n,c,g){const A=n||[];if(typeof c=="string"){const P=h[c];return P?P(r,A,g):(W(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,A,g):c(d(r,A),g||{}):null}}),Ce("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/internal/util.js").warnOnce,U=me("packages/core/src/compute/handle.js").valueComparator,Z=me("packages/core/src/compute/group.js").packKeys,z=me("packages/core/src/compute/total.js").total,re="|",Y="/",se=2e3;function te(s,h,u){return`${s}${re}${h}${re}${u}`}function H(s,h){let u="";for(let t=0;t<s.length;t++){const l=s[t];u+=(t===0?"":h)+(l==null?"":String(l))}return u}function T(s,h,u={}){const t=u.separator||Y,l=h.length,{keyOf:m,readers:e}=Z(s,h,0),d=new Map,f=[],r=[];for(let L=0;L<l;L++){const v=h[L],G=m(v);if(d.has(G))continue;d.set(G,f.length),r.push(G);const S=new Array(e.length);for(let N=0;N<e.length;N++)S[N]=e[N](v);f.push(S)}const n=U(u.locale),c=f.map((L,v)=>v);c.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=V(G[N],S[N],n);if(I!==0)return I}return L-v});const g=new Array(c.length),A=new Array(c.length),P=new Map;for(let L=0;L<c.length;L++){const v=c[L];g[L]=f[v],A[L]=H(f[v],t),P.set(r[v],L)}return{keys:g,paths:A,idOf:L=>{const v=P.get(m(L));return v===void 0?-1:v}}}function V(s,h,u){const t=s==null,l=h==null;return t||l?t&&l?0:t?1:-1:u(s,h)}function ne(s){const h=s.values||s.totals||[];if(h.length&&typeof h[0]=="object"&&h[0]!==null)return h.filter(m=>m&&m.handle);const u=typeof s.handle=="function"?s.handle:null;if(!u)return h.length&&he("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 t=typeof s.totalOf=="function"?s.totalOf:null,l=[];for(const m of h){const e=u(m);e&&l.push({colId:m,handle:e,fn:t?t(m):"sum"})}return l}function R(s,h,u){if(Array.isArray(s)){const t=u||{};return{...t,pivotHandles:s,order:h||null,groups:t.groups||null}}return s||{}}function j(s,h,u){const t=R(s,h,u),l=t.separator||Y,m=ne(t),e=t.maxColumns===void 0?se:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,f=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(G=>H(G,l)):[""]),n=a(f),{keys:c,paths:g,idOf:A}=T(t.pivotHandles||[],n,t),P=g.length*Math.max(1,m.length),q=i(g,m,l);if(e&&P>e){const G=new Map;return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:G,cells:G,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${P} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:P,maxColumns:e}}}const L=new Map,v=g.length;for(let G=0;G<f.length;G++){const S=f[G],N=r[G]===void 0?"":r[G],I=S.length;if(I===0)continue;const K=new Int32Array(I),B=new Uint32Array(v+1);for(let ue=0;ue<I;ue++){const de=A(S[ue]);K[ue]=de,de>=0&&B[de+1]++}for(let ue=0;ue<v;ue++)B[ue+1]+=B[ue];const ee=new Uint32Array(I),J=B.slice(0,v);for(let ue=0;ue<I;ue++){const de=K[ue];de>=0&&(ee[J[de]++]=S[ue])}for(let ue=0;ue<v;ue++){const de=B[ue],Oe=B[ue+1];if(Oe===de)continue;const Ae=ee.subarray(de,Oe);for(let Se=0;Se<m.length;Se++){const D=m[Se],x=z(D.handle,Ae,D.fn,t.totalContext||{locale:t.locale});L.set(te(N,g[ue],D.colId),x)}}}return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:L,cells:L,error:null}}function i(s,h,u){if(h.length===0)return s.slice();const t=[];for(const l of s)for(const m of h)t.push(`${l}${u}${m.colId}`);return t}function a(s){if(s.length===1)return s[0]||new Uint32Array(0);let h=0;for(const l of s)h+=l?l.length:0;const u=new Uint32Array(h);let t=0;for(const l of s)!l||l.length===0||(u.set(l,t),t+=l.length);return u}}),Ce("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/compute/handle.js").valueComparator,U=me("packages/core/src/compute/total.js").total,Z=me("packages/core/src/compute/group.js").packKeys,E=me("packages/core/src/compute/pivot.js"),z=E.joinPath,re=E.DEFAULT_PATH_SEPARATOR,Y=E.DEFAULT_MAX_COLUMNS,se="";function te(i,a,s={}){const h=s.separator||re,u=i||[],t=a instanceof Uint32Array?a:Uint32Array.from(a||[]),l=t.length;if(u.length===0)return{tuples:[[]],paths:[se],buckets:[t]};const{keyOf:m,readers:e}=Z(u,t,0),d=new Map,f=[],r=[],n=[];for(let L=0;L<l;L++){const v=t[L],G=m(v);let S=d.get(G);if(S===void 0){S=f.length,d.set(G,S),r.push(G);const N=new Array(e.length);for(let I=0;I<e.length;I++)N[I]=e[I](v);f.push(N),n.push([])}n[S].push(v)}const c=he(s.locale),g=f.map((L,v)=>v);g.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=H(G[N],S[N],c);if(I!==0)return I}return L-v});const A=new Array(g.length),P=new Array(g.length),q=new Array(g.length);for(let L=0;L<g.length;L++){const v=g[L];A[L]=f[v],P[L]=z(f[v],h),q[L]=Uint32Array.from(n[v])}return{tuples:A,paths:P,buckets:q}}function H(i,a,s){const h=i==null,u=a==null;return h||u?h&&u?0:h?1:-1:s(i,a)}function T(i,a,s){const h=[];for(let u=0;u<i.length;u++)s.has(i[u])&&h.push(i[u]);return Uint32Array.from(h)}function V(i,a,s,h){return{value:a.length?U(i,a,s,h):null,leaves:a,count:a.length}}function ne(i){const a=i&&i.opts||{},s=a.separator||re,h=a.totalContext||{locale:a.locale},u=(i.measures||[]).filter(P=>P&&P.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),l=te(i.rowHandles||[],t,{...a,separator:s}),m=te(i.columnHandles||[],t,{...a,separator:s}),e=a.maxColumns===void 0?Y:a.maxColumns,d=m.paths.length*Math.max(1,u.length),f=new Map;if(e&&d>e)return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:f,rowMargin:f,columnMargin:f,grand:f,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,c=new Map,g=new Map,A=m.buckets.map(P=>new Set(P));for(let P=0;P<m.paths.length;P++){const q=m.buckets[P],L=m.paths[P];for(const v of u)c.set(j(L,v.colId),V(v.handle,q,v.fn,h))}for(let P=0;P<l.paths.length;P++){const q=l.buckets[P],L=l.paths[P];for(const v of u)n.set(j(L,v.colId),V(v.handle,q,v.fn,h));for(let v=0;v<m.paths.length;v++){const G=T(q,m.buckets[v],A[v]);if(G.length===0)continue;const S=m.paths[v];for(const N of u)r.set(R(L,S,N.colId),V(N.handle,G,N.fn,h))}}for(const P of u)g.set(P.colId,V(P.handle,t,P.fn,h));return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function R(i,a,s){return`${i}\\0${a}\\0${s}`}function j(i,a){return`${i}\\0${a}`}}),Ce("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne}});const he=me("packages/core/src/internal/util.js").getPath,W=me("packages/core/src/compute/handle.js"),U=W.isMissing,_=W.valueComparator,E=me("packages/core/src/compute/filter.js").testValue,z="",re="\\0";function Y(i,a){const s=a.includes(".")?he(i,a):i?.[a];return s===void 0?null:s}function se(i,a,s={}){const h=a||[];let u=i.map((t,l)=>l);if(h.length===0)return u;for(let t=h.length-1;t>=0;t--)u=te(i,u,h[t],s);return u}function te(i,a,s,h){const u=s.locale!==void 0?s.locale:h.locale,t=_(u),l=s.descending!==void 0?!!s.descending:s.dir==="desc",m=[],e=[];for(const r of a){const n=Y(i[r],s.col);U(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const f=(r,n)=>{const c=Y(i[r],s.col),g=Y(i[n],s.col);let A;return typeof s.compare=="function"?(A=s.compare(c,g,i[r],i[n],l),l&&(A=-A)):A=l?t(g,c):t(c,g),A!==0?A:d.get(r)-d.get(n)};return m.sort(f),s.nullsFirst?e.concat(m):m.concat(e)}function H(i,a,s={}){const h=[];for(let u=0;u<i.length;u++)T(i[u],a,s,u)&&h.push(u);return h}function T(i,a,s,h){if(!a)return!0;if(Array.isArray(a.conditions)){const u=a.conditions.filter(l=>l!=null);if(u.length===0)return!0;if(a.op==="or")return u.some(l=>T(i,l,s,h));const t=u.every(l=>T(i,l,s,h));return a.op==="not"?!t:t}return a.col===void 0&&typeof s.custom=="function"?!!s.custom(a,i,h):E(Y(i,a.col),a,s.locale)}function V(i,a,s,h){const u=s||i.map((e,d)=>d),t=new Map,l=[],m=[];for(const e of u){const d=a.map((n,c)=>{const g=Y(i[e],n);return h&&h[c]?h[c](g):g}),f=d.map(n=>n==null?re:String(n)).join(z);let r=t.get(f);r===void 0&&(r=l.length,t.set(f,r),l.push(d),m.push([])),m[r].push(e)}return{keys:l,buckets:m}}function ne(i,a,s={}){const h=_(s.locale),u=i.filter(l=>!U(l)),t=u.map(R).filter(l=>l!==null);switch(a){case"count":return i.length;case"countValues":return u.length;case"sum":return t.reduce((l,m)=>l+m,0);case"avg":return u.length===0?null:t.reduce((l,m)=>l+m,0)/u.length;case"min":return u.length===0?null:u.reduce((l,m)=>h(m,l)<0?m:l);case"max":return u.length===0?null:u.reduce((l,m)=>h(m,l)>0?m:l);case"first":return i.length===0?null:j(i[0]);case"last":return i.length===0?null:j(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 a=Number(i);return Number.isNaN(a)?null:a}function j(i){return i===void 0?null:i}}),Ce("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return Z}});const he=me("packages/core/src/compute/sketch.js").Welford;class W{#t;#e;#n=[];#r;#i;constructor(z,re=0,Y=Date.now){if(z!=="count"&&z!=="time"&&z!=="session")throw new RangeError(`unknown window kind: ${z}`);if((z==="count"||z==="time")&&!(re>0))throw new RangeError(`a ${z} window needs a positive span`);this.#t=z,this.#e=Math.floor(re),this.#r=Y,this.#i=Y()}get size(){return this.#n.length}push(z,re=this.#r()){Number.isFinite(z)&&(this.#n.push({t:re,v:z}),this.#s(re))}#s(z){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=z-this.#e;for(;this.#n.length&&this.#n[0].t<re;)this.#n.shift()}}spec(){const z=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:z,size:this.#n.length}}values(){return this.#n.map(z=>z.v)}aggregate(){const z=this.spec();if(!this.#n.length)return{over:z,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const re=new he;let Y=0,se=1/0,te=-1/0;for(const{v:H}of this.#n)Y+=H,H<se&&(se=H),H>te&&(te=H),re.add(H);return{over:z,count:this.#n.length,sum:Y,mean:re.mean(),min:se,max:te,variance:re.variance(),stddev:re.stddev()}}reduce(z){const re=this.aggregate(),Y={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(z in Y))throw new RangeError(`unknown windowed aggregate: ${z}`);return{value:Y[z],over:re.over}}}const U=Object.freeze(["count","time","session"]);function _(E,z=Date.now){const re=E.kind==="time"&&E.minutes!=null?E.minutes*6e4:E.span??0;return new W(E.kind,re,z)}const Z={Window:W,WINDOW_KINDS:U,openWindow:_}}),Ce("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return h}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,U=me("packages/core/src/compute/special.js").logGamma,_=.6745,Z=3.5,E=1.5,z=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function Y(u){if(!u.length)return null;const l=Array.from(u,Number).sort((f,r)=>f-r),m=he(l,.5),e=l.map(f=>Math.abs(f-m)).sort((f,r)=>f-r),d=he(e,.5);return{median:m,mad:d}}function se(u,t={}){const l=Number.isFinite(t.threshold)?t.threshold:Z,m=u.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),f=[];for(let c=0;c<m;c++){const g=Number(u[c]);Number.isFinite(g)&&f.push(g)}if(!f.length)return{median:null,mad:null,threshold:l,scores:e,flags:d,flagged:0};const r=Y(f);if(r.mad===0)return{median:r.median,mad:0,threshold:l,scores:e,flags:d,flagged:0};let n=0;for(let c=0;c<m;c++){const g=Number(u[c]);if(!Number.isFinite(g))continue;const A=_*(g-r.median)/r.mad;e[c]=A,Math.abs(A)>l&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:l,scores:e,flags:d,flagged:n}}function te(u,t={}){const l=Number.isFinite(t.k)?t.k:E,m=[];for(let n=0;n<u.length;n++){const c=Number(u[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),d=he(e,.25),f=he(e,.75),r=f-d;return{q1:d,q3:f,iqr:r,lower:d-l*r,upper:f+l*r,k:l}}function H(u,t){if(t<=0)return 0;const l=U(u);if(t<u+1){let c=u,g=1/u,A=g;for(let P=0;P<1e3&&(c+=1,A*=t/c,g+=A,!(Math.abs(A)<Math.abs(g)*1e-15));P++);return g*Math.exp(-t+u*Math.log(t)-l)}const m=1e-300;let e=t+1-u,d=1/m,f=1/e,r=f;for(let c=1;c<1e3;c++){const g=-c*(c-u);e+=2,f=g*f+e,Math.abs(f)<m&&(f=m),d=e+g/d,Math.abs(d)<m&&(d=m),f=1/f;const A=f*d;if(r*=A,Math.abs(A-1)<1e-15)break}return 1-Math.exp(-t+u*Math.log(t)-l)*r}function T(u,t){return u<=0?0:H(t/2,u/2)}function V(u,t=z){if(!(t>0)||!(t<1))return NaN;let l=0,m=Math.max(1,u);for(;T(m,u)<t;)m*=2;for(let e=0;e<200;e++){const d=(l+m)/2;if(T(d,u)<t?l=d:m=d,m-l<1e-10)break}return(l+m)/2}function ne(u){const t=u.length,l=u.map((m,e)=>{const d=m.slice();for(let f=0;f<t;f++)d.push(e===f?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let f=m+1;f<t;f++)Math.abs(l[f][m])>Math.abs(l[e][m])&&(e=f);if(Math.abs(l[e][m])<1e-12)return null;if(e!==m){const f=l[e];l[e]=l[m],l[m]=f}const d=l[m][m];for(let f=0;f<2*t;f++)l[m][f]/=d;for(let f=0;f<t;f++){if(f===m)continue;const r=l[f][m];if(r!==0)for(let n=0;n<2*t;n++)l[f][n]-=r*l[m][n]}}return l.map(m=>m.slice(t))}function R(u,t){const l=u.length,m=new Array(t).fill(0);for(const f of u)for(let r=0;r<t;r++)m[r]+=f[r];for(let f=0;f<t;f++)m[f]/=l;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const f of u)for(let r=0;r<t;r++){const n=f[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(f[c]-m[c])}const d=l>1?l-1:1;for(let f=0;f<t;f++)for(let r=f;r<t;r++)e[f][r]/=d,e[r][f]=e[f][r];return{mean:m,cov:e}}function j(u,t={}){const l=Number.isFinite(t.p)?t.p:z,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=u.length;if(!e)return null;const d=u[0].length;if(!d)return null;const f=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),c=[],g=[];for(let N=0;N<e;N++){const I=u[N];let K=I.length===d;const B=new Array(d);for(let ee=0;K&&ee<d;ee++){const J=Number(I[ee]);Number.isFinite(J)?B[ee]=J:K=!1}K&&(c.push(N),g.push(B))}const A=d,P=V(A,l);if(g.length<=d)return{center:[],df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0};const{mean:q,cov:L}=R(g,d);let v=ne(L),G=!1;if(!v){G=!0;let N=0;for(let B=0;B<d;B++)N+=L[B][B];const I=N/d*m||m,K=L.map((B,ee)=>B.map((J,ue)=>ee===ue?J+I:J));if(v=ne(K),!v)return{center:q,df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0}}let S=0;for(let N=0;N<g.length;N++){const I=g[N],K=new Array(d);for(let J=0;J<d;J++)K[J]=I[J]-q[J];let B=0;for(let J=0;J<d;J++){let ue=0;for(let de=0;de<d;de++)ue+=v[J][de]*K[de];B+=K[J]*ue}B<0&&(B=0);const ee=c[N];r[ee]=B,f[ee]=Math.sqrt(B),B>P&&(n[ee]=!0,S++)}return{center:q,df:A,cutoff:P,singular:G,used:g.length,distances:f,squared:r,flags:n,flagged:S}}const i=20,a=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function s(u,t={}){const l=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:Z,d=Number.isFinite(t.k)?t.k:E,f=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=u.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let A=0;A<r;A++){const P=Number(u[A]);if(!Number.isFinite(P))continue;const q=Math.max(0,A-m+1),L=[];for(let v=q;v<=A;v++){const G=Number(u[v]);Number.isFinite(G)&&L.push(G)}if(!(L.length<f))if(l==="rollingIqr"){const v=te(L,{k:d});if(!v)continue;(P<v.lower||P>v.upper)&&(c[A]=!0,g++)}else{const v=Y(L);if(!v||v.mad===0)continue;const G=_*(P-v.median)/v.mad;n[A]=G,Math.abs(G)>e&&(c[A]=!0,g++)}}return{method:l,windowLen:m,minPeriods:f,threshold:e,k:d,scores:n,flags:c,flagged:g}}function h(u={}){const t=u||{},l=t.field;if(typeof l!="string"||!l)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(re.includes(m)||a.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,f=t.latest===!0,r=a.includes(m),n=c=>Number(c==null?NaN:c[l]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((v,G)=>{const S=v?.[d],N=G?.[d];return S===N?0:S==null?-1:N==null?1:S<N?-1:1});const A=g.map(n);let P,q;if(r)({flags:P,scores:q}=s(A,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const v=te(A,{k:t.k});P=A.map(G=>v?Number.isFinite(G)&&(G<v.lower||G>v.upper):!1),q=A.map(()=>null)}else({flags:P,scores:q}=se(A,{threshold:t.threshold}));if(f){const v=P.length-1;return v<0||!P[v]?!1:{method:m,field:l,flagged:[{row:g[v],score:q[v]}]}}const L=[];for(let v=0;v<P.length;v++)P[v]&&L.push({row:g[v],score:q[v]});return L.length?{method:m,field:l,flagged:L}:!1}}}),Ce("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return u}});const ae=me("packages/core/src/compute/special.js"),he=ae.normalQuantile,W=ae.studentTQuantile,_=me("packages/core/src/internal/util.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),E=1e-4,z=1-1e-4;function re(t){const l=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,f=Number.isFinite(e.value)?e.value:null;l.push({at:d,value:f})}else l.push({at:m,value:Number.isFinite(e)?Number(e):null})}return l}function Y(t){const l=t.filter(r=>r.value!==null),m=l[0],e=l[l.length-1],d=e.at-m.at,f=l.length>1&&d>0?d/(l.length-1):1;return{lastAt:e.at,step:f}}function se(t){return Math.min(z,Math.max(E,t))}function te(t,l=E,m=z,e=80){const d=(Math.sqrt(5)-1)/2;let f=l,r=m,n=r-d*(r-f),c=f+d*(r-f),g=t(n),A=t(c);for(let P=0;P<e;P++)g<A?(r=c,c=n,A=g,n=r-d*(r-f),g=t(n)):(f=n,n=c,g=A,c=f+d*(r-f),A=t(c));return(f+r)/2}function H(t,l){let m=null,e=0,d=0;for(let f=0;f<t.length;f++){const r=t[f];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=l*r+(1-l)*m}}return{level:m,sse:e,m:d}}function T(t,l,m){let e=null,d=null,f=0,r=0;for(let n=0;n<t.length;n++){const c=t[n];if(c===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=c;continue}d===null&&(d=c-e);const g=e+d;f+=(c-g)**2,r+=1;const A=e;e=l*c+(1-l)*(A+d),d=m*(e-A)+(1-m)*d}return{level:e,trend:d,sse:f,m:r}}function V(t,l,m,e,d){const f=t.length;if(f<2*l)return null;const r=G=>{let S=0,N=0;for(let I=G;I<G+l&&I<f;I++)t[I]!==null&&(S+=t[I],N+=1);return N?S/N:null},n=r(0),c=r(l);if(n===null||c===null)return null;let g=n,A=(c-n)/l;const P=new Array(l).fill(0);for(let G=0;G<l;G++)P[G]=t[G]===null?0:t[G]-g;const q=P.reduce((G,S)=>G+S,0)/l;for(let G=0;G<l;G++)P[G]-=q;let L=0,v=0;for(let G=l;G<f;G++){const S=G%l,N=P[S],I=t[G];if(I===null){g+=A;continue}const K=g+A+N;L+=(I-K)**2,v+=1;const B=g;g=m*(I-N)+(1-m)*(g+A),A=e*(g-B)+(1-e)*A,P[S]=d*(I-g)+(1-d)*N}return{level:g,trend:A,season:P,phase:(f-1)%l,sse:L,count:v}}function ne(t,l,m){let e=1;for(const f of l)e+=f*f;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function R(t,l={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=Z.includes(l.method)?l.method:"linear",e=Math.max(1,Math.floor(Number(l.horizon)||1)),d=Number.isFinite(l.confidence)&&l.confidence>0&&l.confidence<1?l.confidence:.95,f=1-(1-d)/2,r=re(t),n=r.map(L=>L.value),c=n.filter(L=>L!==null),g=c.length,{lastAt:A,step:P}=g?Y(r):{lastAt:0,step:1},q=L=>A+L*P;return m==="linear"?j(r,g,e,d,f,q):m==="movingAverage"?i(c,g,e,d,f,l,q):m==="ses"?a(n,g,e,d,f,l,q):m==="holt"?s(n,g,e,d,f,l,q):h(n,g,e,d,f,l,q)}function j(t,l,m,e,d,f){if(l<2)return null;let r=0,n=0;for(const I of t)I.value!==null&&(r+=I.at,n+=I.value);r/=l,n/=l;let c=0,g=0,A=0;for(const I of t){if(I.value===null)continue;const K=I.at-r,B=I.value-n;c+=K*K,g+=K*B,A+=B*B}if(c===0)return null;const P=g/c,q=n-P*r,L=A===0?1:Math.max(0,Math.min(1,g*g/(c*A))),v=Math.max(0,A-P*g),G=l>2?Math.sqrt(v/(l-2)):null,S=l>2?W(d,l-2):null,N=[];for(let I=1;I<=m;I++){const K=f(I),B=q+P*K;let ee=null,J=null,ue=null,de=null,Oe=null;if(G!==null){const Ae=1/l+(K-r)**2/c,Se=G*Math.sqrt(1+Ae),D=G*Math.sqrt(Ae);Oe=Se,ee=B-S*Se,J=B+S*Se,ue=B-S*D,de=B+S*D}N.push({step:I,at:K,mean:B,lower:ee,upper:J,lowerMean:ue,upperMean:de,se:Oe})}return{method:"linear",horizon:m,confidence:e,n:l,sigma:G,r2:L,params:{slope:P,intercept:q},points:N}}function i(t,l,m,e,d,f,r){if(l<1)return null;const n=Math.max(1,Math.min(l,Math.floor(Number(f.windowLen)||l))),c=t.slice(l-n);let g=0;for(const G of c)g+=G;const A=g/n;let P=null,q=null;if(n>1){let G=0;for(const N of c)G+=(N-A)**2;P=Math.sqrt(G/(n-1))*Math.sqrt(1+1/n),q=W(d,n-1)}const L=P===null?null:q*P,v=[];for(let G=1;G<=m;G++)v.push({step:G,at:r(G),mean:A,lower:L===null?null:A-L,upper:L===null?null:A+L,se:P});return{method:"movingAverage",horizon:m,confidence:e,n:l,sigma:P===null?null:P,params:{windowLen:n},points:v}}function a(t,l,m,e,d,f,r){if(l<1)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null;n===null&&(n=te(q=>H(t,q).sse));const c=H(t,n),g=he(d),A=c.m>0?c.sse/c.m:null,P=[];for(let q=1;q<=m;q++){const L=c.level;let v=null,G=null,S=null;if(A!==null){const N=[];for(let K=1;K<q;K++)N.push(n);const I=ne(A,N,g);S=I.se,v=L-I.margin,G=L+I.margin}P.push({step:q,at:r(q),mean:L,lower:v,upper:G,se:S})}return{method:"ses",horizon:m,confidence:e,n:l,sigma:A===null?null:Math.sqrt(A),params:{alpha:n},points:P}}function s(t,l,m,e,d,f,r){if(l<2)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null,c=Number.isFinite(f.beta)?se(f.beta):null;if(n===null||c===null){let v=n===null?.5:n,G=c===null?.5:c;for(let S=0;S<6;S++)n===null&&(v=te(N=>T(t,N,G).sse)),c===null&&(G=te(N=>T(t,v,N).sse));n=n===null?v:n,c=c===null?G:c}const g=T(t,n,c),A=he(d),P=g.m>0?g.sse/g.m:null,q=n*c,L=[];for(let v=1;v<=m;v++){const G=g.level+v*g.trend;let S=null,N=null,I=null;if(P!==null){const K=[];for(let ee=1;ee<v;ee++)K.push(n+ee*q);const B=ne(P,K,A);I=B.se,S=G-B.margin,N=G+B.margin}L.push({step:v,at:r(v),mean:G,lower:S,upper:N,se:I})}return{method:"holt",horizon:m,confidence:e,n:l,sigma:P===null?null:Math.sqrt(P),params:{alpha:n,beta:c},points:L}}function h(t,l,m,e,d,f,r){const n=Math.floor(Number(f.period));if(!(n>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(l<2*n)return null;let c=Number.isFinite(f.alpha)?se(f.alpha):null,g=Number.isFinite(f.beta)?se(f.beta):null,A=Number.isFinite(f.gamma)?se(f.gamma):null;const P=(I,K,B)=>{const ee=V(t,n,I,K,B);return ee?ee.sse:1/0};if(c===null||g===null||A===null){let I=c===null?.5:c,K=g===null?.5:g,B=A===null?.5:A;for(let ee=0;ee<8;ee++)c===null&&(I=te(J=>P(J,K,B))),g===null&&(K=te(J=>P(I,J,B))),A===null&&(B=te(J=>P(I,K,J)));c=c===null?I:c,g=g===null?K:g,A=A===null?B:A}const q=V(t,n,c,g,A);if(!q)return null;const L=he(d),v=q.count>0?q.sse/q.count:null,G=c*g,S=A*(1-c),N=[];for(let I=1;I<=m;I++){const K=q.season[(q.phase+I)%n],B=q.level+I*q.trend+K;let ee=null,J=null,ue=null;if(v!==null){const de=[];for(let Ae=1;Ae<I;Ae++)de.push(c+Ae*G+(Ae%n===0?S:0));const Oe=ne(v,de,L);ue=Oe.se,ee=B-Oe.margin,J=B+Oe.margin}N.push({step:I,at:r(I),mean:B,lower:ee,upper:J,se:ue})}return{method:"holtWinters",horizon:m,confidence:e,n:l,sigma:v===null?null:Math.sqrt(v),params:{alpha:c,beta:g,gamma:A,period:n},points:N}}const u={FORECAST_METHODS:Z,forecast:R}}),Ce("packages/core/src/compute/index.js",function(o,me){"use strict";const ae=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return ae.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return ae.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return ae.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return ae.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return ae.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return ae.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return ae.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return ae.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const W=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return W.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return W.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return W.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return W.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return W.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return W.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return W.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return W.mentionsColumn}});const U=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return U.packKeys}});const _=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const Z=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const E=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return E.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return E.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return E.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return E.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return E.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return E.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return E.DEFAULT_MAX_COLUMNS}});const z=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return z.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return z.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return z.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return z.GRAND_PATH}});const re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const Y=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return Y.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Y.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return Y.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return Y.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return Y.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return Y.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return Y.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return Y.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return Y.isMissing}});const se=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return se.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return se.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return se.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return se.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return se.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return se.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se.SKETCH_BOUNDS}});const te=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return te.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return te.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te.openWindow}});const H=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return H.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return H.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return H.maintenanceOf}});const T=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return T.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return T.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return T.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return T.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return T.anomalyCondition}});const V=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return V.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return V.forecast}})}),Ce("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return s}});const ae=me("packages/worker/src/transport.js"),he=ae.PROTOCOL,W=ae.OPS,U=ae.CONTROL,_=ae.ERRORS,Z=ae.unpackHandle,E=ae.unpackHandles,z=ae.createMaskPool,re=ae.collectTransfers,Y=me("packages/core/src/store/columnpack.js"),se=Y.packChunk,te=Y.packedTransfers;let H=null,T=null,V=null;async function ne(h){if(H)return H;if(!T){const u=h||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));T=Promise.resolve().then(u).then(t=>(H=t,t)).catch(t=>(V=t,H=null,null))}return T}function R(h){H=h,T=h?Promise.resolve(h):null,V=h?null:V}function j(h,u,t){const l=new Map;for(const m of h)m&&l.set(m.id,m);return{handle(m){return l.get(m)},count:u,pool:z(),locale:t}}function i(h,u){const{op:t,args:l}=h;if(t===W.COLUMNIZE)return se(l.schema||[],l.rows||[],l.opts||{});const m=u[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=_.NO_KERNEL,e}switch(t){case W.COLLATE_STRING_RANKS:return m(l.table||[],(l.table||[]).length,l.locale);case W.SORT_COLUMN:return m(Z(l.handle),l.order??null,l.opts||{});case W.SORT_MULTI:{const e=E(l.handles||[]),d=(l.entries||[]).map(f=>({...f,handle:e[f.index]}));return m(e,d,l.order??null)}case W.EVALUATE_FILTERS:return m(l.filters,j(E(l.handles||[]),l.count,l.locale));case W.COMPACT:return m(l.mask,l.count,void 0);case W.GROUP_BY_COLUMNS:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.TOTAL:return m(Z(l.handle),l.indices??null,l.fn);case W.PIVOT:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.FACET:return m(Z(l.handle),l.indices??null,l.count,l.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=_.PROTOCOL,e}}}async function a(h,u={}){if(!h||h.lattice!==he)return null;const{id:t,op:l}=h;if(l===U.CANCEL)return u.cancelled?.add(h.target),null;if(l===U.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(l===W.COLUMNIZE){if(u.cancelled?.has(t))return u.cancelled.delete(t),null;try{const e=se(h.args.schema||[],h.args.rows||[],h.args.opts||{});return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:te(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ne(u.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:_.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${V?V.message:"module not found"}`}},transfer:[]};if(u.cancelled?.has(t))return u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(h,m);return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function s(h,u={}){const t=new Set,l=async m=>{const e=await a(m.data,{loader:u.loader,cancelled:t});e&&h.postMessage(e.reply,e.transfer)};return h.addEventListener("message",l),ne(u.loader).then(m=>{h.postMessage({lattice:he,id:0,op:U.READY,compute:!!m})}),()=>h.removeEventListener("message",l)}});var kt=at("packages/worker/src/kernel.js");Ot.__latticeKernel=kt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const zt=Kn("packages/modules/webcomponent/index.js"),no=zt.GridElementController,ro=zt.observedAttributeNames,io=zt.domEventName,oo=zt.ATTRIBUTE_CONFIG,so=zt.EVENT_PREFIX,ao=zt.createLatticeElements,lo=zt.defineLatticeElements,uo=zt.ELEMENT_TAGS,co=zt.createLatticeKPIElement,fo=zt.createLatticeChartElement,ho=zt.createLatticeKanbanElement,po=zt.createLatticeCalendarElement,mo=zt.createLatticeGanttElement,go=zt.createLatticeLayoutElement,yo=zt.createLatticeTabsElement,bo=zt.createLatticeRouterElement,wo=zt.adoptLatticeStyles,vo=zt.latticeStyleSheets,ko=zt.VIEWER_EVENTS,So=zt.VIEWER_APPLY,Oo=zt.viewerHandlerName,jo=zt.createViewerController,Ao=zt.EVENT_NAMES,Po=zt.dashedName,Co=zt.createCurrencyType,Eo=zt.createUnitType,To=zt.registerUnitSystem,Mo=zt.createStat,No=zt.createHeadlessGrid,Ro=zt.duckdbAdapter,Lo=zt.createPushdownSource,Fo=zt.TAG_NAME,xo=zt.createLatticeGridElement,$o=zt.defineLatticeGrid;var Io=zt.default;export{oo as ATTRIBUTE_CONFIG,uo as ELEMENT_TAGS,Ao as EVENT_NAMES,so as EVENT_PREFIX,no as GridElementController,Fo as TAG_NAME,So as VIEWER_APPLY,ko as VIEWER_EVENTS,wo as adoptLatticeStyles,Co as createCurrencyType,No as createHeadlessGrid,po as createLatticeCalendarElement,fo as createLatticeChartElement,ao as createLatticeElements,mo as createLatticeGanttElement,xo as createLatticeGridElement,co as createLatticeKPIElement,ho as createLatticeKanbanElement,go as createLatticeLayoutElement,bo as createLatticeRouterElement,yo as createLatticeTabsElement,Lo as createPushdownSource,Mo as createStat,Eo as createUnitType,jo as createViewerController,Po as dashedName,Io as default,lo as defineLatticeElements,$o as defineLatticeGrid,io as domEventName,Ro as duckdbAdapter,vo as latticeStyleSheets,ro as observedAttributeNames,To as registerUnitSystem,Oo as viewerHandlerName};
59
+ `;return n}catch{return""}}function H(l,c){const s=B.get(l);if(s)return s.sheet;const n=W(l);if(!n)return null;const t=c.CSSStyleSheet,r=new t;try{r.replaceSync(n)}catch{return null}r[Q]=!0;let o=null;const f=c.MutationObserver;return typeof f=="function"&&String(l.tagName).toLowerCase()==="style"&&(o=new f(()=>{try{r.replaceSync(String(l.textContent||""))}catch{}}),o.observe(l,{childList:!0,characterData:!0,subtree:!0})),B.set(l,{sheet:r,stop:()=>o&&o.disconnect()}),r}function U(l){return l?l.nodeType===9?l:l.ownerDocument||globalThis.document||null:globalThis.document||null}function z(l){const c=l||globalThis.document;return!c||typeof c.querySelectorAll!="function"?[]:[...c.querySelectorAll("style,link[rel]")].filter(X)}function w(l={}){if(!_())return[];const c=l.document||globalThis.document,s=c&&c.defaultView||globalThis,n=[];for(const t of z(c)){const r=H(t,s);r&&!n.includes(r)&&n.push(r)}return n}function k(l,c={}){const s=()=>{};if(!l||typeof l!="object")return s;const n=c.document||U(l);if(!n)return s;const t=n.defaultView||globalThis;let r=I.get(l);r||(r=new Map,I.set(l,r));const o=[],f=_(),u=a=>{if(r.has(a))return;const p=f?H(a,t):null;if(p){r.set(a,p);const j=l.adoptedStyleSheets||[];j.includes(p)||(l.adoptedStyleSheets=[...j,p]);return}if(String(a.tagName).toLowerCase()!=="link"||typeof l.appendChild!="function")return;const b=n.createElement("link");b.setAttribute("rel","stylesheet"),b.setAttribute("href",a.getAttribute("href")||""),b.setAttribute("data-lattice","adopted"),l.appendChild(b),o.push(b),r.set(a,b)};for(const a of z(n))u(a);let i=null;const m=t.MutationObserver,d=n.head||n.documentElement;typeof m=="function"&&d&&(i=new m(a=>{for(const p of a)for(const b of p.addedNodes||[])X(b)&&u(b)}),i.observe(d,{childList:!0}));let h=!1;return()=>{if(h)return;h=!0,i&&i.disconnect();const a=l.adoptedStyleSheets||[],p=new Set([...r.values()]);l.adoptedStyleSheets=a.filter(b=>!p.has(b));for(const b of o)b.parentNode&&b.parentNode.removeChild(b);r.clear()}}function g(l){if(!l||typeof l.getRootNode!="function"||typeof l.getAttribute=="function"&&String(l.getAttribute("lattice-styles")||"")==="off")return null;const c=l.getRootNode();return!c||c.nodeType!==11||!c.host?null:k(c)}}),Fe("packages/modules/webcomponent/elements.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_GRID_NAME",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DEFAULT_TAG_PREFIX",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VIEWER_ALIASES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"VIEWER_BINDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"coerceElementAttribute",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"attributeConfig",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createElementScope",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"scopeFor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"applyPredicates",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"upgradeProperty",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"installProperty",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"harvestProperties",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"createLatticeCalendarElement",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"gridElementClass",{enumerable:!0,get:function(){return le}});const $=K("packages/core/src/internal/util.js").warnOnce,I=K("packages/modules/shared/adapter.js").aliasConfigKey,_=K("packages/modules/react/viewers.js"),X=_.VIEWER_EVENTS,W=_.viewerHandlerName,H=_.createViewerController,U=K("packages/modules/webcomponent/controller.js"),z=U.GridElementController,w=U.observedAttributeNames,k=U.domEventName,g=U.ATTRIBUTE_CONFIG,c=K("packages/modules/webcomponent/styles.js").adoptIntoHostRoot,s="default",n="lattice-",t=Object.freeze({grid:"grid",kpi:"kpi",chart:"chart",kanban:"kanban",calendar:"calendar",gantt:"gantt",layout:"layout",tabs:"tabs",router:"router"}),r=Object.freeze({chart:ae=>{if("data"in ae){const se=ae.data;delete ae.data,se!=null&&ae.rows===void 0&&(ae.rows=se)}if("stacked"in ae){const se=ae.stacked;delete ae.stacked,se!=null&&ae.stack===void 0&&(ae.stack=se)}if("horizontal"in ae){const se=ae.horizontal;delete ae.horizontal,se&&ae.type==="bar"&&(ae.type="horizontalBar")}},kanban:ae=>{if(!("titleProperty"in ae))return;const se=ae.titleProperty;if(delete ae.titleProperty,typeof se!="string"||!se)return;const ee=ae.card&&typeof ae.card=="object"?ae.card:null;ee&&ee.title!==void 0||(ae.card={title:se,...ee||{}})},gantt:ae=>{if(!("scale"in ae))return;const se=ae.scale;if(delete ae.scale,se==null||se==="")return;const ee=ae.render&&typeof ae.render=="object"?{...ae.render}:{};ee.zoom===void 0&&(ee.zoom=se),ae.render=ee}}),o=Object.freeze({kpi:Object.freeze({label:"lattice-kpi",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["tiles","rows","columns"]),scalars:Object.freeze(["rowKey","locale"])}),chart:Object.freeze({label:"lattice-chart",requires:Object.freeze(["grid"]),fromContext:"grid",properties:Object.freeze(["shapes","series","data"]),scalars:Object.freeze(["type","x","y","value","label","lon","lat","labels","stacked","horizontal","scheme","subtitle","footnote","tooltip","legend"])}),kanban:Object.freeze({label:"lattice-kanban",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["rows","columns","card"]),scalars:Object.freeze(["rowKey","columnProperty","titleProperty","pointsProperty","orderProperty","swimlaneProperty","sprintProperty","epicProperty","swimlanes","virtualize"])}),calendar:Object.freeze({label:"lattice-calendar",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["rows","card","header","colorMap","labels","renderCard"]),scalars:Object.freeze(["rowKey","view","date","startProperty","endProperty","allDayProperty","firstDay","locale","timeZone","colorProperty","eventOrder","dayMaxEvents","readonly","ariaLabel"])}),gantt:Object.freeze({label:"lattice-gantt",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tasks","dependencies","resources","calendar","columns"]),scalars:Object.freeze(["rowKey","scale","projectStart","autoSchedule"])}),layout:Object.freeze({label:"lattice-layout",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["windows"]),scalars:Object.freeze(["columns","rows","compact","columnWidth","rowHeight","gap","overflowX","overflowY"])}),tabs:Object.freeze({label:"lattice-tabs",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tabs"]),scalars:Object.freeze(["lazy"])})}),f=new Set(["grid-name","lattice-styles","name","route","route-options","id","class","style","slot"]),u=new Set(["role","tabindex","hidden","part","exportparts","lang","dir","title-id","is"]),i=Symbol.for("lattice.webcomponent.routerScope"),m=new WeakMap;function d(ae){if(ae==null)return;if(ae===""||ae==="true")return!0;if(ae==="false")return!1;const se=String(ae).trim();if(se.startsWith("[")||se.startsWith("{"))try{return JSON.parse(se)}catch{return ae}return se!==""&&Number.isFinite(Number(se))?Number(se):ae}function h(ae,se){const ee={},ie=ae&&typeof ae.getAttributeNames=="function"?ae.getAttributeNames():[];for(const ce of ie){if(f.has(ce)||u.has(ce)||se&&se.has(ce)||ce.startsWith("data-")||ce.startsWith("aria-"))continue;const he=d(ae.getAttribute(ce));he!==void 0&&(ee[a(ce)]=he)}return ee}function a(ae){const se=I(ae);return se!==ae||!ae.includes("-")?se:ae.replace(/-([a-z0-9])/g,(ee,ie)=>ie.toUpperCase())}function p(ae){return ae&&typeof ae.getAttributeNames=="function"?ae.getAttributeNames():[]}function b(ae){const se=[];for(const ee of p(ae))f.has(ee)||u.has(ee)||ee.startsWith("data-")||ee.startsWith("aria-")||se.push(a(ee));return se}function j(){const ae=new Map,se=new Set;return{publish(ee,ie){const ce=ee||s;ie?ae.set(ce,ie):ae.delete(ce);for(const he of[...se])he()},get(ee){return ae.get(ee||s)||null},names(){return[...ae.keys()]},subscribe(ee){return se.add(ee),()=>{se.delete(ee)}}}}function S(ae={}){const se=typeof ae.createDataRouter=="function"?ae.createDataRouter:null;let ee=null,ie=!1;return{grids:j(),get router(){return ee},attach(he,me,Ee){ie||!se||(ee||(ee=se(ae.config||{})),ee.attach(he,me,Ee||{}))},detach(he){if(!(ie||!ee))try{ee.detach(he)}catch{}},destroy(){ie=!0;const he=ee;ee=null,he&&he.destroy()}}}function y(ae){let se=ae&&ae.parentNode||null;for(;se;){if(se[i])return se[i];se=se.parentNode||se.host||null}const ie=(ae&&typeof ae.getRootNode=="function"?ae.getRootNode():ae&&ae.ownerDocument||null)||globalThis.document||globalThis;let ce=m.get(ie);return ce||(ce=S(),m.set(ie,ce)),ce}function v(ae,se,ee){const ie=se&&typeof se=="object"?se:{},ce=ee&&typeof ee=="object"?ee:{};for(const[he,me]of Object.entries(ie))Object.is(ce[he],me)||ae.filters.where(he,typeof me=="function"?me:null);for(const he of Object.keys(ce))Object.hasOwn(ie,he)||ae.filters.where(he,null)}function R(ae,se){if(!Object.hasOwn(ae,se))return;const ee=ae[se];delete ae[se],ae[se]=ee}const O=new Set(["instance","config","grid","gridName","router"]);function x(ae,se){let ee=Object.getPrototypeOf(ae);for(;ee;){const ie=Object.getOwnPropertyDescriptor(ee,se);if(ie)return typeof ie.get=="function";ee=Object.getPrototypeOf(ee)}return!1}function C(ae,se){if(!se||O.has(se)||se.startsWith("__"))return;const ee=Object.getOwnPropertyDescriptor(ae,se);if(ee&&typeof ee.get=="function")return;if(x(ae,se)){ee&&R(ae,se);return}const ie=ee?ee.value:void 0;ee&&delete ae[se],Object.defineProperty(ae,se,{get(){return this.__props[se]},set(ce){this.__write(se,ce)},configurable:!0,enumerable:!0}),ee&&(ae[se]=ie)}function P(ae){let se=!1;for(const ee of Object.getOwnPropertyNames(ae)){if(ee.startsWith("__")||O.has(ee))continue;const ie=Object.getOwnPropertyDescriptor(ae,ee);!ie||typeof ie.get=="function"||!ie.enumerable||(C(ae,ee),se=!0)}return se}function F(ae,se,ee){if(!ae||typeof ae.dispatchEvent!="function")return;const ie=globalThis.CustomEvent,ce={detail:ee,bubbles:!0,composed:!0};ae.dispatchEvent(typeof ie=="function"?new ie(se,ce):{type:se,...ce})}function E(ae){const se=ae.viewer,ee=o[se],ie=ae.label||ee.label,ce=ae.mount,he=X[se]||[];class me extends ae.Base{__props={};__controller=null;__builtAgainst=null;__connected=!1;__teardownPending=!1;__release=[];__queued=!1;__wired=!1;__scope=null;__ownAttributes=new Set;constructor(){super();for(const ge of["config","grid","gridName",...ee.properties,...ee.scalars])R(this,ge);P(this)}get instance(){return this.__controller?this.__controller.instance:null}move(ge,je){const pe=this.instance;return pe&&typeof pe.move=="function"?pe.move(ge,je):Promise.resolve(!1)}get grid(){return this.__props.grid}set grid(ge){this.__write("grid",ge)}get gridName(){const ge=this.__props.gridName;if(typeof ge=="string")return ge;const je=typeof this.getAttribute=="function"?this.getAttribute("grid-name"):null;return je===null?void 0:je}set gridName(ge){this.__write("gridName",ge)}get config(){return{...this.__props}}set config(ge){if(!(!ge||typeof ge!="object")){for(const[je,pe]of Object.entries(ge))this.__props[je]=pe;this.__schedule()}}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__wired){this.__wired=!0;const ge=c(this);ge&&this.__release.push(ge);const je=y(this);this.__scope=je,ee.fromContext&&this.__release.push(je.grids.subscribe(()=>this.__settle()));const pe=globalThis.MutationObserver;if(typeof pe=="function"){const we=new pe(()=>this.__settle());we.observe(this,{attributes:!0}),this.__release.push(()=>we.disconnect())}}P(this);for(const ge of b(this))C(this,ge);this.__schedule()}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()))}__settleTeardown(){if(this.__teardownPending){this.__teardownPending=!1,this.__wired=!1,this.__scope=null;for(const ge of this.__release.splice(0))try{ge()}catch{}this.__tearDown()}}__write(ge,je){this.__props[ge]=je,this.__schedule()}__schedule(){this.__queued||(this.__queued=!0,queueMicrotask(()=>{this.__queued=!1,this.__settle()}))}__boundGrid(){if(!ee.fromContext)return null;if(this.__props.grid!==void 0)return this.__props.grid||null;const ge=this.__scope;return ge?ge.grids.get(this.gridName):null}__resolve(){const ge={...h(this,this.__ownAttributes),...this.__props};if(delete ge.gridName,ee.fromContext){const pe=this.__boundGrid();pe?ge[ee.fromContext]=pe:delete ge[ee.fromContext]}const je=r[se];je&&je(ge);for(const pe of he)ge[W(pe)]=we=>F(this,k(pe),we);return ge}__settle(){if(!this.__connected)return;P(this);const ge=this.__resolve(),je=ee.fromContext&&ge[ee.fromContext]||null;if(this.__controller&&!Object.is(this.__builtAgainst,je)&&this.__tearDown(),!this.__controller){for(const we of ee.requires)if(ge[we]===void 0||ge[we]===null)return;if(ee.fromContext&&!je&&ge.rows===void 0)return;const pe=new Set(p(this));this.__controller=H({viewer:se,mount:ce,element:this,props:ge,name:ie});for(const we of p(this))pe.has(we)||this.__ownAttributes.add(we);this.__builtAgainst=je,F(this,"ready",{instance:this.__controller.instance});return}this.__controller.update(ge)}__tearDown(){const ge=this.__controller;this.__controller=null,this.__builtAgainst=null,ge&&(F(this,"destroyed",{instance:ge.instance}),ge.destroy())}}for(const Ee of[...ee.properties,...ee.scalars])Ee in ae.Base.prototype||Object.defineProperty(me.prototype,Ee,{get(){return this.__props[Ee]},set(ge){this.__write(Ee,ge)},configurable:!0,enumerable:!0});return me}function D(ae,se,ee){if(typeof ae!="function")throw new TypeError(`${se} needs ${ee}: ${se}({ ${ee} }).`)}function N(){const ae=globalThis.HTMLElement;return typeof ae=="function"?ae:null}function M(ae){D(ae&&ae.createKPI,"createLatticeKPIElement","createKPI");const se=N();return se?E({viewer:"kpi",Base:se,mount:(ee,ie)=>ae.createKPI(ee,ie)}):null}function A(ae){D(ae&&ae.createChart,"createLatticeChartElement","createChart");const se=N();return se?E({viewer:"chart",Base:se,mount:(ee,ie)=>ae.createChart({...ie,container:ee})}):null}function L(ae){D(ae&&ae.createKanban,"createLatticeKanbanElement","createKanban");const se=N();return se?E({viewer:"kanban",Base:se,mount:(ee,ie)=>ae.createKanban(ee,ie)}):null}function G(ae){D(ae&&ae.createCalendar,"createLatticeCalendarElement","createCalendar");const se=N();return se?E({viewer:"calendar",Base:se,mount:(ee,ie)=>ae.createCalendar(ee,ie)}):null}function q(ae){D(ae&&ae.createGantt,"createLatticeGanttElement","createGantt");const se=N();return se?E({viewer:"gantt",Base:se,mount:(ee,ie)=>ae.createGantt({...ie,element:ee})}):null}function Y(ae){D(ae&&ae.createLayout,"createLatticeLayoutElement","createLayout");const se=N();return se?E({viewer:"layout",Base:se,mount:(ee,ie)=>ae.createLayout(ee,ie)}):null}function J(ae){D(ae&&ae.createTabs,"createLatticeTabsElement","createTabs");const se=N();return se?E({viewer:"tabs",Base:se,mount:(ie,ce)=>{const he=new Map,me=typeof ie.querySelectorAll=="function"?[...ie.querySelectorAll("template[data-tab]")]:[];for(const je of me)je.parentNode===ie&&he.set(je.getAttribute("data-tab"),je);const ge=(Array.isArray(ce.tabs)&&ce.tabs.length?ce.tabs:[...he.keys()].map(je=>({id:je,label:he.get(je).getAttribute("data-label")||je}))).map(je=>{const pe=je,we=he.get(pe.id);return we?{...pe,view:ye=>{const Ne=we.content.cloneNode(!0),$e=[...Ne.childNodes];return ye.appendChild(Ne),{destroy(){for(const Ve of $e)Ve.parentNode&&Ve.parentNode.removeChild(Ve)}}}}:pe});return ae.createTabs(ie,{...ce,tabs:ge,createGrid:ae.createGrid||(()=>{throw new Error('[lattice] <lattice-tabs>: a tab has neither a <template data-tab="…"> nor a createGrid to build it with. Give the tab a template, or pass createGrid into createLatticeTabsElement.')})})}}):null}function te(ae){D(ae&&ae.createDataRouter,"createLatticeRouterElement","createDataRouter");const se=N();if(!se)return null;class ee extends se{__scope=null;__config={};constructor(){super(),R(this,"config")}get config(){return{...this.__config}}set config(ce){!ce||typeof ce!="object"||(this.__config={...this.__config,...ce},this.__scope&&this.__scope.router&&$("webcomponent.router.mountOnly.config","[lattice] <lattice-router>: `config` changed after the router was built. Nothing was applied and the router was NOT rebuilt — rebuilding it would detach every grid and drop every row it holds. Replace the <lattice-router> element itself when a genuinely different router is wanted."))}get router(){return this.__scope?this.__scope.router:null}get instance(){return this.router}connectedCallback(){if(this.__scope)return;const ce=h(this);this.__scope=S({createDataRouter:ae.createDataRouter,config:{...ce,...this.__config}}),this[i]=this.__scope}disconnectedCallback(){const ce=this.__scope;if(this.__scope=null,this[i]=null,!ce)return;const he=ce.router;ce.destroy(),he&&F(this,"destroyed",{instance:he})}}return ee}function ne(ae={}){const se={},ee=(ie,ce,he)=>{if(typeof ce!="function")return;const me=he();me&&(se[ie]=me)};return ee("LatticeGridElement",ae.createGrid,()=>le(ae.createGrid)),ee("LatticeKPIElement",ae.createKPI,()=>M({createKPI:ae.createKPI})),ee("LatticeChartElement",ae.createChart,()=>A({createChart:ae.createChart})),ee("LatticeKanbanElement",ae.createKanban,()=>L({createKanban:ae.createKanban})),ee("LatticeCalendarElement",ae.createCalendar,()=>G({createCalendar:ae.createCalendar})),ee("LatticeGanttElement",ae.createGantt,()=>q({createGantt:ae.createGantt})),ee("LatticeLayoutElement",ae.createLayout,()=>Y({createLayout:ae.createLayout})),ee("LatticeTabsElement",ae.createTabs,()=>J({createTabs:ae.createTabs,createGrid:ae.createGrid})),ee("LatticeRouterElement",ae.createDataRouter,()=>te({createDataRouter:ae.createDataRouter})),se}function oe(ae={}){const se=globalThis.customElements,ee={};if(!se||typeof se.define!="function")return ee;const ie=typeof ae.prefix=="string"?ae.prefix:n,ce=ne(ae),he={LatticeGridElement:t.grid,LatticeKPIElement:t.kpi,LatticeChartElement:t.chart,LatticeKanbanElement:t.kanban,LatticeCalendarElement:t.calendar,LatticeGanttElement:t.gantt,LatticeLayoutElement:t.layout,LatticeTabsElement:t.tabs,LatticeRouterElement:t.router};for(const[me,Ee]of Object.entries(ce)){const ge=ie+he[me],je=se.get?se.get(ge):void 0;if(je){ee[ge]=je;continue}se.define(ge,Ee),ee[ge]=Ee}return ee}function le(ae){const se=N();if(!se)return null;class ee extends se{static get observedAttributes(){return w()}__connected=!1;__teardownPending=!1;__published=!1;__publishedAs=s;__scope=null;__predicates=void 0;__rowUpdates=void 0;__release=[];constructor(){super(),this.__controller=new z(this,{createGrid:ae});for(const ce of["rows","columns","config","predicates","rowUpdates",...Object.values(g)])R(this,ce)}get grid(){return this.__controller.grid}get instance(){return this.__controller.grid}get rows(){return this.__controller.config().rows}set rows(ce){this.__controller.configure({rows:ce})}get columns(){return this.__controller.config().columns}set columns(ce){this.__controller.configure({columns:ce})}get config(){return this.__controller.config()}set config(ce){this.__controller.configure(ce)}get predicates(){return this.__predicates}set predicates(ce){const he=this.__published?this.__controller.grid:null;he&&v(he,ce,this.__predicates),this.__predicates=ce}get rowUpdates(){return this.__rowUpdates}set rowUpdates(ce){if(Object.is(ce,this.__rowUpdates))return;this.__rowUpdates=ce;const he=this.__published?this.__controller.grid:null;he&&ce&&he.rows.apply(ce)}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__scope){const ce=c(this);ce&&this.__release.push(ce),this.__scope=y(this)}this.__controller.connect(),queueMicrotask(()=>this.__publish())}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()),this.__controller.disconnect())}attributeChangedCallback(ce,he,me){this.__controller.attributeChanged(ce,me)}__publish(){if(!this.__connected||this.__published)return;const ce=this.__controller.grid;if(!ce)return;this.__published=!0,this.__predicates&&v(ce,this.__predicates,{});const he=typeof this.getAttribute=="function"?this.getAttribute("name"):null;this.__publishedAs=he||s;const me=this.__scope;me&&me.grids.publish(this.__publishedAs,ce);const Ee=typeof this.getAttribute=="function"?this.getAttribute("route"):null;if(me&&Ee!==null){const ge=this.getAttribute("route-options");me.attach(ce,d(Ee),ge===null?{}:d(ge))}this.__rowUpdates&&ce.rows.apply(this.__rowUpdates),F(this,"grid-ready",{grid:ce})}__settleTeardown(){if(!this.__teardownPending)return;this.__teardownPending=!1;const ce=this.__controller.grid,he=this.__scope;this.__scope=null,this.__published=!1;for(const me of this.__release.splice(0))try{me()}catch{}ce&&he&&(F(this,"grid-destroyed",{grid:ce}),he.detach(ce),he.grids.publish(this.__publishedAs,null)),this.__controller.settleTeardown()}}for(const ie of Object.values(g))Object.getOwnPropertyDescriptor(ee.prototype,ie)||ie in se.prototype||Object.defineProperty(ee.prototype,ie,{get(){return this.__controller.config()[ie]},set(ce){this.__controller.configure({[ie]:ce})},configurable:!0,enumerable:!0});return ee}}),Fe("packages/modules/webcomponent/index.js",function(e,K){"use strict";Object.defineProperty(e,"TAG_NAME",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createLatticeGridElement",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"defineLatticeGrid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const Q=K("packages/dom/src/index.js"),$=Q.createGrid,B=K("packages/modules/webcomponent/elements.js"),I=B.gridElementClass,_=K("packages/modules/webcomponent/controller.js");Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return _.GridElementController}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return _.observedAttributeNames}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return _.domEventName}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return _.ATTRIBUTE_CONFIG}}),Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return _.EVENT_PREFIX}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return B.createLatticeElements}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return B.defineLatticeElements}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return B.ELEMENT_TAGS}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return B.createLatticeKPIElement}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return B.createLatticeChartElement}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return B.createLatticeKanbanElement}}),Object.defineProperty(e,"createLatticeCalendarElement",{enumerable:!0,get:function(){return B.createLatticeCalendarElement}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return B.createLatticeGanttElement}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return B.createLatticeLayoutElement}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return B.createLatticeTabsElement}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return B.createLatticeRouterElement}});const X=K("packages/modules/webcomponent/styles.js");Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return X.adoptLatticeStyles}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return X.latticeStyleSheets}});const W=K("packages/modules/react/viewers.js");Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return W.VIEWER_EVENTS}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return W.VIEWER_APPLY}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return W.viewerHandlerName}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return W.createViewerController}});const H=K("packages/modules/shared/adapter.js");Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return H.EVENT_NAMES}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return H.dashedName}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return Q.createCurrencyType}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return Q.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return Q.registerUnitSystem}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return Q.createStat}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return Q.createHeadlessGrid}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return Q.duckdbAdapter}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return Q.createPushdownSource}});const U="lattice-grid";function z(g=$){return I(g)}function w(g={}){const l=globalThis.customElements,c=g.tagName||U;if(!l||typeof l.define!="function")return null;const s=l.get?l.get(c):void 0;if(s)return s;const n=z(g.createGrid||$);return n?(l.define(c,n),n):null}w();const k=w});try{Kn("packages/worker/src/inline.js").setWorkerSource('(function(Ot){"use strict";var ct=Object.create(null),lt=Object.create(null);function Ce(o,me){ct[o]=me}function at(o){var me=lt[o];if(me)return me;var ae=Object.create(null);lt[o]=ae;var he=ct[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(ae,at),ae}Ce("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return Se}});const ae="1.86.5";async function he(){return ae}const W="1.86.5",U=new Set,_=2e3;function Z(D){if(U.add(D),U.size>_){const x=U.values().next().value;x!==void 0&&U.delete(x)}}const E=[],z=500;function re(D,x,fe){E.push({key:D,level:x,message:fe.map(p=>typeof p=="string"?p:Y(p)).join(" "),at:Date.now()}),E.length>z&&E.shift()}function Y(D){if(D instanceof Error)return D.message;try{return JSON.stringify(D)}catch{return String(D)}}function se(){return E.map(D=>({...D}))}function te(D){if(D.length===0||typeof D[0]!="string")return D;const x=D[0].replace(/^\\[lattice\\]\\s*/,"");return x===D[0]?D:[x,...D.slice(1)]}function H(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"warn",fe),console.warn("[lattice]",...fe)}function T(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"info",fe),console.info("[lattice]",...fe)}function V(){U.clear(),E.length=0}function ne(D,x){const fe=new Error(`[lattice] ${D}`);throw x!==void 0&&(fe.cause=x),fe}function R(D,x){D||ne(x)}const j=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(D){return D!==null&&typeof D=="object"&&!Array.isArray(D)}function a(D){return typeof D=="function"}function s(D){return D==null}function h(D){return D==null||D===""}function u(D){return typeof D!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(D))?!0:!!(D.prototype&&Object.getOwnPropertyNames(D.prototype).length>1)}const t=new Map;function l(D){let x=t.get(D);if(x)return x;if(!D.includes("."))x=fe=>fe?.[D];else{const fe=D.split("."),p=fe.length;x=Q=>{let X=Q;for(let ce=0;ce<p;ce++){if(X==null)return;X=X[fe[ce]]}return X}}return t.set(D,x),x}const m=new Map;function e(D){let x=m.get(D);if(x)return x;if(!D.includes("."))x=(fe,p)=>{fe!=null&&(fe[D]=p)};else{const fe=D.split("."),p=fe.length-1;x=(Q,X)=>{let ce=Q;for(let le=0;le<p;le++){if(ce==null)return;const ge=fe[le];ce[ge]==null&&(ce[ge]={}),ce=ce[ge]}ce!=null&&(ce[fe[p]]=X)}}return m.set(D,x),x}function d(D,x){return l(x)(D)}function f(D,x,fe){e(x)(D,fe)}function r(D){return D?(D.includes(".")?D.slice(D.lastIndexOf(".")+1):D).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(/^./,fe=>fe.toUpperCase()):""}const n={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"};function c(D){const x=D==null?"":String(D);return/[&<>"\']/.test(x)?x.replace(/[&<>"\']/g,fe=>n[fe]):x}function g(D){return String(D).replace(/\\w\\S*/g,x=>x[0].toUpperCase()+x.slice(1).toLowerCase())}function A(D,x,fe){if(D!==void 0)return D===!0?{enabled:!0,...fe}:D===!1?{enabled:!1}:i(D)?D:{[x]:D,enabled:!0}}function P(D){return D==null?[]:Array.isArray(D)?D:[D]}const q=Object.freeze(new Set(["__proto__","constructor","prototype"]));function L(D,x){if(!i(D))return i(x)?{...x}:x;if(!i(x))return x===void 0?D:x;const fe={...D};for(const p of Object.keys(x)){if(q.has(p))continue;const Q=x[p];Q!==void 0&&(fe[p]=i(Q)&&i(fe[p])?L(fe[p],Q):Q)}return fe}function v(D,x){if(!i(D)||!i(x)||D===x)return x;const fe=Object.create(Object.getPrototypeOf(D));return Object.assign(fe,D,x),fe}class G{#t;#e=new Map;#n;constructor(x=256,fe=null){this.#t=x,this.#n=fe}get size(){return this.#e.size}get max(){return this.#t}set max(x){this.#t=x,this.#r()}has(x){return this.#e.has(x)}get(x){const fe=this.#e;if(!fe.has(x))return;const p=fe.get(x);return fe.delete(x),fe.set(x,p),p}peek(x){return this.#e.get(x)}set(x,fe){const p=this.#e;return p.has(x)&&p.delete(x),p.set(x,fe),this.#r(),fe}delete(x){const fe=this.#e.get(x);return this.#e.delete(x)&&this.#n&&this.#n(fe,x),fe}clear(){if(this.#n)for(const[x,fe]of this.#e)this.#n(fe,x);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const x=this.#e;for(;x.size>this.#t;){const fe=x.keys().next().value,p=x.get(fe);x.delete(fe),this.#n&&this.#n(p,fe)}}}const S=new Map;function N(D,x){const fe=`${D||""}|${x?JSON.stringify(x):""}`;let p=S.get(fe);return p||(p=new Intl.Collator(D||void 0,{numeric:!0,sensitivity:"variant",...x}),S.set(fe,p)),p}function I(D,x){if(D===x)return 0;if(D==null)return 1;if(x==null)return-1;if(typeof D=="number"&&typeof x=="number")return Number.isNaN(D)?Number.isNaN(x)?0:1:Number.isNaN(x)||D<x?-1:D>x?1:0;const fe=String(D),p=String(x);return fe<p?-1:fe>p?1:0}function K(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const B=typeof requestAnimationFrame=="function";function ee(D){return B?requestAnimationFrame(D):setTimeout(()=>D(K()),16)}function J(D){D!=null&&(B?cancelAnimationFrame(D):clearTimeout(D))}function ue(D){let x=null,fe=null;const p=()=>{x=null;const X=fe;fe=null,D(...X||[])},Q=(...X)=>{fe=X,x===null&&(x=ee(p))};return Q.cancel=()=>{J(x),x=null,fe=null},Q.flush=()=>{x!==null&&(J(x),p())},Q}function de(D,x){let fe=null,p=null;const Q=()=>{if(fe=null,p===null)return;const le=p;p=null,D(...le),X()},X=()=>{fe=setTimeout(Q,x),typeof fe?.unref=="function"&&fe.unref()},ce=(...le)=>{fe===null?(D(...le),X()):(p=le,clearTimeout(fe),X())};return ce.flush=()=>{if(fe!==null&&clearTimeout(fe),fe=null,p===null)return;const le=p;p=null,D(...le)},ce.cancel=()=>{fe!==null&&clearTimeout(fe),fe=null,p=null},ce.pending=()=>fe!==null||p!==null,ce}function Oe(D,x=50){return typeof requestIdleCallback=="function"?requestIdleCallback(D,{timeout:x}):setTimeout(()=>D({timeRemaining:()=>0,didTimeout:!0}),1)}let Ae=0;function Se(D="l"){return`${D}${(++Ae).toString(36)}`}}),Ce("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.isFunction,U=1,_=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),Z=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),E=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function z(a){if(a==null)return null;const s=a.presence;return{id:a.id,kind:a.kind,nullable:!!a.nullable,values:a.values??null,presence:s?s.words??s:null,presenceBits:s?s.size??(s.words??s).length*8:0,dict:a.dict?re(a.dict):null,offsets:a.offsets??null,version:a.version??0}}function re(a){return Array.isArray(a)?a:W(a.values)?a.values():[]}function Y(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=z(a[h]);return s}class se{#t;#e;constructor(s,h){this.#t=s,this.#e=h}get words(){return this.#t}get size(){return this.#e}get(s){return(this.#t[s>>>3]&1<<(s&7))!==0}count(){const s=this.#t;let h=0;for(let u=0;u<s.length;u++){let t=s[u];for(;t;)t&=t-1,h++}return h}}class te{#t;#e=null;#n=0;#r=new Map;constructor(s){this.#t=s||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(s){if(this.#e===null){this.#e=new Map;for(let t=0;t<this.#t.length;t++)this.#e.set(this.#t[t],t)}const h=this.#e.get(s);if(h!==void 0)return h;const u=this.#t.length;return this.#t.push(s),this.#e.set(s,u),this.#n++,u}valueOf(s){return this.#t[s]}values(){return this.#t}ranks(s){const h=s||"",u=this.#r.get(h);if(u&&u.version===this.#n)return u.ranks;const t=this.#t.length,l=new Uint32Array(t);for(let r=0;r<t;r++)l[r]=r;const m=he(s).compare,e=this.#t,d=Array.from(l).sort((r,n)=>{const c=e[r],g=e[n];return c===g?0:c==null?1:g==null?-1:m(String(c),String(g))}),f=new Uint32Array(t);for(let r=0;r<d.length;r++)f[d[r]]=r;return this.#r.set(h,{version:this.#n,ranks:f}),f}}function H(a){if(a==null)return null;const s=a.presence?new se(a.presence,a.presenceBits||a.presence.length*8):null,h=a.dict?new te(a.dict):null,u=a.values,t=a.offsets??null,l=a.kind,m=e=>{if(s&&!s.get(e))return null;switch(l){case"dictionary":return h?h.valueOf(u[e]):u[e];case"bitset":return(u[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],f=t[e+1],r=new Array(f-d);for(let n=d;n<f;n++)r[n-d]=h?h.valueOf(u[n]):u[n];return r}default:return u[e]}};return{id:a.id,kind:l,nullable:a.nullable,values:u,presence:s,dict:h,offsets:t,get:m,version:a.version}}function T(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=H(a[h]);return s}function V(){const a=[],s=[];return{mask(h){for(let u=0;u<a.length;u++)if(a[u].length>=h){const t=a.splice(u,1)[0].subarray(0,h);return t.fill(0),t}return new Uint8Array(h)},indices(h){for(let u=0;u<s.length;u++)if(s[u].length>=h)return s.splice(u,1)[0].subarray(0,h);return new Uint32Array(h)},release(h){h&&(h instanceof Uint8Array?a.push(h):h instanceof Uint32Array&&s.push(h))},clear(){a.length=0,s.length=0}}}function ne(a){if(!ArrayBuffer.isView(a))return!1;const s=a.buffer;return s?typeof SharedArrayBuffer>"u"||!(s instanceof SharedArrayBuffer):!1}function R(a,s=[]){const h=u=>{if(!ne(u))return;const t=u.buffer;s.includes(t)||s.push(t)};if(a==null)return s;if(ArrayBuffer.isView(a))return h(a),s;if(Array.isArray(a)){for(const u of a)h(u);return s}if(typeof a=="object")for(const u of Object.keys(a)){const t=a[u];if(Array.isArray(t))for(const l of t)h(l);else h(t)}return s}function j(a,s=0){if(a==null)return!0;const h=typeof a;if(h==="function"||h==="symbol")return!1;if(h!=="object"||s>4||ArrayBuffer.isView(a)||a instanceof ArrayBuffer||a instanceof Date)return!0;if(Array.isArray(a)){for(const u of a)if(!j(u,s+1))return!1;return!0}for(const u of Object.keys(a))if(!j(a[u],s+1))return!1;return!0}function i(a,s=new Set){if(!a||typeof a!="object")return s;const h=a;typeof h.col=="string"&&s.add(h.col);const u=h.conditions;if(Array.isArray(u))for(const t of u)i(t,s);return s}}),Ce("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const ae=8;class he{static#t=new Uint8Array(256);static{for(let U=1;U<256;U++)he.#t[U]=he.#t[U>>1]+(U&1)}#e;#n;constructor(U=0){const _=Math.max(0,U|0);this.#n=_,this.#e=new Uint8Array(Math.ceil(_/ae))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(U){return U<0||U>=this.#n?0:this.#e[U>>3]>>(U&7)&1}set(U){return U>=0&&U<this.#n&&(this.#e[U>>3]|=1<<(U&7)),this}clear(U){return U>=0&&U<this.#n&&(this.#e[U>>3]&=~(1<<(U&7))),this}assign(U,_){return _?this.set(U):this.clear(U)}fill(U=!1){return this.#e.fill(U?255:0),U&&this.#r(),this}grow(U){const _=Math.max(0,U|0);if(_<=this.#n)return this;const Z=Math.ceil(_/ae);if(Z>this.#e.length){const E=new Uint8Array(Z);E.set(this.#e),this.#e=E}return this.#n=_,this}count(){const U=this.#e,_=he.#t;let Z=0;for(let E=0;E<U.length;E++)Z+=_[U[E]];return Z}and(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]&=_[z];for(let z=E;z<Z.length;z++)Z[z]=0;return this}or(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]|=_[z];return this}not(){const U=this.#e;for(let _=0;_<U.length;_++)U[_]=~U[_]&255;return this.#r(),this}clone(){const U=new he(this.#n);return U.words.set(this.#e.subarray(0,U.words.length)),U}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const U=this.#n&7;if(U===0)return;const _=this.#n>>3;_<this.#e.length&&(this.#e[_]&=(1<<U)-1)}static from(U){const _=Array.isArray(U)?U:Array.from(U),Z=new he(_.length);for(let E=0;E<_.length;E++)_[E]&&Z.set(E);return Z}}}),Ce("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return U}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare;class U{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(Z=[]){this.#t=[];for(let E=0;E<Z.length;E++){const z=Z[E];this.#e.has(z)||(this.#e.set(z,this.#t.length),this.#t.push(z))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let Z=this.#t.length*8;for(let E=0;E<this.#t.length;E++){const z=this.#t[E];typeof z=="string"&&(Z+=z.length*2),Z+=16}return Z}codeOf(Z){const E=this.#e.get(Z);if(E!==void 0)return E;const z=this.#t.length;return this.#t.push(Z),this.#e.set(Z,z),this.#n++,z}lookup(Z){const E=this.#e.get(Z);return E===void 0?-1:E}has(Z){return this.#e.has(Z)}valueOf(Z){return this.#t[Z]}values(){return this.#t}ranks(Z){const E=Z||"";if(this.#r&&this.#i===this.#n&&this.#s===E)return this.#r;const z=this.#t.length,re=new Array(z);for(let H=0;H<z;H++)re[H]=H;const Y=he(Z).compare,se=this.#t;re.sort((H,T)=>this.#h(se[H],se[T],Y));const te=new Uint32Array(z);for(let H=0;H<z;H++)te[re[H]]=H;return this.#r=te,this.#i=this.#n,this.#s=E,te}#h(Z,E,z){return typeof Z=="string"&&typeof E=="string"?z(Z,E):W(Z,E)}}}),Ce("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return ae}});class ae{#t;#e;#n=0;#r=0;constructor(W={}){const U=Math.max(1,W.rows??16),_=Math.max(1,W.values??U);this.#t=new Int32Array(_),this.#e=new Uint32Array(U+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(W){return W<0||W>=this.#n?0:this.#e[W+1]-this.#e[W]}at(W){return W<0||W>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[W],this.#e[W+1])}has(W,U){if(W<0||W>=this.#n)return!1;const _=this.#t,Z=this.#e[W+1];for(let E=this.#e[W];E<Z;E++)if(_[E]===U)return!0;return!1}hasAny(W,U){for(let _=0;_<U.length;_++)if(this.has(W,U[_]))return!0;return!1}hasAll(W,U){for(let _=0;_<U.length;_++)if(!this.has(W,U[_]))return!1;return!0}hasNone(W,U){return!this.hasAny(W,U)}push(W){const U=this.#n,_=W.length;this.#i(U+1),this.#s(this.#r+_);const Z=this.#r;for(let E=0;E<_;E++)this.#t[Z+E]=W[E]|0;return this.#r+=_,this.#n=U+1,this.#e[U]=Z,this.#e[U+1]=this.#r,U}write(W,U){if(W===this.#n){this.push(U);return}if(W<0||W>this.#n)return;const _=this.#e[W],Z=this.#e[W+1],E=U.length;if(Z-_===E){for(let z=0;z<E;z++)this.#t[_+z]=U[z]|0;return}this.#h(W,U)}compact(W,U,_){const Z=this.#t,E=this.#e,z=this.#n,re=new Int32Array(Math.max(1,this.#r)),Y=new Uint32Array(U+1);let se=0;for(let te=0;te<z;te++){if(W[te]===_)continue;const H=E[te],T=E[te+1];Y[W[te]]=se;for(let V=H;V<T;V++)re[se++]=Z[V];Y[W[te]+1]=se}this.#t=re,this.#e=Y,this.#n=U,this.#r=se}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(W){if(W+1<=this.#e.length)return;let U=this.#e.length-1;for(;U<W;)U=U*2||16;const _=new Uint32Array(U+1);_.set(this.#e),this.#e=_}#s(W){if(W<=this.#t.length)return;let U=this.#t.length;for(;U<W;)U=U*2||16;const _=new Int32Array(U);_.set(this.#t),this.#t=_}#h(W,U){const _=this.#t,Z=this.#e,E=this.#n,z=U.length-(Z[W+1]-Z[W]),re=new Int32Array(Math.max(1,this.#r+z)),Y=new Uint32Array(Z.length);let se=0;for(let te=0;te<E;te++){if(Y[te]=se,te===W)for(let H=0;H<U.length;H++)re[se++]=U[H]|0;else for(let H=Z[te];H<Z[te+1];H++)re[se++]=_[H];Y[te+1]=se}this.#t=re,this.#e=Y,this.#r=se}}}),Ce("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return j}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare,U=ae.warnOnce;function _(i){const a=new Uint32Array(i);for(let s=0;s<i;s++)a[s]=s;return a}function Z(i,a){if(a&&typeof a.count=="number")return a.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const s=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):s?i.kind==="bitset"?typeof s.size=="number"?s.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(U(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${s.length*8}`),s.length*8):s.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const E=new WeakMap;function z(i){const a=i.constructor;if(!a)return"unknown";const s=E.get(a);if(s)return s;let h="unknown";try{let u=null;typeof a.from=="function"?u=a.from([!1,!0]):(u=new a(8),u.set(1));const t=u&&u.words;t&&t.length&&(t[0]===2?h="lsb":t[0]===64&&(h="msb"))}catch{h="unknown"}return E.set(a,h),h}function re(i){if(!i)return()=>0;const a=i instanceof Uint8Array?i:i.words;if(a instanceof Uint8Array){const s=i instanceof Uint8Array?"lsb":z(i);if(s==="lsb")return h=>a[h>>>3]>>>(h&7)&1;if(s==="msb")return h=>a[h>>>3]>>>7-(h&7)&1}return typeof i.get=="function"?s=>i.get(s)?1:0:()=>0}function Y(i){return!i||!i.presence?null:re(i.presence)}function se(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function te(i,a){return i?typeof i.valueOf=="function"?i.valueOf(a):typeof i.values=="function"?i.values()[a]:null:null}function H(i,a){const s=i.offsets,h=i.values;if(!s||!h)return[];const u=s[a],t=s[a+1];if(!(t>u))return[];const l=i.dict,m=new Array(t-u);for(let e=u;e<t;e++)m[e-u]=l?te(l,h[e]):h[e];return m}function T(i){if(!i)return()=>{};const a=i.values,s=Y(i),h=i.kind;if(h==="dictionary"){const u=i.dict;return s?t=>s(t)?te(u,a[t]):null:t=>te(u,a[t])}if(h==="bitset"){const u=re(a);return s?t=>s(t)?u(t)===1:null:t=>u(t)===1}if(h==="multi")return s?u=>s(u)?H(i,u):null:u=>H(i,u);if(!a&&typeof i.get=="function"){const u=i.get.bind(i);return t=>{const l=u(t);return l===void 0?null:l}}return s?u=>{if(!s(u))return null;const t=a[u];return t===void 0?null:t}:u=>{const t=a[u];return t===void 0?null:t}}function V(i,a){if(i<a)return-1;if(i>a)return 1;if(i===a){const u=Object.is(i,-0),t=Object.is(a,-0);return u===t?0:u?-1:1}const s=Number.isNaN(i),h=Number.isNaN(a);return s&&h?0:s?1:-1}function ne(i){const a=he(i);return(s,h)=>{if(s===h)return 0;const u=typeof s,t=typeof h;if(u==="string"&&t==="string")return a.compare(s,h);if(u==="number"&&t==="number")return V(s,h);if(u==="boolean"&&t==="boolean")return s===h?0:s?1:-1;if(s instanceof Date||h instanceof Date){const l=s instanceof Date?s.getTime():Number(s),m=h instanceof Date?h.getTime():Number(h);return V(l,m)}return W(s,h)}}function R(i,a){if(i&&typeof i.ranks=="function")return i.ranks(a);const s=i&&typeof i.values=="function"?i.values():[],h=s.length,u=ne(a),t=new Array(h);for(let m=0;m<h;m++)t[m]=m;t.sort((m,e)=>u(s[m],s[e])||m-e);const l=new Uint32Array(h);for(let m=0;m<h;m++)l[t[m]]=m;return l}function j(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Ce("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return v}});const ae=me("packages/core/src/compute/handle.js"),he=ae.bitReader,W=ae.dictRanks,U=ae.dictSize,_=ae.identity,Z=ae.isMissing,E=ae.presenceReader,z=ae.rowCount,re=ae.valueComparator,Y=ae.valueReader,se=new Uint32Array(0),te=new ArrayBuffer(8),H=new Float64Array(te),T=new Uint32Array(te),V=(H[0]=-1,(T[1]&2147483648)!==0?1:0),ne=V===1?0:1;function R(S,N){H[0]=S;let I=T[V],K=T[ne];(I&2147483648)!==0?(I=~I>>>0,K=~K>>>0):I=(I^2147483648)>>>0,N[0]=K,N[1]=I}function j(S,N,I,K){if(K<2)return S;const B=new Uint32Array(256*8);for(let D=0;D<K;D++){const x=N[D],fe=I[D];B[x&255]++,B[256+(x>>>8&255)]++,B[512+(x>>>16&255)]++,B[768+(x>>>24&255)]++,B[1024+(fe&255)]++,B[1280+(fe>>>8&255)]++,B[1536+(fe>>>16&255)]++,B[1792+(fe>>>24&255)]++}let ee=S,J=N,ue=I,de=new Uint32Array(K),Oe=new Uint32Array(K),Ae=new Uint32Array(K);const Se=new Uint32Array(256);for(let D=0;D<8;D++){const x=D<<8,fe=(D&3)<<3,p=D>=4;let Q=!1;for(let le=0;le<256;le++)if(B[x+le]===K){Q=!0;break}if(Q)continue;let X=0;for(let le=0;le<256;le++)Se[le]=X,X+=B[x+le];for(let le=0;le<K;le++){const ge=J[le],Me=ue[le],be=(p?Me:ge)>>>fe&255,ye=Se[be]++;de[ye]=ee[le],Oe[ye]=ge,Ae[ye]=Me}let ce=ee;ee=de,de=ce,ce=J,J=Oe,Oe=ce,ce=ue,ue=Ae,Ae=ce}return ee}function i(S,N,I){if(I<2)return S;const K=new Uint32Array(256*4);for(let Oe=0;Oe<I;Oe++){const Ae=N[Oe];K[Ae&255]++,K[256+(Ae>>>8&255)]++,K[512+(Ae>>>16&255)]++,K[768+(Ae>>>24&255)]++}let B=S,ee=N,J=new Uint32Array(I),ue=new Uint32Array(I);const de=new Uint32Array(256);for(let Oe=0;Oe<4;Oe++){const Ae=Oe<<8,Se=Oe<<3;let D=!1;for(let p=0;p<256;p++)if(K[Ae+p]===I){D=!0;break}if(D)continue;let x=0;for(let p=0;p<256;p++)de[p]=x,x+=K[Ae+p];for(let p=0;p<I;p++){const Q=ee[p],X=de[Q>>>Se&255]++;J[X]=B[p],ue[X]=Q}let fe=B;B=J,J=fe,fe=ee,ee=ue,ue=fe}return B}function a(S,N,I,K){const B=new Uint32Array(K+1);for(let ue=0;ue<I;ue++)B[N[ue]]++;let ee=0;for(let ue=0;ue<=K;ue++){const de=B[ue];B[ue]=ee,ee+=de}const J=new Uint32Array(I);for(let ue=0;ue<I;ue++)J[B[N[ue]]++]=S[ue];return J}function s(S,N,I,K){return I<2?S:K<=65536||K<=I*2?a(S,N,I,K):i(S,N,I)}function h(S,N){return S.length===N&&S.byteOffset===0?S:Uint32Array.prototype.slice.call(S,0,N)}function u(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=new Uint32Array(B),J=new Uint32Array(B),ue=new Uint32Array(B),de=new Uint32Array(B),Oe=new Uint32Array(2);let Ae=0,Se=0;for(let fe=0;fe<B;fe++){const p=K[fe],Q=S[p];if(Number.isNaN(Q)){de[Se++]=p;continue}R(Q,Oe),I?(J[Ae]=~Oe[0]>>>0,ue[Ae]=~Oe[1]>>>0):(J[Ae]=Oe[0],ue[Ae]=Oe[1]),ee[Ae++]=p}const D=j(ee.subarray(0,Ae),J.subarray(0,Ae),ue.subarray(0,Ae),Ae);if(Se===0)return h(D,Ae);const x=new Uint32Array(B);return x.set(D.subarray(0,Ae),0),x.set(de.subarray(0,Se),Ae),x}function t(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=Uint32Array.from(K),J=new Uint32Array(B);for(let ue=0;ue<B;ue++){const de=(S[ee[ue]]^2147483648)>>>0;J[ue]=I?~de>>>0:de}return h(i(ee,J,B),B)}function l(S,N,I={}){const K=N||_(z(S,I)),B=K.length;if(B<2)return Uint32Array.from(K);const ee=W(S.dict,I.locale),J=S.values,ue=E(S),de=Math.max(U(S.dict),ee.length),Oe=de,Ae=Uint32Array.from(K),Se=new Uint32Array(B),D=!!I.descending;for(let x=0;x<B;x++){const fe=Ae[x];let p=ue&&ue(fe)===0?Oe:ee[J[fe]];p===void 0&&(p=Oe),Se[x]=D?Oe-p:p}return h(s(Ae,Se,B,de+1),B)}function m(S,N,I){const K=N.length;let B=Uint32Array.from(N);if(K<2)return B;let ee=new Uint32Array(K);for(let J=1;J<K;J<<=1){for(let de=0;de<K;de+=J<<1){const Oe=Math.min(de+J,K),Ae=Math.min(de+(J<<1),K);let Se=de,D=Oe,x=de;for(;Se<Oe&&D<Ae;)ee[x++]=I(S[B[Se]],S[B[D]])<=0?B[Se++]:B[D++];for(;Se<Oe;)ee[x++]=B[Se++];for(;D<Ae;)ee[x++]=B[D++]}const ue=B;B=ee,ee=ue}return B}function e(S,N,I){const K=he(S.values),B=N.length,ee=new Uint32Array(B),J=I?1:0;let ue=0;for(let de=0;de<B;de++)K(N[de])===J&&(ee[ue++]=N[de]);for(let de=0;de<B;de++)K(N[de])!==J&&(ee[ue++]=N[de]);return ee}function d(S,N){const I=S.values,K=S.kind;if((K==="object"||K===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!S.presence)return I;const ee=Y(S),J=new Array(z(S)||0);for(let ue=0;ue<N.length;ue++){const de=N[ue];J[de]=ee(de)}return J}function f(S,N){for(let I=0;I<N.length;I++)if(typeof S[N[I]]!="string")return!1;return!0}function r(S,N,I,K,B){const ee=S.length,J=Uint32Array.from(S);if(ee<2||K<1)return J;const ue=new Uint32Array(ee),de=K-1;for(let Oe=0;Oe<ee;Oe++){const Ae=I[N[Oe]];ue[Oe]=B?de-Ae:Ae}return h(s(J,ue,ee,K),ee)}function n(S,N,I){const K=re(I),B=new Array(N);for(let J=0;J<N;J++)B[J]=J;B.sort((J,ue)=>K(S[J],S[ue])||J-ue);const ee=new Uint32Array(N);for(let J=0;J<N;J++)ee[B[J]]=J;return ee}function c(S,N,I){const K=N.length,B=new Map,ee=[],J=new Uint32Array(K);for(let Oe=0;Oe<K;Oe++){const Ae=S[N[Oe]];let Se=B.get(Ae);Se===void 0&&(Se=ee.length,B.set(Ae,Se),ee.push(Ae)),J[Oe]=Se}const ue=ee.length,de=n(ee,ue,I.locale);return r(N,J,de,ue,!!I.descending)}function g(S,N,I){const K=d(S,N);if(N.length>=2&&f(K,N)){const J=S.stringRank;return J&&J.version===S.version&&J.usable(N,K,I.locale)?J.sort(N,I):c(K,N,I)}const B=re(I.locale),ee=I.descending?(J,ue)=>B(ue,J):B;return m(K,N,ee)}function A(S,N,I){const K=d(S,N),B=I.compare,J=!!I.descending?(ue,de)=>-B(ue,de,void 0,void 0,!0):(ue,de)=>B(ue,de,void 0,void 0,!1);return m(K,N,J)}function P(S,N){const I=N.length,K=E(S),B=S.values,ee=S.kind==="float64"&&!!B,J=S.kind==="object"||S.kind==="multi"||S.kind===void 0;if(!K&&!ee&&!J)return{present:N,absent:se};const ue=new Uint32Array(I),de=new Uint32Array(I);let Oe=0,Ae=0;if(K&&ee)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1&&!Number.isNaN(B[D])?ue[Oe++]=D:de[Ae++]=D}else if(ee&&!K)for(let Se=0;Se<I;Se++){const D=N[Se];Number.isNaN(B[D])?de[Ae++]=D:ue[Oe++]=D}else if(K&&!J)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1?ue[Oe++]=D:de[Ae++]=D}else{const Se=Y(S);for(let D=0;D<I;D++){const x=N[D];Z(Se(x))?de[Ae++]=x:ue[Oe++]=x}}return Ae===0?{present:N,absent:se}:{present:ue.subarray(0,Oe),absent:de.subarray(0,Ae)}}function q(S,N,I){if(N.length===0)return S;const K=new Uint32Array(S.length+N.length);return I?(K.set(N,0),K.set(S,N.length)):(K.set(S,0),K.set(N,S.length)),K}function L(S,N,I={}){const K=N||_(z(S,I));if(!S||K.length<2)return Uint32Array.from(K);const{present:B,absent:ee}=P(S,K);if(B.length===0)return Uint32Array.from(K);const J=!!I.descending;let ue;if(typeof I.compare=="function")ue=A(S,B,I);else switch(S.kind){case"float64":ue=u(S.values,B,J);break;case"int32":ue=t(S.values,B,J);break;case"dictionary":ue=l(S,B,I);break;case"bitset":ue=e(S,B,J);break;default:ue=g(S,B,I);break}return q(ue,ee,!!I.nullsFirst)}function v(S,N,I,K={}){const B=N||[],ee=B.length&&(B[0].handle||G(S,B[0].col))||S&&S[0];let J=I||_(z(ee,K));for(let ue=B.length-1;ue>=0;ue--){const de=B[ue],Oe=de.handle||G(S,de.col)||S&&S[ue];Oe&&(J=L(Oe,J,{descending:de.descending!==void 0?!!de.descending:de.dir==="desc",nullsFirst:!!de.nullsFirst,locale:de.locale!==void 0?de.locale:K.locale,compare:de.compare}))}return J instanceof Uint32Array?J:Uint32Array.from(J)}function G(S,N){if(!(!S||N===void 0)){for(let I=0;I<S.length;I++)if(S[I]&&S[I].id===N)return S[I]}}}),Ce("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return _}});const ae=me("packages/core/src/compute/sort.js"),he=ae.collateStringRanks,W=ae.rankSortStrings,U=1e5;class _{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(E=U){this.#h=E>0?E:U,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(E){this.#s=E}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let E=this.#n.byteLength;const z=this.#t;for(let re=0;re<z.length;re++)E+=z[re].length*2+24;return E}#a(E,z){const re=this.#e.get(E);if(re!==void 0)return re;if(this.#u)return-1;if(z&&this.#t.length>=this.#h)return this.#u=!0,-1;const Y=this.#t.length;return this.#t.push(E),this.#e.set(E,Y),this.#i++,Y}build(E,z){const re=z|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let Y=0;Y<re;Y++){const se=E[Y],te=typeof se=="string"?this.#a(se,!1):-1;this.#n[Y]=te<0?0:te}this.#r=re}append(E,z,re){const Y=(z|0)+(re|0);if(Y>this.#n.length){const se=new Uint32Array(Y);se.set(this.#n.subarray(0,this.#r)),this.#n=se}for(let se=z|0;se<Y;se++){const te=E[se],H=typeof te=="string"?this.#a(te,!0):-1;this.#n[se]=H<0?0:H}this.#r=Math.max(this.#r,Y)}ranks(E){const z=E||"";if(this.#o&&this.#c===this.#i&&this.#l===z)return this.#o;const re=he(this.#t,this.#t.length,E);return this.#o=re,this.#c=this.#i,this.#l=z,re}usable(E,z,re){if(this.#u||this.#t.length===0)return!1;const Y=this.#n,se=this.#t,te=this.#r;for(let H=0;H<E.length;H++){const T=E[H];if(T>=te||se[Y[T]]!==z[T])return!1}return!0}sort(E,z){const re=this.ranks(z.locale),Y=this.#t.length,se=E.length,te=new Uint32Array(se),H=this.#n;for(let T=0;T<se;T++)te[T]=H[E[T]];return W(E,te,re,Y,!!z.descending)}}}),Ce("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ColumnHandle",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"ColumnStore",{enumerable:!0,get:function(){return l}});const ae=me("packages/core/src/internal/util.js"),he=ae.warnOnce,W=ae.isFunction,U=ae.pathGetter,Z=me("packages/core/src/store/bitset.js").Bitset,z=me("packages/core/src/store/dictionary.js").Dictionary,Y=me("packages/core/src/store/multivalue.js").MultiValue,te=me("packages/core/src/store/stringrank.js").StringRankIndex,H=4294967295,T=1024,V=5e3,ne=.2,R=new Set(["float64","int32","bitset","dictionary","object","multi"]);function j(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function a(m){const e=i(m);return Number.isFinite(e)?e|0:0}function s(m){return j(m)?[]:Array.isArray(m)?m:[m]}function h(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=m.dict.valueOf(d[r]);return f}default:return m.buf[e]}}function u(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],f=m.offsets[e+1],r=m.table||[],n=new Array(f-d);for(let c=d;c<f;c++)n[c-d]=r[m.values[c]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const f=R.has(e.kind)?e.kind:"object";e.kind&&!R.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=f,this.#e=f,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=W(e.read)?e.read:U(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const f=new te(this.#S());return f.build(e,d),f.version=this.#f,this.#d=f,this.#k=this.#f,f.capped?null:f}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=this.#a.valueOf(d[r]);return f}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,f){if(this.#g||f<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,c=this.#m;let g=!1;switch(this.#e){case"float64":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]);if(typeof q=="number"){n&&c.set(d+P),A[d+P]=q;continue}const L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?NaN:i(q)}break}case"int32":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?0:a(q)}break}case"bitset":{const A=this.#c;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A.assign(d+P,!L&&!!q)}break}case"dictionary":{const A=this.#o,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0),A[d+q]=v?0:P.codeOf(L)}break}case"multi":{const A=this.#l,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0);const G=s(L),S=new Array(G.length);for(let N=0;N<G.length;N++)S[N]=P.codeOf(G[N]);A.write(d+q,S)}break}default:{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?null:q}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,f),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,f){if(this.#g||f<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<f;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<f;g++)r.set(d+g);const c=e.kind===this.#e;if(c&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(c&&this.#e==="bitset"){const g=e.values;for(let A=0;A<f;A++)this.#c.assign(d+A,(g[A>>3]&1<<(A&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],A=new Uint32Array(g.length);for(let v=0;v<g.length;v++)A[v]=this.#a.codeOf(g[v]);const P=e.values,q=this.#o,L=r;for(let v=0;v<f;v++){if(L&&(n&&(n[v>>3]&1<<(v&7))===0)){q[d+v]=0;continue}q[d+v]=A[P[v]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],A=new Uint32Array(g.length);for(let L=0;L<g.length;L++)A[L]=this.#a.codeOf(g[L]);const P=e.values,q=e.offsets;for(let L=0;L<f;L++){const v=q[L],G=q[L+1],S=new Array(G-v);for(let N=v;N<G;N++)S[N-v]=A[P[N]]??0;this.#l.write(d+L,S)}this.#f++;return}for(let g=0;g<f;g++){const A=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,A?null:u(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const f=new Array(d);for(let r=0;r<d;r++)f[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,f[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!R.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},f=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<f;n++){const c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?null:h(d,n))}return this.#j(),this.#f++,!0}compact(e,d,f){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[c,g]of r)e[c]!==H&&n.set(e[c],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==H&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=f;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,f,H);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new Z(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new z(this.#h??[]);break;case"multi":this.#l=new Y({rows:d,values:d}),this.#a=this.#a??new z(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new Z(d)),this.#p=d}#A(e,d){const f=j(d);switch(this.#r?this.#m.assign(e,!f):f&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=f?NaN:i(d);break;case"int32":this.#o[e]=f?0:a(d);break;case"bitset":this.#c.assign(e,!f&&!!d);break;case"dictionary":this.#o[e]=f?0:this.#a.codeOf(d);break;case"multi":{const r=s(d),n=new Array(r.length);for(let c=0;c<r.length;c++)n[c]=this.#a.codeOf(r[c]);this.#l.write(e,n);break}default:this.#o[e]=f?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),f=this.#r?new Z(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,f&&!j(n)&&f.set(r)}return this.#O={version:this.#f,values:d,presence:f},this.#O}}class l{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new Z(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??T),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??V:0,this.#w=d.compactRatio??ne;const f={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,f);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const f=e.length|0;if(f===0)return{from:d,to:d};if(this.#l)for(let n=0;n<f;n++)this.#r[d+n]=e[n];if(this.#i=d+f,this.#h+=f,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,f);return{from:d,to:this.#i}}appendPacked(e,d){const f=this.#i;if(this.#b||!e)return{from:f,to:f};const r=e.count|0;if(r===0)return{from:f,to:f};if(this.#l&&d)for(let c=0;c<r;c++)this.#r[f+c]=d[c];this.#i=f+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const c of e.columns)n.set(c.id,c);for(const c of this.#n){const g=n.get(c.id);g?c.appendPacked(g,f,r):c.grow(this.#s)}return{from:f,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const f=this.#e.get(e);return f?f.get(d):void 0}set(e,d,f){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,f)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,f=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)f[n]=this.#o.get(n)===1?H:r++;for(const n of this.#n)n.compact(f,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)f[c]!==H&&(n[f[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new Z(Math.max(this.#s,r)),f}column(e){return this.#e.get(e)}columns(){return this.#n.slice()}liveIndices(){const e=new Uint32Array(this.#h);if(this.#u===0){for(let f=0;f<this.#i;f++)e[f]=f;return e}let d=0;for(let f=0;f<this.#i;f++)this.#o.get(f)===0&&(e[d++]=f);return e}convert(e,d){const f=this.#e.get(e);return f?f.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const f of this.#n)f.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const f of this.#n)d[f.id]=f.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Ce("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.now,W=ae.nextFrame,U=ae.infoOnce,_=ae.warnOnce,Z=ae.isFunction,E=ae.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,Y=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function se(j,i={}){if(i.multi)return"multi";if(j.length===0)return"object";let a=0,s=0,h=0,u=0,t=0;for(let m=0;m<j.length;m++){const e=j[m];typeof e=="number"?a++:typeof e=="boolean"?s++:typeof e=="string"?h++:e instanceof Date?u++:Array.isArray(e)&&t++}const l=j.length;return a===l?"float64":s===l?"bitset":u===l?"float64":h===l?"text":t===l?"multi":"object"}function te(j,i,a){return i<=0||j<a*i?"dictionary":"object"}function H(j,i,a){const s=new Map,h=new Map;for(const c of j){if(c.computed)continue;const g=Z(c.read)?c.read:E(c.field||c.id);h.set(c.id,g),s.set(c.id,g)}const u=i?.order??[],t=i?.fns??{},l=i?.deps??{},m=i?.wrapDeps??null,e=u.filter(c=>Z(t[c])),d=e.some(c=>l[c]==="*");let f=new WeakMap;const r=c=>{const g={};if(d)for(const[A,P]of h)g[A]=P(c);for(const A of e){const P=l[A];let q;if(P==="*")q=g;else{q={};const L=P||[];for(let v=0;v<L.length;v++){const G=L[v];q[G]=G in g?g[G]:h.get(G)?.(c)}}g[A]=t[A](m?m(q,A):q,{data:c,row:null,column:null,grid:null,context:a})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=f.get(c);return g===void 0&&(g=r(c),f.set(c,g)),g};for(const c of e)s.set(c,g=>n(g)[c]);return{readers:s,reset(){f=new WeakMap}}}class T{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,a){this.spec=i,this.read=a,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class V{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,a={},s={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...Y,...s};const h=a.columns??[];this.#r=H(h,a.computed??null,a.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(h,a.computed??null),this.#n=new re(this.#e.map(u=>({id:u.spec.id,kind:u.kind,nullable:u.nullable,read:u.read,dictionary:u.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=he(),{chunkMs:a,chunkRows:s}=this.#s,h=this.#t.length;do{const u=Math.min(this.#i+s,h);this.#n.append(this.#t.slice(this.#i,u)),this.#a(this.#i,u),this.#i=u,this.#r.reset(),this.#w(!1)}while(this.#i<h&&he()-i<a);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:h}),this.#i>=h?(this.#w(!0),this.#h=!0,!1):!0}cancel(){this.#u=!0}result(){return{store:this.#n,schema:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#d(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#u}}#l(i,a){const s=this.#t,h=Math.min(this.#s.sampleSize,s.length),u=this.#s.dictionaryRatio,t=a?.pure instanceof Set?a.pure:new Set(a?.pure??a?.order??[]);for(const l of i){if(!l||!l.id)continue;if(l.computed&&(l.pure===!1||a&&!t.has(l.id))){_(`ingest.impure.${l.id}`,`column "${l.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(l.id)??(Z(l.read)?l.read:E(l.field||l.id)),e=new T(l,m);if(l.kind)e.kind=l.kind,e.reason="declared by the caller";else if(l.dictionary)e.kind=l.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<h&&d.length<this.#s.sampleSize;r++){const n=m(s[r]);n!=null&&d.push(n)}e.inferred=!0;const f=se(d,{multi:l.multi});if(f==="text"){const r=new Set(d).size;e.kind=te(r,d.length,u),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=f,e.reason=`inferred from ${d.length} sampled values`,f==="object"&&d.length&&U(`ingest.mixed.${l.id}`,`column "${l.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(d))}this.#e.push(e)}}#a(i,a){const s=this.#t;for(const h of this.#e){if(!h.candidate||!h.distinct)continue;const u=h.distinct;for(let t=i;t<a;t++){const l=h.read(s[t]);l!=null&&u.add(l)}}}#d(i){if(i.distinct)return i.distinct.size;const a=this.#n.column(i.spec.id);return a?.dict?a.dict.size:0}#w(i){const a=this.#s.dictionaryRatio,s=this.#t.length;for(const h of this.#e){if(!h.candidate)continue;const u=this.#d(h);if(h.kind==="dictionary"&&u>=a*s){const t=this.#n.column(h.spec.id);h.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(h.spec.id,"object"),h.kind="object",h.change="demoted",h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}if(h.kind==="object"&&u>=a*s){h.candidate=!1,h.distinct=null,h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}i&&h.kind==="object"&&u<a*s&&(this.#n.convert(h.spec.id,"dictionary"),h.kind="dictionary",h.change=h.change==="demoted"?null:"promoted",h.reason=`${u} distinct values is below ${a*100}% of ${s} rows`,h.distinct=null),i&&(h.candidate=!1)}}}async function ne(j,i={},a={}){const s=new V(j,i,a),h=a.scheduler?.frame??W;for(;s.slice();)await new Promise(u=>{h(u)});return s.result()}function R(j,i={},a={}){const s=new V(j,i,{...a,chunkMs:1/0});for(;s.slice(););return s.result()}}),Ce("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return V}});const he=me("packages/core/src/internal/util.js").pathGetter,W=me("packages/core/src/store/ingest.js"),U=W.inferKind,_=W.decideText,Z=W.INGEST_DEFAULTS,z=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function Y(ne){if(!Array.isArray(ne)||ne.length===0)return!1;for(const R of ne)if(!R||typeof R.id!="string"||typeof R.field!="string"||R.field===""||R.kind&&!re.has(R.kind))return!1;return!0}function se(ne){const R=z(ne);return Number.isFinite(R)?R|0:0}function te(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}function H(ne,R,j,i){if(ne.kind)return ne.kind;const a=[];for(let u=0;u<R.length&&a.length<Z.sampleSize;u++){const t=R[u];t!=null&&a.push(t)}const s=U(a,{multi:ne.multi});if(s!=="text")return s;const h=new Set(a).size;return _(h,a.length,i)}function T(ne,R,j={}){const i=R.length|0,a=j.dictionaryRatio??Z.dictionaryRatio,s=[];for(const h of ne){const u=he(h.field||h.id),t=h.nullable!==!1,l=new Array(i);for(let r=0;r<i;r++){const n=u(R[r]);l[r]=n===void 0?null:n}const m=H(h,l,i,a),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let f;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?NaN:z(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?0:se(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),!g&&c&&(r[n>>3]|=1<<(n&7))}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],c=new Map;for(let g=0;g<i;g++){const A=l[g];if(A===null){r[g]=0;continue}d(g);let P=c.get(A);P===void 0&&(P=n.length,n.push(A),c.set(A,P)),r[g]=P}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,c=new Uint32Array(i+1),g=[];for(let A=0;A<i;A++){const P=l[A];c[A]=g.length,P===null||d(A);const L=te(P);for(let v=0;v<L.length;v++){const G=L[v];let S=n.get(G);S===void 0&&(S=r.length,r.push(G),n.set(G,S)),g.push(S)}}c[i]=g.length,f={id:h.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:c,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const c=l[n];c!==null&&d(n),r[n]=c}f={id:h.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}s.push(f)}return{count:i,columns:s}}function V(ne){const R=[];if(!ne||!Array.isArray(ne.columns))return R;const j=i=>{ArrayBuffer.isView(i)&&i.buffer&&!R.includes(i.buffer)&&R.push(i.buffer)};for(const i of ne.columns)j(i.values),j(i.presence),j(i.offsets);return R}}),Ce("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return _}});function ae(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function he(Z){return!!Z&&typeof Z.compare!="function"}function W(Z){if(!Z)return!0;for(let E=0;E<Z.length;E++)if(!he(Z[E]))return!1;return!0}function U(Z,E){const z=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,re=Z.locale!==void 0?Z.locale:E;return{col:z,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:ae(re)}}function _(Z,E){const z=Z||[],re=new Array(z.length);for(let Y=0;Y<z.length;Y++)re[Y]=U(z[Y],E);return re}}),Ce("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.isNil,W=ae.warnOnce,U=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(j){const i=[];let a=0,s="";const h=()=>{s&&(i.push({token:null,text:s}),s="")};for(;a<j.length;){const u=j[a];if(u==="\'"){if(j[a+1]==="\'"){s+="\'",a+=2;continue}const l=j.indexOf("\'",a+1);if(l===-1){s+=j.slice(a+1),a=j.length;continue}s+=j.slice(a+1,l),a=l+1;continue}const t=U.find(l=>j.startsWith(l,a));if(t){h(),i.push({token:t,text:t}),a+=t.length;continue}/[A-Za-z]/.test(u)&&W(`date.pattern.token:${u}`,`the date pattern "${j}" contains \'${u}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${U.join(" ")}.`),s+=u,a+=1}return h(),i}const Z=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function E(j){if(he(j)||j==="")return null;if(j instanceof Date)return Number.isNaN(j.getTime())?null:j;if(typeof j=="number")return Number.isNaN(j)?null:new Date(j);if(typeof j=="string"){const i=Z.exec(j.trim());if(i){const[,s,h,u,t="0",l="0",m="0"]=i;return new Date(+s,+h-1,+u,+t,+l,+m)}const a=new Date(j);return Number.isNaN(a.getTime())?null:a}return null}function z(j,i){return String(j).padStart(i,"0")}function re(j){if(!j)return s=>({year:s.getFullYear(),month:s.getMonth()+1,day:s.getDate(),hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),ms:s.getMilliseconds(),weekday:s.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:j,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),a={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return s=>{const h={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:s.getMilliseconds(),weekday:0};for(const u of i.formatToParts(s))switch(u.type){case"year":h.year=Number(u.value);break;case"month":h.month=Number(u.value);break;case"day":h.day=Number(u.value);break;case"hour":h.hour=Number(u.value)%24;break;case"minute":h.minute=Number(u.value);break;case"second":h.second=Number(u.value);break;case"weekday":h.weekday=a[u.value]??0;break;default:break}return h}}function Y(j,i,a){const s=_(j),h=re(a),u=new Set(s.filter(d=>d.token).map(d=>d.token)),t=u.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:a}):null,l=u.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:a}):null,m=u.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:a}):null,e=u.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:a}):null;return d=>{const f=h(d);let r="";for(const n of s){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=z(f.year,4);break;case"yy":r+=z(f.year%100,2);break;case"MMMM":r+=l.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=z(f.month,2);break;case"M":r+=String(f.month);break;case"dd":r+=z(f.day,2);break;case"d":r+=String(f.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=z(f.hour,2);break;case"H":r+=String(f.hour);break;case"hh":r+=z(f.hour%12===0?12:f.hour%12,2);break;case"h":r+=String(f.hour%12===0?12:f.hour%12);break;case"mm":r+=z(f.minute,2);break;case"m":r+=String(f.minute);break;case"ss":r+=z(f.second,2);break;case"s":r+=String(f.second);break;case"SSS":r+=z(f.ms,3);break;case"a":r+=f.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const se=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function te(j,i){const a=j||{},s=a.locale||i||void 0,h=a.nullDisplay??"",u=a.timeZone;let t;if(a.pattern)t=Y(a.pattern,s,u);else if(a.dateStyle||a.timeStyle){const f={timeZone:u};a.dateStyle&&(f.dateStyle=a.dateStyle),a.timeStyle&&(f.timeStyle=a.timeStyle);const r=new Intl.DateTimeFormat(s,f);t=n=>r.format(n)}else{const f=new Intl.DateTimeFormat(s,{dateStyle:"medium",timeZone:u});t=r=>f.format(r)}const l=a.relative?new Intl.RelativeTimeFormat(s,{numeric:"auto"}):null,e=(typeof a.relative=="object"&&a.relative?a.relative.threshold??7:7)*24*36e5,d=(f,r)=>{const n=E(f);if(!n)return h;if(l){const c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[A,P]of se)if(Math.abs(g)>=P||A==="second")return l.format(Math.round(g/P),A)}}return t(n)};return d.spec=a,d}function H(j){if(he(j)||j==="")return null;if(typeof j=="string"){const s=/^(\\d{4}-\\d{2}-\\d{2})/.exec(j.trim());if(s)return s[1];const h=E(j);return h?H(h):null}const i=E(j);if(!i)return null;const a=s=>String(s).padStart(2,"0");return`${i.getFullYear()}-${a(i.getMonth()+1)}-${a(i.getDate())}`}function T(j,i){if(he(j)||j==="")return null;if(typeof j=="string"){const s=j.trim();if(V.test(s)){const t=E(s);return t?ne(t,i):null}const h=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(s);if(h){const[,t,l,m,e]=h;return`${t}T${l}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(s))return`${s}T00:00`;const u=E(s);return u?T(u):null}const a=E(j);return a?ne(a,i):null}const V=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ne(j,i){const a=t=>String(t).padStart(2,"0");if(i)try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(j).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),l=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${l}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const s=`${j.getFullYear()}-${a(j.getMonth()+1)}-${a(j.getDate())}`,h=j.getSeconds(),u=`${a(j.getHours())}:${a(j.getMinutes())}${h?`:${a(h)}`:""}`;return`${s}T${u}`}function R(j,i){const a=he(j)||j===""?null:String(j),s=he(i)||i===""?null:String(i);return a===null?s===null?0:1:s===null||a<s?-1:a>s?1:0}}),Ce("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"wallMs",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return fe}});const ae=me("packages/core/src/internal/util.js"),he=ae.isBlank,W=ae.toArray,U=ae.warnOnce,_=me("packages/core/src/format/date.js"),Z=_.toDate,E=_.toIsoDate,z=me("packages/core/src/compute/handle.js"),re=z.bitReader,Y=z.dictSize,se=z.dictValue,te=z.presenceReader,H=z.valueComparator,T=z.valueReader,V=/^\\d{4}-\\d{2}-\\d{2}$/,ne="\\0null\\0";function R(p,Q){const X=p&&p.pool;if(X){const ce=X.mask||X.acquireMask||X.acquire||X.take;if(typeof ce=="function"){const le=ce.call(X,Q);if(le&&le.length>=Q)return le}}return new Uint8Array(Q)}function j(p,Q){const X=p&&p.pool;if(!X||!Q)return;const ce=X.release||X.releaseMask||X.free||X.recycle;typeof ce=="function"&&ce.call(X,Q)}function i(p,Q,X){return p.fill(X,0,Q),p}function a(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,Q){if(p==null)return p;if(Q==="number")return typeof p=="number"?p:Number(p);if(Q==="date"||Q==="dateString"){const X=E(p);return X===null?h(p):X}return Q==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function h(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function u(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function t(p,Q){const X=typeof p=="string"?p:String(p);return Q?X:X.toLowerCase()}function l(p,Q){return p==null?ne:typeof p=="string"?Q?p:p.toLowerCase():p instanceof Date?p.getTime():p}function m(p,Q,X){const ce=new Set;for(const le of W(p)){const ge=s(le,X);ce.add(l(ge,Q)),typeof ge=="string"&&ge!==""&&Number.isFinite(Number(ge))?ce.add(Number(ge)):typeof ge=="number"&&Number.isFinite(ge)&&ce.add(l(String(ge),Q))}return ce}function e(p,Q,X){if(p==null||Q===null||Q===void 0)return p==null&&Q==null;const ce=typeof p,le=typeof Q;return ce==="string"&&le==="string"?X?p===Q:p.toLowerCase()===Q.toLowerCase():p instanceof Date||Q instanceof Date?h(p)===h(Q):ce==="number"&&le==="number"?p===Q||Number.isNaN(p)&&Number.isNaN(Q):ce==="number"&&le==="string"?p===Number(Q):ce==="string"&&le==="number"?Number(p)===Q:ce==="boolean"||le==="boolean"?p===Q:Array.isArray(p)&&Array.isArray(Q)?p.length===Q.length&&p.every((ge,Me)=>e(ge,Q[Me],X)):p===Q}function d(p,Q){try{if(p instanceof RegExp){const X=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,Q||X.includes("i")?X:`${X}i`)}return new RegExp(String(p),Q?"":"i")}catch(X){return U(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,X),null}}function f(p,Q){if(p&&p.type==="datetime"&&r.has(p.op))return P(p,Q);const X=q(p,Q),ce=p&&p.type;return ce!=="date"&&ce!=="dateString"?X:le=>X(typeof le=="string"&&V.test(le)?le:E(le)??le)}const r=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),n=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3})\\d*)?)?)?$/,c=new Map;function g(p,Q){let X=c.get(Q);if(X===void 0){try{X=new Intl.DateTimeFormat("en-CA",{timeZone:Q,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{X=null}c.set(Q,X)}if(!X)return null;const ce={};for(const le of X.formatToParts(p))le.type!=="literal"&&(ce[le.type]=le.value);return ce}function A(p,Q){if(p==null||p==="")return null;if(typeof p=="string"){const ge=n.exec(p.trim());if(ge)return Date.UTC(+ge[1],+ge[2]-1,+ge[3],+(ge[4]||0),+(ge[5]||0),+(ge[6]||0),+(ge[7]||"0").padEnd(3,"0"))}const X=Z(p);if(!X)return null;const ce=X.getUTCMilliseconds(),le=Q?g(X,Q):null;return le?Date.UTC(+le.year,+le.month-1,+le.day,le.hour==="24"?0:+le.hour,+le.minute,+le.second,ce):Date.UTC(X.getFullYear(),X.getMonth(),X.getDate(),X.getHours(),X.getMinutes(),X.getSeconds(),ce)}function P(p,Q){const X=typeof p.timeZone=="string"&&p.timeZone?p.timeZone:void 0,ce=Me=>A(Me,X),le=Array.isArray(p.value)?p.value.map(ce):ce(p.value),ge=q({...p,type:"number",value:le},Q);return Me=>ge(A(Me))}function q(p,Q){const X=p&&p.op,ce=!!(p&&p.caseSensitive),le=p&&p.type,ge=H(Q),Me=be=>ye=>!be(ye);switch(X){case"eq":{const be=s(p.value,le);return ye=>e(ye,be,ce)}case"ne":{const be=s(p.value,le);return ye=>!e(ye,be,ce)}case"lt":case"lte":case"gt":case"gte":{const be=s(p.value,le);if(a(be))return()=>!1;const ye=X==="lt"?-1:X==="lte"?0:X==="gt"?1:2;return Re=>{if(a(Re))return!1;const Ne=ge(Re,be);return ye===-1?Ne<0:ye===0?Ne<=0:ye===1?Ne>0:Ne>=0}}case"between":case"notBetween":{const be=W(p.value),ye=s(be[0],le),Re=s(be[1],le),Ne=p.bounds||"[]",Ee=Ne.charAt(0)!=="(",Be=Ne.charAt(1)!==")";if(a(ye)||a(Re))return X==="between"?()=>!1:()=>!0;const ze=We=>{if(a(We))return!1;const Xe=ge(We,ye),Ye=ge(We,Re);return(Ee?Xe>=0:Xe>0)&&(Be?Ye<=0:Ye<0)};return X==="between"?ze:Me(ze)}case"in":case"notIn":{const be=m(p.value,ce,le),ye=Re=>be.has(l(Re,ce));return X==="in"?ye:Me(ye)}case"contains":case"notContains":{const be=t(s(p.value,le),ce),ye=Re=>Re==null?!1:t(Re,ce).includes(be);return X==="contains"?ye:Me(ye)}case"startsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).startsWith(be)}case"endsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).endsWith(be)}case"matches":{const be=d(p.value,ce);return be?ye=>ye==null?!1:be.test(String(ye)):()=>!1}case"blank":return be=>he(be)||Array.isArray(be)&&be.length===0;case"notBlank":return be=>!(he(be)||Array.isArray(be)&&be.length===0);case"containsAny":case"containsNone":{const be=m(p.value,ce,le),ye=Re=>{const Ne=Re==null?[]:W(Re);for(let Ee=0;Ee<Ne.length;Ee++)if(be.has(l(Ne[Ee],ce)))return!0;return!1};return X==="containsAny"?ye:Me(ye)}case"containsAll":{const be=W(p.value).map(ye=>l(s(ye,le),ce));return ye=>{const Re=ye==null?[]:W(ye);if(be.length===0)return!0;const Ne=new Set(Re.map(Ee=>l(Ee,ce)));for(let Ee=0;Ee<be.length;Ee++)if(!Ne.has(be[Ee]))return!1;return!0}}default:{const be=fe(X);return be?be.compile(p.value):(U(`op:${String(X)}`,`unknown filter operator "${String(X)}"; the condition is refused rather than matching every row`),()=>!1)}}}function L(p,Q,X){return f(Q,X)(p)}const v=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),G=new Set(["containsAny","containsAll","containsNone"]);function S(p,Q,X){const ce=p&&p.op,le=v[ce]||ce,ge=f({...p,op:le,type:Q.type},X),Me=Q.items,be=ye=>{const Re=Me(ye);if(!Re)return!1;for(let Ne=0;Ne<Re.length;Ne++)if(ge(Re[Ne]))return!0;return!1};return v[ce]?ye=>!be(ye):be}function N(p,Q,X,ce){const le=te(p);if(le){const be=Q?1:0;for(let ye=0;ye<ce;ye++)X[ye]=le(ye)===be?1:0;return X}const ge=p.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return i(X,ce,Q?1:0);const Me=T(p);for(let be=0;be<ce;be++){const ye=Me(be),Re=he(ye)||Array.isArray(ye)&&ye.length===0;X[be]=Re===Q?0:1}return X}function I(p,Q,X,ce){const le=p.dict,ge=Y(le),Me=new Uint8Array(ge);for(let Ne=0;Ne<ge;Ne++)Me[Ne]=Q(se(le,Ne))?1:0;const be=p.values,ye=te(p);if(!ye){for(let Ne=0;Ne<ce;Ne++)X[Ne]=Me[be[Ne]];return X}const Re=Q(null)?1:0;for(let Ne=0;Ne<ce;Ne++)X[Ne]=ye(Ne)===1?Me[be[Ne]]:Re;return X}function K(p,Q,X,ce){const le=re(p.values),ge=Q(!0)?1:0,Me=Q(!1)?1:0,be=te(p);if(!be){for(let Re=0;Re<ce;Re++)X[Re]=le(Re)===1?ge:Me;return X}const ye=Q(null)?1:0;for(let Re=0;Re<ce;Re++)X[Re]=be(Re)===0?ye:le(Re)===1?ge:Me;return X}function B(p,Q,X,ce,le){const ge=p.values,Me=Q.type,be=Q.op;let ye=!0;switch(be){case"eq":case"ne":{const Ne=u(s(Q.value,Me)),Ee=typeof Q.value=="number"&&Number.isNaN(Q.value),Be=be==="ne"?1:0;if(Ee)for(let ze=0;ze<le;ze++)ce[ze]=(Number.isNaN(ge[ze])?1:0)^Be;else for(let ze=0;ze<le;ze++)ce[ze]=(ge[ze]===Ne?1:0)^Be;break}case"lt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<Ne?1:0;break}case"lte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<=Ne?1:0;break}case"gt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>Ne?1:0;break}case"gte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>=Ne?1:0;break}case"between":case"notBetween":{const Ne=W(Q.value),Ee=u(s(Ne[0],Me)),Be=u(s(Ne[1],Me)),ze=Q.bounds||"[]",We=ze.charAt(0)!=="(",Xe=ze.charAt(1)!==")",Ye=be==="notBetween"?1:0;if(We&&Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<=Be?1:0)^Ye;else if(We)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<Be?1:0)^Ye;else if(Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<=Be?1:0)^Ye;else for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<Be?1:0)^Ye;break}case"in":case"notIn":{const Ne=new Set;for(const Be of W(Q.value)){const ze=u(s(Be,Me));Number.isNaN(ze)||Ne.add(ze)}const Ee=be==="notIn"?1:0;for(let Be=0;Be<le;Be++)ce[Be]=(Ne.has(ge[Be])?1:0)^Ee;break}default:ye=!1;break}if(!ye)return!1;const Re=te(p);if(Re){const Ne=X(null)?1:0;for(let Ee=0;Ee<le;Ee++)Re(Ee)===0&&(ce[Ee]=Ne)}return!0}function ee(p,Q,X,ce){const le=T(p);for(let ge=0;ge<ce;ge++)X[ge]=Q(le(ge))?1:0;return X}function J(p,Q,X){const ce=Q.count|0,le=X||R(Q,ce);if(!p)return i(le,ce,1);const ge=typeof Q.handle=="function"?Q.handle(p.col):void 0,Me=typeof Q.custom=="function"?Q.custom:null;if(!ge){if(Me){for(let Ne=0;Ne<ce;Ne++)le[Ne]=Me(p,Ne)?1:0;return le}return U(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),i(le,ce,0)}const be=p.op;if(be==="blank"||be==="notBlank")return N(ge,be==="notBlank",le,ce);const ye=typeof Q.itemwise=="function"?Q.itemwise(p.col):null;if(ye&&!fe(be)&&!G.has(be))return ee(ge,S(p,ye,Q.locale),le,ce);const Re=f(p,Q.locale);switch(ge.kind){case"dictionary":return I(ge,Re,le,ce);case"bitset":return K(ge,Re,le,ce);case"float64":case"int32":return B(ge,p,Re,le,ce)?le:ee(ge,Re,le,ce);default:return ee(ge,Re,le,ce)}}function ue(p,Q,X){if(!p)return i(R(Q,X),X,1);if(Array.isArray(p.conditions)){const ce=p.conditions.filter(Me=>Me!=null),le=p.op==="or"?"or":p.op==="not"?"not":"and";if(ce.length===0)return i(R(Q,X),X,1);const ge=ue(ce[0],Q,X);for(let Me=1;Me<ce.length;Me++){const be=ue(ce[Me],Q,X);if(le==="or")for(let ye=0;ye<X;ye++)ge[ye]|=be[ye];else for(let ye=0;ye<X;ye++)ge[ye]&=be[ye];j(Q,be)}if(le==="not")for(let Me=0;Me<X;Me++)ge[Me]^=1;return ge}return J(p,Q,R(Q,X))}function de(p,Q){return ue(p,Q,Q.count|0)}function Oe(p,Q){if(!p||!Q)return p||null;const X=p;if(Array.isArray(X.conditions)){if((X.op==="or"?"or":X.op==="not"?"not":"and")!=="and")return Ae(X,Q)?null:p;const le=[];for(const ge of X.conditions){const Me=Oe(ge,Q);Me&&le.push(Me)}return le.length?{...X,op:"and",conditions:le}:null}return X.col===Q?null:p}function Ae(p,Q){if(!p||typeof p!="object")return!1;const X=p;if(X.col===Q)return!0;if(Array.isArray(X.conditions)){for(const ce of X.conditions)if(Ae(ce,Q))return!0}return!1}function Se(p,Q,X){if(X&&X.length>=Q){let Me=0;for(let be=0;be<Q;be++)p[be]&&(X[Me++]=be);return X.subarray(0,Me)}let ce=0;for(let Me=0;Me<Q;Me++)ce+=p[Me]?1:0;const le=new Uint32Array(ce);let ge=0;for(let Me=0;Me<Q;Me++)p[Me]&&(le[ge++]=Me);return le}const D=new Map;function x(p){if(!(!p||typeof p!="object"))for(const[Q,X]of Object.entries(p))X&&typeof X.compile=="function"&&D.set(Q,X)}function fe(p){return typeof p=="string"?D.get(p):void 0}}),Ce("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return te}});const ae=me("packages/core/src/compute/handle.js"),he=ae.dictSize,W=ae.identity,U=ae.presenceReader,_=ae.rowCount,Z=ae.valueReader,E="",z="\\0",re=1<<20;function Y(H,T,V,ne){const R=H.length,j=H.map(t=>Z(t)),i=Array.isArray(ne)&&ne.some(Boolean),a=i?j.map((t,l)=>ne[l]?m=>ne[l](t(m)):t):j;if(!i&&R>0&&H.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=H.map(m=>he(m.dict)+1);let l=1;for(let m=0;m<R;m++)l*=t[m];if(l<=Number.MAX_SAFE_INTEGER){const m=H.map(r=>r.values),e=H.map(r=>U(r)),d=r=>{let n=0;for(let c=0;c<R;c++){const g=e[c],A=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+A}return n},f=new Float64Array(V);for(let r=0;r<V;r++)f[r]=d(T[r]);return{packed:f,strings:null,product:l,readers:a,keyOf:d}}}const h=t=>{let l="";for(let m=0;m<R;m++){const e=a[m](t);l+=(m===0?"":E)+(e==null?z:String(e))}return l},u=new Array(V);for(let t=0;t<V;t++)u[t]=h(T[t]);return{packed:null,strings:u,product:1/0,readers:a,keyOf:h}}function se(H,T,V,ne){const R=new Uint32Array(ne+1);for(let s=0;s<V;s++)R[T[s]+1]++;for(let s=0;s<ne;s++)R[s+1]+=R[s];const j=new Uint32Array(V),i=R.slice(0,ne);for(let s=0;s<V;s++)j[i[T[s]]++]=H[s];const a=new Array(ne);for(let s=0;s<ne;s++)a[s]=j.subarray(R[s],R[s+1]);return a}function te(H,T,V={}){const ne=H||[],R=T||W(_(ne[0],V)),j=R.length;if(ne.length===0||j===0)return{keys:[],buckets:[]};const{packed:i,strings:a,product:s,readers:h}=Y(ne,R,j,V.project),u=new Uint32Array(j);let t=0,l=null;if(i&&s<=Math.max(1024,Math.min(re,j*4))){const f=s,r=new Int32Array(f).fill(-1);for(let n=0;n<j;n++)r[i[n]]=0;for(let n=0;n<f;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<j;n++)u[n]=r[i[n]];l=new Float64Array(t);for(let n=0;n<f;n++)r[n]>=0&&(l[r[n]]=n)}else if(i){const f=new Map;for(let r=0;r<j;r++){const n=i[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}l=new Float64Array(t);for(const[r,n]of f)l[n]=r}else{const f=new Map;for(let r=0;r<j;r++){const n=a[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}}const m=se(R,u,j,t),e=new Array(t);for(let f=0;f<t;f++){const r=m[f][0],n=new Array(h.length);for(let c=0;c<h.length;c++)n[c]=h[c](r);e[f]=n}const d={keys:e,buckets:m};return l&&(d.packed=l),d}}),Ce("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=ae.dictSize,_=ae.dictValue,Z=Object.freeze(["equal","quantile","log"]),E=Object.freeze(["hour","day","week","month","quarter","year"]),z=20,re=50,Y=1e4;function se(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const A=c&&c.base;if(A==="date"||A==="datetime"||A==="time"||A==="dateString")return"date";switch(n.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return A==="number"?"numeric":A==="boolean"?"boolean":A==="text"?"category":"none"}}function te(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return P=>c[P];const A=W(n);return P=>H(A(P))}function H(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const c=Number(n);if(Number.isFinite(c))return c;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function T(n,c,g,A=re){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:U(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const P=W(n),q=c?c.length:g,L=new Set;for(let v=0;v<q;v++){const G=P(c?c[v]:v);if(G!=null&&(L.add(G),L.size>A))return{cardinality:L.size,exact:!1}}return{cardinality:L.size,exact:!0}}const V=36e5,ne=864e5;function R(n,c=z){const g=Number.isFinite(n)&&n>0?n:0,A=Math.max(1,c)*2;return g/V<=A?"hour":g/ne<=A?"day":g/(7*ne)<=A?"week":g/(30*ne)<=A?"month":g/(91*ne)<=A?"quarter":"year"}function j(n,c){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(c){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const A=(g.getDay()+6)%7;return g.setDate(g.getDate()-A),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,c){const g=new Date(n);switch(c){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function a(n,c,g){const A=te(n),P=he(n),q=c?c.length:g;let L=1/0,v=-1/0,G=0,S=0;for(let N=0;N<q;N++){const I=c?c[N]:N;if(P&&!P(I)){G++;continue}const K=A(I);if(!Number.isFinite(K)){G++;continue}K<L&&(L=K),K>v&&(v=K),S++}return{min:L,max:v,nulls:G,finite:S}}function s(n,c,g,A){const P=te(n),q=he(n),L=c?c.length:g,v=L>A?L/A:1,G=[];for(let N=0;N<L;N+=v){const I=c?c[Math.floor(N)]:Math.floor(N);if(q&&!q(I))continue;const K=P(I);Number.isFinite(K)&&G.push(K)}const S=Float64Array.from(G);return S.sort(),S}function h(n,c,g,A={}){const P=A.kind||se(n,A.type);return P==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:P==="boolean"?u(n,c,g):P==="category"?t(n,c,g,A):l(n,c,g,P,A)}function u(n,c,g){const A=he(n);let P=0;if(A){const L=c?c.length:g;for(let v=0;v<L;v++)A(c?c[v]:v)||P++}const q=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&q.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:q}}function t(n,c,g,A){const P=A.cardinalityLimit??re,{cardinality:q}=T(n,c,g,P);if(q>P&&(A.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:q};const L=W(n),v=c?c.length:g,G=new Map;let S=0;for(let ee=0;ee<v;ee++){const J=L(c?c[ee]:ee);if(J==null||J===""){S++;continue}if(Array.isArray(J)){if(!J.length){S++;continue}for(const ue of J)G.set(ue,(G.get(ue)||0)+1);continue}G.set(J,(G.get(J)||0)+1)}let N=[...G.entries()];A.order==="alpha"?N.sort((ee,J)=>String(ee[0]).localeCompare(String(J[0]))):N.sort((ee,J)=>J[1]-ee[1]);let I=0,K=0;if(N.length>P){K=N.length-P;for(let ee=P;ee<N.length;ee++)I+=N[ee][1];N=N.slice(0,P)}const B=N.map(([ee])=>({value:ee,label:String(ee)}));return I>0&&B.push({remainder:!0,label:`Other (${K} values)`}),S>0&&B.push({null:!0,label:"Empty"}),{kind:"category",buckets:B,cardinality:q}}function l(n,c,g,A,P){const{min:q,max:L,nulls:v,finite:G}=a(n,c,g);if(!G)return{kind:A,buckets:v?[{null:!0,label:"Empty"}]:[],empty:!0};const S=Math.max(1,Math.floor(P.buckets||z));let N=[];if(A==="date"){const K=E.includes(P.granularity)?P.granularity:R(L-q,S);let B=j(q,K);for(;B<=L&&N.length<4096;){const ee=i(B,K);if(!(ee>B))break;N.push({from:B,to:ee}),B=ee}return{kind:A,buckets:m(N,v),granularity:K}}const I=Z.includes(P.strategy)?P.strategy:"equal";if(I==="quantile"){const K=s(n,c,g,Y);if(K.length){const B=[K[0]];for(let ee=1;ee<S;ee++){const J=K[Math.min(K.length-1,Math.floor(ee/S*K.length))];J>B[B.length-1]&&B.push(J)}B.push(L);for(let ee=0;ee<B.length-1;ee++)N.push({from:B[ee],to:B[ee+1]})}}else if(I==="log"&&q>0){const K=Math.log10(q),ee=(Math.log10(L)-K)/S||1;for(let J=0;J<S;J++)N.push({from:10**(K+J*ee),to:10**(K+(J+1)*ee)})}if(!N.length){const K=(L-q)/S||1;for(let B=0;B<S;B++)N.push({from:q+B*K,to:q+(B+1)*K})}return N[N.length-1].to=L,{kind:A,buckets:m(N,v),strategy:I,min:q,max:L}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,A,P){const q=A&&A.buckets||[],L=P&&P.length>=q.length?P.subarray(0,q.length):new Uint32Array(q.length);if(L.fill(0),!n||!q.length)return L;const v=q.length-1,G=!!q[v]&&q[v].null===!0,S=c?c.length:g;if(A.kind==="boolean"){const ee=W(n);for(let J=0;J<S;J++){const ue=ee(c?c[J]:J);if(ue==null){G&&L[v]++;continue}L[ue?1:0]++}return L}if(A.kind==="category"){const ee=new Map;for(let de=0;de<q.length;de++)!q[de].null&&!q[de].remainder&&ee.set(q[de].value,de);const J=q.findIndex(de=>de.remainder),ue=W(n);for(let de=0;de<S;de++){const Oe=ue(c?c[de]:de);if(Oe==null||Oe===""){G&&L[v]++;continue}if(Array.isArray(Oe)){if(!Oe.length){G&&L[v]++;continue}for(const Se of Oe){const D=ee.get(Se);D!==void 0?L[D]++:J>=0&&L[J]++}continue}const Ae=ee.get(Oe);Ae!==void 0?L[Ae]++:J>=0&&L[J]++}return L}const N=G?q.length-1:q.length,I=new Float64Array(N+1);for(let ee=0;ee<N;ee++)I[ee]=q[ee].from;I[N]=N?q[N-1].to:0;const K=te(n),B=he(n);for(let ee=0;ee<S;ee++){const J=c?c[ee]:ee;if(B&&!B(J)){G&&L[v]++;continue}const ue=K(J);if(!Number.isFinite(ue)){G&&L[v]++;continue}const de=d(I,N,ue);de>=0&&L[de]++}return L}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let A=0,P=c-1;for(;A<P;){const q=A+P+1>>>1;g>=n[q]?A=q:P=q-1}return A}function f(n,c,g,A={}){const P=A.bounds||h(n,A.boundsIndices??c,g,A);return{bounds:P,counts:e(n,c,g,P)}}const r=f}),Ce("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ne}});const ae=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,W=1e-300;function U(R){if(R<.5)return Math.log(Math.PI/Math.sin(Math.PI*R))-U(1-R);const j=R-1;let i=.9999999999998099;const a=j+7.5;for(let s=0;s<ae.length;s++)i+=ae[s]/(j+s+1);return .5*Math.log(2*Math.PI)+(j+.5)*Math.log(a)-a+Math.log(i)}function _(R,j,i){const a=R+j,s=R+1,h=R-1;let u=1,t=1-a*i/s;Math.abs(t)<W&&(t=W),t=1/t;let l=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(j-m)*i/((h+e)*(R+e));t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t,l*=t*u,d=-(R+m)*(a+m)*i/((R+e)*(s+e)),t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t;const f=t*u;if(l*=f,Math.abs(f-1)<he)break}return l}function Z(R,j,i){if(!(R>0)||!(j>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const a=Math.exp(U(R+j)-U(R)-U(j)+R*Math.log(i)+j*Math.log(1-i));return i<(R+1)/(R+j+2)?a*_(R,j,i)/R:1-a*_(j,R,1-i)/j}function E(R){if(!(R>0)||!(R<1))return R===0?-1/0:R===1?1/0:Number.NaN;const j=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],a=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],s=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],h=.02425;let u,t,l;R<h?(u=Math.sqrt(-2*Math.log(R)),l=(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1)):R<=1-h?(u=R-.5,t=u*u,l=(((((j[0]*t+j[1])*t+j[2])*t+j[3])*t+j[4])*t+j[5])*u/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(u=Math.sqrt(-2*Math.log(1-R)),l=-(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1));const e=(.5*z(-l/Math.SQRT2)-R)*Math.sqrt(2*Math.PI)*Math.exp(l*l/2);return l-e/(1+l*e/2)}function z(R){const j=Math.abs(R),i=2/(2+j),a=4*i-2,s=[-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 h=0,u=0,t;for(let m=s.length-1;m>0;m--)t=u,u=a*u-h+s[m],h=t;const l=i*Math.exp(-j*j+.5*(s[0]+a*u)-h);return R>=0?l:2-l}function re(R){return .5*z(-R/Math.SQRT2)}function Y(R,j){if(!(j>0)||!Number.isFinite(R))return Number.NaN;const i=.5*Z(j/2,.5,j/(j+R*R));return R>0?1-i:i}function se(R,j){if(!(R>0)||!(R<1)||!(j>0))return Number.NaN;if(j>1e7)return E(R);let i=-1e4,a=1e4,s=E(R);const h=U(j/2)+U(.5)-U((j+1)/2);for(let u=0;u<60;u++){const t=Y(s,j);t<R?i=s:a=s;const l=Math.exp(-((j+1)/2)*Math.log(1+s*s/j)-h)/Math.sqrt(j),m=l>0?(t-R)/l:0;if(Math.abs(m)<1e-12)break;const e=s-m;if(s=e>i&&e<a&&Number.isFinite(e)?e:(i+a)/2,a-i<1e-12)break}return s}function te(R,j){let i=R,a=1/R,s=a;for(let h=0;h<300&&(i+=1,s*=j/i,a+=s,!(Math.abs(s)<Math.abs(a)*he));h++);return a*Math.exp(-j+R*Math.log(j)-U(R))}function H(R,j){let i=j+1-R,a=1/W,s=1/i,h=s;for(let u=1;u<=300;u++){const t=-u*(u-R);i+=2,s=t*s+i,Math.abs(s)<W&&(s=W),a=i+t/a,Math.abs(a)<W&&(a=W),s=1/s;const l=s*a;if(h*=l,Math.abs(l-1)<he)break}return Math.exp(-j+R*Math.log(j)-U(R))*h}function T(R,j){return!(R>0)||!(j>=0)||!Number.isFinite(j)?Number.NaN:j===0?0:j<R+1?te(R,j):1-H(R,j)}function V(R,j){return j>0?T(j/2,R/2):Number.NaN}function ne(R,j){const i=V(R,j);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Ce("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return Z}});function ae(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++)for(let se=0;se<=Y;se++){let te=E[Y][se];for(let H=0;H<se;H++)te-=re[Y][H]*re[se][H];if(Y===se){if(!(te>0))return null;re[Y][se]=Math.sqrt(te)}else re[Y][se]=te/re[se][se]}return re}function he(E,z){const re=E.length,Y=new Array(re).fill(0);for(let te=0;te<re;te++){let H=z[te];for(let T=0;T<te;T++)H-=E[te][T]*Y[T];Y[te]=H/E[te][te]}const se=new Array(re).fill(0);for(let te=re-1;te>=0;te--){let H=Y[te];for(let T=te+1;T<re;T++)H-=E[T][te]*se[T];se[te]=H/E[te][te]}return se}function W(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++){const se=new Array(z).fill(0);se[Y]=1;const te=he(E,se);for(let H=0;H<z;H++)re[H][Y]=te[H]}return re}function U(E,z,re){const Y=E.length,se=Y?E[0].length:0,te=Array.from({length:se},()=>new Array(se).fill(0)),H=new Array(se).fill(0);for(let T=0;T<Y;T++){const V=re?re[T]:1,ne=E[T];for(let R=0;R<se;R++){const j=V*ne[R];H[R]+=j*z[T];for(let i=R;i<se;i++)te[R][i]+=j*ne[i]}}for(let T=0;T<se;T++)for(let V=0;V<T;V++)te[T][V]=te[V][T];return{xtwx:te,xtwy:H}}function _(E,z){return E.map(re=>re.reduce((Y,se,te)=>Y+se*z[te],0))}function Z(E,z){let re=0;for(let Y=0;Y<E.length;Y++){let se=0;for(let te=0;te<E.length;te++)se+=z[Y][te]*E[te];re+=E[Y]*se}return re}}),Ce("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return te}});class ae{#t=0;#e=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.#t}add(T){if(!Number.isFinite(T))return;this.#t++;const V=T-this.#e;this.#e+=V/this.#t,this.#n+=V*(T-this.#e)}merge(T){if(T.#t===0)return;if(this.#t===0){this.#t=T.#t,this.#e=T.#e,this.#n=T.#n;return}const V=this.#t+T.#t,ne=T.#e-this.#e;this.#e+=ne*(T.#t/V),this.#n+=T.#n+ne*ne*(this.#t*T.#t/V),this.#t=V}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const T=this.variance();return T===null?null:Math.sqrt(T)}stddevP(){const T=this.varianceP();return T===null?null:Math.sqrt(T)}}class he{#t=[];#e=0;#n;#r;constructor(T,V=Math.random){if(!(T>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(T),this.#r=V}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.#e}get size(){return this.#t.length}add(T){if(!Number.isFinite(T))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(T);return}const V=Math.floor(this.#r()*this.#e);V<this.#n&&(this.#t[V]=T)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let T=0;for(const V of this.#t)T+=V;return T/this.#t.length}quantile(T){const V=this.#t.length;if(!V)return null;const ne=this.#t.slice().sort((a,s)=>a-s);if(V===1)return ne[0];const R=(V-1)*Math.min(1,Math.max(0,T)),j=Math.floor(R),i=Math.ceil(R);return j===i?ne[j]:ne[j]+(R-j)*(ne[i]-ne[j])}}function W(H){return H^=H>>>16,H=Math.imul(H,2246822507),H^=H>>>13,H=Math.imul(H,3266489909),H^=H>>>15,H>>>0}function U(H){if(typeof H=="number"){const ne=new DataView(new ArrayBuffer(8));return ne.setFloat64(0,H===0?0:H),W(ne.getUint32(0)^ne.getUint32(4))}const T=typeof H=="string"?H:String(H);let V=2166136261;for(let ne=0;ne<T.length;ne++)V^=T.charCodeAt(ne),V=Math.imul(V,16777619);return W(V)}class _{#t;#e;#n;constructor(T=14){const V=Math.floor(T);if(V<4||V>16)throw new RangeError("HLL precision must be 4..16");this.#t=V,this.#e=1<<V,this.#n=new Uint8Array(this.#e)}static errorBoundFor(T=14){const V=1<<Math.floor(T),ne=1.04/Math.sqrt(V);return Object.freeze({kind:"probabilistic",metric:"relative",value:ne,statement:`distinct count within ~${(ne*100).toFixed(2)}% relative standard error (m=${V} buckets)`})}errorBound(){return _.errorBoundFor(this.#t)}add(T){const V=U(T),ne=V&this.#e-1,R=V>>>this.#t|1<<32-this.#t;let j=1,i=R;for(;(i&1)===0;)j++,i>>>=1;j>this.#n[ne]&&(this.#n[ne]=j)}count(){const T=this.#e,V=32-this.#t,ne=new Float64Array(V+2);for(let i=0;i<T;i++)ne[this.#n[i]]++;let R=T*z(1-ne[V+1]/T);for(let i=V;i>=1;i--)R=.5*(R+ne[i]);R+=T*E(ne[0]/T);const j=Z*T*T/R;return Math.round(j)}}const Z=.5/Math.log(2);function E(H){if(H===1)return 1/0;let T=1,V=H,ne;do H*=H,ne=V,V+=H*T,T+=T;while(V!==ne);return V}function z(H){if(H===0||H===1)return 0;let T=1,V=1-H,ne;do H=Math.sqrt(H),ne=V,T*=.5,V-=(1-H)**2*T;while(V!==ne);return V/3}class re{#t=new Map;#e;#n=0;constructor(T){if(!(T>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(T)}errorBoundFor(T){const V=T/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:V,statement:`each count overestimates the truth by at most N/m = ${V.toFixed(2)} (N=${T}, m=${this.#e})`})}get seen(){return this.#n}add(T){this.#n++;const V=this.#t.get(T);if(V){V.count++;return}if(this.#t.size<this.#e){this.#t.set(T,{count:1,error:0});return}let ne,R=1/0;for(const[j,i]of this.#t)i.count<R&&(R=i.count,ne=j);this.#t.delete(ne),this.#t.set(T,{count:R+1,error:R})}top(T=this.#e){return[...this.#t.entries()].map(([ne,R])=>({item:ne,count:R.count,error:R.error})).sort((ne,R)=>R.count-ne.count).slice(0,Math.max(0,Math.floor(T)))}}class Y{#t;#e=[[]];#n=0;#r;#i;constructor(T=200,V=Math.random){this.#t=Math.max(8,Math.floor(T)),this.#r=V,this.#i=2/3}static errorBoundFor(T=200){const V=1/Math.max(8,Math.floor(T));return Object.freeze({kind:"probabilistic",metric:"rank",value:V,statement:`queried quantile\'s true rank within ~${(V*100).toFixed(2)}% of N of the requested rank (k=${T})`})}errorBound(){return Y.errorBoundFor(this.#t)}get count(){return this.#n}#s(T){const ne=this.#e.length-1-T,R=Math.ceil(this.#t*this.#i**ne);return Math.max(2,R)}add(T){Number.isFinite(T)&&(this.#n++,this.#e[0].push(T),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(T){const V=this.#e[T];V.sort((j,i)=>j-i),T+1>=this.#e.length&&this.#e.push([]);const ne=this.#e[T+1],R=this.#r()<.5?0:1;for(let j=R;j<V.length;j+=2)ne.push(V[j]);this.#e[T]=[];for(let j=0;j<this.#e.length;j++)if(this.#e[j].length>=this.#s(j)){this.#h(j);return}}#u(){const T=[];for(let V=0;V<this.#e.length;V++){const ne=1<<V;for(const R of this.#e[V])T.push({v:R,w:ne})}return T}quantile(T){const V=this.#u();if(!V.length)return null;V.sort((i,a)=>i.v-a.v);let ne=0;for(const i of V)ne+=i.w;const R=Math.min(1,Math.max(0,T))*ne;let j=0;for(const i of V)if(j+=i.w,j>=R)return i.v;return V[V.length-1].v}rank(T){let V=0;for(let ne=0;ne<this.#e.length;ne++){const R=1<<ne;for(const j of this.#e[ne])j<=T&&(V+=R)}return V}}const se=Object.freeze({distinct:_.errorBoundFor(14),median:Y.errorBoundFor(200),p25:Y.errorBoundFor(200),p75:Y.errorBoundFor(200),p90:Y.errorBoundFor(200),p95:Y.errorBoundFor(200),p99:Y.errorBoundFor(200),iqr:Y.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"})}),te={Welford:ae,Reservoir:he,HyperLogLog:_,SpaceSaving:re,KLL:Y,hash32:U,SKETCH_BOUNDS:se}}),Ce("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=me("packages/core/src/compute/special.js"),_=U.studentTQuantile,Z=U.studentT,E=U.normalQuantile,z=U.normalCdf,re=U.chiSquareUpperTail,Y=me("packages/core/src/compute/linalg.js"),se=Y.cholesky,te=Y.choleskySolve,H=Y.choleskyInverse,T=Y.normalEquations,V=Y.quadForm,R=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,j=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"}),a=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 s(b){const k=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(a,b)?a[b]:null;return{stat:b,exact:k,approximate:y}}function h(b,k){const y=k.length,w=new Float64Array(y);let O=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const F=b.values,C=he(b);for(let ie=0;ie<y;ie++){const oe=k[ie];if(C&&C(oe)!==1)continue;const ke=F[oe];Number.isNaN(ke)||(w[O++]=ke)}return w.subarray(0,O)}const $=W(b);for(let F=0;F<y;F++){const C=$(k[F]);if(C==null||C==="")continue;const ie=typeof C=="number"?C:Number(C);Number.isFinite(ie)&&(w[O++]=ie)}return w.subarray(0,O)}function u(b,k){const y=new Map,w=W(b);let O=0;for(let $=0;$<k.length;$++){const F=w(k[$]);if(F==null||F===""||typeof F=="number"&&Number.isNaN(F))continue;const C=typeof F=="object"?String(F):F;y.set(C,(y.get(C)||0)+1),O++}const M=[...y.values()].sort(($,F)=>F-$);return{counts:M,total:O,distinct:M.length}}function t(b){return b.total>0?b.counts.map(k=>k/b.total):[]}function l(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))w+=O*O;return w}function m(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w}function e(b,k){const y=u(b,k);if(!y.total||y.distinct<2)return y.total?1:null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w/Math.log2(y.distinct)}function d(b,k,y=3){const w=u(b,k);if(!w.total)return null;const O=Math.max(1,Math.floor(y));let M=0;for(let $=0;$<Math.min(O,w.counts.length);$++)M+=w.counts[$];return M/w.total}function f(b,k){const y=h(b,k),w=y.length;if(!w)return null;const O=y.slice().sort();if(O[0]<0)return null;let M=0,$=0;for(let F=0;F<w;F++)M+=O[F],$+=(F+1)*O[F];return M===0?0:2*$/(w*M)-(w+1)/w}function r(b){let k=0,y=0,w=0;for(let O=0;O<b.length;O++){const M=b[O];k++;const $=M-y;y+=$/k,w+=$*(M-y)}return{n:k,mean:y,m2:w}}function n(b,k){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const w=(y-1)*Math.min(1,Math.max(0,k)),O=Math.floor(w),M=Math.ceil(w);return O===M?b[O]:b[O]+(w-O)*(b[M]-b[O])}function c(b,k){if(!b.length)return NaN;const y=b.slice().sort();return n(y,k)}function g(b,k){const y=W(b);let w=0,O=0,M=0;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=String(F).toUpperCase();C==="PASS"?w++:C==="FAIL"?O++:C==="WARN"&&M++}return{pass:w+M,fail:O,warn:M,judged:w+M+O}}const A=Object.freeze({hhi:(b,k)=>l(b,k),entropy:(b,k)=>m(b,k),evenness:(b,k)=>e(b,k),top3Share:(b,k)=>d(b,k,3),top10Share:(b,k)=>d(b,k,10),gini:(b,k)=>f(b,k),trimmedMean:(b,k)=>G(h(b,k),.1),winsorizedMean:(b,k)=>S(h(b,k),.1),robustOutliers:(b,k)=>N(h(b,k),3.5),jarqueBera:(b,k)=>I(h(b,k)),variance:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?w/(y-1):null},varianceP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?w/y:null},stddev:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?Math.sqrt(w/(y-1)):null},stddevP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?Math.sqrt(w/y):null},median:(b,k)=>{const y=h(b,k);return y.length?c(y,.5):null},p25:(b,k)=>{const y=h(b,k);return y.length?c(y,.25):null},p75:(b,k)=>{const y=h(b,k);return y.length?c(y,.75):null},p90:(b,k)=>{const y=h(b,k);return y.length?c(y,.9):null},p95:(b,k)=>{const y=h(b,k);return y.length?c(y,.95):null},p99:(b,k)=>{const y=h(b,k);return y.length?c(y,.99):null},iqr:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=y.slice().sort();return n(w,.75)-n(w,.25)},mad:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=c(y,.5),O=new Float64Array(y.length);for(let M=0;M<y.length;M++)O[M]=Math.abs(y[M]-w);return c(O,.5)},range:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=1/0,O=-1/0;for(let M=0;M<y.length;M++)y[M]<w&&(w=y[M]),y[M]>O&&(O=y[M]);return O-w},distinct:(b,k)=>{const y=W(b),w=new Set;for(let O=0;O<k.length;O++){const M=y(k[O]);M==null||M===""||w.add(M instanceof Date?M.getTime():M)}return w.size},mode:(b,k)=>{const y=W(b),w=new Map;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=F instanceof Date?F.getTime():F;w.set(C,(w.get(C)||0)+1)}let O=null,M=1;for(const[$,F]of w)F>M&&(M=F,O=$);return O},skewness:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<3||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let C=0;C<y.length;C++)F+=((y[C]-O)/$)**3;return w/((w-1)*(w-2))*F},kurtosis:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<4||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let oe=0;oe<y.length;oe++)F+=((y[oe]-O)/$)**4;const C=w*(w+1)/((w-1)*(w-2)*(w-3)),ie=3*(w-1)**2/((w-2)*(w-3));return C*F-ie},geomean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]<=0)return null;w+=Math.log(y[O])}return Math.exp(w/y.length)},harmean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]===0)return null;w+=1/y[O]}return y.length/w},sumSquares:(b,k)=>{const y=h(b,k);let w=0;for(let O=0;O<y.length;O++)w+=y[O]*y[O];return w},passRate:(b,k)=>{const{pass:y,judged:w}=g(b,k);return w?y/w:null},failureCount:(b,k)=>g(b,k).fail}),P=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 q(b,k,y){const w=W(b),O=W(k);let M=0,$=0;for(let F=0;F<y.length;F++){const C=y[F],ie=Number(w(C)),oe=Number(O(C));!Number.isFinite(ie)||!Number.isFinite(oe)||(M+=ie*oe,$+=oe)}return $===0?null:M/$}function L(b,k,y){const w=W(b);let O=null,M=y?-1/0:1/0;for(let $=0;$<k.length;$++){const F=k[$],C=Number(w(F));Number.isFinite(C)&&(y?C>M:C<M)&&(M=C,O=F)}return O}function v(b,k,y){const w=W(b),O=W(k);let M=0,$=0,F=0,C=0,ie=0,oe=0;for(let pe=0;pe<y.length;pe++){const ve=y[pe],Le=Number(w(ve)),we=Number(O(ve));!Number.isFinite(Le)||!Number.isFinite(we)||(M++,$+=Le,F+=we,C+=Le*Le,ie+=we*we,oe+=Le*we)}if(M<2)return null;const ke=M*oe-$*F,je=Math.sqrt((M*C-$*$)*(M*ie-F*F));if(je===0)return null;const Pe=ke/je;return Math.max(-1,Math.min(1,Pe))}function G(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((F,C)=>F-C),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w.slice(O,y-O);if(!M.length)return n(w,.5);let $=0;for(const F of M)$+=F;return $/M.length}function S(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w[O],$=w[y-1-O];let F=0;for(const C of w)F+=Math.min($,Math.max(M,C));return F/y}function N(b,k=3.5){if(!b.length)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=n(w,.5),M=w.map(C=>Math.abs(C-O)).sort((C,ie)=>C-ie),$=n(M,.5);if($===0)return null;let F=0;for(const C of w)Math.abs(.6745*(C-O)/$)>k&&F++;return F}function I(b){const k=b.length;if(k<8)return null;let y=0;for(const C of b)y+=C;y/=k;let w=0,O=0,M=0;for(const C of b){const ie=C-y;w+=ie*ie,O+=ie*ie*ie,M+=ie*ie*ie*ie}if(w/=k,O/=k,M/=k,w===0)return null;const $=O/w**1.5,F=M/(w*w)-3;return k/6*($*$+F*F/4)}function K(b,k,y){const w=[];let O=0;for(let C=0;C<b.length;C++){const ie=Number(b[C]),oe=Number(k[C]);!Number.isFinite(ie)||!Number.isFinite(oe)||oe<=0||(w.push([ie,oe]),O+=oe)}if(!w.length||O<=0)return null;if(w.sort((C,ie)=>C[0]-ie[0]),w.length===1)return w[0][0];const M=[];let $=0;for(const[,C]of w)M.push(($+C/2)/O),$+=C;const F=Math.max(0,Math.min(1,y));if(F<=M[0])return w[0][0];if(F>=M[M.length-1])return w[w.length-1][0];for(let C=1;C<M.length;C++){if(F>M[C])continue;const ie=M[C]-M[C-1],oe=ie>0?(F-M[C-1])/ie:0;return w[C-1][0]+(w[C][0]-w[C-1][0])*oe}return w[w.length-1][0]}function B(b,k,y){const w=W(b),O=W(k),M=new Float64Array(y.length),$=new Float64Array(y.length);let F=0;for(let C=0;C<y.length;C++){const ie=y[C],oe=Number(w(ie)),ke=Number(O(ie));!Number.isFinite(oe)||!Number.isFinite(ke)||(M[F]=oe,$[F]=ke,F++)}return{xs:M.subarray(0,F),ys:$.subarray(0,F),n:F}}function ee(b,k,y,w=!1){const{xs:O,ys:M,n:$}=B(b,k,y);if($<2)return null;let F=0,C=0;for(let oe=0;oe<$;oe++)F+=O[oe],C+=M[oe];F/=$,C/=$;let ie=0;for(let oe=0;oe<$;oe++)ie+=(O[oe]-F)*(M[oe]-C);return ie/(w?$:$-1)}function J(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;let $=0,F=0;for(let Le=0;Le<M;Le++)$+=w[Le],F+=O[Le];$/=M,F/=M;let C=0,ie=0,oe=0;for(let Le=0;Le<M;Le++){const we=w[Le]-$,De=O[Le]-F;C+=we*we,ie+=we*De,oe+=De*De}if(C===0)return null;const ke=ie/C,je=F-ke*$,Pe=oe===0?1:Math.max(0,Math.min(1,ie*ie/(C*oe))),pe=Math.max(0,oe-ke*ie),ve=M>2?Math.sqrt(pe/(M-2)/C):0;return{slope:ke,intercept:je,r2:Pe,stdError:ve,n:M}}const ue=new Set(["ols","wls","robust"]),de=new Set(["quantile"]),Oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),Ae=1.345;function Se(b,k,y){const{xtwx:w,xtwy:O}=T(b,k,y),M=se(w);if(!M)return null;const $=te(M,O),F=H(M),C=D(b,$),ie=k.map((oe,ke)=>oe-C[ke]);return{beta:$,cov:F,fitted:C,residuals:ie}}function D(b,k){return b.map(y=>y.reduce((w,O,M)=>w+O*k[M],0))}function x(b,k){const y=b.length,w=b.map(ie=>ie[k]),O=b.map(ie=>[1,...ie.filter((oe,ke)=>ke!==k)]),M=Se(O,w,null);if(!M)return 1;const $=w.reduce((ie,oe)=>ie+oe,0)/y;let F=0,C=0;for(let ie=0;ie<y;ie++)F+=M.residuals[ie]**2,C+=(w[ie]-$)**2;return C===0?1:Math.max(0,Math.min(1,1-F/C))}function fe(b){const k=[...b].sort((O,M)=>O-M),y=p(k),w=b.map(O=>Math.abs(O-y)).sort((O,M)=>O-M);return p(w)/.6745}function p(b){const k=b.length;if(!k)return 0;const y=Math.floor(k/2);return k%2?b[y]:(b[y-1]+b[y])/2}function Q(b,k,y={}){const w=y.method||"ols";if(Oe.has(w))throw new Error(`[lattice] regression method "${w}" is out of scope; use ols, wls or robust.`);if(de.has(w))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ue.has(w))throw new Error(`[lattice] unknown regression method "${w}"; use ols, wls or robust.`);const O=Array.isArray(k)?k.length:0,M=O&&Array.isArray(b[0])?b[0].length:0,$=M+1;if(!(O>$))return null;for(let Te=0;Te<O;Te++){if(!Number.isFinite(k[Te])||!Array.isArray(b[Te])||b[Te].length!==M)return null;for(let Fe=0;Fe<M;Fe++)if(!Number.isFinite(b[Te][Fe]))return null}let F=null;if(w==="wls"){if(F=y.weights,!Array.isArray(F)||F.length!==O)return null;for(let Te=0;Te<O;Te++)if(!(F[Te]>0)||!Number.isFinite(F[Te]))return null}const C=b.map(Te=>[1,...Te]);let ie,oe=null;if(w==="robust"){if(ie=Se(C,k,null),!ie)return null;for(let Te=0;Te<50;Te++){const Fe=fe(ie.residuals);if(!(Fe>0))break;const Ue=ie.residuals.map(Ge=>{const xe=Math.abs(Ge/Fe);return xe<=Ae?1:Ae/xe}),qe=Se(C,k,Ue);if(!qe)return null;const Je=qe.beta.reduce((Ge,xe,it)=>Math.max(Ge,Math.abs(xe-ie.beta[it])),0);if(ie=qe,oe=Ue,Je<1e-10)break}}else if(ie=Se(C,k,F),!ie)return null;const ke=w==="robust"?oe:F,{beta:je,cov:Pe,fitted:pe,residuals:ve}=ie;let Le=0,we=0,De=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Le+=Fe*ve[Te]**2,we+=Fe,De+=Fe*k[Te]}const $e=De/we;let Ke=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Ke+=Fe*(k[Te]-$e)**2}const He=O-$,Qe=Le/He,Ve=Ke===0?1:Math.max(0,Math.min(1,1-Le/Ke)),ut=1-(1-Ve)*(O-1)/He,nt=Array.isArray(y.names)&&y.names.length===M?y.names:b[0].map((Te,Fe)=>`x${Fe+1}`),Ze=tt(y.confidence),rt=He>0?_(1-(1-Ze)/2,He):1/0,Lt=je.map((Te,Fe)=>{const Ue=Math.sqrt(Math.max(0,Qe*Pe[Fe][Fe])),qe=Ue>0?Te/Ue:Te===0?0:1/0,Je=Number.isFinite(qe)?2*(1-Z(Math.abs(qe),He)):0,Ge=Number.isFinite(rt)?rt*Ue:null;return{name:Fe===0?"(intercept)":nt[Fe-1],estimate:Te,stdError:Ue,t:qe,p:Math.max(0,Math.min(1,Je)),lower:Ge===null?null:Te-Ge,upper:Ge===null?null:Te+Ge}}),bt=new Array(O),yt=new Array(O);for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1,Ue=Math.max(0,Math.min(1,Fe*V(C[Te],Pe)));bt[Te]=Ue;const qe=(1-Ue)**2;yt[Te]=qe>0&&Qe>0?ve[Te]**2/($*Qe)*(Ue/qe):null}const Ft=b[0].map((Te,Fe)=>{if(M<2)return 1;const Ue=x(b,Fe);return Ue>=1?1/0:1/(1-Ue)});let pt=null;{const Te=ve.map(Ue=>Ue*Ue),Fe=Se(C,Te,null);if(Fe){const Ue=Te.reduce((et,Ct)=>et+Ct,0)/O;let qe=0,Je=0;for(let et=0;et<O;et++)qe+=Fe.residuals[et]**2,Je+=(Te[et]-Ue)**2;const Ge=Je===0?0:Math.max(0,Math.min(1,1-qe/Je)),xe=O*Ge,it=re(xe,M);pt={statistic:xe,df:M,p:it,heteroscedastic:it<.05}}}let wt=null;if(M===1){const Te=b.map((Fe,Ue)=>Ue).sort((Fe,Ue)=>b[Fe][0]-b[Ue][0]);wt={confidence:Ze,points:Te.map(Fe=>{const Ue=C[Fe],qe=Math.sqrt(Math.max(0,Qe*V(Ue,Pe)));return{x:b[Fe][0],yhat:pe[Fe],lower:pe[Fe]-rt*qe,upper:pe[Fe]+rt*qe}})}}return{method:w,coefficients:Lt,r2:Ve,adjR2:ut,n:O,df:He,sigma2:Qe,fitted:pe,residuals:ve,leverage:bt,cooksD:yt,vif:Ft,heteroscedasticity:pt,band:wt,weights:ke?[...ke]:null}}function X(b){const k=b.length,y=Array.from({length:k},(M,$)=>$).sort((M,$)=>b[M]-b[$]),w=new Float64Array(k);let O=0;for(;O<k;){let M=O;for(;M+1<k&&b[y[M+1]]===b[y[O]];)M++;const $=(O+M)/2+1;for(let F=O;F<=M;F++)w[y[F]]=$;O=M+1}return w}const ce=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function le(b){const k=[.01,.05,.1],y=[ce["1%"],ce["5%"],ce["10%"]];if(b<=y[0]){const M=(Math.log(k[1])-Math.log(k[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(k[0])+M*(b-y[0]))))}if(b>=y[2]){const M=(Math.log(k[2])-Math.log(k[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(k[2])+M*(b-y[2]))))}const w=b<y[1]?0:1,O=(b-y[w])/(y[w+1]-y[w]);return Math.exp(Math.log(k[w])+O*(Math.log(k[w+1])-Math.log(k[w])))}function ge(b,k,y,w){const O=y-w,M=w+3,$=new Array(O),F=new Array(O);let C=!0,ie=w;for(let pe=0;pe<O;pe++){const ve=w+pe,Le=new Float64Array(M);Le[0]=1,Le[1]=pe+1,Le[2]=b[ve];for(let we=1;we<=w;we++)Le[2+we]=k[ve-we];for(let we=1;we<M;we++)Number.isFinite(Le[we])||(ie=Math.min(ie,we-3));$[pe]=Le,F[pe]=k[ve],Number.isFinite(F[pe])||(C=!1)}if(!C)return 0;const{xtwx:oe,xtwy:ke}=T($,F,null);let je=0,Pe=1/0;for(let pe=0;pe<=ie;pe++){const ve=pe+3;if(!(O>ve))continue;const Le=new Array(ve);for(let Ve=0;Ve<ve;Ve++)Le[Ve]=oe[Ve].slice(0,ve);const we=se(Le);if(!we)continue;const De=te(we,ke.slice(0,ve));let $e=0;for(let Ve=0;Ve<O;Ve++){const ut=$[Ve];let nt=0;for(let Ze=0;Ze<ve;Ze++)nt+=ut[Ze]*De[Ze];$e+=(F[Ve]-nt)**2}const He=$e/(O-ve)*(O-ve);if(!(He>0))continue;const Qe=O*Math.log(He/O)+2*ve;Qe<Pe&&(Pe=Qe,je=pe)}return je}function Me(b,k={}){const y=[];for(let Pe=0;Pe<b.length;Pe++){const pe=Number(b[Pe]);Number.isFinite(pe)&&y.push(pe)}const w=y.length,O=w-1;if(w<8||O<6)return null;const M=new Array(O);for(let Pe=0;Pe<O;Pe++)M[Pe]=y[Pe+1]-y[Pe];let $=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.ceil(12*(w/100)**.25);$=Math.max(0,Math.min($,Math.floor((O-5)/2)));const F=(Pe,pe)=>{const ve=[],Le=[];for(let we=pe;we<O;we++){const De=[we-pe+1,y[we]];for(let $e=1;$e<=Pe;$e++)De.push(M[we-$e]);ve.push(De),Le.push(M[we])}return Q(ve,Le,{method:"ols"})},C=ge(y,M,O,$),ie=F(C,C);if(!ie||!ie.coefficients[2])return null;const oe=ie.coefficients[2].t,ke=le(oe),je=oe<ce["5%"];return{statistic:oe,usedLag:C,nobs:O-C,criticalValues:{...ce},pValue:ke,pApproximate:!0,stationary:je,verdict:je?"stationary":"non-stationary",regression:"ct"}}function be(b,k={}){const y=[];for(let je=0;je<b.length;je++){const Pe=Number(b[je]);Number.isFinite(Pe)&&y.push(Pe)}const w=y.length;if(w<3)return null;let O=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.min(10,w-1);O=Math.max(1,Math.min(O,w-1));let M=0;for(const je of y)M+=je;M/=w;const $=y.map(je=>je-M);let F=0;for(const je of $)F+=je*je;F/=w;const C=new Array(O+1).fill(0);C[0]=1;for(let je=1;je<=O;je++){let Pe=0;for(let pe=je;pe<w;pe++)Pe+=$[pe]*$[pe-je];C[je]=F>0?Pe/w/F:0}const ie=new Array(O+1).fill(0);ie[0]=1;let oe=[];for(let je=1;je<=O;je++){let Pe=C[je];for(let we=1;we<je;we++)Pe-=oe[we-1]*C[je-we];let pe=1;for(let we=1;we<je;we++)pe-=oe[we-1]*C[we];const ve=pe!==0?Pe/pe:0,Le=new Array(je);for(let we=1;we<je;we++)Le[we-1]=oe[we-1]-ve*oe[je-1-we];Le[je-1]=ve,ie[je]=ve,oe=Le}const ke=1.96/Math.sqrt(w);return{acf:C,pacf:ie,bounds:{upper:ke,lower:-ke},n:w,nlags:O,approximate:!0}}function ye(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;const $=X(w),F=X(O);let C=0,ie=0;for(let Pe=0;Pe<M;Pe++)C+=$[Pe],ie+=F[Pe];C/=M,ie/=M;let oe=0,ke=0,je=0;for(let Pe=0;Pe<M;Pe++){const pe=$[Pe]-C,ve=F[Pe]-ie;oe+=pe*ve,ke+=pe*pe,je+=ve*ve}return ke===0||je===0?null:Math.max(-1,Math.min(1,oe/Math.sqrt(ke*je)))}function Re(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2||M>j)return null;let $=0,F=0,C=0,ie=0;for(let je=0;je<M;je++)for(let Pe=je+1;Pe<M;Pe++){const pe=Math.sign(w[je]-w[Pe]),ve=Math.sign(O[je]-O[Pe]),Le=pe*ve;Le>0?$++:Le<0?F++:pe===0&&ve===0||(pe===0?C++:ie++)}const oe=$+F+ie,ke=$+F+C;return oe===0||ke===0?null:($-F)/Math.sqrt(oe*ke)}function Ne(b,k={}){const y=b.length;if(y<2)return null;const w=b[0],O=b[y-1],M=[];for(let we=1;we<y;we++){const De=b[we-1];De!==0&&M.push((b[we]-De)/Math.abs(De))}let $=null;if(M.length>1){let we=0;for(const $e of M)we+=$e;we/=M.length;let De=0;for(const $e of M)De+=($e-we)**2;$=Math.sqrt(De/(M.length-1))}const F=Number(k.periodsPerYear)>0?Number(k.periodsPerYear):null;let C=b[0],ie=0,oe=0,ke=0,je=0;for(let we=1;we<y;we++){if(b[we]>C){C=b[we],ie=we;continue}if(C<=0)continue;const De=(C-b[we])/C;De>oe&&(oe=De,ke=ie,je=we)}let Pe=null;if(y>2){let we=0;for(let Ke=0;Ke<y;Ke++)we+=b[Ke];we/=y;let De=0,$e=0;for(let Ke=0;Ke<y;Ke++){const He=b[Ke]-we;$e+=He*He,Ke>0&&(De+=He*(b[Ke-1]-we))}Pe=$e>0?De/$e:null}let pe=0,ve=0;for(const we of M)we>0?pe++:we<0&&ve++;let Le=null;if(w>0&&O>0){const we=(O/w)**(1/(y-1))-1;Le=F?(1+we)**F-1:we}return{n:y,first:w,last:O,change:O-w,changePercent:w===0?null:(O-w)/Math.abs(w)*100,volatility:$,annualisedVolatility:$!==null&&F?$*Math.sqrt(F):null,growth:Le,maxDrawdown:oe,maxDrawdownFrom:ke,maxDrawdownTo:je,autocorrelation:Pe,upDays:pe,downDays:ve}}const Ee=1.128,Be=3.267;function ze(b){const k=b.length;if(k<2)return null;const y=[];for(let O=1;O<k;O++)y.push(Math.abs(b[O]-b[O-1]));const w=y.reduce((O,M)=>O+M,0)/y.length;return{ranges:y,centre:w,upper:Be*w,lower:0}}function We(b){const k=b.length;if(k<2)return null;let y=0;for(let O=1;O<k;O++)y+=Math.abs(b[O]-b[O-1]);const w=y/(k-1);return{sigma:w/Ee,meanRange:w}}function Xe(b,k){const y=b.length;if(y<2||!k)return null;const w=Number.isFinite(Number(k.lower))?Number(k.lower):null,O=Number.isFinite(Number(k.upper))?Number(k.upper):null;if(w===null&&O===null)return null;let M=0;for(let pe=0;pe<y;pe++)M+=b[pe];M/=y;let $=0;for(let pe=0;pe<y;pe++)$+=(b[pe]-M)**2;const F=Math.sqrt($/(y-1)),C=We(b),ie=C?C.sigma:null,oe=pe=>{if(!pe||pe<=0)return{index:null,k:null};const Le=w!==null&&O!==null?(O-w)/(6*pe):null,we=O!==null?(O-M)/(3*pe):1/0,De=w!==null?(M-w)/(3*pe):1/0;return{index:Le,k:Math.min(we,De)}},ke=oe(ie),je=oe(F);let Pe=0;for(let pe=0;pe<y;pe++){if(w!==null&&b[pe]<w){Pe++;continue}O!==null&&b[pe]>O&&Pe++}return{n:y,mean:M,lower:w,upper:O,target:Number.isFinite(Number(k.target))?Number(k.target):null,sigmaWithin:ie,sigmaOverall:F,cp:ke.index,cpk:ke.k,pp:je.index,ppk:je.k,outOfSpec:Pe,defectRate:y?Pe/y:null}}function Ye(b){const k=b.length;if(k<2)return null;const y=We(b);if(!y||!(y.sigma>0))return null;let w=0;for(let O=0;O<k;O++)w+=b[O];return w/=k,{centre:w,sigma:y.sigma,upper:w+3*y.sigma,lower:w-3*y.sigma}}function Ie(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=F=>(b[F]-w)/O,$=[];for(let F=0;F<y;F++){if(Math.abs(M(F))>3&&$.push({index:F,rule:1,description:"beyond three sigma"}),F>=2)for(const C of[1,-1]){let ie=0;for(let oe=F-2;oe<=F;oe++)M(oe)*C>2&&ie++;if(ie>=2){$.push({index:F,rule:2,description:"two of three past two sigma"});break}}if(F>=4)for(const C of[1,-1]){let ie=0;for(let oe=F-4;oe<=F;oe++)M(oe)*C>1&&ie++;if(ie>=4){$.push({index:F,rule:3,description:"four of five past one sigma"});break}}if(F>=7)for(const C of[1,-1]){let ie=!0;for(let oe=F-7;oe<=F;oe++)if(M(oe)*C<=0){ie=!1;break}if(ie){$.push({index:F,rule:4,description:"eight in a row on one side"});break}}}return $}function ft(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=C=>(b[C]-w)/O,$=(C,ie,oe,ke)=>{for(const je of[1,-1]){let Pe=0;for(let pe=C;pe<=ie;pe++)M(pe)*je>oe&&Pe++;if(Pe>=ke)return!0}return!1},F=[];for(let C=0;C<y;C++){if(Math.abs(M(C))>3&&F.push({index:C,rule:1,description:"beyond three sigma"}),C>=8)for(const ie of[1,-1]){let oe=!0;for(let ke=C-8;ke<=C;ke++)if(M(ke)*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:2,description:"nine in a row on one side"});break}}if(C>=5)for(const ie of[1,-1]){let oe=!0;for(let ke=C-4;ke<=C;ke++)if((b[ke]-b[ke-1])*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:3,description:ie>0?"six rising":"six falling"});break}}if(C>=13){let ie=!0;for(let oe=C-12;oe<=C;oe++){const ke=b[oe]-b[oe-1],je=b[oe+1<=C?oe+1:oe]-b[oe];if(oe+1>C)break;if(ke===0||je===0||ke>0==je>0){ie=!1;break}}ie&&F.push({index:C,rule:4,description:"fourteen alternating"})}if(C>=2&&$(C-2,C,2,2)&&F.push({index:C,rule:5,description:"two of three past two sigma"}),C>=4&&$(C-4,C,1,4)&&F.push({index:C,rule:6,description:"four of five past one sigma"}),C>=14){let ie=!0;for(let oe=C-14;oe<=C;oe++)if(Math.abs(M(oe))>=1){ie=!1;break}ie&&F.push({index:C,rule:7,description:"fifteen within one sigma"})}if(C>=7){let ie=!0;for(let oe=C-7;oe<=C;oe++)if(Math.abs(M(oe))<=1){ie=!1;break}ie&&F.push({index:C,rule:8,description:"eight beyond one sigma"})}}return F}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,k,y="westernElectric"){return String(y)==="nelson"?ft(b,k):Ie(b,k)}function Mt(b,k,y){let w=0;for(let O=0;O<b.length;O++)(b[O]<k||b[O]>y)&&w++;return w}function Pt(b,k,y,w=20){const O=b.length;if(!O)return[];const M=b[0],$=b[O-1];if($===M)return[{from:M,to:$,count:O}];const F=y-k,C=1.5*F;let ie=F>0?Math.max(M,k-C):M,oe=F>0?Math.min($,y+C):$;oe>ie||(ie=M,oe=$);const ke=F>0?2*F/Math.cbrt(O):(oe-ie)/(Math.ceil(Math.log2(O))+1),je=ke>0?Math.min(w,Math.max(1,Math.ceil((oe-ie)/ke))):1,Pe=(oe-ie)/je,pe=[];for(let ve=0;ve<je;ve++)pe.push({from:ie+ve*Pe,to:ie+(ve+1)*Pe,count:0});for(let ve=0;ve<O;ve++){const Le=Math.min(je-1,Math.max(0,Math.floor((b[ve]-ie)/Pe)));pe[Le].count++}return pe[0].from=M,pe[je-1].to=$,pe}const _e=.95;function tt(b){const k=Number(b);return Number.isFinite(k)&&k>0&&k<1?k:_e}function Nt(b,k=_e){const y=b.length;if(y<2)return null;let w=0;for(let oe=0;oe<y;oe++)w+=b[oe];const O=w/y;let M=0;for(let oe=0;oe<y;oe++){const ke=b[oe]-O;M+=ke*ke}const $=Math.sqrt(M/(y-1)),F=tt(k),ie=_(1-(1-F)/2,y-1)*$/Math.sqrt(y);return{mean:O,lower:O-ie,upper:O+ie,margin:ie,n:y,confidence:F}}function St(b,k,y=_e){const w=Number(b),O=Number(k);if(!(O>0)||!(w>=0)||w>O)return null;const M=tt(y),$=E(1-(1-M)/2),F=w/O,C=$*$,ie=1+C/O,oe=(F+C/(2*O))/ie,ke=$/ie*Math.sqrt(F*(1-F)/O+C/(4*O*O));return{proportion:F,lower:Math.max(0,oe-ke),upper:Math.min(1,oe+ke),n:O,confidence:M}}function vt(b,k=_e){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=tt(k),O=_(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-O,upper:b.slope+O,margin:O,confidence:y}}function Tt(b,k,y=_e){const w=Number(b),O=Number(k);if(!Number.isFinite(w)||!(O>1))return null;const M=tt(y),F=E(1-(1-M)/2)*Math.sqrt(1/(9*O)+w*w/(2*(O-1)));return{index:w,lower:w-F,upper:w+F,margin:F,n:O,confidence:M}}function ht(b,k){return!b||!(b.sd>0)||!Number.isFinite(k)||!Number.isFinite(b.mean)?null:(k-b.mean)/b.sd}function dt(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*z(Math.abs(b)/2)-1)):0}function ot(b,k){const y=new Map,w=W(b);let O=0;for(let M=0;M<k.length;M++){const $=w(k[M]);if($==null||$===""||typeof $=="number"&&Number.isNaN($))continue;const F=$ instanceof Date?$.getTime():typeof $=="object"?String($):$;y.set(F,(y.get(F)||0)+1),O++}return{map:y,total:O}}function mt(b,k,y,w){if(!(k>0)||!(w>0))return null;let O=0;const M=new Set(b.keys());for(const $ of y.keys())M.add($);for(const $ of M){const F=(b.get($)||0)/k,C=(y.get($)||0)/w;O+=Math.abs(F-C)}return O/2}const st=10;function Et(b,k,y){if(y&&y.numeric){const F=h(b,k),{n:C,mean:ie}=r(F),oe=C>0?ht({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:oe,distance:oe===null?0:dt(oe),direction:oe===null?0:Math.sign(oe),subsetN:C,populationN:y.n||0,reliable:C>=st}}const{map:O,total:M}=ot(b,k),$=mt(O,M,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:$,distance:$===null?0:$,direction:0,subsetN:M,populationN:y.total||0,reliable:M>=st}}function gt(b,k){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=W(b);let w=0,O=0;for(let M=0;M<k.length&&w<200;M++){const $=y(k[M]);if($==null||$==="")continue;if($ instanceof Date)return!1;w++;const F=typeof $=="number"?$:Number($);Number.isFinite(F)&&O++}return w===0?!1:O/w>=.9}function Rt(b,k){if(gt(b,k)){const O=h(b,k),{n:M,mean:$,m2:F}=r(O);return{numeric:!0,mean:$,sd:M>0?Math.sqrt(F/M):0,n:M}}const{map:y,total:w}=ot(b,k);return{numeric:!1,map:y,total:w}}}),Ce("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return f}});const ae=me("packages/core/src/internal/util.js"),he=ae.isFunction,W=ae.warnOnce,U=me("packages/core/src/compute/handle.js"),_=U.presenceReader,Z=U.valueComparator,E=U.valueReader,z=me("packages/core/src/compute/statistics.js"),re=z.STAT_FNS,Y=z.STAT_LABELS;function se(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function te(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++){const v=P[n[L]];Number.isNaN(v)||(g+=v)}return g}for(let L=0;L<c;L++){const v=n[L];if(q(v)===1){const G=P[v];Number.isNaN(G)||(g+=G)}}return g}const A=E(r);for(let P=0;P<c;P++){const q=s(A(n[P]));q!==null&&(g+=q)}return g}te.kernel=!0;function H(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++)Number.isNaN(P[n[L]])||g++;return g}for(let L=0;L<c;L++){const v=n[L];q(v)===1&&!Number.isNaN(P[v])&&g++}return g}const A=E(r);for(let P=0;P<c;P++){const q=A(n[P]);q!=null&&!(typeof q=="number"&&Number.isNaN(q))&&g++}return g}H.kernel=!0;function T(r,n){return n.length}T.kernel=!0;function V(r,n){const c=H(r,n);return c===0?null:te(r,n)/c}V.kernel=!0;function ne(r,n,c,g){const A=n.length;if(se(r)){const v=r.values,G=_(r);let S=null;if(!G){for(let N=0;N<A;N++){const I=v[n[N]];Number.isNaN(I)||(S===null||(c<0?I<S:I>S))&&(S=I)}return S}for(let N=0;N<A;N++){const I=n[N];if(G(I)===0)continue;const K=v[I];Number.isNaN(K)||(S===null||(c<0?K<S:K>S))&&(S=K)}return S}const P=E(r),q=Z(g);let L=null;for(let v=0;v<A;v++){const G=P(n[v]);G==null||typeof G=="number"&&Number.isNaN(G)||(L===null||(c<0?q(G,L)<0:q(G,L)>0))&&(L=G)}return L}function R(r,n,c){return ne(r,n,-1,c&&c.locale)}R.kernel=!0;function j(r,n,c){return ne(r,n,1,c&&c.locale)}j.kernel=!0;function i(r,n){return n.length===0?null:E(r)(n[0])}i.kernel=!0;function a(r,n){return n.length===0?null:E(r)(n[n.length-1])}a.kernel=!0;function s(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isNaN(n)?null:n}const h={sum:te,min:R,max:j,avg:V,count:T,first:i,last:a,countValues:H,...re},u=Object.freeze({...Y,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function t(r){return r?typeof r=="string"?u[r]||r:"Total":""}const l=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const c=l.filter(g=>g in h);for(const g of Object.keys(h))c.includes(g)||c.push(g);return c}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const c=E(r),g=[];for(let A=0;A<n.length;A++){const P=c(n[A]);P!=null&&g.push(P)}return g}function f(r,n,c,g){const A=n||[];if(typeof c=="string"){const P=h[c];return P?P(r,A,g):(W(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,A,g):c(d(r,A),g||{}):null}}),Ce("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/internal/util.js").warnOnce,U=me("packages/core/src/compute/handle.js").valueComparator,Z=me("packages/core/src/compute/group.js").packKeys,z=me("packages/core/src/compute/total.js").total,re="|",Y="/",se=2e3;function te(s,h,u){return`${s}${re}${h}${re}${u}`}function H(s,h){let u="";for(let t=0;t<s.length;t++){const l=s[t];u+=(t===0?"":h)+(l==null?"":String(l))}return u}function T(s,h,u={}){const t=u.separator||Y,l=h.length,{keyOf:m,readers:e}=Z(s,h,0),d=new Map,f=[],r=[];for(let L=0;L<l;L++){const v=h[L],G=m(v);if(d.has(G))continue;d.set(G,f.length),r.push(G);const S=new Array(e.length);for(let N=0;N<e.length;N++)S[N]=e[N](v);f.push(S)}const n=U(u.locale),c=f.map((L,v)=>v);c.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=V(G[N],S[N],n);if(I!==0)return I}return L-v});const g=new Array(c.length),A=new Array(c.length),P=new Map;for(let L=0;L<c.length;L++){const v=c[L];g[L]=f[v],A[L]=H(f[v],t),P.set(r[v],L)}return{keys:g,paths:A,idOf:L=>{const v=P.get(m(L));return v===void 0?-1:v}}}function V(s,h,u){const t=s==null,l=h==null;return t||l?t&&l?0:t?1:-1:u(s,h)}function ne(s){const h=s.values||s.totals||[];if(h.length&&typeof h[0]=="object"&&h[0]!==null)return h.filter(m=>m&&m.handle);const u=typeof s.handle=="function"?s.handle:null;if(!u)return h.length&&he("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 t=typeof s.totalOf=="function"?s.totalOf:null,l=[];for(const m of h){const e=u(m);e&&l.push({colId:m,handle:e,fn:t?t(m):"sum"})}return l}function R(s,h,u){if(Array.isArray(s)){const t=u||{};return{...t,pivotHandles:s,order:h||null,groups:t.groups||null}}return s||{}}function j(s,h,u){const t=R(s,h,u),l=t.separator||Y,m=ne(t),e=t.maxColumns===void 0?se:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,f=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(G=>H(G,l)):[""]),n=a(f),{keys:c,paths:g,idOf:A}=T(t.pivotHandles||[],n,t),P=g.length*Math.max(1,m.length),q=i(g,m,l);if(e&&P>e){const G=new Map;return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:G,cells:G,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${P} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:P,maxColumns:e}}}const L=new Map,v=g.length;for(let G=0;G<f.length;G++){const S=f[G],N=r[G]===void 0?"":r[G],I=S.length;if(I===0)continue;const K=new Int32Array(I),B=new Uint32Array(v+1);for(let ue=0;ue<I;ue++){const de=A(S[ue]);K[ue]=de,de>=0&&B[de+1]++}for(let ue=0;ue<v;ue++)B[ue+1]+=B[ue];const ee=new Uint32Array(I),J=B.slice(0,v);for(let ue=0;ue<I;ue++){const de=K[ue];de>=0&&(ee[J[de]++]=S[ue])}for(let ue=0;ue<v;ue++){const de=B[ue],Oe=B[ue+1];if(Oe===de)continue;const Ae=ee.subarray(de,Oe);for(let Se=0;Se<m.length;Se++){const D=m[Se],x=z(D.handle,Ae,D.fn,t.totalContext||{locale:t.locale});L.set(te(N,g[ue],D.colId),x)}}}return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:L,cells:L,error:null}}function i(s,h,u){if(h.length===0)return s.slice();const t=[];for(const l of s)for(const m of h)t.push(`${l}${u}${m.colId}`);return t}function a(s){if(s.length===1)return s[0]||new Uint32Array(0);let h=0;for(const l of s)h+=l?l.length:0;const u=new Uint32Array(h);let t=0;for(const l of s)!l||l.length===0||(u.set(l,t),t+=l.length);return u}}),Ce("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/compute/handle.js").valueComparator,U=me("packages/core/src/compute/total.js").total,Z=me("packages/core/src/compute/group.js").packKeys,E=me("packages/core/src/compute/pivot.js"),z=E.joinPath,re=E.DEFAULT_PATH_SEPARATOR,Y=E.DEFAULT_MAX_COLUMNS,se="";function te(i,a,s={}){const h=s.separator||re,u=i||[],t=a instanceof Uint32Array?a:Uint32Array.from(a||[]),l=t.length;if(u.length===0)return{tuples:[[]],paths:[se],buckets:[t]};const{keyOf:m,readers:e}=Z(u,t,0),d=new Map,f=[],r=[],n=[];for(let L=0;L<l;L++){const v=t[L],G=m(v);let S=d.get(G);if(S===void 0){S=f.length,d.set(G,S),r.push(G);const N=new Array(e.length);for(let I=0;I<e.length;I++)N[I]=e[I](v);f.push(N),n.push([])}n[S].push(v)}const c=he(s.locale),g=f.map((L,v)=>v);g.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=H(G[N],S[N],c);if(I!==0)return I}return L-v});const A=new Array(g.length),P=new Array(g.length),q=new Array(g.length);for(let L=0;L<g.length;L++){const v=g[L];A[L]=f[v],P[L]=z(f[v],h),q[L]=Uint32Array.from(n[v])}return{tuples:A,paths:P,buckets:q}}function H(i,a,s){const h=i==null,u=a==null;return h||u?h&&u?0:h?1:-1:s(i,a)}function T(i,a,s){const h=[];for(let u=0;u<i.length;u++)s.has(i[u])&&h.push(i[u]);return Uint32Array.from(h)}function V(i,a,s,h){return{value:a.length?U(i,a,s,h):null,leaves:a,count:a.length}}function ne(i){const a=i&&i.opts||{},s=a.separator||re,h=a.totalContext||{locale:a.locale},u=(i.measures||[]).filter(P=>P&&P.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),l=te(i.rowHandles||[],t,{...a,separator:s}),m=te(i.columnHandles||[],t,{...a,separator:s}),e=a.maxColumns===void 0?Y:a.maxColumns,d=m.paths.length*Math.max(1,u.length),f=new Map;if(e&&d>e)return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:f,rowMargin:f,columnMargin:f,grand:f,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,c=new Map,g=new Map,A=m.buckets.map(P=>new Set(P));for(let P=0;P<m.paths.length;P++){const q=m.buckets[P],L=m.paths[P];for(const v of u)c.set(j(L,v.colId),V(v.handle,q,v.fn,h))}for(let P=0;P<l.paths.length;P++){const q=l.buckets[P],L=l.paths[P];for(const v of u)n.set(j(L,v.colId),V(v.handle,q,v.fn,h));for(let v=0;v<m.paths.length;v++){const G=T(q,m.buckets[v],A[v]);if(G.length===0)continue;const S=m.paths[v];for(const N of u)r.set(R(L,S,N.colId),V(N.handle,G,N.fn,h))}}for(const P of u)g.set(P.colId,V(P.handle,t,P.fn,h));return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function R(i,a,s){return`${i}\\0${a}\\0${s}`}function j(i,a){return`${i}\\0${a}`}}),Ce("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne}});const he=me("packages/core/src/internal/util.js").getPath,W=me("packages/core/src/compute/handle.js"),U=W.isMissing,_=W.valueComparator,E=me("packages/core/src/compute/filter.js").testValue,z="",re="\\0";function Y(i,a){const s=a.includes(".")?he(i,a):i?.[a];return s===void 0?null:s}function se(i,a,s={}){const h=a||[];let u=i.map((t,l)=>l);if(h.length===0)return u;for(let t=h.length-1;t>=0;t--)u=te(i,u,h[t],s);return u}function te(i,a,s,h){const u=s.locale!==void 0?s.locale:h.locale,t=_(u),l=s.descending!==void 0?!!s.descending:s.dir==="desc",m=[],e=[];for(const r of a){const n=Y(i[r],s.col);U(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const f=(r,n)=>{const c=Y(i[r],s.col),g=Y(i[n],s.col);let A;return typeof s.compare=="function"?(A=s.compare(c,g,i[r],i[n],l),l&&(A=-A)):A=l?t(g,c):t(c,g),A!==0?A:d.get(r)-d.get(n)};return m.sort(f),s.nullsFirst?e.concat(m):m.concat(e)}function H(i,a,s={}){const h=[];for(let u=0;u<i.length;u++)T(i[u],a,s,u)&&h.push(u);return h}function T(i,a,s,h){if(!a)return!0;if(Array.isArray(a.conditions)){const u=a.conditions.filter(l=>l!=null);if(u.length===0)return!0;if(a.op==="or")return u.some(l=>T(i,l,s,h));const t=u.every(l=>T(i,l,s,h));return a.op==="not"?!t:t}return a.col===void 0&&typeof s.custom=="function"?!!s.custom(a,i,h):E(Y(i,a.col),a,s.locale)}function V(i,a,s,h){const u=s||i.map((e,d)=>d),t=new Map,l=[],m=[];for(const e of u){const d=a.map((n,c)=>{const g=Y(i[e],n);return h&&h[c]?h[c](g):g}),f=d.map(n=>n==null?re:String(n)).join(z);let r=t.get(f);r===void 0&&(r=l.length,t.set(f,r),l.push(d),m.push([])),m[r].push(e)}return{keys:l,buckets:m}}function ne(i,a,s={}){const h=_(s.locale),u=i.filter(l=>!U(l)),t=u.map(R).filter(l=>l!==null);switch(a){case"count":return i.length;case"countValues":return u.length;case"sum":return t.reduce((l,m)=>l+m,0);case"avg":return u.length===0?null:t.reduce((l,m)=>l+m,0)/u.length;case"min":return u.length===0?null:u.reduce((l,m)=>h(m,l)<0?m:l);case"max":return u.length===0?null:u.reduce((l,m)=>h(m,l)>0?m:l);case"first":return i.length===0?null:j(i[0]);case"last":return i.length===0?null:j(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 a=Number(i);return Number.isNaN(a)?null:a}function j(i){return i===void 0?null:i}}),Ce("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return Z}});const he=me("packages/core/src/compute/sketch.js").Welford;class W{#t;#e;#n=[];#r;#i;constructor(z,re=0,Y=Date.now){if(z!=="count"&&z!=="time"&&z!=="session")throw new RangeError(`unknown window kind: ${z}`);if((z==="count"||z==="time")&&!(re>0))throw new RangeError(`a ${z} window needs a positive span`);this.#t=z,this.#e=Math.floor(re),this.#r=Y,this.#i=Y()}get size(){return this.#n.length}push(z,re=this.#r()){Number.isFinite(z)&&(this.#n.push({t:re,v:z}),this.#s(re))}#s(z){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=z-this.#e;for(;this.#n.length&&this.#n[0].t<re;)this.#n.shift()}}spec(){const z=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:z,size:this.#n.length}}values(){return this.#n.map(z=>z.v)}aggregate(){const z=this.spec();if(!this.#n.length)return{over:z,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const re=new he;let Y=0,se=1/0,te=-1/0;for(const{v:H}of this.#n)Y+=H,H<se&&(se=H),H>te&&(te=H),re.add(H);return{over:z,count:this.#n.length,sum:Y,mean:re.mean(),min:se,max:te,variance:re.variance(),stddev:re.stddev()}}reduce(z){const re=this.aggregate(),Y={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(z in Y))throw new RangeError(`unknown windowed aggregate: ${z}`);return{value:Y[z],over:re.over}}}const U=Object.freeze(["count","time","session"]);function _(E,z=Date.now){const re=E.kind==="time"&&E.minutes!=null?E.minutes*6e4:E.span??0;return new W(E.kind,re,z)}const Z={Window:W,WINDOW_KINDS:U,openWindow:_}}),Ce("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return h}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,U=me("packages/core/src/compute/special.js").logGamma,_=.6745,Z=3.5,E=1.5,z=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function Y(u){if(!u.length)return null;const l=Array.from(u,Number).sort((f,r)=>f-r),m=he(l,.5),e=l.map(f=>Math.abs(f-m)).sort((f,r)=>f-r),d=he(e,.5);return{median:m,mad:d}}function se(u,t={}){const l=Number.isFinite(t.threshold)?t.threshold:Z,m=u.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),f=[];for(let c=0;c<m;c++){const g=Number(u[c]);Number.isFinite(g)&&f.push(g)}if(!f.length)return{median:null,mad:null,threshold:l,scores:e,flags:d,flagged:0};const r=Y(f);if(r.mad===0)return{median:r.median,mad:0,threshold:l,scores:e,flags:d,flagged:0};let n=0;for(let c=0;c<m;c++){const g=Number(u[c]);if(!Number.isFinite(g))continue;const A=_*(g-r.median)/r.mad;e[c]=A,Math.abs(A)>l&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:l,scores:e,flags:d,flagged:n}}function te(u,t={}){const l=Number.isFinite(t.k)?t.k:E,m=[];for(let n=0;n<u.length;n++){const c=Number(u[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),d=he(e,.25),f=he(e,.75),r=f-d;return{q1:d,q3:f,iqr:r,lower:d-l*r,upper:f+l*r,k:l}}function H(u,t){if(t<=0)return 0;const l=U(u);if(t<u+1){let c=u,g=1/u,A=g;for(let P=0;P<1e3&&(c+=1,A*=t/c,g+=A,!(Math.abs(A)<Math.abs(g)*1e-15));P++);return g*Math.exp(-t+u*Math.log(t)-l)}const m=1e-300;let e=t+1-u,d=1/m,f=1/e,r=f;for(let c=1;c<1e3;c++){const g=-c*(c-u);e+=2,f=g*f+e,Math.abs(f)<m&&(f=m),d=e+g/d,Math.abs(d)<m&&(d=m),f=1/f;const A=f*d;if(r*=A,Math.abs(A-1)<1e-15)break}return 1-Math.exp(-t+u*Math.log(t)-l)*r}function T(u,t){return u<=0?0:H(t/2,u/2)}function V(u,t=z){if(!(t>0)||!(t<1))return NaN;let l=0,m=Math.max(1,u);for(;T(m,u)<t;)m*=2;for(let e=0;e<200;e++){const d=(l+m)/2;if(T(d,u)<t?l=d:m=d,m-l<1e-10)break}return(l+m)/2}function ne(u){const t=u.length,l=u.map((m,e)=>{const d=m.slice();for(let f=0;f<t;f++)d.push(e===f?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let f=m+1;f<t;f++)Math.abs(l[f][m])>Math.abs(l[e][m])&&(e=f);if(Math.abs(l[e][m])<1e-12)return null;if(e!==m){const f=l[e];l[e]=l[m],l[m]=f}const d=l[m][m];for(let f=0;f<2*t;f++)l[m][f]/=d;for(let f=0;f<t;f++){if(f===m)continue;const r=l[f][m];if(r!==0)for(let n=0;n<2*t;n++)l[f][n]-=r*l[m][n]}}return l.map(m=>m.slice(t))}function R(u,t){const l=u.length,m=new Array(t).fill(0);for(const f of u)for(let r=0;r<t;r++)m[r]+=f[r];for(let f=0;f<t;f++)m[f]/=l;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const f of u)for(let r=0;r<t;r++){const n=f[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(f[c]-m[c])}const d=l>1?l-1:1;for(let f=0;f<t;f++)for(let r=f;r<t;r++)e[f][r]/=d,e[r][f]=e[f][r];return{mean:m,cov:e}}function j(u,t={}){const l=Number.isFinite(t.p)?t.p:z,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=u.length;if(!e)return null;const d=u[0].length;if(!d)return null;const f=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),c=[],g=[];for(let N=0;N<e;N++){const I=u[N];let K=I.length===d;const B=new Array(d);for(let ee=0;K&&ee<d;ee++){const J=Number(I[ee]);Number.isFinite(J)?B[ee]=J:K=!1}K&&(c.push(N),g.push(B))}const A=d,P=V(A,l);if(g.length<=d)return{center:[],df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0};const{mean:q,cov:L}=R(g,d);let v=ne(L),G=!1;if(!v){G=!0;let N=0;for(let B=0;B<d;B++)N+=L[B][B];const I=N/d*m||m,K=L.map((B,ee)=>B.map((J,ue)=>ee===ue?J+I:J));if(v=ne(K),!v)return{center:q,df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0}}let S=0;for(let N=0;N<g.length;N++){const I=g[N],K=new Array(d);for(let J=0;J<d;J++)K[J]=I[J]-q[J];let B=0;for(let J=0;J<d;J++){let ue=0;for(let de=0;de<d;de++)ue+=v[J][de]*K[de];B+=K[J]*ue}B<0&&(B=0);const ee=c[N];r[ee]=B,f[ee]=Math.sqrt(B),B>P&&(n[ee]=!0,S++)}return{center:q,df:A,cutoff:P,singular:G,used:g.length,distances:f,squared:r,flags:n,flagged:S}}const i=20,a=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function s(u,t={}){const l=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:Z,d=Number.isFinite(t.k)?t.k:E,f=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=u.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let A=0;A<r;A++){const P=Number(u[A]);if(!Number.isFinite(P))continue;const q=Math.max(0,A-m+1),L=[];for(let v=q;v<=A;v++){const G=Number(u[v]);Number.isFinite(G)&&L.push(G)}if(!(L.length<f))if(l==="rollingIqr"){const v=te(L,{k:d});if(!v)continue;(P<v.lower||P>v.upper)&&(c[A]=!0,g++)}else{const v=Y(L);if(!v||v.mad===0)continue;const G=_*(P-v.median)/v.mad;n[A]=G,Math.abs(G)>e&&(c[A]=!0,g++)}}return{method:l,windowLen:m,minPeriods:f,threshold:e,k:d,scores:n,flags:c,flagged:g}}function h(u={}){const t=u||{},l=t.field;if(typeof l!="string"||!l)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(re.includes(m)||a.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,f=t.latest===!0,r=a.includes(m),n=c=>Number(c==null?NaN:c[l]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((v,G)=>{const S=v?.[d],N=G?.[d];return S===N?0:S==null?-1:N==null?1:S<N?-1:1});const A=g.map(n);let P,q;if(r)({flags:P,scores:q}=s(A,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const v=te(A,{k:t.k});P=A.map(G=>v?Number.isFinite(G)&&(G<v.lower||G>v.upper):!1),q=A.map(()=>null)}else({flags:P,scores:q}=se(A,{threshold:t.threshold}));if(f){const v=P.length-1;return v<0||!P[v]?!1:{method:m,field:l,flagged:[{row:g[v],score:q[v]}]}}const L=[];for(let v=0;v<P.length;v++)P[v]&&L.push({row:g[v],score:q[v]});return L.length?{method:m,field:l,flagged:L}:!1}}}),Ce("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return u}});const ae=me("packages/core/src/compute/special.js"),he=ae.normalQuantile,W=ae.studentTQuantile,_=me("packages/core/src/internal/util.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),E=1e-4,z=1-1e-4;function re(t){const l=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,f=Number.isFinite(e.value)?e.value:null;l.push({at:d,value:f})}else l.push({at:m,value:Number.isFinite(e)?Number(e):null})}return l}function Y(t){const l=t.filter(r=>r.value!==null),m=l[0],e=l[l.length-1],d=e.at-m.at,f=l.length>1&&d>0?d/(l.length-1):1;return{lastAt:e.at,step:f}}function se(t){return Math.min(z,Math.max(E,t))}function te(t,l=E,m=z,e=80){const d=(Math.sqrt(5)-1)/2;let f=l,r=m,n=r-d*(r-f),c=f+d*(r-f),g=t(n),A=t(c);for(let P=0;P<e;P++)g<A?(r=c,c=n,A=g,n=r-d*(r-f),g=t(n)):(f=n,n=c,g=A,c=f+d*(r-f),A=t(c));return(f+r)/2}function H(t,l){let m=null,e=0,d=0;for(let f=0;f<t.length;f++){const r=t[f];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=l*r+(1-l)*m}}return{level:m,sse:e,m:d}}function T(t,l,m){let e=null,d=null,f=0,r=0;for(let n=0;n<t.length;n++){const c=t[n];if(c===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=c;continue}d===null&&(d=c-e);const g=e+d;f+=(c-g)**2,r+=1;const A=e;e=l*c+(1-l)*(A+d),d=m*(e-A)+(1-m)*d}return{level:e,trend:d,sse:f,m:r}}function V(t,l,m,e,d){const f=t.length;if(f<2*l)return null;const r=G=>{let S=0,N=0;for(let I=G;I<G+l&&I<f;I++)t[I]!==null&&(S+=t[I],N+=1);return N?S/N:null},n=r(0),c=r(l);if(n===null||c===null)return null;let g=n,A=(c-n)/l;const P=new Array(l).fill(0);for(let G=0;G<l;G++)P[G]=t[G]===null?0:t[G]-g;const q=P.reduce((G,S)=>G+S,0)/l;for(let G=0;G<l;G++)P[G]-=q;let L=0,v=0;for(let G=l;G<f;G++){const S=G%l,N=P[S],I=t[G];if(I===null){g+=A;continue}const K=g+A+N;L+=(I-K)**2,v+=1;const B=g;g=m*(I-N)+(1-m)*(g+A),A=e*(g-B)+(1-e)*A,P[S]=d*(I-g)+(1-d)*N}return{level:g,trend:A,season:P,phase:(f-1)%l,sse:L,count:v}}function ne(t,l,m){let e=1;for(const f of l)e+=f*f;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function R(t,l={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=Z.includes(l.method)?l.method:"linear",e=Math.max(1,Math.floor(Number(l.horizon)||1)),d=Number.isFinite(l.confidence)&&l.confidence>0&&l.confidence<1?l.confidence:.95,f=1-(1-d)/2,r=re(t),n=r.map(L=>L.value),c=n.filter(L=>L!==null),g=c.length,{lastAt:A,step:P}=g?Y(r):{lastAt:0,step:1},q=L=>A+L*P;return m==="linear"?j(r,g,e,d,f,q):m==="movingAverage"?i(c,g,e,d,f,l,q):m==="ses"?a(n,g,e,d,f,l,q):m==="holt"?s(n,g,e,d,f,l,q):h(n,g,e,d,f,l,q)}function j(t,l,m,e,d,f){if(l<2)return null;let r=0,n=0;for(const I of t)I.value!==null&&(r+=I.at,n+=I.value);r/=l,n/=l;let c=0,g=0,A=0;for(const I of t){if(I.value===null)continue;const K=I.at-r,B=I.value-n;c+=K*K,g+=K*B,A+=B*B}if(c===0)return null;const P=g/c,q=n-P*r,L=A===0?1:Math.max(0,Math.min(1,g*g/(c*A))),v=Math.max(0,A-P*g),G=l>2?Math.sqrt(v/(l-2)):null,S=l>2?W(d,l-2):null,N=[];for(let I=1;I<=m;I++){const K=f(I),B=q+P*K;let ee=null,J=null,ue=null,de=null,Oe=null;if(G!==null){const Ae=1/l+(K-r)**2/c,Se=G*Math.sqrt(1+Ae),D=G*Math.sqrt(Ae);Oe=Se,ee=B-S*Se,J=B+S*Se,ue=B-S*D,de=B+S*D}N.push({step:I,at:K,mean:B,lower:ee,upper:J,lowerMean:ue,upperMean:de,se:Oe})}return{method:"linear",horizon:m,confidence:e,n:l,sigma:G,r2:L,params:{slope:P,intercept:q},points:N}}function i(t,l,m,e,d,f,r){if(l<1)return null;const n=Math.max(1,Math.min(l,Math.floor(Number(f.windowLen)||l))),c=t.slice(l-n);let g=0;for(const G of c)g+=G;const A=g/n;let P=null,q=null;if(n>1){let G=0;for(const N of c)G+=(N-A)**2;P=Math.sqrt(G/(n-1))*Math.sqrt(1+1/n),q=W(d,n-1)}const L=P===null?null:q*P,v=[];for(let G=1;G<=m;G++)v.push({step:G,at:r(G),mean:A,lower:L===null?null:A-L,upper:L===null?null:A+L,se:P});return{method:"movingAverage",horizon:m,confidence:e,n:l,sigma:P===null?null:P,params:{windowLen:n},points:v}}function a(t,l,m,e,d,f,r){if(l<1)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null;n===null&&(n=te(q=>H(t,q).sse));const c=H(t,n),g=he(d),A=c.m>0?c.sse/c.m:null,P=[];for(let q=1;q<=m;q++){const L=c.level;let v=null,G=null,S=null;if(A!==null){const N=[];for(let K=1;K<q;K++)N.push(n);const I=ne(A,N,g);S=I.se,v=L-I.margin,G=L+I.margin}P.push({step:q,at:r(q),mean:L,lower:v,upper:G,se:S})}return{method:"ses",horizon:m,confidence:e,n:l,sigma:A===null?null:Math.sqrt(A),params:{alpha:n},points:P}}function s(t,l,m,e,d,f,r){if(l<2)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null,c=Number.isFinite(f.beta)?se(f.beta):null;if(n===null||c===null){let v=n===null?.5:n,G=c===null?.5:c;for(let S=0;S<6;S++)n===null&&(v=te(N=>T(t,N,G).sse)),c===null&&(G=te(N=>T(t,v,N).sse));n=n===null?v:n,c=c===null?G:c}const g=T(t,n,c),A=he(d),P=g.m>0?g.sse/g.m:null,q=n*c,L=[];for(let v=1;v<=m;v++){const G=g.level+v*g.trend;let S=null,N=null,I=null;if(P!==null){const K=[];for(let ee=1;ee<v;ee++)K.push(n+ee*q);const B=ne(P,K,A);I=B.se,S=G-B.margin,N=G+B.margin}L.push({step:v,at:r(v),mean:G,lower:S,upper:N,se:I})}return{method:"holt",horizon:m,confidence:e,n:l,sigma:P===null?null:Math.sqrt(P),params:{alpha:n,beta:c},points:L}}function h(t,l,m,e,d,f,r){const n=Math.floor(Number(f.period));if(!(n>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(l<2*n)return null;let c=Number.isFinite(f.alpha)?se(f.alpha):null,g=Number.isFinite(f.beta)?se(f.beta):null,A=Number.isFinite(f.gamma)?se(f.gamma):null;const P=(I,K,B)=>{const ee=V(t,n,I,K,B);return ee?ee.sse:1/0};if(c===null||g===null||A===null){let I=c===null?.5:c,K=g===null?.5:g,B=A===null?.5:A;for(let ee=0;ee<8;ee++)c===null&&(I=te(J=>P(J,K,B))),g===null&&(K=te(J=>P(I,J,B))),A===null&&(B=te(J=>P(I,K,J)));c=c===null?I:c,g=g===null?K:g,A=A===null?B:A}const q=V(t,n,c,g,A);if(!q)return null;const L=he(d),v=q.count>0?q.sse/q.count:null,G=c*g,S=A*(1-c),N=[];for(let I=1;I<=m;I++){const K=q.season[(q.phase+I)%n],B=q.level+I*q.trend+K;let ee=null,J=null,ue=null;if(v!==null){const de=[];for(let Ae=1;Ae<I;Ae++)de.push(c+Ae*G+(Ae%n===0?S:0));const Oe=ne(v,de,L);ue=Oe.se,ee=B-Oe.margin,J=B+Oe.margin}N.push({step:I,at:r(I),mean:B,lower:ee,upper:J,se:ue})}return{method:"holtWinters",horizon:m,confidence:e,n:l,sigma:v===null?null:Math.sqrt(v),params:{alpha:c,beta:g,gamma:A,period:n},points:N}}const u={FORECAST_METHODS:Z,forecast:R}}),Ce("packages/core/src/compute/index.js",function(o,me){"use strict";const ae=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return ae.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return ae.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return ae.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return ae.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return ae.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return ae.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return ae.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return ae.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const W=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return W.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return W.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return W.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return W.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return W.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return W.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return W.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return W.mentionsColumn}});const U=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return U.packKeys}});const _=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const Z=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const E=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return E.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return E.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return E.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return E.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return E.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return E.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return E.DEFAULT_MAX_COLUMNS}});const z=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return z.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return z.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return z.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return z.GRAND_PATH}});const re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const Y=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return Y.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Y.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return Y.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return Y.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return Y.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return Y.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return Y.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return Y.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return Y.isMissing}});const se=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return se.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return se.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return se.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return se.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return se.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return se.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se.SKETCH_BOUNDS}});const te=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return te.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return te.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te.openWindow}});const H=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return H.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return H.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return H.maintenanceOf}});const T=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return T.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return T.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return T.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return T.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return T.anomalyCondition}});const V=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return V.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return V.forecast}})}),Ce("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return s}});const ae=me("packages/worker/src/transport.js"),he=ae.PROTOCOL,W=ae.OPS,U=ae.CONTROL,_=ae.ERRORS,Z=ae.unpackHandle,E=ae.unpackHandles,z=ae.createMaskPool,re=ae.collectTransfers,Y=me("packages/core/src/store/columnpack.js"),se=Y.packChunk,te=Y.packedTransfers;let H=null,T=null,V=null;async function ne(h){if(H)return H;if(!T){const u=h||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));T=Promise.resolve().then(u).then(t=>(H=t,t)).catch(t=>(V=t,H=null,null))}return T}function R(h){H=h,T=h?Promise.resolve(h):null,V=h?null:V}function j(h,u,t){const l=new Map;for(const m of h)m&&l.set(m.id,m);return{handle(m){return l.get(m)},count:u,pool:z(),locale:t}}function i(h,u){const{op:t,args:l}=h;if(t===W.COLUMNIZE)return se(l.schema||[],l.rows||[],l.opts||{});const m=u[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=_.NO_KERNEL,e}switch(t){case W.COLLATE_STRING_RANKS:return m(l.table||[],(l.table||[]).length,l.locale);case W.SORT_COLUMN:return m(Z(l.handle),l.order??null,l.opts||{});case W.SORT_MULTI:{const e=E(l.handles||[]),d=(l.entries||[]).map(f=>({...f,handle:e[f.index]}));return m(e,d,l.order??null)}case W.EVALUATE_FILTERS:return m(l.filters,j(E(l.handles||[]),l.count,l.locale));case W.COMPACT:return m(l.mask,l.count,void 0);case W.GROUP_BY_COLUMNS:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.TOTAL:return m(Z(l.handle),l.indices??null,l.fn);case W.PIVOT:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.FACET:return m(Z(l.handle),l.indices??null,l.count,l.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=_.PROTOCOL,e}}}async function a(h,u={}){if(!h||h.lattice!==he)return null;const{id:t,op:l}=h;if(l===U.CANCEL)return u.cancelled?.add(h.target),null;if(l===U.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(l===W.COLUMNIZE){if(u.cancelled?.has(t))return u.cancelled.delete(t),null;try{const e=se(h.args.schema||[],h.args.rows||[],h.args.opts||{});return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:te(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ne(u.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:_.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${V?V.message:"module not found"}`}},transfer:[]};if(u.cancelled?.has(t))return u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(h,m);return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function s(h,u={}){const t=new Set,l=async m=>{const e=await a(m.data,{loader:u.loader,cancelled:t});e&&h.postMessage(e.reply,e.transfer)};return h.addEventListener("message",l),ne(u.loader).then(m=>{h.postMessage({lattice:he,id:0,op:U.READY,compute:!!m})}),()=>h.removeEventListener("message",l)}});var kt=at("packages/worker/src/kernel.js");Ot.__latticeKernel=kt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const zt=Kn("packages/modules/webcomponent/index.js"),no=zt.GridElementController,ro=zt.observedAttributeNames,io=zt.domEventName,oo=zt.ATTRIBUTE_CONFIG,so=zt.EVENT_PREFIX,ao=zt.createLatticeElements,lo=zt.defineLatticeElements,uo=zt.ELEMENT_TAGS,co=zt.createLatticeKPIElement,fo=zt.createLatticeChartElement,ho=zt.createLatticeKanbanElement,po=zt.createLatticeCalendarElement,mo=zt.createLatticeGanttElement,go=zt.createLatticeLayoutElement,yo=zt.createLatticeTabsElement,bo=zt.createLatticeRouterElement,wo=zt.adoptLatticeStyles,vo=zt.latticeStyleSheets,ko=zt.VIEWER_EVENTS,So=zt.VIEWER_APPLY,Oo=zt.viewerHandlerName,jo=zt.createViewerController,Ao=zt.EVENT_NAMES,Po=zt.dashedName,Co=zt.createCurrencyType,Eo=zt.createUnitType,To=zt.registerUnitSystem,Mo=zt.createStat,No=zt.createHeadlessGrid,Ro=zt.duckdbAdapter,Lo=zt.createPushdownSource,Fo=zt.TAG_NAME,xo=zt.createLatticeGridElement,$o=zt.defineLatticeGrid;var Io=zt.default;export{oo as ATTRIBUTE_CONFIG,uo as ELEMENT_TAGS,Ao as EVENT_NAMES,so as EVENT_PREFIX,no as GridElementController,Fo as TAG_NAME,So as VIEWER_APPLY,ko as VIEWER_EVENTS,wo as adoptLatticeStyles,Co as createCurrencyType,No as createHeadlessGrid,po as createLatticeCalendarElement,fo as createLatticeChartElement,ao as createLatticeElements,mo as createLatticeGanttElement,xo as createLatticeGridElement,co as createLatticeKPIElement,ho as createLatticeKanbanElement,go as createLatticeLayoutElement,bo as createLatticeRouterElement,yo as createLatticeTabsElement,Lo as createPushdownSource,Mo as createStat,Eo as createUnitType,jo as createViewerController,Po as dashedName,Io as default,lo as defineLatticeElements,$o as defineLatticeGrid,io as domEventName,Ro as duckdbAdapter,vo as latticeStyleSheets,ro as observedAttributeNames,To as registerUnitSystem,Oo as viewerHandlerName};
60
60
 
61
61
  //# sourceMappingURL=webcomponent.esm.min.js.map