@toclocoinc/lattice-grid 1.89.0 → 1.89.1

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 (310) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +1 -1
  3. package/angular/package.json +1 -1
  4. package/docs/API.html +5 -5
  5. package/docs/THEMING.md +27 -0
  6. package/docs/api/adapters.html +1 -1
  7. package/docs/api/ai.html +1 -1
  8. package/docs/api/alarms.html +1 -1
  9. package/docs/api/calendar.html +1 -1
  10. package/docs/api/charts.html +1 -1
  11. package/docs/api/dashboard.html +1 -1
  12. package/docs/api/data-router.html +1 -1
  13. package/docs/api/deckgl.html +1 -1
  14. package/docs/api/designer.html +2 -2
  15. package/docs/api/gantt.html +1 -1
  16. package/docs/api/geometry.html +1 -1
  17. package/docs/api/grid.html +2 -2
  18. package/docs/api/index.html +1 -1
  19. package/docs/api/kanban.html +1 -1
  20. package/docs/api/kpi.html +1 -1
  21. package/docs/api/layout.html +1 -1
  22. package/docs/api/leaflet.html +1 -1
  23. package/docs/api/list.html +1 -1
  24. package/docs/api/mapview.html +1 -1
  25. package/docs/api/mock-socket.html +1 -1
  26. package/docs/api/presets.html +1 -1
  27. package/docs/api/tabs.html +1 -1
  28. package/docs/api/types.html +1 -1
  29. package/docs/api-detail.html +4 -4
  30. package/docs/warnings.json +1 -1
  31. package/lattice-grid.d.ts +1 -1
  32. package/lattice-grid.esm.min.js +3 -3
  33. package/lattice-grid.min.cjs +3 -3
  34. package/lattice-grid.min.css +1 -1
  35. package/lattice-grid.min.js +3 -3
  36. package/modules/ai.d.ts +1 -1
  37. package/modules/ai.esm.min.js +2 -2
  38. package/modules/ai.min.cjs +2 -2
  39. package/modules/ai.min.js +2 -2
  40. package/modules/alarms.d.ts +1 -1
  41. package/modules/alarms.esm.min.js +2 -2
  42. package/modules/alarms.min.cjs +2 -2
  43. package/modules/alarms.min.js +2 -2
  44. package/modules/angular.d.ts +1 -1
  45. package/modules/angular.esm.min.js +2 -2
  46. package/modules/angular.min.cjs +2 -2
  47. package/modules/angular.min.js +2 -2
  48. package/modules/calendar.d.ts +1 -1
  49. package/modules/calendar.esm.min.js +2 -2
  50. package/modules/calendar.min.cjs +2 -2
  51. package/modules/calendar.min.js +2 -2
  52. package/modules/chart-alluvial.d.ts +1 -1
  53. package/modules/chart-alluvial.esm.min.js +1 -1
  54. package/modules/chart-alluvial.min.cjs +1 -1
  55. package/modules/chart-alluvial.min.js +1 -1
  56. package/modules/chart-arc.d.ts +1 -1
  57. package/modules/chart-arc.esm.min.js +1 -1
  58. package/modules/chart-arc.min.cjs +1 -1
  59. package/modules/chart-arc.min.js +1 -1
  60. package/modules/chart-barrace.d.ts +1 -1
  61. package/modules/chart-barrace.esm.min.js +1 -1
  62. package/modules/chart-barrace.min.cjs +1 -1
  63. package/modules/chart-barrace.min.js +1 -1
  64. package/modules/chart-bubblemap.d.ts +1 -1
  65. package/modules/chart-bubblemap.esm.min.js +1 -1
  66. package/modules/chart-bubblemap.min.cjs +1 -1
  67. package/modules/chart-bubblemap.min.js +1 -1
  68. package/modules/chart-bump.d.ts +1 -1
  69. package/modules/chart-bump.esm.min.js +1 -1
  70. package/modules/chart-bump.min.cjs +1 -1
  71. package/modules/chart-bump.min.js +1 -1
  72. package/modules/chart-calendar.d.ts +1 -1
  73. package/modules/chart-calendar.esm.min.js +1 -1
  74. package/modules/chart-calendar.min.cjs +1 -1
  75. package/modules/chart-calendar.min.js +1 -1
  76. package/modules/chart-choropleth.d.ts +1 -1
  77. package/modules/chart-choropleth.esm.min.js +1 -1
  78. package/modules/chart-choropleth.min.cjs +1 -1
  79. package/modules/chart-choropleth.min.js +1 -1
  80. package/modules/chart-decomposition.d.ts +1 -1
  81. package/modules/chart-decomposition.esm.min.js +1 -1
  82. package/modules/chart-decomposition.min.cjs +1 -1
  83. package/modules/chart-decomposition.min.js +1 -1
  84. package/modules/chart-diverging.d.ts +1 -1
  85. package/modules/chart-diverging.esm.min.js +1 -1
  86. package/modules/chart-diverging.min.cjs +1 -1
  87. package/modules/chart-diverging.min.js +1 -1
  88. package/modules/chart-dumbbell.d.ts +1 -1
  89. package/modules/chart-dumbbell.esm.min.js +1 -1
  90. package/modules/chart-dumbbell.min.cjs +1 -1
  91. package/modules/chart-dumbbell.min.js +1 -1
  92. package/modules/chart-fan.d.ts +1 -1
  93. package/modules/chart-fan.esm.min.js +1 -1
  94. package/modules/chart-fan.min.cjs +1 -1
  95. package/modules/chart-fan.min.js +1 -1
  96. package/modules/chart-forcetree.d.ts +1 -1
  97. package/modules/chart-forcetree.esm.min.js +1 -1
  98. package/modules/chart-forcetree.min.cjs +1 -1
  99. package/modules/chart-forcetree.min.js +1 -1
  100. package/modules/chart-hexbin.d.ts +1 -1
  101. package/modules/chart-hexbin.esm.min.js +1 -1
  102. package/modules/chart-hexbin.min.cjs +1 -1
  103. package/modules/chart-hexbin.min.js +1 -1
  104. package/modules/chart-hexmap.d.ts +1 -1
  105. package/modules/chart-hexmap.esm.min.js +1 -1
  106. package/modules/chart-hexmap.min.cjs +1 -1
  107. package/modules/chart-hexmap.min.js +1 -1
  108. package/modules/chart-icicle.d.ts +1 -1
  109. package/modules/chart-icicle.esm.min.js +1 -1
  110. package/modules/chart-icicle.min.cjs +1 -1
  111. package/modules/chart-icicle.min.js +1 -1
  112. package/modules/chart-markermap.d.ts +1 -1
  113. package/modules/chart-markermap.esm.min.js +1 -1
  114. package/modules/chart-markermap.min.cjs +1 -1
  115. package/modules/chart-markermap.min.js +1 -1
  116. package/modules/chart-motion.d.ts +1 -1
  117. package/modules/chart-motion.esm.min.js +1 -1
  118. package/modules/chart-motion.min.cjs +1 -1
  119. package/modules/chart-motion.min.js +1 -1
  120. package/modules/chart-pack.d.ts +1 -1
  121. package/modules/chart-pack.esm.min.js +1 -1
  122. package/modules/chart-pack.min.cjs +1 -1
  123. package/modules/chart-pack.min.js +1 -1
  124. package/modules/chart-parallel.d.ts +1 -1
  125. package/modules/chart-parallel.esm.min.js +1 -1
  126. package/modules/chart-parallel.min.cjs +1 -1
  127. package/modules/chart-parallel.min.js +1 -1
  128. package/modules/chart-pictorial.d.ts +1 -1
  129. package/modules/chart-pictorial.esm.min.js +1 -1
  130. package/modules/chart-pictorial.min.cjs +1 -1
  131. package/modules/chart-pictorial.min.js +1 -1
  132. package/modules/chart-polararea.d.ts +1 -1
  133. package/modules/chart-polararea.esm.min.js +1 -1
  134. package/modules/chart-polararea.min.cjs +1 -1
  135. package/modules/chart-polararea.min.js +1 -1
  136. package/modules/chart-polarscatter.d.ts +1 -1
  137. package/modules/chart-polarscatter.esm.min.js +1 -1
  138. package/modules/chart-polarscatter.min.cjs +1 -1
  139. package/modules/chart-polarscatter.min.js +1 -1
  140. package/modules/chart-pyramid.d.ts +1 -1
  141. package/modules/chart-pyramid.esm.min.js +1 -1
  142. package/modules/chart-pyramid.min.cjs +1 -1
  143. package/modules/chart-pyramid.min.js +1 -1
  144. package/modules/chart-radialbar.d.ts +1 -1
  145. package/modules/chart-radialbar.esm.min.js +1 -1
  146. package/modules/chart-radialbar.min.cjs +1 -1
  147. package/modules/chart-radialbar.min.js +1 -1
  148. package/modules/chart-ridgeline.d.ts +1 -1
  149. package/modules/chart-ridgeline.esm.min.js +1 -1
  150. package/modules/chart-ridgeline.min.cjs +1 -1
  151. package/modules/chart-ridgeline.min.js +1 -1
  152. package/modules/chart-roc.d.ts +1 -1
  153. package/modules/chart-roc.esm.min.js +1 -1
  154. package/modules/chart-roc.min.cjs +1 -1
  155. package/modules/chart-roc.min.js +1 -1
  156. package/modules/chart-serpentine.d.ts +1 -1
  157. package/modules/chart-serpentine.esm.min.js +1 -1
  158. package/modules/chart-serpentine.min.cjs +1 -1
  159. package/modules/chart-serpentine.min.js +1 -1
  160. package/modules/chart-slope.d.ts +1 -1
  161. package/modules/chart-slope.esm.min.js +1 -1
  162. package/modules/chart-slope.min.cjs +1 -1
  163. package/modules/chart-slope.min.js +1 -1
  164. package/modules/chart-spiral.d.ts +1 -1
  165. package/modules/chart-spiral.esm.min.js +1 -1
  166. package/modules/chart-spiral.min.cjs +1 -1
  167. package/modules/chart-spiral.min.js +1 -1
  168. package/modules/chart-splom.d.ts +1 -1
  169. package/modules/chart-splom.esm.min.js +1 -1
  170. package/modules/chart-splom.min.cjs +1 -1
  171. package/modules/chart-splom.min.js +1 -1
  172. package/modules/chart-tree.d.ts +1 -1
  173. package/modules/chart-tree.esm.min.js +1 -1
  174. package/modules/chart-tree.min.cjs +1 -1
  175. package/modules/chart-tree.min.js +1 -1
  176. package/modules/chart-venn.d.ts +1 -1
  177. package/modules/chart-venn.esm.min.js +1 -1
  178. package/modules/chart-venn.min.cjs +1 -1
  179. package/modules/chart-venn.min.js +1 -1
  180. package/modules/chart-voronoi.d.ts +1 -1
  181. package/modules/chart-voronoi.esm.min.js +1 -1
  182. package/modules/chart-voronoi.min.cjs +1 -1
  183. package/modules/chart-voronoi.min.js +1 -1
  184. package/modules/chart-waffle.d.ts +1 -1
  185. package/modules/chart-waffle.esm.min.js +1 -1
  186. package/modules/chart-waffle.min.cjs +1 -1
  187. package/modules/chart-waffle.min.js +1 -1
  188. package/modules/chart-wordcloud.d.ts +1 -1
  189. package/modules/chart-wordcloud.esm.min.js +1 -1
  190. package/modules/chart-wordcloud.min.cjs +1 -1
  191. package/modules/chart-wordcloud.min.js +1 -1
  192. package/modules/charts.d.ts +1 -1
  193. package/modules/charts.esm.min.js +2 -2
  194. package/modules/charts.min.cjs +2 -2
  195. package/modules/charts.min.js +2 -2
  196. package/modules/dashboard.d.ts +1 -1
  197. package/modules/dashboard.esm.min.js +2 -2
  198. package/modules/dashboard.min.cjs +2 -2
  199. package/modules/dashboard.min.js +2 -2
  200. package/modules/data-router.d.ts +1 -1
  201. package/modules/data-router.esm.min.js +2 -2
  202. package/modules/data-router.min.cjs +2 -2
  203. package/modules/data-router.min.js +2 -2
  204. package/modules/deckgl.d.ts +1 -1
  205. package/modules/deckgl.esm.min.js +2 -2
  206. package/modules/deckgl.min.cjs +2 -2
  207. package/modules/deckgl.min.js +2 -2
  208. package/modules/designer.d.ts +1 -1
  209. package/modules/designer.esm.min.js +187 -73
  210. package/modules/designer.esm.min.js.map +2 -2
  211. package/modules/designer.min.cjs +187 -73
  212. package/modules/designer.min.js +187 -73
  213. package/modules/designer.min.js.map +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/antd5.css +9 -0
  283. package/modules/presets/bootstrap5.css +9 -0
  284. package/modules/presets/fluent2.css +9 -0
  285. package/modules/presets/material3.css +9 -0
  286. package/modules/presets.d.ts +1 -1
  287. package/modules/presets.esm.min.js +2 -2
  288. package/modules/presets.min.cjs +2 -2
  289. package/modules/presets.min.js +2 -2
  290. package/modules/react.d.ts +1 -1
  291. package/modules/react.esm.min.js +2 -2
  292. package/modules/react.min.cjs +2 -2
  293. package/modules/react.min.js +2 -2
  294. package/modules/svelte.d.ts +1 -1
  295. package/modules/svelte.esm.min.js +2 -2
  296. package/modules/svelte.min.cjs +2 -2
  297. package/modules/svelte.min.js +2 -2
  298. package/modules/tabs.d.ts +1 -1
  299. package/modules/tabs.esm.min.js +2 -2
  300. package/modules/tabs.min.cjs +2 -2
  301. package/modules/tabs.min.js +2 -2
  302. package/modules/vue.d.ts +1 -1
  303. package/modules/vue.esm.min.js +2 -2
  304. package/modules/vue.min.cjs +2 -2
  305. package/modules/vue.min.js +2 -2
  306. package/modules/webcomponent.d.ts +1 -1
  307. package/modules/webcomponent.esm.min.js +3 -3
  308. package/modules/webcomponent.min.cjs +3 -3
  309. package/modules/webcomponent.min.js +3 -3
  310. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Lattice Grid 1.89.0, webcomponent module
2
+ * Lattice Grid 1.89.1, webcomponent module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- var hr=Object.create(null),pr=Object.create(null);function Le(e,K){hr[e]=K}function Wn(e){var K=pr[e];if(K)return K;var Q=Object.create(null);pr[e]=Q;var x=hr[e];if(!x)throw new Error("[lattice] missing module: "+e);return x(Q,Wn),Q}Le("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 d}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return i}}),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 o}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return b}}),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 j}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return N}}),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.89.0";async function x(){return Q}const B="1.89.0",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 V(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 S(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=S(le);V(oe,"warn",ae),console.warn("[lattice]",...ae)}function l(oe,...le){if(I.has(oe))return;X(oe);const ae=S(le);V(oe,"info",ae),console.info("[lattice]",...ae)}function d(){I.clear(),W.length=0}function a(oe,le){const ae=new Error(`[lattice] ${oe}`);throw le!==void 0&&(ae.cause=le),ae}function r(oe,le){oe||a(le)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(oe){return oe!==null&&typeof oe=="object"&&!Array.isArray(oe)}function i(oe){return typeof oe=="function"}function f(oe){return oe==null}function u(oe){return oe==null||oe===""}function o(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 c(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 de=0;de<se;de++){if(ie==null)return;ie=ie[ae[de]]}return ie}}return m.set(oe,le),le}const h=new Map;function s(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 de=ee;for(let he=0;he<se;he++){if(de==null)return;const ge=ae[he];de[ge]==null&&(de[ge]={}),de=de[ge]}de!=null&&(de[ae[se]]=ie)}}return h.set(oe,le),le}function p(oe,le){return c(le)(oe)}function y(oe,le,ae){s(le)(oe,ae)}function O(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 A={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function b(oe){const le=oe==null?"":String(oe);return/[&<>"']/.test(le)?le.replace(/[&<>"']/g,ae=>A[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}:n(oe)?oe:{[le]:oe,enabled:!0}}function j(oe){return oe==null?[]:Array.isArray(oe)?oe:[oe]}const F=Object.freeze(new Set(["__proto__","constructor","prototype"]));function C(oe,le){if(!n(oe))return n(le)?{...le}:le;if(!n(le))return le===void 0?oe:le;const ae={...oe};for(const se of Object.keys(le)){if(F.has(se))continue;const ee=le[se];ee!==void 0&&(ae[se]=n(ee)&&n(ae[se])?C(ae[se],ee):ee)}return ae}function T(oe,le){if(!n(oe)||!n(le)||oe===le)return le;const ae=Object.create(Object.getPrototypeOf(oe));return Object.assign(ae,oe,le),ae}class L{#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 $(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 P(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const k=typeof requestAnimationFrame=="function";function N(oe){return k?requestAnimationFrame(oe):setTimeout(()=>oe(P()),16)}function G(oe){oe!=null&&(k?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=N(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()},de=(...he)=>{ae===null?(oe(...he),ie()):(se=he,clearTimeout(ae),ie())};return de.flush=()=>{if(ae!==null&&clearTimeout(ae),ae=null,se===null)return;const he=se;se=null,oe(...he)},de.cancel=()=>{ae!==null&&clearTimeout(ae),ae=null,se=null},de.pending=()=>ae!==null||se!==null,de}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)}`}}),Le("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 V}}),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 S}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return r}}),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"),x=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,j){const F=Number(R),C=Number(j);if(R!==null&&R!==""&&j!==null&&j!==""&&Number.isFinite(F)&&Number.isFinite(C))return F<C?-1:F>C?1:0;const L=String(R??"").toLowerCase(),E=String(j??"").toLowerCase();return L<E?-1:L>E?1:0}function H(R){return R==null||R===""}function V(R,j){if(!j||typeof j!="object")return!1;const{op:F}=j,C=j.value,T=j.value2;switch(F){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(F){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,T)<=0;case"outside":return W(R,C)<0||W(R,T)>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,j,F){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)},[T,L,E]=C(R),[D,$,P]=C(j),k=Math.max(0,Math.min(1,F)),N=(G,q)=>Math.round(G+(q-G)*k);return`#${[N(T,D),N(L,$),N(E,P)].map(G=>G.toString(16).padStart(2,"0")).join("")}`}function w(R){const j=[];for(const D of R||[]){if(D==null||D==="")continue;const $=D instanceof Date?D.getTime():Number(D);Number.isFinite($)&&j.push($)}if(!j.length)return null;j.sort((D,$)=>D-$);let F=0,C=0,T=0;for(const D of j){F++;const $=D-C;C+=$/F,T+=$*(D-C)}const L=S(j,.25),E=S(j,.75);return{n:j.length,min:j[0],max:j[j.length-1],mean:C,stddev:j.length>1?Math.sqrt(T/(j.length-1)):0,median:S(j,.5),q1:L,q3:E,iqr:E-L,sorted:j}}function S(R,j){if(!R.length)return 0;const F=(R.length-1)*Math.max(0,Math.min(1,j)),C=Math.floor(F),T=Math.ceil(F);return C===T?R[C]:R[C]+(F-C)*(R[T]-R[C])}function g(R){for(const j of Array.isArray(R)?R:[])if(!(!j||typeof j!="object")&&(j.when&&_.includes(j.when.op)||j.scale&&j.scale.from||j.dataBar&&!(Number.isFinite(Number(j.dataBar.min))&&Number.isFinite(Number(j.dataBar.max)))||j.iconSet&&!Array.isArray(j.iconSet.thresholds)))return!0;return!1}function l(R,j){const F=Number(R.value),C=T=>S(j.sorted,T);switch(R.op){case"topPercent":{const T=d(F,10);return{op:"gte",value:C(1-T)}}case"bottomPercent":{const T=d(F,10);return{op:"lte",value:C(T)}}case"topN":{const T=Math.max(1,Math.floor(F)||1),L=Math.max(0,j.sorted.length-T);return{op:"gte",value:j.sorted[L]}}case"bottomN":{const T=Math.max(1,Math.floor(F)||1),L=Math.min(j.sorted.length-1,T-1);return{op:"lte",value:j.sorted[L]}}case"aboveMean":return{op:"gt",value:j.mean};case"belowMean":return{op:"lt",value:j.mean};case"aboveMedian":return{op:"gt",value:j.median};case"belowMedian":return{op:"lt",value:j.median};case"zAbove":return j.stddev?{op:"gte",value:j.mean+(Number.isFinite(F)?F:2)*j.stddev}:null;case"zBelow":return j.stddev?{op:"lte",value:j.mean-(Number.isFinite(F)?F:2)*j.stddev}:null;case"outlier":{const T=(Number.isFinite(F)&&F>0?F:1.5)*j.iqr;return j.iqr?{op:"outside",value:j.q1-T,value2:j.q3+T}:null}default:return null}}function d(R,j){const F=Number.isFinite(R)?R:j,C=F>1?F/100:F;return Math.max(0,Math.min(1,C))}function a(R,j){if(R.from==="minmax")return{...R,min:j.min,max:j.max};if(R.from==="quantile")return{...R,min:S(j.sorted,d(Number(R.low),5)),max:S(j.sorted,d(Number(R.high),95))};if(R.from==="stddev"){const F=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:j.mean-F*j.stddev,max:j.mean+F*j.stddev}}return R}function r(R,j){const F=Array.isArray(R)?R:[];return!j||!j.n?F.map(C=>C&&g([C])?{...C,enabled:!1}:C):F.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:a(C.scale,j)};if(C.dataBar)return{...C,dataBar:t(C.dataBar,j)};if(C.iconSet)return{...C,iconSet:n(C.iconSet,j)};if(!C.when||!_.includes(C.when.op))return C;const T=l(C.when,j);return T?{...C,when:T}:{...C,enabled:!1}})}function t(R,j){const F=Number.isFinite(Number(R.min))?Number(R.min):void 0,C=Number.isFinite(Number(R.max))?Number(R.max):void 0;if(F!==void 0&&C!==void 0)return{...R,min:F,max:C};if(R.from==="quantile")return{...R,min:F??S(j.sorted,d(Number(R.low),5)),max:C??S(j.sorted,d(Number(R.high),95))};if(R.from==="stddev"){const T=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:F??j.mean-T*j.stddev,max:C??j.mean+T*j.stddev}}return{...R,min:F??j.min,max:C??j.max}}function n(R,j){if(Array.isArray(R.thresholds))return R;const F=i(R),C=[];for(let T=1;T<F;T++)C.push(S(j.sorted,T/F));return{...R,thresholds:C}}function i(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 j=s[R.set];return j?j.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 o(R,j){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${j==="up"?"8,2 14,13 2,13":j==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${R}"/></svg>`}function m(R,j){const F="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 ${j*16} 16">`;for(let T=0;T<j;T++){const L=T<R?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${T*16},0)" d="${F}" fill="${L}"/>`}return`${C}</svg>`}const c=Object.freeze([o("#c0392b","down"),o("#e0a800","right"),o("#2e7d32","up")]),h=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),s=Object.freeze({arrows:c,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 y(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 j=R.set||"arrows";if(j==="ratings"){const C=i(R),T=[];for(let L=1;L<=C;L++)T.push(f(m(L,C)));return T}const F=s[j];return F?F.map(f):(B(`iconSet:${j}`,`unknown icon set '${j}'; falling back to arrows.`),c.map(f))}function O(R){const j=Number(R.min),C=Number(R.max)-j,T=R.colour||R.color||"#5b9bd5",L=R.negativeColour||R.negativeColor||"#d13438",E=R.direction==="rtl"?"left":"right",D=P=>Math.max(0,Math.min(1,(P-j)/C))*100,$=C?Math.max(0,Math.min(100,(0-j)/C*100)):0;return P=>{if(H(P))return null;const k=Number(P);if(!Number.isFinite(k)||!C)return null;const N=D(k),G=Math.min(N,$),q=Math.max(N,$),Y=k>=0?T:L;return{backgroundImage:`linear-gradient(to ${E}, transparent ${G}%, ${Y} ${G}%, ${Y} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function A(R){const j=y(R),F=R.reverse?[...j].reverse():j,C=(Array.isArray(R.thresholds)?R.thresholds:[]).map(Number).filter(Number.isFinite),T=Number.isFinite(Number(R.size))?Number(R.size):16,L=R.set==="ratings"?T*i(R):T;return E=>{if(H(E))return null;const D=Number(E);if(!Number.isFinite(D))return null;let $=0;for(const k of C)D>=k&&$++;const P=F[Math.min($,F.length-1)];return P?{backgroundImage:P,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${T}px`,paddingLeft:`${L+4}px`}:null}}function b(R){const j=Array.isArray(R.colours)&&R.colours.length>=2?R.colours:["#f8f9fa","#1a6bc7"],F=Number(R.min),C=Number(R.max),T=C-F,L=j.length-1,E=[];for(let $=0;$<=L;$++)E.push(L?$/L:0);const D=Number(R.mid);if(R.mid!==void 0&&R.mid!==null)if(j.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${j.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&T&&D>Math.min(F,C)&&D<Math.max(F,C)){const $=L/2,P=Math.max(0,Math.min(1,(D-F)/T));for(let k=0;k<=L;k++)E[k]=k<=$?$?k/$*P:P:P+(k-$)/(L-$)*(1-P)}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 $=>{const P=Number($);if(!Number.isFinite(P)||!T)return null;const k=Math.max(0,Math.min(1,(P-F)/T));let N=0;for(;N<L-1&&k>E[N+1];)N++;const G=E[N+1]-E[N],q=G>0?(k-E[N])/G:0;return{background:z(j[N],j[N+1],Math.max(0,Math.min(1,q)))}}}function v(R,j=null){const F=g(R)?r(R,j):R,C=(Array.isArray(F)?F:[]).filter(L=>L&&typeof L=="object");if(!C.length)return()=>null;const T=C.map(L=>L.scale?{scale:b(L.scale),enabled:L.enabled!==!1}:L.dataBar?{scale:O(L.dataBar),enabled:L.enabled!==!1}:L.iconSet?{scale:A(L.iconSet),enabled:L.enabled!==!1}:{when:L.when,style:L.style,stop:L.stopIfTrue!==!1,enabled:L.enabled!==!1});return L=>{const E=L?L.value:void 0;let D=null;for(const $ of T){if(!$.enabled)continue;if($.scale){const k=$.scale(E);k&&(D={...D||{},...k});continue}if(!V(E,$.when))continue;const P=x($.style)?$.style(L):$.style;if(P&&(D={...D||{},...P}),$.stop)break}return D}}}),Le("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",x="str",B="ref",I="name",_="op",X="end",W=["<=",">=","<>","!="],H="+-*/^%(),<>=";class V extends Error{constructor(i,f){super(i),this.name="FormulaError",this.at=f}}function z(n){const i=[];let f=0;for(;f<n.length;){const u=n[f];if(u===" "||u===" "||u===`
6
+ var hr=Object.create(null),pr=Object.create(null);function Le(e,K){hr[e]=K}function Wn(e){var K=pr[e];if(K)return K;var Q=Object.create(null);pr[e]=Q;var x=hr[e];if(!x)throw new Error("[lattice] missing module: "+e);return x(Q,Wn),Q}Le("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 d}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return i}}),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 o}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return b}}),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 j}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return N}}),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.89.1";async function x(){return Q}const B="1.89.1",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 V(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 S(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=S(le);V(oe,"warn",ae),console.warn("[lattice]",...ae)}function l(oe,...le){if(I.has(oe))return;X(oe);const ae=S(le);V(oe,"info",ae),console.info("[lattice]",...ae)}function d(){I.clear(),W.length=0}function a(oe,le){const ae=new Error(`[lattice] ${oe}`);throw le!==void 0&&(ae.cause=le),ae}function r(oe,le){oe||a(le)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(oe){return oe!==null&&typeof oe=="object"&&!Array.isArray(oe)}function i(oe){return typeof oe=="function"}function f(oe){return oe==null}function u(oe){return oe==null||oe===""}function o(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 c(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 de=0;de<se;de++){if(ie==null)return;ie=ie[ae[de]]}return ie}}return m.set(oe,le),le}const h=new Map;function s(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 de=ee;for(let he=0;he<se;he++){if(de==null)return;const ge=ae[he];de[ge]==null&&(de[ge]={}),de=de[ge]}de!=null&&(de[ae[se]]=ie)}}return h.set(oe,le),le}function p(oe,le){return c(le)(oe)}function y(oe,le,ae){s(le)(oe,ae)}function O(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 A={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function b(oe){const le=oe==null?"":String(oe);return/[&<>"']/.test(le)?le.replace(/[&<>"']/g,ae=>A[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}:n(oe)?oe:{[le]:oe,enabled:!0}}function j(oe){return oe==null?[]:Array.isArray(oe)?oe:[oe]}const F=Object.freeze(new Set(["__proto__","constructor","prototype"]));function C(oe,le){if(!n(oe))return n(le)?{...le}:le;if(!n(le))return le===void 0?oe:le;const ae={...oe};for(const se of Object.keys(le)){if(F.has(se))continue;const ee=le[se];ee!==void 0&&(ae[se]=n(ee)&&n(ae[se])?C(ae[se],ee):ee)}return ae}function T(oe,le){if(!n(oe)||!n(le)||oe===le)return le;const ae=Object.create(Object.getPrototypeOf(oe));return Object.assign(ae,oe,le),ae}class L{#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 $(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 P(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const k=typeof requestAnimationFrame=="function";function N(oe){return k?requestAnimationFrame(oe):setTimeout(()=>oe(P()),16)}function G(oe){oe!=null&&(k?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=N(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()},de=(...he)=>{ae===null?(oe(...he),ie()):(se=he,clearTimeout(ae),ie())};return de.flush=()=>{if(ae!==null&&clearTimeout(ae),ae=null,se===null)return;const he=se;se=null,oe(...he)},de.cancel=()=>{ae!==null&&clearTimeout(ae),ae=null,se=null},de.pending=()=>ae!==null||se!==null,de}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)}`}}),Le("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 V}}),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 S}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return r}}),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"),x=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,j){const F=Number(R),C=Number(j);if(R!==null&&R!==""&&j!==null&&j!==""&&Number.isFinite(F)&&Number.isFinite(C))return F<C?-1:F>C?1:0;const L=String(R??"").toLowerCase(),E=String(j??"").toLowerCase();return L<E?-1:L>E?1:0}function H(R){return R==null||R===""}function V(R,j){if(!j||typeof j!="object")return!1;const{op:F}=j,C=j.value,T=j.value2;switch(F){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(F){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,T)<=0;case"outside":return W(R,C)<0||W(R,T)>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,j,F){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)},[T,L,E]=C(R),[D,$,P]=C(j),k=Math.max(0,Math.min(1,F)),N=(G,q)=>Math.round(G+(q-G)*k);return`#${[N(T,D),N(L,$),N(E,P)].map(G=>G.toString(16).padStart(2,"0")).join("")}`}function w(R){const j=[];for(const D of R||[]){if(D==null||D==="")continue;const $=D instanceof Date?D.getTime():Number(D);Number.isFinite($)&&j.push($)}if(!j.length)return null;j.sort((D,$)=>D-$);let F=0,C=0,T=0;for(const D of j){F++;const $=D-C;C+=$/F,T+=$*(D-C)}const L=S(j,.25),E=S(j,.75);return{n:j.length,min:j[0],max:j[j.length-1],mean:C,stddev:j.length>1?Math.sqrt(T/(j.length-1)):0,median:S(j,.5),q1:L,q3:E,iqr:E-L,sorted:j}}function S(R,j){if(!R.length)return 0;const F=(R.length-1)*Math.max(0,Math.min(1,j)),C=Math.floor(F),T=Math.ceil(F);return C===T?R[C]:R[C]+(F-C)*(R[T]-R[C])}function g(R){for(const j of Array.isArray(R)?R:[])if(!(!j||typeof j!="object")&&(j.when&&_.includes(j.when.op)||j.scale&&j.scale.from||j.dataBar&&!(Number.isFinite(Number(j.dataBar.min))&&Number.isFinite(Number(j.dataBar.max)))||j.iconSet&&!Array.isArray(j.iconSet.thresholds)))return!0;return!1}function l(R,j){const F=Number(R.value),C=T=>S(j.sorted,T);switch(R.op){case"topPercent":{const T=d(F,10);return{op:"gte",value:C(1-T)}}case"bottomPercent":{const T=d(F,10);return{op:"lte",value:C(T)}}case"topN":{const T=Math.max(1,Math.floor(F)||1),L=Math.max(0,j.sorted.length-T);return{op:"gte",value:j.sorted[L]}}case"bottomN":{const T=Math.max(1,Math.floor(F)||1),L=Math.min(j.sorted.length-1,T-1);return{op:"lte",value:j.sorted[L]}}case"aboveMean":return{op:"gt",value:j.mean};case"belowMean":return{op:"lt",value:j.mean};case"aboveMedian":return{op:"gt",value:j.median};case"belowMedian":return{op:"lt",value:j.median};case"zAbove":return j.stddev?{op:"gte",value:j.mean+(Number.isFinite(F)?F:2)*j.stddev}:null;case"zBelow":return j.stddev?{op:"lte",value:j.mean-(Number.isFinite(F)?F:2)*j.stddev}:null;case"outlier":{const T=(Number.isFinite(F)&&F>0?F:1.5)*j.iqr;return j.iqr?{op:"outside",value:j.q1-T,value2:j.q3+T}:null}default:return null}}function d(R,j){const F=Number.isFinite(R)?R:j,C=F>1?F/100:F;return Math.max(0,Math.min(1,C))}function a(R,j){if(R.from==="minmax")return{...R,min:j.min,max:j.max};if(R.from==="quantile")return{...R,min:S(j.sorted,d(Number(R.low),5)),max:S(j.sorted,d(Number(R.high),95))};if(R.from==="stddev"){const F=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:j.mean-F*j.stddev,max:j.mean+F*j.stddev}}return R}function r(R,j){const F=Array.isArray(R)?R:[];return!j||!j.n?F.map(C=>C&&g([C])?{...C,enabled:!1}:C):F.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:a(C.scale,j)};if(C.dataBar)return{...C,dataBar:t(C.dataBar,j)};if(C.iconSet)return{...C,iconSet:n(C.iconSet,j)};if(!C.when||!_.includes(C.when.op))return C;const T=l(C.when,j);return T?{...C,when:T}:{...C,enabled:!1}})}function t(R,j){const F=Number.isFinite(Number(R.min))?Number(R.min):void 0,C=Number.isFinite(Number(R.max))?Number(R.max):void 0;if(F!==void 0&&C!==void 0)return{...R,min:F,max:C};if(R.from==="quantile")return{...R,min:F??S(j.sorted,d(Number(R.low),5)),max:C??S(j.sorted,d(Number(R.high),95))};if(R.from==="stddev"){const T=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:F??j.mean-T*j.stddev,max:C??j.mean+T*j.stddev}}return{...R,min:F??j.min,max:C??j.max}}function n(R,j){if(Array.isArray(R.thresholds))return R;const F=i(R),C=[];for(let T=1;T<F;T++)C.push(S(j.sorted,T/F));return{...R,thresholds:C}}function i(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 j=s[R.set];return j?j.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 o(R,j){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${j==="up"?"8,2 14,13 2,13":j==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${R}"/></svg>`}function m(R,j){const F="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 ${j*16} 16">`;for(let T=0;T<j;T++){const L=T<R?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${T*16},0)" d="${F}" fill="${L}"/>`}return`${C}</svg>`}const c=Object.freeze([o("#c0392b","down"),o("#e0a800","right"),o("#2e7d32","up")]),h=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),s=Object.freeze({arrows:c,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 y(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 j=R.set||"arrows";if(j==="ratings"){const C=i(R),T=[];for(let L=1;L<=C;L++)T.push(f(m(L,C)));return T}const F=s[j];return F?F.map(f):(B(`iconSet:${j}`,`unknown icon set '${j}'; falling back to arrows.`),c.map(f))}function O(R){const j=Number(R.min),C=Number(R.max)-j,T=R.colour||R.color||"#5b9bd5",L=R.negativeColour||R.negativeColor||"#d13438",E=R.direction==="rtl"?"left":"right",D=P=>Math.max(0,Math.min(1,(P-j)/C))*100,$=C?Math.max(0,Math.min(100,(0-j)/C*100)):0;return P=>{if(H(P))return null;const k=Number(P);if(!Number.isFinite(k)||!C)return null;const N=D(k),G=Math.min(N,$),q=Math.max(N,$),Y=k>=0?T:L;return{backgroundImage:`linear-gradient(to ${E}, transparent ${G}%, ${Y} ${G}%, ${Y} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function A(R){const j=y(R),F=R.reverse?[...j].reverse():j,C=(Array.isArray(R.thresholds)?R.thresholds:[]).map(Number).filter(Number.isFinite),T=Number.isFinite(Number(R.size))?Number(R.size):16,L=R.set==="ratings"?T*i(R):T;return E=>{if(H(E))return null;const D=Number(E);if(!Number.isFinite(D))return null;let $=0;for(const k of C)D>=k&&$++;const P=F[Math.min($,F.length-1)];return P?{backgroundImage:P,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${T}px`,paddingLeft:`${L+4}px`}:null}}function b(R){const j=Array.isArray(R.colours)&&R.colours.length>=2?R.colours:["#f8f9fa","#1a6bc7"],F=Number(R.min),C=Number(R.max),T=C-F,L=j.length-1,E=[];for(let $=0;$<=L;$++)E.push(L?$/L:0);const D=Number(R.mid);if(R.mid!==void 0&&R.mid!==null)if(j.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${j.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&T&&D>Math.min(F,C)&&D<Math.max(F,C)){const $=L/2,P=Math.max(0,Math.min(1,(D-F)/T));for(let k=0;k<=L;k++)E[k]=k<=$?$?k/$*P:P:P+(k-$)/(L-$)*(1-P)}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 $=>{const P=Number($);if(!Number.isFinite(P)||!T)return null;const k=Math.max(0,Math.min(1,(P-F)/T));let N=0;for(;N<L-1&&k>E[N+1];)N++;const G=E[N+1]-E[N],q=G>0?(k-E[N])/G:0;return{background:z(j[N],j[N+1],Math.max(0,Math.min(1,q)))}}}function v(R,j=null){const F=g(R)?r(R,j):R,C=(Array.isArray(F)?F:[]).filter(L=>L&&typeof L=="object");if(!C.length)return()=>null;const T=C.map(L=>L.scale?{scale:b(L.scale),enabled:L.enabled!==!1}:L.dataBar?{scale:O(L.dataBar),enabled:L.enabled!==!1}:L.iconSet?{scale:A(L.iconSet),enabled:L.enabled!==!1}:{when:L.when,style:L.style,stop:L.stopIfTrue!==!1,enabled:L.enabled!==!1});return L=>{const E=L?L.value:void 0;let D=null;for(const $ of T){if(!$.enabled)continue;if($.scale){const k=$.scale(E);k&&(D={...D||{},...k});continue}if(!V(E,$.when))continue;const P=x($.style)?$.style(L):$.style;if(P&&(D={...D||{},...P}),$.stop)break}return D}}}),Le("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",x="str",B="ref",I="name",_="op",X="end",W=["<=",">=","<>","!="],H="+-*/^%(),<>=";class V extends Error{constructor(i,f){super(i),this.name="FormulaError",this.at=f}}function z(n){const i=[];let f=0;for(;f<n.length;){const u=n[f];if(u===" "||u===" "||u===`
7
7
  `||u==="\r"){f++;continue}if(u>="0"&&u<="9"){f=S(n,f,i);continue}if(u==="."&&n[f+1]>="0"&&n[f+1]<="9"){f=S(n,f,i);continue}if(u==='"'||u==="'"){f=g(n,f,i);continue}if(u==="["){const m=n.indexOf("]",f+1);if(m<0)throw new V("a [column reference] was opened and never closed",f);i.push({kind:B,value:n.slice(f+1,m).trim(),at:f}),f=m+1;continue}if(w(u)){f=l(n,f,i);continue}const o=n.slice(f,f+2);if(W.includes(o)){i.push({kind:_,value:o==="!="?"<>":o,at:f}),f+=2;continue}if(H.includes(u)){i.push({kind:_,value:u,at:f}),f++;continue}throw new V(`unexpected character ${JSON.stringify(u)}`,f)}return i.push({kind:X,value:null,at:n.length}),i}function w(n){return/[A-Za-z_À-￿]/.test(n)}function S(n,i,f){let u=i,o=!1;for(;u<n.length;){const m=n[u];if(m>="0"&&m<="9"){u++;continue}if(m==="."&&!o){o=!0,u++;continue}if((m==="e"||m==="E")&&/[0-9+-]/.test(n[u+1]||"")){for(u+=2;u<n.length&&n[u]>="0"&&n[u]<="9";)u++;break}break}return f.push({kind:Q,value:Number(n.slice(i,u)),at:i}),u}function g(n,i,f){const u=n[i];let o=i+1,m="";for(;o<n.length;){if(n[o]===u){if(n[o+1]===u){m+=u,o+=2;continue}return f.push({kind:x,value:m,at:i}),o+1}m+=n[o],o++}throw new V("a string was opened and never closed",i)}function l(n,i,f){let u=i;for(;u<n.length&&/[A-Za-z0-9_.À-￿]/.test(n[u]);)u++;const o=n.slice(i,u);let m=u;for(;m<n.length&&n[m]===" ";)m++;return f.push({kind:n[m]==="("?I:B,value:o,at:i}),u}const d={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function a(n){const i=String(n??"").replace(/^\s*=/,"");if(!i.trim())throw new V("the formula is empty");const f=z(i);let u=0;const o=()=>f[u],m=()=>f[u++],c=b=>{const v=o();if(v.kind!==_||v.value!==b)throw new V(`expected ${JSON.stringify(b)}`,v.at);u++},h=b=>{let v=s();for(;;){const R=o();if(R.kind!==_)break;const j=d[R.value];if(!j||j<b)break;u++;const F=h(R.value==="^"?j:j+1);v={kind:"bin",op:R.value,left:v,right:F}}return v},s=()=>{const b=o();return b.kind===_&&(b.value==="-"||b.value==="+")?(u++,{kind:"unary",op:b.value,arg:s()}):p()},p=()=>{let b=y();for(;o().kind===_&&o().value==="%";)u++,b={kind:"unary",op:"%",arg:b};return b},y=()=>{const b=m();if(b.kind===Q)return{kind:"num",value:b.value};if(b.kind===x)return{kind:"str",value:b.value};if(b.kind===B)return{kind:"ref",name:b.value};if(b.kind===I){c("(");const v=[];if(!(o().kind===_&&o().value===")"))for(;;){if(v.push(h(1)),o().kind===_&&o().value===","){u++;continue}break}return c(")"),{kind:"call",name:String(b.value).toUpperCase(),args:v}}if(b.kind===_&&b.value==="("){const v=h(1);return c(")"),v}throw b.kind===X?new V("the formula ends unexpectedly",b.at):new V(`unexpected ${JSON.stringify(b.value)}`,b.at)},O=h(1),A=o();if(A.kind!==X)throw new V(`unexpected ${JSON.stringify(A.value)}: is an operator missing?`,A.at);return O}function r(n){const i=new Set,f=u=>{if(!(!u||typeof u!="object")){if(u.kind==="ref"){i.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 o of u.args)f(o)}};return f(n),[...i]}function t(n){return typeof n=="string"&&/^\s*=/.test(n)&&n.trim()!=="="}}),Le("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 S}});const x=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 x(`${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 d of g){if(Array.isArray(d)){for(const a of d)a!=null&&a!==""&&l.push(B(a));continue}d==null||d===""||l.push(B(d))}return l}function W(g,l){const d=10**l,a=g*d;return Math.sign(a)*Math.round(Math.abs(a)+Number.EPSILON*Math.abs(a))/d}function H(g,l){if(!g.length)return 0;const d=g.slice().sort((n,i)=>n-i),a=(d.length-1)*Math.min(1,Math.max(0,l)),r=Math.floor(a),t=Math.ceil(a);return r===t?d[r]:d[r]+(a-r)*(d[t]-d[r])}function V(g,l){let d=0,a=0,r=0;for(const n of g){d++;const i=n-a;a+=i/d,r+=i*(n-a)}const t=l?d-1:d;return t>0?Math.sqrt(r/t):0}const z={SUM:g=>X(g).reduce((l,d)=>l+d,0),AVERAGE:g=>{const l=X(g);return l.length?l.reduce((d,a)=>d+a,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,d)=>l*d,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),d=B(g[0])*l;return(d<0?Math.ceil(d):Math.floor(d))/l},ROUNDUP:g=>{const l=10**(g.length>1?B(g[1]):0),d=B(g[0])*l;return(d<0?Math.floor(d):Math.ceil(d))/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 x("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=>V(X(g),!0),STDEVP:g=>V(X(g),!1),VAR:g=>{const l=V(X(g),!0);return l*l},VARP:g=>{const l=V(X(g),!1);return l*l},COUNTDISTINCT:g=>{const l=new Set;for(const d of g){const a=Array.isArray(d)?d:[d];for(const r of a)r!=null&&r!==""&&l.add(r)}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 d=Number(g),a=Number(l);if(g!==null&&g!==""&&l!==null&&l!==""&&Number.isFinite(d)&&Number.isFinite(a))return d<a?-1:d>a?1:0;const t=I(g).toLowerCase(),n=I(l).toLowerCase();return t<n?-1:t>n?1:0}function S(g,l={}){const d=typeof l.lookup=="function"?l.lookup:null,a=l.functions?{...z,...l.functions}:z,r=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!d)throw new x(`there is no column called ${JSON.stringify(t.name)} here`);const n=d(String(t.name));if(n===void 0)throw new x(`there is no column called ${JSON.stringify(t.name)}`);return n}case"unary":{if(t.op==="%")return B(r(t.arg))/100;const n=B(r(t.arg));return t.op==="-"?-n:n}case"bin":{const n=t.op;if(n==="=")return w(r(t.left),r(t.right))===0;if(n==="<>")return w(r(t.left),r(t.right))!==0;if(n==="<")return w(r(t.left),r(t.right))<0;if(n==="<=")return w(r(t.left),r(t.right))<=0;if(n===">")return w(r(t.left),r(t.right))>0;if(n===">=")return w(r(t.left),r(t.right))>=0;const i=B(r(t.left)),f=B(r(t.right));if(n==="+")return i+f;if(n==="-")return i-f;if(n==="*")return i*f;if(n==="^")return i**f;if(n==="/"){if(f===0)throw new x("division by zero");return i/f}throw new x(`unknown operator ${JSON.stringify(n)}`)}case"call":{const n=l.lazy&&l.lazy[t.name];if(typeof n=="function")return n(t.args,r,l);const i=a[t.name];if(typeof i!="function")throw new x(`there is no function called ${t.name}`);return i(t.args.map(r),l)}default:throw new x("the formula could not be read")}};return r(g)}}),Le("packages/core/src/formula/index.js",function(e,K){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return x}}),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 V}}),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"),x=Q.parseFormula,B=Q.referencesOf,I=Q.looksLikeFormula,_=Q.FormulaError,X=Q.tokenise,W=K("packages/core/src/formula/evaluate.js"),H=W.evaluateAst,V=W.FUNCTIONS;function z(S){const{grid:g,row:l,data:d}=S||{},a=f=>String(f).toLowerCase().replace(/[\s_-]/g,""),r=g&&g.columns&&typeof g.columns.all=="function"?g.columns.all():[],t=g&&g.permissions,n=t&&typeof t.isReadable=="function"?f=>t.isReadable(f):()=>!0,i=new Set;for(const f of r)n(f)||(i.add(a(f.id)),f.field&&i.add(a(f.field)),f.title&&i.add(a(f.title)));return f=>{const u=a(f);if(i.has(u))throw new _(`"${f}" cannot be read`);for(const o of r)if(a(o.id)===u||o.field&&a(o.field)===u||o.title&&a(o.title)===u)return l&&g.rows&&typeof g.rows.value=="function"?g.rows.value(l.key,o.id):d?d[o.field||o.id]:void 0;if(d&&typeof d=="object"){for(const o of Object.keys(d))if(a(o)===u){if(!n(o))throw new _(`"${f}" cannot be read`);return d[o]}}}}function w(S,g={}){try{const l=x(S);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}}}}),Le("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 V}});const Q=K("packages/core/src/internal/util.js"),x=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(!x(z)||Object.getPrototypeOf(z)!==Object.prototype&&Object.getPrototypeOf(z)!==null)return z;if(w.has(z))throw new X;w.add(z);const S={};for(const[g,l]of Object.entries(z))S[g]=W(l,w);return w.delete(z),S}function H(z){if(z===void 0)return W(_??{});if(z===null)return _=null,{};if(!x(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 V(z){return _===null?z:B(W(_),z)}}),Le("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"]),x=new Set(Q);function B(I){return I==="*"||x.has(I)}}),Le("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"),x=Q.warnOnce,B=Q.uid,I=Q.DEV,X=K("packages/core/src/events/names.js").isKnownEvent,W="*";function H(d,a){!I||X(a)||x(`bus.unknown:${a}`,`${d}('${a}') 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 V=new Set(["api","user","init","ai"]),z=new WeakMap;function w(d){let a=z.get(d);return a||(a=B("h"),z.set(d,a)),a}function S(){return typeof performance=="object"&&performance?performance.now():Date.now()}function g(d){if(!d||typeof d!="object")return{};const a={};for(const[r,t]of Object.entries(d))r!=="grid"&&(t==null?a[r]=String(t):Array.isArray(t)?a[r]=`[${t.length}]`:typeof t=="object"?a[r]=t.key?`row ${t.key}`:"{…}":typeof t=="function"?a[r]="[function]":a[r]=String(t).slice(0,60));return a}class l{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#s=!1;#l=0;constructor(a=null){this.#i=a}attach(a){this.#i=a}get grid(){return this.#i}get destroyed(){return this.#s}on(a,r){if(typeof r!="function")return x(`bus.handler:${a}`,`on('${a}') needs a function; ignored.`),()=>{};H("on",a);let t=this.#e.get(a);return t||(t=[],this.#e.set(a,t)),t.push(r),()=>this.off(a,r)}once(a,r){if(typeof r!="function")return x(`bus.handler:${a}`,`once('${a}') needs a function; ignored.`),()=>{};H("once",a);const t=n=>{this.off(a,r),r(n)};return this.#o.set(r,t),this.on(a,t)}off(a,r){if(r===void 0){this.#e.delete(a);return}const t=this.#e.get(a);if(!t)return;const n=this.#o.get(r),i=n&&t.includes(n)?n:r,f=t.indexOf(i);f>=0&&t.splice(f,1),n&&i===n&&this.#o.delete(r),t.length===0&&this.#e.delete(a)}count(a){const r=this.#e.get(a),t=a===W?null:this.#e.get(W);return(r?r.length:0)+(t?t.length:0)}#a(a,r,t,n,i){this.#n.push({type:a,origin:r,listeners:(n?n.length:0)+(i?i.length:0),payload:g(t),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(a,r){this.#t=!!a,Number.isFinite(r)&&r>0&&(this.#r=Math.floor(r)),a||(this.#n=[])}eventLog(){return this.#n.map(a=>({...a}))}clearEventLog(){this.#n=[]}counts(){const a={};for(const[r,t]of this.#e)a[r]=t.length;return a}emit(a,r,t){const n=t??(r&&r.origin),i=V.has(n)?n:"api",f={...r||null,type:a,origin:i,grid:this.#i};if(this.#s)return f;const u=this.#e.get(a),o=a===W?void 0:this.#e.get(W);if(this.#t&&this.#a(a,i,r,u,o),!u&&!o)return f;const m=this.#t?S():0;this.#l++;try{u&&this.#u(u.slice(),f,a),o&&this.#u(o.slice(),f,W)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=S()-m)}return f}emitBefore(a,r,t){const n=t??(r&&r.origin),i=V.has(n)?n:"user";let f=!1,u=null;const o=y=>{f=!0,y!=null&&u===null&&(u=String(y))},m={...r||null,type:a,origin:i,grid:this.#i,get defaultPrevented(){return f},get reason(){return u},preventDefault(y){o(y)}};if(this.#s)return!0;const c=this.#e.get(a);this.#t&&this.#a(a,i,r,c,void 0);const h=c?c.slice():[];if(h.length===0)return!0;const s=()=>(f&&u===null&&(u="prevented"),f&&r&&typeof r=="object"&&(r.reason=u),!f),p=[];for(const y of h)try{const O=y(m);O&&typeof O.then=="function"?p.push(O):O===!1&&o("prevented")}catch(O){o("error"),x(`bus.beforeThrow:${a}:${w(y)}`,`a '${a}' before-handler threw; the action was cancelled.`,O)}return p.length===0?s():Promise.allSettled(p).then(y=>{for(const O of y)O.status==="rejected"?(o("error"),x(`bus.beforeReject:${a}`,`a '${a}' before-handler rejected; the action was cancelled.`,O.reason)):O.value===!1&&o("prevented");return s()})}#u(a,r,t){for(let n=0;n<a.length;n++)try{a[n](r)}catch(i){x(`bus.throw:${t}:${w(a[n])}`,`a '${t}' handler threw; other handlers were unaffected.`,i)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#s=!0,this.#i=null}}}),Le("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"}),Le("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 V}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return S}}),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 a}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return b}}),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 j}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return F}});const x=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,V="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",w=(()=>{const C=new Int16Array(128).fill(-1);for(let T=0;T<z.length;T++)C[z.charCodeAt(T)]=T;return C[43]=62,C[47]=63,C})();function S(C){if(typeof C!="string")return null;let T="";for(let k=0;k<C.length;k++){const N=C.charCodeAt(k);if(N!==61){if(N>127||w[N]<0)return null;T+=C[k]}}const L=T.length;if(L%4===1)return null;const E=new Uint8Array(Math.floor(L*3/4));let D=0,$=0,P=0;for(let k=0;k<L;k++)D=D<<6|w[T.charCodeAt(k)],$+=6,$>=8&&($-=8,E[P++]=D>>$&255);return P===E.length?E:E.subarray(0,P)}function g(C){let T="",L=0;for(;L+2<C.length;L+=3){const D=C[L]<<16|C[L+1]<<8|C[L+2];T+=z[D>>18&63]+z[D>>12&63]+z[D>>6&63]+z[D&63]}const E=C.length-L;if(E===1){const D=C[L]<<16;T+=z[D>>18&63]+z[D>>12&63]}else if(E===2){const D=C[L]<<16|C[L+1]<<8;T+=z[D>>18&63]+z[D>>12&63]+z[D>>6&63]}return T}function l(C){const T=new Uint8Array(C.length);for(let L=0;L<C.length;L++)T[L]=C.charCodeAt(L)&127;return T}function d(C){if(typeof TextDecoder=="function")return new TextDecoder().decode(C);let T="";for(let L=0;L<C.length;L++)T+=String.fromCharCode(C[L]);return T}function a(C){const T={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{...T,reason:"missing"};const L=C.trim(),E=L.split(".");if(E.length!==3)return T;const[D,$,P]=E;if(D!==W)return{...T,reason:"prefix"};const k=S($),N=S(P);if(!k||!N)return T;let G;try{G=JSON.parse(d(k))}catch{return T}return G===null||typeof G!="object"?T:{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($),signature:N,raw:L}}function r(C,T){if(!C)return!1;const L=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(C)?`${C}T23:59:59.999Z`:C);return Number.isNaN(L)?!0:T>L}function t(C){return C==="non-commercial"?"non-commercial":"commercial"}let n=null,i=null,f=null;function u(){const C=globalThis.crypto;return C&&C.subtle?C.subtle:null}async function o(C){if(n&&i===C)return n;const T=u();if(!T)return null;const L=S(C);if(!L)return null;try{const E=await T.importKey("raw",L,{name:"Ed25519"},!1,["verify"]);return n=E,i=C,E}catch{return null}}async function m(){return f!==null||(f=await o(V)!==null),f}async function c(C,T={}){const L=T.warn!==!1,E=T.product||_,D=T.publicKey||V,$=T.now??Date.now(),P=T.host??s(),k=h(P)?"":` ${I}`,N=a(C);if(!N.ok){const te=N.reason==="missing"?"missing":"malformed";return L&&x(`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.${k}`:`licence key could not be read. The grid will render with a watermark.${k}`),{valid:!1,reason:te,terms:"commercial"}}const G={product:N.product||void 0,issuedTo:N.issuedTo||void 0,expires:N.expires||void 0,terms:t(N.terms)};if(N.product!==E)return L&&x("licence.product",`licence key is for '${N.product}', not '${E}'. The grid will render with a watermark.`),{valid:!1,...G,reason:"product"};if(r(N.expires,$))return L&&x("licence.expired",`licence expired on ${N.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...G,reason:"expired"};const q=N.deployments||[];if(q.length&&P&&!h(P)&&!p(P,q))return L&&x("licence.domain",`licence key is not valid for ${P}; it covers ${q.join(", ")}. The grid will render with a watermark.`),{valid:!1,...G,reason:"domain"};const Y=await o(D);if(!Y){const te=!!N.signature&&N.signature.length===H;return L&&x("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,N.signature,N.message)}catch{J=!1}return J?{valid:!0,...G}:(L&&x("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...G,reason:"signature"})}function h(C){const T=String(C??s()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!T||T==="localhost"||T.endsWith(".localhost")||T==="::1"||T==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(T)}function s(){const C=globalThis.location;return C&&typeof C.hostname=="string"?C.hostname:null}function p(C,T){const L=y(C);return!L||!Array.isArray(T)?!1:T.some(E=>{const D=y(E);if(!D)return!1;if(D==="*")return!0;if(D.startsWith("*.")){const $=D.slice(2);return L===$||L.endsWith(`.${$}`)}return L===D})}function y(C){return String(C??"").trim().toLowerCase().replace(/\.$/,"")}class O{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#o;#i=new Set;constructor(T={}){this.#o=T}set(T){this.#e=typeof T=="string"?T.trim():"";const L=a(this.#e);return this.#t=L.ok?{valid:!r(L.expires,Date.now())&&L.product===(this.#o.product||_),product:L.product||void 0,issuedTo:L.issuedTo||void 0,expires:L.expires||void 0,terms:t(L.terms),reason:"pending"}:{valid:!1,reason:L.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const T=this.#e;return this.#n=c(T,this.#o).then(L=>{if(this.#e===T){this.#t=L;for(const E of this.#i)E(L)}return L}),this.#n}onSettled(T){return this.#i.add(T),()=>this.#i.delete(T)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!h(this.#r)}setHost(T){this.#r=T}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 A=new O;function b(C){return A.set(C)}function v(){return A.info()}function R(){return A.watermark()}function j(){return A.state()}function F(){return A}}),Le("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 V}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return t}});const Q=K("packages/core/src/internal/util.js"),x=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"],V=["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(i={}){for(const f of H)this.#t.set(f,new Map);this.#o=i.holder||W(),this.#s=i.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),i.licence&&this.setLicence(i.licence)}registerModules(i,f={}){f.licence&&this.setLicence(f.licence),f.grid!==void 0&&(this.#s=f.grid);const u=Array.isArray(i)?i:[i],o=[];for(const m of u){if(!m||typeof m!="object"||typeof m.name!="string"||!m.name){x("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)){x(`registry.module.install:${m.name}`,`module '${m.name}' has no install() and was ignored.`);continue}const c={registry:this,grid:this.#s};try{m.install(c)}catch(h){x(`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);o.push(m.name),this.#d({reason:"module",name:m.name,capabilities:this.capabilities(),regions:l(m)})}return o}unregisterModule(i){const f=this.#e.get(i);if(!f)return!1;if(B(f.uninstall))try{f.uninstall({registry:this,grid:this.#s})}catch(u){x(`registry.module.uninstall:${i}`,`module '${i}' threw during uninstall.`,u)}return this.#e.delete(i),this.#u(),this.#d({reason:"unmodule",name:i,capabilities:this.capabilities(),regions:l(f)}),!0}modules(){return[...this.#e.values()]}has(i){return this.#e.has(i)}#u(){this.#n.clear();for(const i of this.#e.values())for(const f of w(i))this.#n.add(f)}#c(i,f){!i||i===f||S(i,f)||x(`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(i){return this.#n.has(i)}onChange(i){return B(i)?(this.#r.add(i),this.#a.set(i,this.#s),()=>{this.#r.delete(i),this.#a.delete(i)}):()=>{}}#d(i){for(const f of[...this.#r])try{f(i)}catch(u){x("registry.onChange.throw","a registry change handler threw.",u)}}register(i,f,u){const o=this.#t.get(i);if(!o){x(`registry.kind:${i}`,`unknown registry kind '${i}'; expected one of ${H.join(", ")}.`);return}if(!f||typeof f!="string"){x(`registry.name:${i}`,`register('${i}', ...) needs a name.`);return}o.has(f)&&o.get(f)!==u&&x(`registry.replace:${i}:${f}`,`'${f}' was already registered as a ${i} and has been replaced.`),o.set(f,u),this.#d({reason:"register",name:f,kind:i,capabilities:this.capabilities(),regions:d(i)})}registerAll(i,f){if(f)for(const u of Object.keys(f))this.register(i,u,f[u])}get(i,f){const u=this.#t.get(i);return u?u.get(f):void 0}names(i){const f=this.#t.get(i);return f?[...f.keys()]:[]}#f(i,f){const u=this.#t.get(i).get(f);return u!==void 0?u:this.#t.get("component").get(f)}renderer(i){return this.#f("renderer",i)}editor(i){return this.#f("editor",i)}filter(i){return this.#f("filter",i)}dataType(i){return this.get("dataType",i)}totalFn(i){return this.get("totalFn",i)}pipe(i){return this.get("pipe",i)}setLicence(i){return this.#o.set(i)}licence(){return this.#o.info()}licenceVerified(){return this.#o.verify()}watermark(){return this.#o.watermark()}attach(i){i!=null&&(this.#l.add(i),this.#s=i)}detach(i){if(i!=null){this.#l.delete(i);for(const[f,u]of[...this.#a])u===i&&(this.#r.delete(f),this.#a.delete(f));if(this.#s===i){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(i){if(i!=null){this.detach(i);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(n){const i=n.capabilities,f=Array.isArray(i)?i.filter(u=>typeof u=="string"):[];return[n.name,...f]}function S(n,i){return n.install!==i.install||n.uninstall!==i.uninstall||(n.version||"")!==(i.version||"")?!1:g(w(n),w(i))&&g(l(n),l(i))}function g(n,i){const f=new Set(n),u=new Set(i);if(f.size!==u.size)return!1;for(const o of f)if(!u.has(o))return!1;return!0}function l(n){const i=n.regions;return!Array.isArray(i)||i.length===0?["all"]:i.filter(f=>V.includes(f))}function d(n){switch(n){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const a=new z;function r(){return a}function t(n,i={}){return a.registerModules(n,i)}}),Le("packages/core/src/format/number.js",function(e,K){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return B}});const x=K("packages/core/src/internal/util.js").isNil;function B(I,_){const X=I||{},W=X.locale||_||void 0,H=X.style||"decimal",V=typeof X.scale=="number"?X.scale:1,z=X.nullDisplay??"",w=X.zeroDisplay,S=X.prefix||"",g=X.suffix||"",l=X.negative||"minus",d=X.signed===!0,a={style:H,notation:X.notation||"standard"};H==="currency"&&(a.currency=X.currency||"USD",X.currencyDisplay&&(a.currencyDisplay=X.currencyDisplay)),typeof X.decimals=="number"?(a.minimumFractionDigits=X.decimals,a.maximumFractionDigits=X.decimals):(typeof X.minDecimals=="number"&&(a.minimumFractionDigits=X.minDecimals),typeof X.maxDecimals=="number"&&(a.maximumFractionDigits=X.maxDecimals),a.minimumFractionDigits>(a.maximumFractionDigits??20)&&(a.maximumFractionDigits=a.minimumFractionDigits)),X.thousandsSeparator===!1&&(a.useGrouping=!1),a.notation==="compact"&&(a.compactDisplay=X.compactDisplay||"short");const r=new Intl.NumberFormat(W,a),t=typeof X.thousandsSeparator=="string"?X.thousandsSeparator:null,n=typeof X.decimalSeparator=="string"?X.decimalSeparator:null;let i=",",f=".";if(t||n)for(const s of r.formatToParts(12345.6))s.type==="group"?i=s.value:s.type==="decimal"&&(f=s.value);const u=s=>{let p=s;return t&&(p=p.split(i).join("")),n&&(p=p.split(f).join("")),t&&(p=p.split("").join(t)),n&&(p=p.split("").join(n)),p},o=!!(t||n),m=S!==""&&H==="currency",c=s=>{let p;if(m){const y=r.formatToParts(s);let O=!1;p="";for(const A of y)p+=A.value,!O&&A.type==="currency"&&(p+=S,O=!0);O||(p=S+p)}else p=S+r.format(s);return o&&(p=u(p)),p+g},h=s=>{if(x(s)||s==="")return z;const p=typeof s=="number"?s:Number(s);if(Number.isNaN(p))return z;const y=V===1?p:p*V;return y===0&&w!==void 0?w:y<0?l==="parentheses"?`(${c(-y)})`:l==="suffix"?`${c(-y)}-`:c(y):d&&y>0?`+${c(y)}`:c(y)};return h.negativeClass=X.negativeClass||null,h.spec=X,h}}),Le("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 S}}),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 r}});const Q=K("packages/core/src/internal/util.js"),x=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 n=[];let i=0,f="";const u=()=>{f&&(n.push({token:null,text:f}),f="")};for(;i<t.length;){const o=t[i];if(o==="'"){if(t[i+1]==="'"){f+="'",i+=2;continue}const c=t.indexOf("'",i+1);if(c===-1){f+=t.slice(i+1),i=t.length;continue}f+=t.slice(i+1,c),i=c+1;continue}const m=I.find(c=>t.startsWith(c,i));if(m){u(),n.push({token:m,text:m}),i+=m.length;continue}/[A-Za-z]/.test(o)&&B(`date.pattern.token:${o}`,`the date pattern "${t}" contains '${o}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${I.join(" ")}.`),f+=o,i+=1}return u(),n}const X=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function W(t){if(x(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 n=X.exec(t.trim());if(n){const[,f,u,o,m="0",c="0",h="0"]=n;return new Date(+f,+u-1,+o,+m,+c,+h)}const i=new Date(t);return Number.isNaN(i.getTime())?null:i}return null}function H(t,n){return String(t).padStart(n,"0")}function V(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 n=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"}),i={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 o of n.formatToParts(f))switch(o.type){case"year":u.year=Number(o.value);break;case"month":u.month=Number(o.value);break;case"day":u.day=Number(o.value);break;case"hour":u.hour=Number(o.value)%24;break;case"minute":u.minute=Number(o.value);break;case"second":u.second=Number(o.value);break;case"weekday":u.weekday=i[o.value]??0;break;default:break}return u}}function z(t,n,i){const f=_(t),u=V(i),o=new Set(f.filter(p=>p.token).map(p=>p.token)),m=o.has("MMM")?new Intl.DateTimeFormat(n,{month:"short",timeZone:i}):null,c=o.has("MMMM")?new Intl.DateTimeFormat(n,{month:"long",timeZone:i}):null,h=o.has("EEE")?new Intl.DateTimeFormat(n,{weekday:"short",timeZone:i}):null,s=o.has("EEEE")?new Intl.DateTimeFormat(n,{weekday:"long",timeZone:i}):null;return p=>{const y=u(p);let O="";for(const A of f){if(!A.token){O+=A.text;continue}switch(A.token){case"yyyy":O+=H(y.year,4);break;case"yy":O+=H(y.year%100,2);break;case"MMMM":O+=c.format(p);break;case"MMM":O+=m.format(p);break;case"MM":O+=H(y.month,2);break;case"M":O+=String(y.month);break;case"dd":O+=H(y.day,2);break;case"d":O+=String(y.day);break;case"EEEE":O+=s.format(p);break;case"EEE":O+=h.format(p);break;case"HH":O+=H(y.hour,2);break;case"H":O+=String(y.hour);break;case"hh":O+=H(y.hour%12===0?12:y.hour%12,2);break;case"h":O+=String(y.hour%12===0?12:y.hour%12);break;case"mm":O+=H(y.minute,2);break;case"m":O+=String(y.minute);break;case"ss":O+=H(y.second,2);break;case"s":O+=String(y.second);break;case"SSS":O+=H(y.ms,3);break;case"a":O+=y.hour<12?"AM":"PM";break;default:O+=A.text;break}}return O}}const w=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function S(t,n){const i=t||{},f=i.locale||n||void 0,u=i.nullDisplay??"",o=i.timeZone;let m;if(i.pattern)m=z(i.pattern,f,o);else if(i.dateStyle||i.timeStyle){const y={timeZone:o};i.dateStyle&&(y.dateStyle=i.dateStyle),i.timeStyle&&(y.timeStyle=i.timeStyle);const O=new Intl.DateTimeFormat(f,y);m=A=>O.format(A)}else{const y=new Intl.DateTimeFormat(f,{dateStyle:"medium",timeZone:o});m=O=>y.format(O)}const c=i.relative?new Intl.RelativeTimeFormat(f,{numeric:"auto"}):null,s=(typeof i.relative=="object"&&i.relative?i.relative.threshold??7:7)*24*36e5,p=(y,O)=>{const A=W(y);if(!A)return u;if(c){const b=O&&typeof O.now=="number"?O.now:Date.now(),v=A.getTime()-b;if(Math.abs(v)<s){for(const[R,j]of w)if(Math.abs(v)>=j||R==="second")return c.format(Math.round(v/j),R)}}return m(A)};return p.spec=i,p}function g(t){if(x(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 n=W(t);if(!n)return null;const i=f=>String(f).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())}`}function l(t,n){if(x(t)||t==="")return null;if(typeof t=="string"){const f=t.trim();if(d.test(f)){const m=W(f);return m?a(m,n):null}const u=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(f);if(u){const[,m,c,h,s]=u;return`${m}T${c}:${h}${s&&s!=="00"?`:${s}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(f))return`${f}T00:00`;const o=W(f);return o?l(o):null}const i=W(t);return i?a(i,n):null}const d=/(?:Z|[+-]\d{2}:?\d{2})$/i;function a(t,n){const i=m=>String(m).padStart(2,"0");if(n)try{const m=new Intl.DateTimeFormat("en-CA",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(t).reduce((s,p)=>(p.type!=="literal"&&(s[p.type]=p.value),s),{}),c=m.hour==="24"?"00":m.hour,h=Number(m.second);return`${m.year}-${m.month}-${m.day}T${c}:${m.minute}`+(h?`:${m.second}`:"")}catch{}const f=`${t.getFullYear()}-${i(t.getMonth()+1)}-${i(t.getDate())}`,u=t.getSeconds(),o=`${i(t.getHours())}:${i(t.getMinutes())}${u?`:${i(u)}`:""}`;return`${f}T${o}`}function r(t,n){const i=x(t)||t===""?null:String(t),f=x(n)||n===""?null:String(n);return i===null?f===null?0:1:f===null||i<f?-1:i>f?1:0}}),Le("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 x=K("packages/core/src/internal/util.js").isNil,B={true:"☑",false:"☐",null:""},I={true:"◉",false:"◯",null:""};function _(W){if(x(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 V=W||{},z=V.display||"text",w=V.trueLabel??"Yes",S=V.falseLabel??"No",g=V.nullLabel??"";let l=w,d=S;const a=g;z==="checkbox"?(l=B.true,d=B.false):z==="switch"?(l=I.true,d=I.false):z==="icon"&&(l=V.trueIcon??w,d=V.falseIcon??S);const r=t=>{const n=_(t);return n===null?a:n?l:d};return r.display=z,r.labels={true:w,false:S,null:g},r.locale=H,r.spec=V,r}}),Le("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"),x=Q.isNil,B=Q.titleCase;function I(_,X){const W=_||{},H=W.locale||X||void 0,V=W.nullDisplay??"",z=W.emptyDisplay??"",w=W.transform||"none",S=typeof W.truncate=="number"?{chars:W.truncate}:W.truncate||null,g=S?S.chars:0,l=S?S.ellipsis??"…":"",d=r=>{switch(w){case"upper":return H?r.toLocaleUpperCase(H):r.toUpperCase();case"lower":return H?r.toLocaleLowerCase(H):r.toLowerCase();case"title":return B(r);default:return r}},a=r=>{if(x(r))return V;let t=typeof r=="string"?r:String(r);return t===""?z:(w!=="none"&&(t=d(t)),g>0&&t.length>g&&(t=t.slice(0,g)+l),t)};return a.spec=W,a}}),Le("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","#","?",",","."]),x="\0";function B(H){const V=[];let z="",w=!1;for(let S=0;S<H.length;S++){const g=H[S];if(g==="\\"){z+=g+(H[S+1]??""),S+=1;continue}if(g==='"'){w=!w,z+=g;continue}if(g===";"&&!w){V.push(z),z="";continue}z+=g}return V.push(z),V}function I(H){let V="",z="",w="",S=1,g=!1,l=!1;const d=m=>{l?z+=m:V+=m};for(let m=0;m<H.length;m++){const c=H[m];if(c==="\\"){d(H[m+1]??""),m+=1;continue}if(c==='"'){const h=H.indexOf('"',m+1);d(h===-1?H.slice(m+1):H.slice(m+1,h)),m=h===-1?H.length:h;continue}if(c==="%"){S*=100,d("%");continue}if(c==="@"){g=!0,d("\0");continue}if(Q.has(c)){w+=c,l=!0;continue}d(c)}let a=-1;for(let m=w.length-1;m>=0;m--){const c=w[m];if(c==="0"||c==="#"||c==="?"){a=m;break}}let r=!1,t="";for(let m=0;m<w.length;m++){const c=w[m];if(c===","){m>a?S/=1e3:r=!0;continue}t+=c}const n=t.indexOf("."),i=n===-1?t:t.slice(0,n),f=n===-1?"":t.slice(n+1);let u=0;for(const m of i)m==="0"&&(u+=1);let o=0;for(const m of f)m==="0"&&(o+=1);return{prefix:V,suffix:z,minInt:u,minDec:o,maxDec:f.length,grouping:r,scale:S,hasNumber:a!==-1,isText:g}}function _(H,V){const z=new Intl.NumberFormat(V,{minimumIntegerDigits:Math.max(H.minInt,1),minimumFractionDigits:H.minDec,maximumFractionDigits:Math.max(H.maxDec,H.minDec),useGrouping:H.grouping}),{prefix:w,suffix:S,scale:g,hasNumber:l}=H;return d=>{if(!l)return w+S;const a=g===1?d:d*g;return w+z.format(a)+S}}function X(H,V){const w=B(String(H)).map(I),S=w.map(t=>_(t,V)),g=0,l=w.length>1?1:-1,d=w.length>2?2:-1,a=w.length>3?3:-1,r=t=>{if(t==null||t==="")return"";if(typeof t!="number"||Number.isNaN(t)){const n=Number(t);if(Number.isNaN(n))return a===-1?String(t):(w[a].prefix+w[a].suffix).split("\0").join(String(t));t=n}return t===0&&d!==-1?S[d](0):t<0&&l!==-1?S[l](-t):S[g](t)};return r.spec={mask:H},{format:r,ooxml:W(String(H))}}function W(H){return H.trim()}}),Le("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"],x=/[#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:x.test(H)}function _(H){return typeof H!="string"||H===""||X(H)?!1:B.test(H)}function X(H){const V=H.indexOf(":"),z=V===-1?H:H.slice(0,V);return Q.includes(z)?z:null}function W(H){const V=X(H);if(!V)return null;const z=H.indexOf(":"),w=z===-1?"":H.slice(z+1),S=w===""?[]:w.split(":");switch(V){case"currency":{const g={type:"number",style:"currency",currency:S[0]||"USD"};return S[1]!==void 0&&S[1]!==""&&(g.decimals=Number(S[1])),g}case"number":{const g={type:"number",style:"decimal"};return S[0]!==void 0&&S[0]!==""&&(g.decimals=Number(S[0])),g}case"percent":{const g={type:"number",style:"percent"};return S[0]!==void 0&&S[0]!==""&&(g.decimals=Number(S[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 S[0]&&(g.transform=S[0]),S[1]!==void 0&&S[1]!==""&&(g.truncate=Number(S[1])),g}default:return null}}}),Le("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 O}});const Q=K("packages/core/src/internal/util.js"),x=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,V=W.scanPattern,z=K("packages/core/src/format/boolean.js"),w=z.compileBoolean,S=K("packages/core/src/format/text.js"),g=S.compileText,l=K("packages/core/src/format/mask.js"),d=l.compileMask,a=K("packages/core/src/format/shorthand.js"),r=a.parseShorthand,t=a.looksLikeMask,n=a.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 S.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 a.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return a.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return a.looksLikeDatePattern}});const i=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"])},o=new Set(["number","date","boolean","text"]);function m(R,j){const F=R.type;if(F===void 0||o.has(F)||!i.has(String(F)))return;const C=j?`"${j}"`:"with no id";I(`format:unknown-style-key:${j||""}:${F}`,`column ${C} has format: { type: "${F}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${F}" instead?`)}function c(R,j,F){const C=u[j],T=F?`"${F}"`:"with no id";for(const L of R){if(f.has(L)||C.has(L))continue;const E=Object.keys(u).find(D=>D!==j&&u[D].has(L));E?I(`format:inapplicable:${F||""}:${L}`,`column ${T} has format key "${L}", which applies to a ${E} column, not the ${j} column it was applied to; it is ignored.`):I(`format:unknown:${F||""}:${L}`,`column ${T} has an unrecognised format key "${L}" for its ${j} format; it is ignored.`)}}function h(R){if(R.type==="number"||R.type==="date"||R.type==="boolean"||R.type==="text")return!0;const j=i.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||j||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 s(R,j){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 F=j&&j.base;return F==="number"?"number":F==="date"||F==="dateString"?"date":F==="boolean"?"boolean":"text"}function p(R,j=null,F=void 0,C=void 0,T=void 0){if(R==null||R==="")return null;const L=B(R)?Object.keys(R):null;if(typeof R=="function"){const $=(P,k)=>String(R({...k||{},value:P,locale:F})??"");return $.ooxml=j&&j.excel||"General",$}if(typeof R=="string"){if(t(R)){const{format:P,ooxml:k}=d(R,F);return P.ooxml=k,P}const $=r(R)||(n(R)?{type:"date",pattern:R}:null);return $?p($,j,F,C,T):(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(j&&x(j.format)&&!h(R)||j&&x(j.format)&&Array.isArray(j.formatPatterns)&&R.type===void 0)return null;const E=s(R,j);E==="date"&&C&&R.timeZone===void 0&&(R={...R,timeZone:C}),m(R,T),c(L||Object.keys(R),E,T);let D;switch(E){case"number":D=X(R,F);break;case"date":D=H(R,F);break;case"boolean":D=w(R,F);break;default:D=g(R,F);break}return D.ooxml=O(R,E,F,j),D.kind=E,D}const y={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 O(R,j,F=void 0,C=null){if(j==="date"){if(R.pattern){let $="";for(const P of V(R.pattern))$+=P.token?y[P.token]??P.text:P.text;return $}return C&&C.excel||"yyyy-mm-dd"}if(j==="boolean")return"General";if(j==="text")return"@";if(R.notation==="compact"||R.notation==="scientific")return"General";const T=typeof R.decimals=="number"?R.decimals:typeof R.minDecimals=="number"?R.minDecimals:R.style==="currency"?2:0;let E=`${R.thousandsSeparator===!1?"":"#,#"}#0${T>0?`.${"0".repeat(T)}`:""}`,D="";return R.style==="currency"&&(D+=A(v(R.currency||"USD",F))),R.prefix&&(D+=A(R.prefix)),E=D+E,R.style==="percent"&&(E=`${E}%`),R.suffix&&(E+=A(R.suffix)),R.negative==="parentheses"?`${E};(${E})`:R.negative==="suffix"?`${E};${E}-`:E}function A(R){return`"${String(R).split('"').join("")}"`}const b=new Map;function v(R,j){const F=`${R}|${j||""}`;let C=b.get(F);if(C!==void 0)return C;C=R;try{const L=new Intl.NumberFormat(j,{style:"currency",currency:R}).formatToParts(0).find(E=>E.type==="currency");L&&(C=L.value)}catch{}return b.set(F,C),C}}),Le("packages/core/src/columns/types/temporal.js",function(e,K){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return S}}),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 d}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return c}}),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 j}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return $}}),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 ye}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Ye}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,B=Q.isFunction,I=K("packages/core/src/format/date.js"),_=I.toDate,X=I.compilePattern,W=I.compileDate,H=I.toIsoDateTime,V=I.compareIso,z=864e5,w=Object.freeze({}),S=1e3,g=60*S,l=60*g,d=24*l,a=7*d,r=new WeakMap;function t(je,He){const Ze=je&&je.locale||"",rt=je&&je.column;if(!rt)return Ze?{locale:Ze}:w;const st=r.get(rt);if(st&&st.locale===Ze)return st.bag;const ht=rt.typeOptions||rt[He]||(n(rt.format)?rt.format:null),yt={...ht||w,locale:ht&&ht.locale||Ze||void 0};return r.set(rt,{locale:Ze,bag:yt}),yt}function n(je){return je!==null&&typeof je=="object"&&!Array.isArray(je)&&!(je instanceof Date)}function i(je,He){const Ze=je===null||Number.isNaN(je)?null:je,rt=He===null||Number.isNaN(He)?null:He;return Ze===null?rt===null?0:1:rt===null||Ze<rt?-1:Ze>rt?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 o(je,He,Ze,rt){return!(je>=0&&je<=23)||!(He>=0&&He<=59)||!(Ze>=0&&Ze<=59)||!(rt>=0&&rt<=999)?null:je*l+He*g+Ze*S+rt}function m(je){if(x(je))return null;const He=String(je).trim();if(He==="")return null;const Ze=u.exec(He);if(Ze){const Tt=Ze[1];if(Tt.length===5)return null;const Et=Tt.length===3?1:2;return o(Number(Tt.slice(0,Et)),Number(Tt.slice(Et,Et+2)),Number(Tt.slice(Et+2,Et+4)||0),0)}const rt=f.exec(He);if(!rt)return null;let st=Number(rt[1]);const ht=Number(rt[2]||0),yt=Number(rt[3]||0),St=rt[4]?Number(rt[4].padEnd(3,"0")):0,Ct=rt[5]?rt[5][0].toLowerCase():null;if(Ct){if(st<1||st>12)return null;st=st%12,Ct==="p"&&(st+=12)}return o(st,ht,yt,St)}function c(je){return x(je)||je===""?null:typeof je=="number"?Number.isFinite(je)?(je%d+d)%d:null:je instanceof Date?Number.isNaN(je.getTime())?null:je.getHours()*l+je.getMinutes()*g+je.getSeconds()*S+je.getMilliseconds():m(je)}const h=new Map;function s(je){const He=je.pattern||"",Ze=je.timeStyle||(je.seconds?"medium":"short"),rt=`${je.locale||""}|${He}|${Ze}`;let st=h.get(rt);if(st)return st;if(He)st=X(He,je.locale||void 0,"UTC");else{const ht=new Intl.DateTimeFormat(je.locale||void 0,{timeStyle:Ze,timeZone:"UTC"});st=yt=>ht.format(yt)}return h.set(rt,st),st}function p(je,He){const Ze=He||w;if(je==null||typeof je!="number"||!Number.isFinite(je))return Ze.nullDisplay??"";const rt=(je%d+d)%d;return s(Ze)(new Date(rt))}function y(je){return je instanceof Date?!Number.isNaN(je.getTime()):typeof je=="number"?Number.isFinite(je)&&je>=0&&je<d:typeof je!="string"||!je.includes(":")?!1:m(je)!==null}function O(je){const He=c(je);return He==null?"":p(He,{pattern:He%S===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const A=new Map;function b(je){const He=je||"";let Ze=A.get(He);return Ze||(Ze=new Intl.DateTimeFormat("en-GB",{timeZone:je||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),A.set(He,Ze)),Ze}function v(je,He){const Ze={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const rt of b(He).formatToParts(new Date(je)))rt.type==="year"?Ze.year=Number(rt.value):rt.type==="month"?Ze.month=Number(rt.value):rt.type==="day"?Ze.day=Number(rt.value):rt.type==="hour"?Ze.hour=Number(rt.value)%24:rt.type==="minute"?Ze.minute=Number(rt.value):rt.type==="second"&&(Ze.second=Number(rt.value));return Ze}function R(je,He){const Ze=v(je,He);return Date.UTC(Ze.year,Ze.month-1,Ze.day,Ze.hour,Ze.minute,Ze.second,0)-Math.floor(je/1e3)*1e3}function j(je,He){const Ze=je.hour||0,rt=je.minute||0,st=je.second||0,ht=je.ms||0;if(!He)return new Date(je.year,je.month-1,je.day,Ze,rt,st,ht).getTime();const yt=Date.UTC(je.year,je.month-1,je.day,Ze,rt,st,ht);let St=yt-R(yt,He);return St=yt-R(St,He),St}const F=/(?:Z|[+-]\d{2}:?\d{2})$/i,C=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function T(je,He){if(x(je))return null;const Ze=String(je).trim();if(Ze==="")return null;const rt=He&&He.timeZone||void 0;if(!F.test(Ze)){const st=C.exec(Ze);if(st){const ht=(st[4]||"").trim(),yt=ht===""?0:m(ht);if(yt===null)return null;const St=j({year:Number(st[1]),month:Number(st[2]),day:Number(st[3]),hour:Math.floor(yt/l),minute:Math.floor(yt/g)%60,second:Math.floor(yt/S)%60,ms:yt%S},rt);return Number.isNaN(St)?null:new Date(St)}}return _(Ze)}function L(je){if(typeof je=="number")return Number.isFinite(je)?je:null;const He=_(je);return He?He.getTime():null}const E=new Map;function D(je){const He=[je.locale||"",je.pattern||"",je.dateStyle||"",je.timeStyle||"",je.timeZone||"",je.seconds?"1":""].join("|");let Ze=E.get(He);if(Ze)return Ze;const rt=je.pattern?{type:"date",pattern:je.pattern,timeZone:je.timeZone}:{type:"date",dateStyle:je.dateStyle||"medium",timeStyle:je.timeStyle||(je.seconds?"medium":"short"),timeZone:je.timeZone};return Ze=W(rt,je.locale||void 0),E.set(He,Ze),Ze}function $(je,He){const Ze=He||w,rt=L(je);return rt==null?Ze.nullDisplay??"":D(Ze)(rt)}function P(je){return je instanceof Date?!Number.isNaN(je.getTime()):typeof je!="string"||!C.test(je.trim())?!1:T(je)!==null}const k=Object.freeze([{key:"w",ms:a,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:d,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms: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:S,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"]}]),N=new Map;for(const je of k)for(const He of je.names)N.set(He,je);const G=Object.freeze(k.filter(je=>je.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(je){const He=je&&je.defaultUnit?N.get(String(je.defaultUnit).toLowerCase()):null;return He?He.ms:g}function ne(je){return(je&&je.defaultUnit?N.get(String(je.defaultUnit).toLowerCase()):null)||N.get("m")}function oe(je,He){if(x(je))return null;let Ze=String(je).trim().toLowerCase();if(Ze==="")return null;let rt=1;if(Ze[0]==="-"?(rt=-1,Ze=Ze.slice(1).trim()):Ze[0]==="+"&&(Ze=Ze.slice(1).trim()),Ze==="")return null;const st=J.exec(Ze);if(st){const Ct=st[3]!==void 0,Tt=Number(st[1])*l+Number(st[2])*g+(Ct?Number(st[3])*S:0)+(st[4]?Number(st[4].padEnd(3,"0")):0);return rt*Tt}if(Y.test(Ze))return Math.round(rt*Number(Ze)*te(He||w));let ht=Ze,yt=0,St=0;for(;ht!=="";){const Ct=q.exec(ht);if(!Ct)return null;const Tt=N.get(Ct[2]);if(!Tt)return null;yt+=Number(Ct[1])*Tt.ms,ht=ht.slice(Ct[0].length),St++}return St===0?null:Math.round(rt*yt)}function le(je){return x(je)||je===""?null:typeof je=="number"?Number.isFinite(je)?je:null:oe(je)}const ae=new Map;function se(je,He,Ze){const rt=`${Ze||""}|${He.intl}`;let st=ae.get(rt);if(st===void 0){try{st=new Intl.NumberFormat(Ze||void 0,{style:"unit",unit:He.intl,unitDisplay:"long"})}catch{st=null}ae.set(rt,st)}return st?st.format(je):`${je} ${je===1?He.long[0]:He.long[1]}`}function ee(je,He){return String(je).padStart(He,"0")}function ie(je,He){const Ze=He||w;if(je==null||typeof je!="number"||!Number.isFinite(je))return Ze.nullDisplay??"";const rt=Ze.style||"short",st=je<0;let ht=Math.round(Math.abs(je));const yt=st?"-":"";if(ht===0&&Ze.zeroDisplay!=null)return Ze.zeroDisplay;if(rt==="clock"){const Et=Math.floor(ht/l),Bt=Math.floor(ht/g)%60,Dt=Math.floor(ht/S)%60;return`${yt}${ee(Et,2)}:${ee(Bt,2)}:${ee(Dt,2)}`}if(ht===0){const Et=ne(Ze);return rt==="long"?se(0,Et,Ze.locale):`0${Et.key}`}const St=Ze.weeks===!0?k:G,Ct=typeof Ze.maxUnits=="number"&&Ze.maxUnits>0?Ze.maxUnits:Ze.maxUnits===void 0?2:1/0,Tt=[];for(const Et of St){if(Tt.length>=Ct)break;const Bt=Math.floor(ht/Et.ms);Bt!==0&&(ht-=Bt*Et.ms,Tt.push(rt==="long"?se(Bt,Et,Ze.locale):`${Bt}${Et.key}`))}return yt+Tt.join(" ")}function de(je){if(typeof je!="string")return!1;const He=je.trim();return He===""||J.test(He)||!/[a-z]/i.test(He)?!1:oe(He)!==null}const he=Date.UTC(1899,11,30),ge=new Map;function Ee(je,He){const Ze=je||"";let rt=ge.get(Ze);rt||(rt=new Intl.DateTimeFormat("en-GB",{timeZone:je||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),ge.set(Ze,rt));const st=typeof He=="number"?He:Date.now();for(const ht of rt.formatToParts(new Date(st)))if(ht.type==="timeZoneName")return ht.value;return""}function ye(je){if(je)return je;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Ae(je,He){const Ze=ye(je),rt=Ee(je,He);return rt?`${Ze} (${rt})`:Ze}function pe(je,He){if(je&&je.timeZone)return je.timeZone;const Ze=He&&He.grid;return(Ze&&B(Ze.get)?Ze.get("timeZone"):void 0)||void 0}function we(je,He){const Ze=He||w,rt=L(je);if(rt==null)return Ze.nullDisplay??"";const st=D(Ze)(rt);if(!Ze.showOrigin)return st;const ht=Ze.originZone;return ht?ht===(Ze.timeZone||ye(Ze.timeZone))?st:`${st} (${Ae(ht,rt)})`:`${st} (no origin recorded)`}function be(je,He,Ze,rt){if(He==="instant"||!He)return je;const st=v(je,Ze);if(He==="month")return j({year:st.year,month:st.month,day:1},Ze);if(He==="week"){const ht=rt>=1&&rt<=7?rt:1,St=((new Date(Date.UTC(st.year,st.month-1,st.day)).getUTCDay()+6)%7+1-ht+7)%7,Ct=new Date(Date.UTC(st.year,st.month-1,st.day-St));return j({year:Ct.getUTCFullYear(),month:Ct.getUTCMonth()+1,day:Ct.getUTCDate()},Ze)}return j({year:st.year,month:st.month,day:st.day},Ze)}function Ne(je,He){const Ze=je&&je.group,rt=Ze&&Ze.granularity||"day";if(rt==="instant")return null;const st=Ze&&Ze.weekStart;return ht=>typeof ht=="number"?be(ht,rt,He,st):ht}const Ie={time:{base:"number",storage:"float64",matches:y,format:je=>p(c(je.value),t(je,"time")),parse:je=>m(je.text),compare:(je,He)=>i(c(je),c(He)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:je=>{const He=c(je);return He===null?null:He/z},toStorage:je=>c(je),toClipboard:O,fromClipboard:m},datetime:{base:"dateString",storage:"dictionary",matches:P,format:je=>$(je.value,t(je,"datetime")),parse:je=>H(T(je.text,t(je,"datetime"))??je.text),compare:V,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(je,He)=>H(je,He&&He.timeZone),toClipboard:je=>x(je)?"":String(je),fromClipboard:je=>H(je)},duration:{base:"number",storage:"float64",matches:de,format:je=>ie(le(je.value),t(je,"duration")),parse:je=>oe(je.text,t(je,"duration")),compare:(je,He)=>i(le(je),le(He)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:je=>{const He=le(je);return He===null?null:He/z},toStorage:je=>le(je),toClipboard:je=>ie(le(je),{style:"short",maxUnits:-1}),fromClipboard:je=>oe(je)},timestamp:{base:"number",storage:"float64",format:je=>{const He=t(je,"timestamp");return we(je.value,{...He,timeZone:pe(He,je)})},parse:je=>{const He=t(je,"timestamp"),Ze=T(je.text,{timeZone:pe(He,je)});return Ze?Ze.getTime():null},compare:(je,He)=>i(L(je),L(He)),groupProjector:(je,He)=>Ne(je,He),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(je,He)=>{const Ze=L(je);if(Ze==null)return null;const rt=v(Ze,He&&He.timeZone||void 0);return(Date.UTC(rt.year,rt.month-1,rt.day,rt.hour,rt.minute,rt.second)-he)/z},toStorage:je=>L(je),toClipboard:je=>{const He=L(je);return He==null?"":new Date(He).toISOString()},fromClipboard:je=>L(je)}},Ve=["datetime","time","duration"],Ye=Ie}),Le("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 V}}),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 d}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return i}}),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 o}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return y}}),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 j}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,B=Q.Lru,I=4294967295,_=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function X(L){if(x(L))return null;if(typeof L=="string")return W(L);const E=Number(L);return Number.isFinite(E)?E<0?E<-2147483648?null:E>>>0:E>I?null:Math.trunc(E)>>>0:null}function W(L){if(x(L))return null;const E=String(L).trim();if(E==="")return null;const D=_.exec(E);if(!D)return null;let $=0;for(let P=1;P<=4;P++){const k=D[P];if(k.length>1&&k.charCodeAt(0)===48)return null;const N=Number(k);if(N>255)return null;$=$*256+N}return $}function H(L){const E=X(L);return E===null?"":`${E>>>24&255}.${E>>>16&255}.${E>>>8&255}.${E&255}`}function V(L){return typeof L=="string"&&W(L)!==null}function z(L,E){const D=X(L),$=X(E);return D===null?$===null?0:1:$===null||D<$?-1:D>$?1:0}const w=64,S=I*w+32,g=/^(?:0|[1-9]\d?)$/;function l(L,E){return L*w+E}function d(L){if(x(L))return null;if(typeof L=="string"){const $=a(L);return $===null?null:d($)}if(typeof L=="object"){const $=X(L.address),P=Number(L.prefix);return $===null||!Number.isInteger(P)||P<0||P>32?null:{address:$,prefix:P}}const E=Number(L);if(!Number.isInteger(E)||E<0||E>S)return null;const D=E%w;return D>32?null:{address:(E-D)/w,prefix:D}}function a(L){if(x(L))return null;const E=String(L).trim();if(E==="")return null;const D=E.indexOf("/");if(D<0)return null;const $=W(E.slice(0,D));if($===null)return null;const P=E.slice(D+1).trim();if(!g.test(P))return null;const k=Number(P);return k>32?null:l($,k)}function r(L){const E=d(L);return E?`${H(E.address)}/${E.prefix}`:""}function t(L){return typeof L=="string"&&a(L)!==null}function n(L,E){const D=d(L),$=d(E);return D?$?D.address!==$.address?D.address<$.address?-1:1:D.prefix-$.prefix:-1:$?1:0}function i(L){return L===0?0:4294967295<<32-L>>>0}function f(L){const E=d(L);return E?(E.address&i(E.prefix))>>>0:null}function u(L){const E=d(L);return E?(E.address&i(E.prefix)|~i(E.prefix)>>>0)>>>0:null}function o(L){const E=d(L);return E?2**(32-E.prefix):null}function m(L){const E=d(L);return E?E.prefix===32?1:E.prefix===31?2:2**(32-E.prefix)-2:null}function c(L,E){const D=d(L);if(!D)return!1;const $=X(E);if($===null)return!1;const P=i(D.prefix);return($&P)>>>0===(D.address&P)>>>0}function h(L,E){const D=f(L),$=f(E);return D===null||$===null?!1:D<=u(E)&&$<=u(L)}const s=/^[0-9a-fA-F]{1,4}$/,p=new B(512);function y(L){if(x(L))return null;let E=String(L).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 $=E.split("::");if($.length>2)return null;const P=O($[0]);if(P===null)return null;if($.length===1)return P.length===8?P:null;const k=O($[1]);if(k===null)return null;const N=8-P.length-k.length;if(N<1)return null;const G=P.slice();for(let q=0;q<N;q++)G.push(0);for(const q of k)G.push(q);return G}function O(L){if(L==="")return[];const E=[];for(const D of L.split(":")){if(!s.test(D))return null;E.push(parseInt(D,16))}return E}function A(L){if(typeof L!="string")return y(L);if(p.has(L))return p.get(L);const E=y(L);return p.set(L,E),E}function b(L){if(L[0]===0&&L[1]===0&&L[2]===0&&L[3]===0&&L[4]===0&&L[5]===65535)return`::ffff:${H((L[6]<<16|L[7])>>>0)}`;let E=-1,D=0,$=-1,P=0;for(let G=0;G<8;G++)L[G]===0?($<0?($=G,P=1):P++,P>D&&(D=P,E=$)):($=-1,P=0);if(D<2)return L.map(G=>G.toString(16)).join(":");const k=L.slice(0,E).map(G=>G.toString(16)).join(":"),N=L.slice(E+D).map(G=>G.toString(16)).join(":");return`${k}::${N}`}function v(L){const E=y(L);return E===null?null:b(E)}function R(L){return v(L)??""}function j(L){return typeof L=="string"&&L.indexOf(":")>=0&&y(L)!==null}function F(L,E){const D=A(L),$=A(E);if(!D)return $?1:0;if(!$)return-1;for(let P=0;P<8;P++)if(D[P]!==$[P])return D[P]<$[P]?-1:1;return 0}const C=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:V,parse:L=>W(L.text),compare:z,format:L=>H(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>X(L),toClipboard:L=>H(L),fromClipboard:L=>W(L)},cidr:{base:"number",storage:"float64",matches:t,parse:L=>a(L.text),compare:n,format:L=>r(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>{const E=d(L);return E===null?null:l(E.address,E.prefix)},toClipboard:L=>r(L),fromClipboard:L=>a(L)},ipv6:{base:"text",storage:"dictionary",matches:j,parse:L=>v(L.text),compare:F,format:L=>R(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:L=>v(L),toClipboard:L=>R(L),fromClipboard:L=>v(L)}}),T=C}),Le("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 x=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","designer.canvas":"Dashboard canvas","designer.chrome":"Designer tools","designer.page":"Page {n}","a11y.designer.edit":"Edit mode","a11y.designer.view":"View mode","layout.region":"Dashboard layout","layout.move":"Move {title}","layout.resize":"Resize {title}","layout.close":"Close {title}","a11y.layout.grabbed":"{title} grabbed, column {x} of {columns}, row {y}","a11y.layout.position":"{title}, column {x} of {columns}, row {y}","a11y.layout.dropped":"{title} dropped, column {x} of {columns}, row {y}","a11y.layout.cancelled":"{title} move cancelled","a11y.layout.resizeCancelled":"{title} resize cancelled","a11y.layout.reverted":"{title} returned to column {x}, row {y}","a11y.layout.resizeGrabbed":"{title} resize grabbed, {w} by {h} cells","a11y.layout.resizeStep":"{title}, {w} by {h} cells","a11y.layout.resized":"{title} resized to {w} by {h} cells","a11y.layout.closed":"{title} closed","layout.maximise":"Maximise {title}","layout.minimise":"Minimise {title}","layout.restore":"Restore {title}","a11y.layout.maximised":"{title} maximised, filling the dashboard; press Escape to restore it","a11y.layout.minimised":"{title} minimised","a11y.layout.restored":"{title} restored to column {x}, row {y}","a11y.group.cleared":"Grouping cleared","a11y.group.by":"Grouped by {columns}","a11y.group.expanded":"{label} expanded, {rows} shown","a11y.group.collapsed":"{label} collapsed, {rows} shown","a11y.page.position":"Page {page} of {pages}","a11y.updates.paused":"Updates paused","a11y.updates.resumed":"Updates resumed","a11y.edit.refusedOne":"Edit to {column} was refused and put back to {value}{reason}","a11y.edit.refusedMany":{one:"{count} edit was refused and put back{reason}",other:"{count} edits were refused and put back{reason}"},"a11y.edit.reason":", {reason}","a11y.history.undo":"Undid {label}","a11y.history.redo":"Redid {label}","a11y.history.undoLast":"Undid the last change","a11y.history.redoLast":"Redid the last change","a11y.column.cannotResize":"{column} cannot be resized","a11y.column.resized":"{column} is {width} pixels wide","a11y.column.atMinimum":"{column} is at its narrowest, {width} pixels","a11y.column.atMaximum":"{column} is at its widest, {width} pixels","a11y.column.cannotMove":"{column} cannot be moved","a11y.column.alreadyFirst":"{column} is already first in its group","a11y.column.alreadyLast":"{column} is already last in its group","a11y.column.cannotMoveThere":"{column} cannot be moved there","a11y.column.moved":"{column} moved to position {at} of {of}","a11y.group.formed":"{column} grouped with {other} in a new band","a11y.group.dissolved":"band {group} dissolved","a11y.group.renamed":"band renamed to {group}","a11y.group.moved":"band {group} moved to position {at} of {of}","a11y.column.addedToGroup":"{column} added to band {group}","a11y.column.removedFromGroup":"{column} removed from its band","a11y.column.notInGroup":"{column} is not in a band","a11y.column.cannotGroup":"{column} cannot be grouped","a11y.group.cannotMove":"band {group} cannot be moved there","columngroup.newGroup":"New group","columngroup.rename":"Rename band","columngroup.dissolve":"Dissolve band","columngroup.group":"Group with adjacent column","columngroup.untitled":"Untitled band","panel.bandCollapse":"Collapse band {band}","panel.bandExpand":"Expand band {band}","panel.bandVisible":"Show or hide every column in band {band}","panel.bandRenameFor":"Rename band {band}","panel.bandDissolveFor":"Dissolve band {band}","header.filter":"Filter {column}","header.menu":"Column menu for {column}","header.toggleGroup":"Toggle {group}","header.dragHint":"Drag {column} to reorder, or onto another column to group","header.dragRole":"draggable column header","header.group":"group","header.selectAllRows":"Select all rows","header.clearSelection":"Clear selection","cell.selectRow":"Select row","cell.detail.show":"Show detail","cell.detail.hide":"Hide detail","cell.detail.showInPane":"Show in the detail pane","cell.detail.showingInPane":"Showing in the detail pane","cell.group.expand":"Expand","cell.group.collapse":"Collapse","cell.delta.up":"up","cell.delta.down":"down","cell.delta.unchanged":"unchanged","cell.delta.moved":"{direction} {magnitude}","cell.delta.describedUnchanged":"{label}, unchanged","cell.delta.described":"{label}, {direction} by {magnitude}","cell.qr.of":"QR code for {text}","cell.qr.empty":"No QR code","cell.rating.of":"{rating} of {max}","cell.rating.empty":"Not rated","a11y.panel.cannotMove":"{column} cannot be moved","a11y.panel.alreadyFirst":"{column} is already first","a11y.panel.alreadyLast":"{column} is already last","a11y.panel.moved":"{column} moved to position {at} of {of}","a11y.panel.removedFrom":"{column} removed from {list}","a11y.panel.addedTo":"{column} added to {list}","a11y.panel.cannotAddTo":"{column} cannot be added to {list}","a11y.annotate.erased":"Annotation removed","a11y.annotate.noMarks":"No annotations to erase","a11y.annotate.focusedMark":"Mark {at} of {of} selected","a11y.annotate.confirmClear":"Clear all annotations? Choose Clear or Keep.","a11y.annotate.cleared":"All annotations cleared","a11y.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"a11y.range.cleared":{one:"{count} cell cleared",other:"{count} cells cleared"},"paste.preview.title":"Review paste","paste.preview.summary":{one:"{changes} cell will change, {rejected} rejected.",other:"{changes} cells will change, {rejected} rejected."},"paste.preview.changesHeading":{one:"{count} change",other:"{count} changes"},"paste.preview.rejectedHeading":{one:"{count} rejected",other:"{count} rejected"},"paste.preview.colOld":"Current","paste.preview.colNew":"New","paste.preview.colCell":"Cell","paste.preview.colReason":"Reason","paste.preview.empty":"This paste would change nothing.","paste.preview.confirm":"Apply","paste.preview.cancel":"Cancel","paste.preview.reason.permission":"Not permitted","paste.preview.reason.readOnly":"Read-only","paste.preview.reason.validation":"Invalid value","paste.preview.reason.locked":"Being edited","paste.preview.reason.missing":"No such cell","a11y.paste.previewOpened":{one:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel.",other:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel."},"a11y.paste.cancelled":"Paste cancelled; nothing changed","status.total":"{rows}","status.counting":"Counting rows…","status.shownOfTotal":"{shown} of {total}","status.selected":"{count} selected","status.selectedAcrossSource":"{count} selected across the source","status.selectedAcrossSourceCounting":"All matching rows selected, counting…","status.count":"Count {count}","status.loading":"Loading {count}…","status.loadingOf":"Loading {loaded} of {total} ({percent}%)","status.stat.sum":"Sum","status.stat.min":"Min","status.stat.max":"Max","status.stat.avg":"Avg","status.paused":"Paused","status.pausedWaiting":"Paused · {waiting}","status.coalesced":"{count} coalesced","status.hiddenComments":"{comments} on hidden rows","pagination.label":"Pagination","pagination.first":"First page","pagination.previous":"Previous page","pagination.next":"Next page","pagination.last":"Last page","pagination.page":"Page","pagination.ofPages":"of {pages}","pagination.summary":"{from}–{to} of {total}","pagination.pageSize":"Rows per page","pagination.range":"{from}–{to}","pagination.counting":"{from}–{to}, counting…","pagination.jump":"Page number, press Enter to jump","pagination.jumpBounded":"Page number, 1 to {pages}, press Enter to jump","panel.columns":"Columns","panel.filters":"Filters","panel.views":"Views","panel.quickFilter":"Quick filter","find.label":"Find in grid","find.placeholder":"Find in grid","find.next":"Next match","find.previous":"Previous match","find.close":"Close find","find.matchCase":"Match case","find.wholeCell":"Whole cell","find.columnScope":"Search in","find.allColumns":"All columns","find.count":"{current} of {total}","find.countPartial":"{current} of {total} so far","find.none":"No matches","find.searching":"Searching…","find.loadedRows":"in loaded rows","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","insights.subset":"Filtered subset vs whole","insights.dataset":"This grid vs another dataset","insights.groups":"Group comparison","insights.noFilter":"Filter the grid to compare the subset against the whole.","insights.by":"Group by","insights.test":"Test","insights.effect":"Effect size","insights.interval":"Confidence interval","insights.pValue":"p-value","insights.smallSample":"small sample — interpret with care","insights.needGroups":"Choose two columns with groups to compare.","insights.empty":"No columns to analyse.","insights.anomalies":"Anomalies","insights.anomalyCount":"{count} flagged of {n}","insights.anomalyMethod":"Method","insights.anomalyThreshold":"Threshold","anomaly.chip":"{count} anomalies flagged","anomaly.chipActive":"Showing {count} anomalies — clear","compare.first":"First column","compare.second":"Second column","compare.needTwo":"Two numeric columns are needed to compare","compare.noPairs":"No rows have a value in both","compare.pairs":"{count} pairs","compare.pearson":"Correlation (Pearson)","compare.spearman":"Rank correlation (Spearman)","compare.kendall":"Kendall’s tau","compare.covariance":"Covariance","compare.slope":"Slope","compare.intercept":"Intercept","compare.r2":"R²","compare.stdError":"Standard error","compare.weighted":"Weighted average","panel.zone.group":"row groups","panel.zone.values":"values","panel.zone.pivot":"pivot columns","groupZone.label":"Row groups","groupZone.title":"Group by","groupZone.hint":"Drag a column here to group rows by its values","groupZone.chip":"{column}, group {at} of {of}","groupZone.remove":"Stop grouping by {column}","groupZone.add":"Add a group","total.sum":"Sum","total.avg":"Average","total.min":"Min","total.max":"Max","total.count":"Count","total.countValues":"Count of values","total.first":"First","total.last":"Last","total.custom":"Total","total.median":"Median","total.p25":"25th percentile","total.p75":"75th percentile","total.p90":"90th percentile","total.p95":"95th percentile","total.p99":"99th percentile","total.iqr":"Interquartile range","total.mad":"Median absolute deviation","total.variance":"Variance","total.varianceP":"Variance (population)","total.stddev":"Standard deviation","total.stddevP":"Standard deviation (population)","total.range":"Range","total.distinct":"Distinct","total.mode":"Mode","total.skewness":"Skewness","total.kurtosis":"Kurtosis","total.geomean":"Geometric mean","total.harmean":"Harmonic mean","total.sumSquares":"Sum of squares","total.weightedAvg":"Weighted average","total.argmin":"Lowest by","total.argmax":"Highest by","total.hhi":"Concentration (HHI)","total.entropy":"Entropy","total.evenness":"Evenness","total.top3Share":"Top 3 share","total.top10Share":"Top 10 share","total.gini":"Gini coefficient","total.trimmedMean":"Trimmed mean","total.winsorizedMean":"Winsorized mean","total.robustOutliers":"Outliers (robust)","total.jarqueBera":"Jarque–Bera","total.passRate":"Pass rate","total.failureCount":"Failures","stats.column":"Column","stats.choose":"Choose a column to profile","stats.noColumns":"No numeric columns to profile","stats.noValues":"Nothing numeric in this column","stats.count":"Count","stats.present":"Present","stats.missing":"Missing","stats.distinct":"Distinct","stats.min":"Minimum","stats.max":"Maximum","stats.mean":"Mean","stats.median":"Median","stats.q1":"Lower quartile","stats.q3":"Upper quartile","stats.iqr":"Interquartile range","stats.stddev":"Standard deviation","stats.outliers":"Outliers","stats.distribution":"Distribution","stats.distribution.detail":"Distribution: rows per range","stats.bin":"{count} between {from} and {to}","stats.topValues":"Top values","stats.section.shape":"Shape","stats.section.robust":"Robust","stats.section.concentration":"Concentration","stats.section.capability":"Capability","stats.cp":"Cp","stats.cpk":"Cpk","stats.pp":"Pp","stats.ppk":"Ppk","stats.outOfSpec":"Out of specification","stats.filtered":"Over the {count} filtered rows","stats.unavailable":"Not computed by the source: {stats}.","stats.unavailable.notPlain":"`{column}` is not a plain column the engine can name","stats.unavailable.where":"a `where` predicate is in force ({list}), which only the browser can run","stats.unavailable.filter":"the grid's filter did not fully push to the engine","stats.unavailable.quick":"the quick search did not push to the engine","stats.unavailable.client":'the source did not compute "{fn}" in the engine ({reason}); set the pushdown source\'s `{setting}`',"stats.unavailable.outliers":"the count of values outside Tukey's fences is not an engine aggregate","stats.unavailable.histogram":"the shape of the column is not an engine aggregate","stats.unavailable.topValues":"the source did not answer a grouped count in the engine","regression.noModel":"No model configured. Set predictors and a response on the panel.","regression.cannotFit":"The model cannot be fitted over the current rows.","regression.observations":"Fitted over {count} rows","regression.r2":"R²","regression.adjR2":"Adjusted R²","regression.coefficients":"Coefficients","regression.term":"Term","regression.estimate":"Estimate ± SE","regression.stdError":"Std error","regression.t":"t","regression.p":"p","regression.vif":"Variance inflation (VIF)","regression.heteroscedasticity":"Heteroscedasticity (Breusch–Pagan)","regression.heteroscedastic":"Heteroscedastic: BP {statistic}, p {p}","regression.homoscedastic":"No heteroscedasticity detected: BP {statistic}, p {p}","menu.sortAscending":"Sort ascending","menu.sortDescending":"Sort descending","menu.clearSort":"Clear sort","menu.groupBy":"Group by this column","menu.ungroup":"Stop grouping by this column","menu.hideColumn":"Hide column","menu.pinStart":"Pin to start","menu.pinEnd":"Pin to end","menu.unpin":"Unpin","menu.autosize":"Fit to content","ai.valuesNotAmongOptions":'{values} {shown} not among the options for "{column}"',"menu.clearCells":{one:"Clear cell",other:"Clear {count} cells"},"menu.fillDown":"Fill down","menu.copy":"Copy","menu.copyWithHeaders":"Copy with headers","menu.paste":"Paste","menu.filterEllipsis":"Filter…","menu.columnStatistics":"Column statistics","menu.pinColumn":"Pin column","menu.sizeToFit":"Size to fit content","menu.sizeAllToFit":"Size all columns to fit","menu.width":"Width","menu.narrower":"Narrower","menu.wider":"Wider","menu.moveColumn":"Move column","menu.moveLeft":"Move left","menu.moveRight":"Move right","menu.moveToStart":"Move to start","menu.moveToEnd":"Move to end","menu.unpivot":"Remove from pivot","menu.pivotBy":"Pivot by this column","menu.stopTotalling":"Stop totalling","menu.totalColumn":"Total this column","menu.aggregate":"Aggregate","menu.aggregateNone":"None","menu.aggregateGroup":"Group subtotals","menu.aggregateGrand":"Grand total","menu.aggregateSame":"Same as total","menu.redactColumn":"Redact column","menu.stopRedacting":"Stop redacting","menu.stopRedactingAll":"Stop redacting everything","menu.sortGroupsAscending":"Sort groups ascending","menu.sortGroupsDescending":"Sort groups descending","menu.filterGroups":"Filter groups…","menu.expandAll":"Expand all","menu.collapseAll":"Collapse all","menu.clearGrouping":"Clear grouping","menu.colour":"Colour","menu.importCsv":"Import rows from CSV…","import.title":"Import rows","import.clipboard":"the clipboard","import.summary":{one:"{count} row from {name}",other:"{count} rows from {name}"},"import.opened":{one:"Import preview open, {count} row",other:"Import preview open, {count} rows"},"import.done":{one:"{count} row imported",other:"{count} rows imported"},"import.confirm":"Import","import.cancel":"Cancel","import.colSource":"Column","import.colField":"Maps to","import.colType":"Type","import.skip":"— skip —","import.mapLabel":'Map "{source}" to a field',"import.modeLabel":"On import","import.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.row.moveHandle":"Drag to reorder or re-parent {name}","gantt.a11y.rowMoved":"{name} moved.","gantt.a11y.rowReparented":"{name} moved under {parent}.","gantt.a11y.rowPromoted":"{name} moved to the top level.","gantt.a11y.rowMoveCancelled":"Move cancelled.","gantt.a11y.linkCycle":"Linking {from} to {to} would create a cycle; link not created.","gantt.a11y.linkCreated":"{from} linked to {to}, {type}.","gantt.a11y.linkDeleted":"Link from {from} to {to} deleted.","gantt.a11y.linkLabel":"Link, {from} to {to}, {type}","gantt.linkEditor.title":"Edit link from {from} to {to}","gantt.linkEditor.type":"Link type","gantt.linkEditor.lag":"Lag, in days","gantt.linkEditor.apply":"Apply","gantt.linkEditor.delete":"Delete link","gantt.linkEditor.cancel":"Cancel","gantt.a11y.undone":"Undone.","gantt.a11y.redone":"Redone.","gantt.a11y.nothingToUndo":"Nothing to undo.","gantt.a11y.nothingToRedo":"Nothing to redo.","gantt.workload.title":"Resource workload","gantt.workload.resource":"Resource","gantt.workload.total":"Total","gantt.workload.unassigned":"Unassigned","gantt.workload.cell":"{hours} h from {date}","gantt.workload.over":"{hours} h from {date}, over a capacity of {capacity} h","gantt.workload.expand":"Show {name}’s tasks","gantt.workload.collapse":"Hide {name}’s tasks","gantt.workload.unitToggle":"Hours / % / Cost","gantt.workload.unitHours":"Showing hours","gantt.workload.unitPercent":"Showing percent of capacity","gantt.workload.unitCost":"Showing cost","gantt.workload.cellPercent":"{percent}% from {date}","gantt.workload.overPercent":"{percent}% from {date}, over capacity","gantt.workload.cellNoCapacity":"No available hours from {date}","gantt.workload.cellCost":"{cost} from {date}","gantt.workload.otherProjectLabel":"{name} (other project)","gantt.workload.external":"External booking","gantt.a11y.hoursSet":"{name}: {hours} h from {date}","gantt.a11y.hoursCleared":"{name}: no hours from {date}","gantt.a11y.hoursRefused":"{date} is not a working day; {name} was not changed.","gantt.histogram.title":"Resource histogram","gantt.histogram.tableTitle":"Resource histogram data","gantt.histogram.resource":"Resource","gantt.histogram.period":"Period","gantt.histogram.hours":"Hours","gantt.histogram.percent":"Percent of capacity","gantt.histogram.cost":"Cost","gantt.histogram.capacity":"Capacity","gantt.histogram.overAllocated":"Over-allocated","gantt.histogram.yes":"Yes","gantt.histogram.no":"No","gantt.histogram.tip":"{name}, {from} to {to}: {value}{capacity}{tasks}","gantt.histogram.tipHours":"{hours} h","gantt.histogram.tipPercent":"{percent}% of capacity","gantt.histogram.tipCost":"{cost}","gantt.histogram.tipCapacity":", capacity {hours} h","gantt.histogram.tipTasks":" ({tasks})","gantt.histogram.tipOver":", over capacity","gantt.histogram.tipNoCapacity":"no available hours","gantt.picker.title":"Assign resources to {name}","gantt.picker.open":"Edit assignments for {name}","gantt.picker.search":"Search resources","gantt.picker.list":"Resources","gantt.picker.selected":"Assigned resources","gantt.picker.load":"{load}% booked of {capacity}% over these dates","gantt.picker.none":"No matching resources","gantt.picker.units":"{name}, units in percent","gantt.picker.remove":"Remove {name}","gantt.picker.apply":"Apply","gantt.picker.cancel":"Cancel","gantt.picker.warn":"{name} would be over-allocated: {load}% booked of {capacity}%","gantt.picker.ok":"No resource would be over-allocated","gantt.picker.assign":"Assign","gantt.col.effort":"Effort","gantt.col.units":"Units","gantt.unscheduled":"Unscheduled","gantt.col.unscheduled":"Unscheduled","gantt.col.slack":"Slack","gantt.col.deadline":"Deadline","gantt.row.ancestor":"Shown because a task inside it matches the filter","gantt.progress.handle":"Drag to set the progress of {name}","gantt.a11y.progress":"{name} {percent}% complete","gantt.col.name":"Task name","gantt.col.start":"Start","gantt.col.end":"Finish","gantt.col.duration":"Duration","gantt.col.assignee":"Assignee","gantt.col.progress":"%","gantt.zoom.label":"Zoom","gantt.zoom.day":"Day","gantt.zoom.week":"Week","gantt.zoom.month":"Month","gantt.zoom.quarter":"Quarter","gantt.zoom.fit":"Fit to plan","gantt.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","gantt.tip.effort":"{hours}h","gantt.tip.row":"{label}: {value}","gantt.tip.start":"Start","gantt.tip.end":"End","gantt.tip.date":"Date","gantt.tip.durationLabel":"Duration","gantt.tip.durationValue":"{days} days","gantt.tip.complete":"Complete","gantt.tip.effortLabel":"Effort","gantt.tip.effortValue":"{hours} h","gantt.tip.assigned":"Assigned","gantt.tip.cost":"Cost","gantt.tip.slackLabel":"Slack","gantt.tip.slackValue":"{days} days","gantt.tip.deadline":"Deadline","gantt.mode.fixedDuration":"Fixed duration","gantt.mode.fixedEffort":"Fixed effort","gantt.mode.fixedUnits":"Fixed units","gantt.scurve.spi":"SPI {index}","gantt.scurve.cpi":"CPI {index}","gantt.print.page":"Page {page} of {pages}","gantt.print.printed":"Printed {date}","gantt.issues.title":"Scheduling conflicts","gantt.issues.empty":"No scheduling conflicts","gantt.issues.count":"{count} scheduling conflicts","gantt.issues.toggle":"Toggle the conflicts panel","gantt.issues.cycle":"Circular dependency: {tasks}","gantt.issues.constraint":"{task} cannot meet its {constraint} constraint of {date}","gantt.issues.lock":"{task} is locked but a dependency would move it","gantt.issues.deadline":"{task} finishes after its deadline of {date}","gantt.issues.fixRemoveLink":"Remove link","gantt.issues.fixAsap":"Set as soon as possible","gantt.issues.fixUnlock":"Unlock task","gantt.issues.fixClearDeadline":"Clear deadline","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":x,"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))}),Le("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 S}});const x=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 d=null;try{d=new Intl.PluralRules(g||void 0)}catch{d=null}return I.set(l,d),d}function W(g,l,d="conjunction"){const a=Array.isArray(g)?g.filter(n=>n!=null&&n!==""):[];if(a.length===0)return"";if(a.length===1)return String(a[0]);const r=`${l||""}|${d}`;let t=_.get(r);if(t===void 0){try{t=new Intl.ListFormat(l||void 0,{style:"long",type:d})}catch{t=null}_.set(r,t)}return t?t.format(a.map(String)):a.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 V(g,l,d){if(typeof g=="string")return g;if(!g||typeof g!="object")return"";const a=l&&typeof l.count=="number"?l.count:null;if(a===null)return g.other??"";const r=X(d),t=r?r.select(a):a===1?"one":"other";return g[t]??g.other??""}function z(g,l={},d){const a=V(g,l,d);return a?a.replace(B,(r,t)=>Object.prototype.hasOwnProperty.call(l,t)?H(l[t],d):r):""}function w(g,l,d="en-GB"){return typeof g=="string"&&g?g:typeof l=="string"&&l?l:d}function S(g,l){const d=g?g[l]:void 0;return d==null||x(d)?l:d}}),Le("packages/core/src/i18n/index.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return S}}),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 d}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/i18n/catalogue.js"),x=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,V=K("packages/core/src/internal/util.js"),z=V.isFunction,w=V.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 S="en-GB";class g{#e=S;#t=x;constructor(t={}){this.configure(t)}configure(t={}){this.#e=H(t.locale,t.declared,S);const n=t.messages;if(!n||typeof n!="object"){this.#t=x;return}const i=Object.keys(n).filter(f=>!(f in x));i.length&&w(`i18n:unknown:${i[0]}`,`message keys not in the catalogue and so ignored: ${i.slice(0,5).join(", ")}${i.length>5?`, and ${i.length-5} more`:""}`),this.#t={...x,...n}}get locale(){return this.#e}t(t,n){return _(W(this.#t,t),n||{},this.#e)}list(t,n){return X(t,this.#e,n)}number(t,n){const i=Number(t);return Number.isFinite(i)?i.toLocaleString(this.#e,n||{maximumFractionDigits:20}):""}}const l=new g;function d(r){return r instanceof g?r:new g(r||{})}function a(r){const t=r&&typeof r=="object"?r:{},n=B.filter(f=>{const u=t[f];return u==null||u===""||z(u)}),i=Object.keys(t).filter(f=>!(f in x));return{missing:n,unknown:i}}}),Le("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 d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/internal/util.js"),x=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(r,t){const n=t||{},i=n.emptyDisplay??X.emptyDisplay;if(x(r)||r==="")return i;const u=[...typeof n.char=="string"&&n.char!==""?n.char:X.char][0]||X.char,o=n.fixedLength??X.fixedLength,m=Number.isFinite(n.length)&&Number(n.length)>0?Math.floor(Number(n.length)):X.length,c=typeof r=="string"?r:typeof r=="number"||typeof r=="boolean"||typeof r=="bigint"?String(r):null;let h=0;if(c!==null){const s=Number.isFinite(n.lastVisible)?Math.floor(Number(n.lastVisible)):X.lastVisible,p=[...c];if(h=s>0&&s<p.length?s:0,h>0){const y=p.slice(p.length-h).join(""),O=Math.max(1,(o?m:p.length)-h);return u.repeat(O)+y}return u.repeat(o?m:Math.max(1,p.length))}return u.repeat(m)}const H=48;function V(r){try{const t=JSON.stringify(r);return t===void 0?null:t}catch{return null}}function z(r,t){if(x(r))return"";const n=Number.isFinite(t&&t.inlineLimit)?Number(t.inlineLimit):H;if(typeof r=="string")return r.length>n?`${r.slice(0,n-1)}…`:r;if(typeof r!="object")return String(r);const i=V(r);if(i!==null&&i.length<=n)return i;if(Array.isArray(r)){const u=r.length;return`[${_.t("count.items",{count:u})}]`}const f=Object.keys(r).length;return`{${_.t("count.keys",{count:f})}}`}function w(r,t){if(r==null)return"null";const n=typeof r;if(n==="number"||n==="boolean"||n==="bigint")return String(r);if(n==="string")return JSON.stringify(r);if(n!=="object")return JSON.stringify(String(r));const i=t||new WeakSet;return i.has(r)?'"[circular]"':(i.add(r),r instanceof Date?JSON.stringify(r.toISOString()):Array.isArray(r)?`[${r.map(o=>w(o,i)).join(",")}]`:`{${Object.keys(r).sort().map(o=>`${JSON.stringify(o)}:${w(r[o],i)}`).join(",")}}`)}function S(r,t){if(x(r))return x(t)?0:1;if(x(t))return-1;const n=w(r),i=w(t);return n<i?-1:n>i?1:0}function g(r){if(x(r))return null;const t=String(r);if(t.trim()==="")return null;try{return JSON.parse(t)}catch{return t}}function l(r){const t=r&&r.cell&&r.cell.props;return B(t)?t:{}}const d=Object.freeze({json:{base:"object",storage:"object",format:r=>z(r&&r.value,l(r&&r.column)),parse:r=>g(r&&r.text),compare:S,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:r=>{if(x(r))return"";if(typeof r=="string")return r;try{const t=JSON.stringify(r,null,2);return t===void 0?String(r):t}catch{return String(r)}},fromClipboard:r=>g(r)},secret:{base:"text",storage:"object",format:r=>W(r&&r.value,l(r&&r.column)),parse:r=>{const t=r&&r.text;return x(t)||String(t)===""?null:String(t)},compare:(r,t)=>{const n=x(r)||r==="",i=x(t)||t==="";return n===i?0:n?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:r=>W(r),fromClipboard:r=>x(r)||String(r)===""?null:String(r)}}),a=d}),Le("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 S}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,B=Q.warnOnce;function I(P,k,N,G){return Object.freeze({symbol:P,factor:k,aliases:Object.freeze(N||[]),binary:!!(G&&G.binary),prefix:G&&G.prefix||null,auto:!(G&&G.auto===!1)})}function _(P,k,N,G){return I(P,k,N,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,V=new Map;function z(P,k){const N=String(P||"").trim();if(!N)throw new Error("[lattice] a unit system needs a name");if(X[N]||V.has(N))throw new Error(`[lattice] unit system "${N}" already exists`);const G=[...k||[]];if(!G.length)throw new Error(`[lattice] unit system "${N}" has no units`);if(!G.some(Y=>Y.factor===1))throw new Error(`[lattice] unit system "${N}" 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 "${N}" declares "${Y.symbol}" twice`);q.add(Y.symbol)}return V.set(N,Object.freeze(G)),H.delete(N),N}function w(){return[...Object.keys(X),...V.keys()]}function S(P){const k=g(P);return k?k.units:[]}function g(P){const k=String(P||""),N=H.get(k);if(N!==void 0)return N;const G=X[k]||V.get(k);if(!G)return H.set(k,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(k,ne),ne}function l(P,k){return k&&P.binary||P.decimal}function d(P,k){const N=g(P);if(!N||x(k))return null;const G=N.units.find(Y=>Y.symbol===String(k));if(G)return G;const q=N.byToken.get(String(k).trim().toLowerCase());return q&&q!==W?q:null}const a=new WeakMap;function r(P){const k=P||{};if(typeof k=="object"&&k!==null){const Y=a.get(k);if(Y!==void 0)return Y}const N=k.system||"data",G=g(N);let q=null;if(!G)B(`unit:system:${N}`,`unknown unit system "${N}"; known systems are ${w().join(", ")}`);else{let Y=k.unit?d(N,k.unit):null;Y||(k.unit&&B(`unit:unit:${N}:${k.unit}`,`unknown unit "${k.unit}" in system "${N}"; falling back to ${G.units[0].symbol}`),Y=G.units.find(J=>J.factor===1)||G.units[0]),q={index:G,base:Y,binary:k.binary===!0}}return typeof k=="object"&&k!==null&&a.set(k,q),q}const t=new WeakMap;function n(P,k){if(!P||!k||!Array.isArray(P.compound)||P.compound.length===0)return null;const N=t.get(P);if(N!==void 0)return N;const G=new Set,q=[];for(const J of P.compound){const te=d(P.system||"data",J);if(!te){B(`unit:compound:${P.system}:${J}`,`unknown compound unit "${J}" in system "${P.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(P,Y),Y}function i(P,k,N){return k===N||k.factor===N.factor?P:P*k.factor/N.factor}const f=new Map;function u(P){const k=P||"",N=f.get(k);if(N)return N;const G={group:",",decimal:"."};try{for(const q of new Intl.NumberFormat(P||void 0).formatToParts(12345.6))q.type==="group"?G.group=q.value:q.type==="decimal"&&(G.decimal=q.value)}catch{}return f.set(k,G),G}const o=/[\s   ]/g,m=/^[+-]?[\d   '’ .,]*(?:[eE][+-]?\d+)?/,c=/^[^\d+\-(.,\s]+\s*/,h=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function s(P,k){const{group:N,decimal:G}=u(k);let q=String(P).replace(o,"");if(q==="")return null;const Y=G?q.indexOf(G):-1;if(N&&N!==G){if(Y>=0&&q.indexOf(N,Y+G.length)>=0)return null;q=q.split(N).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(P,k,N){const G=String(P).trim().replace(/\.$/,"");if(G==="")return null;const q=k.units.find(le=>le.symbol===G);if(q)return q;const Y=G.toLowerCase(),J=k.byToken.get(Y);if(J===W)return null;if(J)return J;const te=k.byPrefix.get(Y);if(!te||!te.length)return null;const ne=l(k,N),oe=te.filter(le=>ne.includes(le));return oe.length===1?oe[0]:null}function y(P,k,N,G){let q=P,Y=0,J=!1,te=!1;for(;q!=="";){const ne=m.exec(q)[0];if(ne==="")return null;const oe=s(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+=i(oe,N[0],k.base)}else{const se=p(ae,k.index,k.binary);if(!se)return null;Y+=i(oe,se,k.base)}if(J=!0,te&&q!=="")return null}return J?Y:null}function O(P,k){if(x(P))return null;if(typeof P=="number")return Number.isFinite(P)?P:null;const N=r(k);if(!N)return null;let G=String(P).trim();if(G==="")return null;let q=!1;G.startsWith("(")&&G.endsWith(")")&&(q=!0,G=G.slice(1,-1).trim());const Y=n(k,N);if(Y){G.startsWith("-")&&(q=!0,G=G.slice(1).trim());const ee=y(G,N,Y,k);return ee===null?null:q?-ee:ee}let J=null;const te=c.exec(G);if(te&&te[0]){const ee=p(te[0].trim(),N.index,N.binary);ee&&(J=ee,G=G.slice(te[0].length).trim())}const ne=m.exec(G)[0],oe=s(ne,k&&k.locale);if(oe===null)return null;const le=G.slice(ne.length).trim();if(J&&le!=="")return null;const ae=J||(le===""?N.base:p(le,N.index,N.binary));if(!ae)return null;const se=i(oe,ae,N.base);return q?-se:se}const A=new Map;function b(P,k,N,G){const q=`${P||""}|${k}|${N}|${G?1:0}`;let Y=A.get(q);return Y||(Y=new Intl.NumberFormat(P||void 0,{minimumFractionDigits:k,maximumFractionDigits:N,useGrouping:G}),A.set(q,Y)),Y}function v(P,k){if(!Number.isFinite(P)||P===0)return Math.max(0,k-1);const N=Math.floor(Math.log10(Math.abs(P)));return Math.min(20,Math.max(0,k-1-N))}function R(P,k){if(!Number.isFinite(P)||P===0)return P;const N=Math.ceil(Math.log10(Math.abs(P))),G=10**(k-N);return Math.round(P*G)/G}function j(P,k,N){if(!N||N===k.base.symbol)return k.base;if(N!=="auto")return F(k,N);if(P===0||!Number.isFinite(P))return k.base;const G=Math.abs(P)*k.base.factor,q=l(k.index,k.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 k.index.units)ne.binary!==k.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 k.index.units)ne.binary!==k.binary&&ne.factor!==1||ne.factor<te.factor&&(te=ne);return te.factor<k.base.factor?te:k.base}function F(P,k){const N=P.index.units.find(q=>q.symbol===k);if(N)return N;const G=P.index.byToken.get(String(k).toLowerCase());return G&&G!==W?G:(B(`unit:display:${k}`,`unknown display unit "${k}"; rendering in ${P.base.symbol}`),P.base)}function C(P,k,N,G){const q=P<0;let Y=Math.abs(P)*k.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<N.length;ae++){const se=N[ae],ee=ae===N.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 de=ee?b(G.locale,J,te,G.group!==!1):b(G.locale,0,0,G.group!==!1);oe.push(`${de.format(ie)}${ne}${se.symbol}`)}const le=oe.join(" ");return q?`-${le}`:le}function T(P,k){const N=k||{},G=N.nullDisplay??"";if(x(P)||P==="")return G;const q=typeof P=="number"?P:Number(P);if(!Number.isFinite(q))return G;const Y=r(N);if(!Y)return String(q);const J=n(N,Y);if(J)return C(q,Y,J,N);const te=typeof N.significantFigures=="number"&&N.significantFigures>0?N.significantFigures:0,ne=te?R(q,te):q,oe=j(ne,Y,N.display),le=i(ne,Y.base,oe);let ae=typeof N.decimals=="number"?N.decimals:N.minDecimals??0,se=typeof N.decimals=="number"?N.decimals:N.maxDecimals??Math.max(ae,2);te&&(ae=v(le,te),se=ae);const ee=b(N.locale,ae,se,N.group!==!1).format(le),ie=N.space??" ";return N.placement==="prefix"?`${oe.symbol}${N.space??""}${ee}`:`${ee}${ie}${oe.symbol}`}function L(P,k){const N=x(P)||Number.isNaN(P)?null:Number(P),G=x(k)||Number.isNaN(k)?null:Number(k);return N===null||Number.isNaN(N)?G===null||Number.isNaN(G)?0:1:G===null||Number.isNaN(G)||N<G?-1:N>G?1:0}function E(P){const k=typeof P.decimals=="number"&&P.decimals>0?`.${"0".repeat(P.decimals)}`:"";return`${typeof P.decimals=="number"?`#,##0${k}`:"#,##0.##"}" ${P.symbol}"`}function D(P){const k={system:"data",...P||{}},N=r(k),G=N?N.base.symbol:String(k.unit||""),q=Object.freeze({...k,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=>T(ne.value,ne.locale?te(ne.locale):q),parse:ne=>O(ne.text,ne.locale?te(ne.locale):q),compare:L,defaults:{filter:"number",editor:"unit",align:"end",total:k.total||"sum"},...k.totals?{totals:k.totals}:{},excel:k.excel||E({decimals:k.decimals,symbol:G}),toStorage:ne=>typeof ne=="number"?Number.isFinite(ne)?ne:null:typeof ne=="string"?O(ne,q):x(ne)?null:O(String(ne),q),toClipboard:ne=>T(ne,Y),fromClipboard:ne=>O(ne,q)}}const $=D}),Le("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 x=K("packages/core/src/internal/util.js").isNil,I=K("packages/core/src/columns/types/unit.js").createUnitType;function _(H){const V=2*Math.PI/H;return z=>{let w=0,S=0,g=0;for(const d of z||[]){if(x(d))continue;const a=Number(d);Number.isFinite(a)&&(w+=Math.cos(a*V),S+=Math.sin(a*V),g+=1)}return!g||Math.hypot(w,S)/g<1e-12?null:(Math.atan2(S,w)/V%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})})}),Le("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 V}}),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"),x=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(S){const g=String(S.base),l=new Set([...S.prefixes||X,""]),d=[];for(const a of _){if(!l.has(a.symbol))continue;const r=`${a.symbol}${g}`,t=[];if(S.name){t.push(`${a.name}${S.name}`,`${a.name}${S.name}s`);const n=a.name.slice(-1);if(n&&S.name.startsWith(n)){const i=`${a.name.slice(0,-1)}${S.name}`;t.push(i,`${i}s`)}}a.symbol==="µ"&&t.push(`u${g}`),a.factor===1&&S.aliases&&t.push(...S.aliases),d.push(x(r,a.factor,t))}for(const a of S.extra||[])d.push(a);return d}function H(S,g){const l=W(g);return B(S,l)}function V(S,g,l){return H(S,g),I({system:S,unit:g.base,display:"auto",maxDecimals:3,...l||{}})}const z=Object.freeze({voltage:V("voltage",{base:"V",name:"volt"}),current:V("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:V("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:V("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:V("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:V("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[x("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),x("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:V("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:V("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[x("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:V("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:V("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:V("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:V("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:V("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:V("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:V("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[x("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:V("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),w=V}),Le("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 S}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const x=K("packages/core/src/internal/util.js").isNil,B=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:d=>d+273.15,fromKelvin:d=>d-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:d=>(d+459.67)*(5/9),fromKelvin:d=>d*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:d=>d,fromKelvin:d=>d}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:d=>d*(5/9),fromKelvin:d=>d*(9/5)})});function I(d){if(x(d))return null;const a=String(d).trim();if(a==="")return null;for(const[t,n]of Object.entries(B))if(a===t||a===n.symbol)return{key:t,scale:n};const r=a.toLowerCase();for(const[t,n]of Object.entries(B))if(n.aliases.includes(r))return{key:t,scale:n};return null}function _(d,a,r){const t=I(a),n=I(r);return!t||!n||!Number.isFinite(Number(d))?null:t.key===n.key?Number(d):n.scale.fromKelvin(t.scale.toKelvin(Number(d)))}const X=new Map;function W(d,a,r){const t=`${d||""}|${a}|${r}`;let n=X.get(t);return n||(n=new Intl.NumberFormat(d||void 0,{minimumFractionDigits:a,maximumFractionDigits:r}),X.set(t,n)),n}function H(d,a){const r=a||{},t=r.nullDisplay??"";if(x(d)||d==="")return t;const n=Number(d);if(!Number.isFinite(n))return t;const i=I(r.scale||"C");if(!i)return String(n);const f=I(r.display||r.scale||"C")||i,u=f.key===i.key?n:f.scale.fromKelvin(i.scale.toKelvin(n)),o=typeof r.decimals=="number"?r.decimals:null,m=o??r.minDecimals??0,c=o??r.maxDecimals??1;return`${W(r.locale,m,c).format(u)}${r.space??" "}${f.scale.symbol}`}const V=/^[+-]?[\d\s.,  ]*\d/;function z(d,a){const r=String(d).trim();if(r==="")return null;const t=new Intl.NumberFormat(a||void 0).formatToParts(1.1).find(u=>u.type==="decimal")?.value||".",n=t===","?".":",",i=r.split(n).join("").split(/[\s  ]/).join("").replace(t,"."),f=Number(i);return Number.isFinite(f)?f:null}function w(d,a){if(x(d))return null;const r=a||{},t=I(r.scale||"C");if(!t)return null;if(typeof d=="number")return Number.isFinite(d)?d:null;let n=String(d).trim();if(n==="")return null;let i=!1;n.startsWith("(")&&n.endsWith(")")&&(i=!0,n=n.slice(1,-1).trim());const f=V.exec(n);if(!f)return null;const u=z(f[0],r.locale);if(u===null)return null;const o=n.slice(f[0].length).trim();if(o==="")return i?-u:u;const m=I(o);if(!m)return null;const c=m.key===t.key?u:t.scale.fromKelvin(m.scale.toKelvin(u));return i?-c:c}function S(d){const a=Object.freeze({scale:"C",...d||{}}),t=(I(a.scale)||I("C")).scale.symbol,n=Object.freeze({...a,display:a.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),i=new Map([[a.locale||"",a]]),f=u=>{const o=u||"";let m=i.get(o);return m||(m=Object.freeze({...a,locale:u||void 0}),i.set(o,m)),m};return{base:"number",extends:"number",storage:"float64",temperatureConfig:a,format:u=>H(u.value,u.locale?f(u.locale):a),parse:u=>w(u.text,u.locale?f(u.locale):a),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:a.excel||`#,##0${typeof a.decimals=="number"&&a.decimals>0?`.${"0".repeat(a.decimals)}`:".#"}" ${t}"`,toStorage:u=>typeof u=="number"?Number.isFinite(u)?u:null:typeof u=="string"?w(u,a):x(u)?null:w(String(u),a),toClipboard:u=>H(u,n),fromClipboard:u=>w(u,a)}}const g=Object.freeze({celsius:S({scale:"C"}),fahrenheit:S({scale:"F"}),kelvin:S({scale:"K"})}),l=S}),Le("packages/core/src/columns/types/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return n}}),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 o}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return C}});const Q=K("packages/core/src/internal/util.js"),x=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}),V=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,S=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,g=Object.freeze([8,16,32,53]),l=new WeakSet,d=new WeakMap,a=new Map,r=new WeakMap,t=new WeakMap,n=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 i(T){if(T==null)return 16;const L=typeof T=="string"?T.toLowerCase():T,E=I[L];return E||(B(`radix:base:${String(T)}`,`unsupported radix ${String(T)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function f(T,L){return Math.ceil(T/_[L])}function u(T,L){if(!T)return L?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!L)return{min:0,max:2**T-1};const E=2**(T-1);return{min:-E,max:E-1}}function o(T){return V[T]||"hexadecimal"}function m(T){if(typeof T=="string"){const L=n[T];return L||B(`radix:preset:${T}`,`unknown radix preset "${T}"; known presets are ${Object.keys(n).join(", ")}`),{...L||{}}}if(T&&typeof T.preset=="string"){const L=n[T.preset];return L||B(`radix:preset:${T.preset}`,`unknown radix preset "${T.preset}"; known presets are ${Object.keys(n).join(", ")}`),{...L||{},...T}}return T||{}}function c(T){const L=m(T),E=i(L.radix),D=_[E];let $=null;if(L.bitWidth!==void 0&&L.bitWidth!==null&&L.bitWidth!==!1){const ne=Number(L.bitWidth);g.includes(ne)?$=ne:B(`radix:width:${String(L.bitWidth)}`,`unsupported bitWidth ${String(L.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let P=L.signed!==!1;!P&&$===null&&(B("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),$=32);const k=L.prefix===void 0||L.prefix===!0?X[E]:L.prefix===!1?"":String(L.prefix);let N=0;L.pad===!0?N=$?f($,E):0:typeof L.pad=="number"&&L.pad>0&&(N=Math.floor(L.pad));let G=0;L.group===!0?G=W[E]:typeof L.group=="number"&&L.group>0&&(G=Math.floor(L.group));const q=u($,P),Y=typeof L.min=="number"?Math.max(q.min,L.min):q.min,J=typeof L.max=="number"?Math.min(q.max,L.max):q.max,te=Object.freeze({radix:E,bits:D,prefix:k,uppercase:L.uppercase!==!1,pad:N,group:G,groupSeparator:typeof L.groupSeparator=="string"?L.groupSeparator:" ",bitWidth:$,signed:P,min:Y,max:J<Y?Y:J,nullDisplay:typeof L.nullDisplay=="string"?L.nullDisplay:"",name:o(E)});return l.add(te),te}function h(T){if(T&&l.has(T))return T;if(typeof T=="string"){let L=a.get(T);return L||(L=c(T),a.set(T,L)),L}if(T&&typeof T=="object"){let L=d.get(T);return L||(L=c(T),d.set(T,L)),L}return h("hex")}function s(T){return T<0?-Math.round(-T):Math.round(T)}function p(T,L,E){if(L<=0||T.length<=L)return T;const D=T.length%L||L,$=[T.slice(0,D)];for(let P=D;P<T.length;P+=L)$.push(T.slice(P,P+L));return $.join(E)}function y(T){const L=h(T),{radix:E,prefix:D,uppercase:$,pad:P,group:k,groupSeparator:N,signed:G,bitWidth:q,nullDisplay:Y}=L,J=q?2**q:0,te=ne=>{if(x(ne)||ne==="")return Y;const oe=typeof ne=="number"?ne:Number(ne);if(!Number.isFinite(oe))return Y;const le=s(oe);let ae="",se=le;le<0&&(G?(ae="-",se=-le):se=(le%J+J)%J);let ee=se.toString(E);return ee=$?ee.toUpperCase():ee.toLowerCase(),P>0&&ee.length<P&&(ee=ee.padStart(P,"0")),k>0&&(ee=p(ee,k,N)),ae+D+ee};return te.options=L,te}function O(T,L){const E=h(L);let D=r.get(E);return D||(D=y(E),r.set(E,D)),D(T)}function A(T){const L=h(T),{radix:E,groupSeparator:D,signed:$,min:P,max:k}=L,N=H[E],G=q=>{if(x(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(N.test(Y))te=parseInt(Y,E);else if(S.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=s(J?-te:te);return!$&&ne<0?{ok:!1,value:ne,reason:"negative"}:ne<P||ne>k?{ok:!1,value:ne,reason:"range"}:{ok:!0,value:ne,reason:"ok"}};return G.options=L,G}function b(T,L){const E=h(L);let D=t.get(E);return D||(D=A(E),t.set(E,D)),D(T)}function v(T,L){const E=b(T,L);return E.ok?E.value:null}function R(T,L){const E=x(T)||Number.isNaN(T)?null:Number(T),D=x(L)||Number.isNaN(L)?null:Number(L);return E===null?D===null?0:1:D===null||E<D?-1:E>D?1:0}function j(T){const L=T.min>=-2147483648&&T.max<=2147483647;return T.bitWidth&&L?"int32":"float64"}function F(T){const L=c(T),E=y(L),D=A(L);return{base:"number",extends:"number",storage:j(L),matches:null,format:$=>E($.value),parse:$=>{const P=D($.text);return P.ok?P.value:null},compare:R,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:$=>E($),fromClipboard:$=>{const P=D($);return P.ok?P.value:null},radix:L,formatValue:E,parseText:D}}const C=F}),Le("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 V}}),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 x=K("packages/core/src/internal/util.js").isNil;function B(z){const w=[];for(const S of z||[]){if(x(S))continue;const g=Number(S);Number.isFinite(g)&&w.push(g)}return w}function I(z){return w=>{const S=B(w);if(!S.length)return null;let g=0;for(const l of S)g+=10**(l/z);return z*Math.log10(g)}}function _(z){return w=>{const S=B(w);if(!S.length)return null;let g=0;for(const l of S)g+=10**(l/z);return z*Math.log10(g/S.length)}}function X(z,w){const S=w&&w.column,l=(S&&S.typeOptions||{}).weight,d=w&&w.valueAt;if(!l||typeof d!="function")return null;let a=0,r=0;for(let t=0;t<z.length;t++){if(x(z[t]))continue;const n=Number(z[t]);if(!Number.isFinite(n))continue;const i=d(l,t);if(x(i))continue;const f=Number(i);!Number.isFinite(f)||f<=0||(a+=n*f,r+=f)}return r===0?null:a/r}function W(z={}){const w=z.factor===20?20:10,S=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 d=l&&l.value;return x(d)||!Number.isFinite(Number(d))?"":`${Number(d).toFixed(g)}${S}`},parse:l=>{const d=String((l&&l.text)??"").replace(S,"").trim();if(!d)return null;const a=Number(d);return Number.isFinite(a)?a: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,S=z.percent===!0;return{base:"number",storage:"float64",name:z.name||"ratio",format:g=>{const l=g&&g.value;return x(l)||!Number.isFinite(Number(l))?"":S?`${Number(l).toFixed(w)}%`:Number(l).toFixed(w)},parse:g=>{const l=String((g&&g.text)??"").replace("%","").trim();if(!l)return null;const d=Number(l);return Number.isFinite(d)?d:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:X}}}}const V=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})})}),Le("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 S}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const x=K("packages/core/src/internal/util.js").isNil,B="⚠ no rate";function I(u){if(x(u))return null;const o=String(u).trim().toUpperCase();return o===""?null:o}function _(u){if(x(u))return null;if(typeof u=="object"&&!Array.isArray(u)){const o=Number(u.amount),m=I(u.code);return!m||!Number.isFinite(o)?null:{amount:o,code:m}}if(Array.isArray(u)&&u.length===2){const o=Number(u[0]),m=I(u[1]);return!m||!Number.isFinite(o)?null:{amount:o,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 V(u,o){const m=String(u).trim();if(m==="")return null;const c=new Intl.NumberFormat(o||void 0).formatToParts(1.1).find(y=>y.type==="decimal")?.value||".",h=c===","?".":",",s=m.split(h).join("").split(/[\s ]/).join("").replace(c,"."),p=Number(s);return Number.isFinite(p)?p:null}function z(u,o){const m=o||{},c=I(m.code);if(x(u))return null;const h=_(u);if(h)return h;if(typeof u=="number")return Number.isFinite(u)&&c?{amount:u,code:c}:null;let s=String(u).trim();if(s==="")return null;let p=!1;s.startsWith("(")&&s.endsWith(")")&&(p=!0,s=s.slice(1,-1).trim());let y=null;for(const[j,F]of Object.entries(X)){if(s.startsWith(j)){y=F,s=s.slice(j.length).trim();break}if(s.endsWith(j)){y=F,s=s.slice(0,-j.length).trim();break}}const O=H.exec(s);if(!O)return null;const A=V(O[0],m.locale);if(A===null)return null;const b=(s.slice(0,O.index)+" "+s.slice(O.index+O[0].length)).trim();!y&&b!==""&&(y=I(b));const v=y||c;return v?{amount:p?-A:A,code:v}:null}function w(u,o){if(typeof u=="function")return(m,c)=>{if(m===c)return 1;const h=u(m,c);return typeof h=="number"&&Number.isFinite(h)&&h>0?h:null};if(u&&typeof u=="object"){const m=u;return(c,h)=>{if(c===h)return 1;const s=Number(m[c]),p=Number(m[h]);return!Number.isFinite(s)||!Number.isFinite(p)||s<=0||p<=0?null:p/s}}return(m,c)=>m===c?1:null}function S(u,o,m){if(!u)return null;if(u.code===o)return u.amount;const c=m(u.code,o);return c===null?null:u.amount*c}const g=new Map;function l(u,o,m){const c=`${u||""}|${o}|${m??""}`;let h=g.get(c);if(!h){const s={style:"currency",currency:o};typeof m=="number"&&(s.minimumFractionDigits=m,s.maximumFractionDigits=m);try{h={fmt:new Intl.NumberFormat(u||void 0,s),currency:!0}}catch{h={fmt:new Intl.NumberFormat(u||void 0,typeof m=="number"?{minimumFractionDigits:m,maximumFractionDigits:m}:{}),currency:!1}}g.set(c,h)}return h}function d(u,o){const m=o||{},c=m.nullDisplay??"",h=_(u);if(!h)return c;const s=I(m.display)||h.code;let p=h.amount,y=h.code;if(s!==h.code){const b=m.rateFn||w(m.rates,m.rateBase),v=S(h,s,b);if(v===null)return`${m.missingRate??B} ${h.code}→${s}`;p=v,y=s}const{fmt:O,currency:A}=l(m.locale,y,m.decimals);return A?O.format(p):`${O.format(p)} ${y}`}function a(u){const o=_(u);return o?`${o.amount} ${o.code}`:""}function r(u){const o=u||{},m=I(o.display),c=o.rateFn||w(o.rates,o.rateBase);return(h,s)=>{const p=_(h),y=_(s);if(!p&&!y)return 0;if(!p)return 1;if(!y)return-1;if(m){const O=S(p,m,c),A=S(y,m,c);if(O!==null&&A!==null)return O===A?0:O<A?-1:1}return p.code===y.code?p.amount===y.amount?0:p.amount<y.amount?-1:1:p.code<y.code?-1:1}}function t(u){const o=u||{},m=(h,s)=>{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:s(p.map(R=>R.amount)),code:v}}const O=I(o.display);if(!O)return`${o.missingRate??B}: mixed currencies, no display currency set`;const A=o.rateFn||w(o.rates,o.rateBase),b=[];for(const v of p){const R=S(v,O,A);if(R===null)return`${o.missingRate??B}: ${v.code}→${O}`;b.push(R)}return{amount:s(b),code:O}},c=h=>h.reduce((s,p)=>s+p,0);return{sum:h=>m(h,c),avg:h=>m(h,s=>c(s)/s.length),min:h=>m(h,s=>Math.min(...s)),max:h=>m(h,s=>Math.max(...s))}}function n(u){const o=Object.freeze({code:"USD",...u||{}}),m=w(o.rates,o.rateBase),c=Object.freeze({...o,rateFn:m}),h=t(c),s=r(c),p=new Map([[o.locale||"",c]]),y=b=>{const v=b||"";let R=p.get(v);return R||(R=Object.freeze({...c,locale:b||void 0}),p.set(v,R)),R},O=W[I(o.display||o.code)]||"",A=typeof o.decimals=="number"&&o.decimals>0?`.${"0".repeat(o.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:c,format:b=>d(b.value,b.locale?y(b.locale):c),parse:b=>z(b.text,b.locale?y(b.locale):c),compare:s,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:h},excel:o.excel||(O?`"${O}"#,##0${A}`:`#,##0${A}`),toStorage:b=>{const v=_(b);return v||(typeof b=="string"||typeof b=="number"?z(b,c):null)},toClipboard:b=>a(b),fromClipboard:b=>z(b,c)}}const i=Object.freeze({currency:n({code:"USD"}),usd:n({code:"USD"}),eur:n({code:"EUR"}),gbp:n({code:"GBP"}),jpy:n({code:"JPY",decimals:0})}),f=n}),Le("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 V}}),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 S}}),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 d}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return i}}),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 o}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return b}}),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 j}});const Q=K("packages/core/src/columns/types/temporal.js"),x=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,V=W.UNIT_SYSTEMS,z=W.parseUnit,w=W.formatUnit,S=W.registerUnitSystem,g=W.unitSystemNames,l=W.unitsOf,d=W.defineUnit,a=K("packages/core/src/columns/types/engineering.js"),r=a.ENGINEERING_TYPES,t=K("packages/core/src/columns/types/si.js"),n=t.SI_TYPES,i=t.createSiType,f=t.createSiSystem,u=t.siUnits,o=t.SI_PREFIXES,m=K("packages/core/src/columns/types/temperature.js"),c=m.TEMPERATURE_TYPES,h=m.createTemperatureType,s=m.convertTemperature,p=m.formatTemperature,y=m.parseTemperature,O=m.TEMPERATURE_SCALES,A=K("packages/core/src/columns/types/radix.js"),b=A.createRadixType,v=A.RADIX_PRESETS,R=A.parseRadix,j=A.formatRadix,F=K("packages/core/src/columns/types/aggregable.js"),C=F.AGGREGABLE_TYPES,T=K("packages/core/src/columns/types/currency.js"),L=T.CURRENCY_TYPES,E=T.createCurrencyType,D=T.parseMoney,$=T.formatMoney,P=T.convertMoney,k=T.toMoney,N=T.rateFunction,G=T.moneyComparator,q=T.normaliseCode,Y=T.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return W.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return a.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return a.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 T.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return T.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return T.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return T.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return T.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return T.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return T.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return T.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return T.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return T.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 F.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return F.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return F.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({...x,...I,...X,...C,hex:b(v.hex),hex8:b(v.hex8),hex16:b(v.hex16),hex32:b(v.hex32),binary:b(v.binary),binary8:b(v.binary8),octal:b(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"}),...r,...n,...c,...L});{const te=new Set;for(const ne of[x,I,X,C,r,n,c,L])for(const oe of Object.keys(ne)){if(te.has(oe))throw new Error(`[lattice] data type "${oe}" is declared twice`);te.add(oe)}}}),Le("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 V}}),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 S}}),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 d}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return t}});const Q=K("packages/core/src/internal/util.js"),x=Q.collator,B=Q.defaultCompare,I=Q.warnOnce;function _(n){const i=new Uint32Array(n);for(let f=0;f<n;f++)i[f]=f;return i}function X(n,i){if(i&&typeof i.count=="number")return i.count;if(!n)return 0;if(typeof n.count=="number")return n.count;if(typeof n.length=="number")return n.length;const f=n.values;return n.kind==="multi"&&n.offsets?Math.max(0,n.offsets.length-1):f?n.kind==="bitset"?typeof f.size=="number"?f.size:n.presence&&typeof n.presence.size=="number"?n.presence.size:(I(`count:${n.id}`,`column "${n.id}" is bitset-backed with no declared row count; assuming ${f.length*8}`),f.length*8):f.length:n.presence&&typeof n.presence.size=="number"?n.presence.size:0}const W=new WeakMap;function H(n){const i=n.constructor;if(!i)return"unknown";const f=W.get(i);if(f)return f;let u="unknown";try{let o=null;typeof i.from=="function"?o=i.from([!1,!0]):(o=new i(8),o.set(1));const m=o&&o.words;m&&m.length&&(m[0]===2?u="lsb":m[0]===64&&(u="msb"))}catch{u="unknown"}return W.set(i,u),u}function V(n){if(!n)return()=>0;const i=n instanceof Uint8Array?n:n.words;if(i instanceof Uint8Array){const f=n instanceof Uint8Array?"lsb":H(n);if(f==="lsb")return u=>i[u>>>3]>>>(u&7)&1;if(f==="msb")return u=>i[u>>>3]>>>7-(u&7)&1}return typeof n.get=="function"?f=>n.get(f)?1:0:()=>0}function z(n){return!n||!n.presence?null:V(n.presence)}function w(n){return n?typeof n.size=="number"?n.size:typeof n.values=="function"?n.values().length:0:0}function S(n,i){return n?typeof n.valueOf=="function"?n.valueOf(i):typeof n.values=="function"?n.values()[i]:null:null}function g(n,i){const f=n.offsets,u=n.values;if(!f||!u)return[];const o=f[i],m=f[i+1];if(!(m>o))return[];const c=n.dict,h=new Array(m-o);for(let s=o;s<m;s++)h[s-o]=c?S(c,u[s]):u[s];return h}function l(n){if(!n)return()=>{};const i=n.values,f=z(n),u=n.kind;if(u==="dictionary"){const o=n.dict;return f?m=>f(m)?S(o,i[m]):null:m=>S(o,i[m])}if(u==="bitset"){const o=V(i);return f?m=>f(m)?o(m)===1:null:m=>o(m)===1}if(u==="multi")return f?o=>f(o)?g(n,o):null:o=>g(n,o);if(!i&&typeof n.get=="function"){const o=n.get.bind(n);return m=>{const c=o(m);return c===void 0?null:c}}return f?o=>{if(!f(o))return null;const m=i[o];return m===void 0?null:m}:o=>{const m=i[o];return m===void 0?null:m}}function d(n,i){if(n<i)return-1;if(n>i)return 1;if(n===i){const o=Object.is(n,-0),m=Object.is(i,-0);return o===m?0:o?-1:1}const f=Number.isNaN(n),u=Number.isNaN(i);return f&&u?0:f?1:-1}function a(n){const i=x(n);return(f,u)=>{if(f===u)return 0;const o=typeof f,m=typeof u;if(o==="string"&&m==="string")return i.compare(f,u);if(o==="number"&&m==="number")return d(f,u);if(o==="boolean"&&m==="boolean")return f===u?0:f?1:-1;if(f instanceof Date||u instanceof Date){const c=f instanceof Date?f.getTime():Number(f),h=u instanceof Date?u.getTime():Number(u);return d(c,h)}return B(f,u)}}function r(n,i){if(n&&typeof n.ranks=="function")return n.ranks(i);const f=n&&typeof n.values=="function"?n.values():[],u=f.length,o=a(i),m=new Array(u);for(let h=0;h<u;h++)m[h]=h;m.sort((h,s)=>o(f[h],f[s])||h-s);const c=new Uint32Array(u);for(let h=0;h<u;h++)c[m[h]]=h;return c}function t(n){return n==null||typeof n=="number"&&Number.isNaN(n)}}),Le("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 y}}),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"),x=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"),V=H.bitReader,z=H.dictSize,w=H.dictValue,S=H.presenceReader,g=H.valueComparator,l=H.valueReader,d=/^\d{4}-\d{2}-\d{2}$/,a="\0null\0";function r(se,ee){const ie=se&&se.pool;if(ie){const de=ie.mask||ie.acquireMask||ie.acquire||ie.take;if(typeof de=="function"){const he=de.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 de=ie.release||ie.releaseMask||ie.free||ie.recycle;typeof de=="function"&&de.call(ie,ee)}function n(se,ee,ie){return se.fill(ie,0,ee),se}function i(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 o(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 c(se,ee){return se==null?a:typeof se=="string"?ee?se:se.toLowerCase():se instanceof Date?se.getTime():se}function h(se,ee,ie){const de=new Set;for(const he of B(se)){const ge=f(he,ie);de.add(c(ge,ee)),typeof ge=="string"&&ge!==""&&Number.isFinite(Number(ge))?de.add(Number(ge)):typeof ge=="number"&&Number.isFinite(ge)&&de.add(c(String(ge),ee))}return de}function s(se,ee,ie){if(se==null||ee===null||ee===void 0)return se==null&&ee==null;const de=typeof se,he=typeof ee;return de==="string"&&he==="string"?ie?se===ee:se.toLowerCase()===ee.toLowerCase():se instanceof Date||ee instanceof Date?u(se)===u(ee):de==="number"&&he==="number"?se===ee||Number.isNaN(se)&&Number.isNaN(ee):de==="number"&&he==="string"?se===Number(ee):de==="string"&&he==="number"?Number(se)===ee:de==="boolean"||he==="boolean"?se===ee:Array.isArray(se)&&Array.isArray(ee)?se.length===ee.length&&se.every((ge,Ee)=>s(ge,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 y(se,ee){if(se&&se.type==="datetime"&&O.has(se.op))return j(se,ee);const ie=F(se,ee),de=se&&se.type;return de!=="date"&&de!=="dateString"?ie:he=>ie(typeof he=="string"&&d.test(he)?he:W(he)??he)}const O=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),A=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,b=new Map;function v(se,ee){let ie=b.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}b.set(ee,ie)}if(!ie)return null;const de={};for(const he of ie.formatToParts(se))he.type!=="literal"&&(de[he.type]=he.value);return de}function R(se,ee){if(se==null||se==="")return null;if(typeof se=="string"){const ge=A.exec(se.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 ie=X(se);if(!ie)return null;const de=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,de):Date.UTC(ie.getFullYear(),ie.getMonth(),ie.getDate(),ie.getHours(),ie.getMinutes(),ie.getSeconds(),de)}function j(se,ee){const ie=typeof se.timeZone=="string"&&se.timeZone?se.timeZone:void 0,de=Ee=>R(Ee,ie),he=Array.isArray(se.value)?se.value.map(de):de(se.value),ge=F({...se,type:"number",value:he},ee);return Ee=>ge(R(Ee))}function F(se,ee){const ie=se&&se.op,de=!!(se&&se.caseSensitive),he=se&&se.type,ge=g(ee),Ee=ye=>Ae=>!ye(Ae);switch(ie){case"eq":{const ye=f(se.value,he);return Ae=>s(Ae,ye,de)}case"ne":{const ye=f(se.value,he);return Ae=>!s(Ae,ye,de)}case"lt":case"lte":case"gt":case"gte":{const ye=f(se.value,he);if(i(ye))return()=>!1;const Ae=ie==="lt"?-1:ie==="lte"?0:ie==="gt"?1:2;return pe=>{if(i(pe))return!1;const we=ge(pe,ye);return Ae===-1?we<0:Ae===0?we<=0:Ae===1?we>0:we>=0}}case"between":case"notBetween":{const ye=B(se.value),Ae=f(ye[0],he),pe=f(ye[1],he),we=se.bounds||"[]",be=we.charAt(0)!=="(",Ne=we.charAt(1)!==")";if(i(Ae)||i(pe))return ie==="between"?()=>!1:()=>!0;const Ie=Ve=>{if(i(Ve))return!1;const Ye=ge(Ve,Ae),je=ge(Ve,pe);return(be?Ye>=0:Ye>0)&&(Ne?je<=0:je<0)};return ie==="between"?Ie:Ee(Ie)}case"in":case"notIn":{const ye=h(se.value,de,he),Ae=pe=>ye.has(c(pe,de));return ie==="in"?Ae:Ee(Ae)}case"contains":case"notContains":{const ye=m(f(se.value,he),de),Ae=pe=>pe==null?!1:m(pe,de).includes(ye);return ie==="contains"?Ae:Ee(Ae)}case"startsWith":{const ye=m(f(se.value,he),de);return Ae=>Ae==null?!1:m(Ae,de).startsWith(ye)}case"endsWith":{const ye=m(f(se.value,he),de);return Ae=>Ae==null?!1:m(Ae,de).endsWith(ye)}case"matches":{const ye=p(se.value,de);return ye?Ae=>Ae==null?!1:ye.test(String(Ae)):()=>!1}case"blank":return ye=>x(ye)||Array.isArray(ye)&&ye.length===0;case"notBlank":return ye=>!(x(ye)||Array.isArray(ye)&&ye.length===0);case"containsAny":case"containsNone":{const ye=h(se.value,de,he),Ae=pe=>{const we=pe==null?[]:B(pe);for(let be=0;be<we.length;be++)if(ye.has(c(we[be],de)))return!0;return!1};return ie==="containsAny"?Ae:Ee(Ae)}case"containsAll":{const ye=B(se.value).map(Ae=>c(f(Ae,he),de));return Ae=>{const pe=Ae==null?[]:B(Ae);if(ye.length===0)return!0;const we=new Set(pe.map(be=>c(be,de)));for(let be=0;be<ye.length;be++)if(!we.has(ye[be]))return!1;return!0}}default:{const ye=ae(ie);return ye?ye.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 y(ee,ie)(se)}const T=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),L=new Set(["containsAny","containsAll","containsNone"]);function E(se,ee,ie){const de=se&&se.op,he=T[de]||de,ge=y({...se,op:he,type:ee.type},ie),Ee=ee.items,ye=Ae=>{const pe=Ee(Ae);if(!pe)return!1;for(let we=0;we<pe.length;we++)if(ge(pe[we]))return!0;return!1};return T[de]?Ae=>!ye(Ae):ye}function D(se,ee,ie,de){const he=S(se);if(he){const ye=ee?1:0;for(let Ae=0;Ae<de;Ae++)ie[Ae]=he(Ae)===ye?1:0;return ie}const ge=se.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return n(ie,de,ee?1:0);const Ee=l(se);for(let ye=0;ye<de;ye++){const Ae=Ee(ye),pe=x(Ae)||Array.isArray(Ae)&&Ae.length===0;ie[ye]=pe===ee?0:1}return ie}function $(se,ee,ie,de){const he=se.dict,ge=z(he),Ee=new Uint8Array(ge);for(let we=0;we<ge;we++)Ee[we]=ee(w(he,we))?1:0;const ye=se.values,Ae=S(se);if(!Ae){for(let we=0;we<de;we++)ie[we]=Ee[ye[we]];return ie}const pe=ee(null)?1:0;for(let we=0;we<de;we++)ie[we]=Ae(we)===1?Ee[ye[we]]:pe;return ie}function P(se,ee,ie,de){const he=V(se.values),ge=ee(!0)?1:0,Ee=ee(!1)?1:0,ye=S(se);if(!ye){for(let pe=0;pe<de;pe++)ie[pe]=he(pe)===1?ge:Ee;return ie}const Ae=ee(null)?1:0;for(let pe=0;pe<de;pe++)ie[pe]=ye(pe)===0?Ae:he(pe)===1?ge:Ee;return ie}function k(se,ee,ie,de,he){const ge=se.values,Ee=ee.type,ye=ee.op;let Ae=!0;switch(ye){case"eq":case"ne":{const we=o(f(ee.value,Ee)),be=typeof ee.value=="number"&&Number.isNaN(ee.value),Ne=ye==="ne"?1:0;if(be)for(let Ie=0;Ie<he;Ie++)de[Ie]=(Number.isNaN(ge[Ie])?1:0)^Ne;else for(let Ie=0;Ie<he;Ie++)de[Ie]=(ge[Ie]===we?1:0)^Ne;break}case"lt":{const we=o(f(ee.value,Ee));for(let be=0;be<he;be++)de[be]=ge[be]<we?1:0;break}case"lte":{const we=o(f(ee.value,Ee));for(let be=0;be<he;be++)de[be]=ge[be]<=we?1:0;break}case"gt":{const we=o(f(ee.value,Ee));for(let be=0;be<he;be++)de[be]=ge[be]>we?1:0;break}case"gte":{const we=o(f(ee.value,Ee));for(let be=0;be<he;be++)de[be]=ge[be]>=we?1:0;break}case"between":case"notBetween":{const we=B(ee.value),be=o(f(we[0],Ee)),Ne=o(f(we[1],Ee)),Ie=ee.bounds||"[]",Ve=Ie.charAt(0)!=="(",Ye=Ie.charAt(1)!==")",je=ye==="notBetween"?1:0;if(Ve&&Ye)for(let He=0;He<he;He++)de[He]=(ge[He]>=be&ge[He]<=Ne?1:0)^je;else if(Ve)for(let He=0;He<he;He++)de[He]=(ge[He]>=be&ge[He]<Ne?1:0)^je;else if(Ye)for(let He=0;He<he;He++)de[He]=(ge[He]>be&ge[He]<=Ne?1:0)^je;else for(let He=0;He<he;He++)de[He]=(ge[He]>be&ge[He]<Ne?1:0)^je;break}case"in":case"notIn":{const we=new Set;for(const Ne of B(ee.value)){const Ie=o(f(Ne,Ee));Number.isNaN(Ie)||we.add(Ie)}const be=ye==="notIn"?1:0;for(let Ne=0;Ne<he;Ne++)de[Ne]=(we.has(ge[Ne])?1:0)^be;break}default:Ae=!1;break}if(!Ae)return!1;const pe=S(se);if(pe){const we=ie(null)?1:0;for(let be=0;be<he;be++)pe(be)===0&&(de[be]=we)}return!0}function N(se,ee,ie,de){const he=l(se);for(let ge=0;ge<de;ge++)ie[ge]=ee(he(ge))?1:0;return ie}function G(se,ee,ie){const de=ee.count|0,he=ie||r(ee,de);if(!se)return n(he,de,1);const ge=typeof ee.handle=="function"?ee.handle(se.col):void 0,Ee=typeof ee.custom=="function"?ee.custom:null;if(!ge){if(Ee){for(let we=0;we<de;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`),n(he,de,0)}const ye=se.op;if(ye==="blank"||ye==="notBlank")return D(ge,ye==="notBlank",he,de);const Ae=typeof ee.itemwise=="function"?ee.itemwise(se.col):null;if(Ae&&!ae(ye)&&!L.has(ye))return N(ge,E(se,Ae,ee.locale),he,de);const pe=y(se,ee.locale);switch(ge.kind){case"dictionary":return $(ge,pe,he,de);case"bitset":return P(ge,pe,he,de);case"float64":case"int32":return k(ge,se,pe,he,de)?he:N(ge,pe,he,de);default:return N(ge,pe,he,de)}}function q(se,ee,ie){if(!se)return n(r(ee,ie),ie,1);if(Array.isArray(se.conditions)){const de=se.conditions.filter(Ee=>Ee!=null),he=se.op==="or"?"or":se.op==="not"?"not":"and";if(de.length===0)return n(r(ee,ie),ie,1);const ge=q(de[0],ee,ie);for(let Ee=1;Ee<de.length;Ee++){const ye=q(de[Ee],ee,ie);if(he==="or")for(let Ae=0;Ae<ie;Ae++)ge[Ae]|=ye[Ae];else for(let Ae=0;Ae<ie;Ae++)ge[Ae]&=ye[Ae];t(ee,ye)}if(he==="not")for(let Ee=0;Ee<ie;Ee++)ge[Ee]^=1;return ge}return G(se,ee,r(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 ge of ie.conditions){const Ee=J(ge,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 de of ie.conditions)if(te(de,ee))return!0}return!1}function ne(se,ee,ie){if(ie&&ie.length>=ee){let Ee=0;for(let ye=0;ye<ee;ye++)se[ye]&&(ie[Ee++]=ye);return ie.subarray(0,Ee)}let de=0;for(let Ee=0;Ee<ee;Ee++)de+=se[Ee]?1:0;const he=new Uint32Array(de);let ge=0;for(let Ee=0;Ee<ee;Ee++)se[Ee]&&(he[ge++]=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}}),Le("packages/core/src/columns/datatypes.js",function(e,K){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return s}}),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 F}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return L}});const Q=K("packages/core/src/internal/util.js"),x=Q.collator,B=Q.defaultCompare,I=Q.isNil,_=Q.isObject,X=Q.isFunction,W=Q.fail,H=Q.titleCase,V=K("packages/core/src/format/date.js"),z=V.toDate,w=V.toIsoDate,S=V.compareIso,l=K("packages/core/src/format/boolean.js").toTriState,a=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,r=K("packages/core/src/formula/index.js"),t=r.evaluateFormula,n=r.looksLikeFormula,f=K("packages/core/src/compute/filter.js").declareOperators,u=/^\d{4}-\d{2}-\d{2}$/;function o(E){return E.getHours()===0&&E.getMinutes()===0&&E.getSeconds()===0&&E.getMilliseconds()===0}const m=new Map;function c(E){const D=E||"",$=m.get(D);if($)return $;const P={group:",",decimal:"."};try{for(const k of new Intl.NumberFormat(E||void 0).formatToParts(12345.6))k.type==="group"?P.group=k.value:k.type==="decimal"&&(P.decimal=k.value)}catch{}return m.set(D,P),P}const h=/\d\s*[*/^]\s*[\d.(]/;function s(E,D){if(I(E))return null;let $=String(E).trim();if($===""||$.startsWith("=")||h.test($))return null;let P=1;$.startsWith("(")&&$.endsWith(")")&&(P=-1,$=$.slice(1,-1));const k=$.endsWith("%"),{group:N,decimal:G}=c(D);if($=$.replace(/[\s\u00a0\u202f\u2009']/g,""),N&&N!=="."&&N!==","&&($=$.split(N).join("")),$=$.replace(/[^0-9eE+\-.,]/g,""),G===","?$=$.split(".").join("").replace(",","."):$=$.split(",").join(""),$===""||$==="-"||$==="+")return null;const q=Number($);return Number.isNaN(q)?null:P*(k?q/100:q)}function p(E,D){const $=I(E)||Number.isNaN(E)?null:Number(E),P=I(D)||Number.isNaN(D)?null:Number(D);return $===null?P===null?0:1:P===null||$<P?-1:$>P?1:0}function y(E,D){const $=l(E),P=l(D);return $===null?P===null?0:1:P===null?-1:$===P?0:$?1:-1}function O(E,D){const $=z(E),P=z(D);if(!$)return P?1:0;if(!P)return-1;const k=$.getTime(),N=P.getTime();return k<N?-1:k>N?1:0}const A=new Map;function b(E){const D=z(E.value);if(!D)return"";const $=E.locale||"";let P=A.get($);return P||(P=new Intl.DateTimeFormat(E.locale||void 0,{dateStyle:"medium"}),A.set($,P)),P.format(D)}const v={boolean:{base:"boolean",storage:"bitset",matches:E=>typeof E=="boolean",parse:E=>l(E.text),compare:y,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(n(E.text)){const D=t(E.text,E);if(!D.ok)return null;const $=Number(D.value);return Number.isFinite($)?$:null}return s(E.text,E.locale)},compare:p,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:E=>I(E)?"":String(E),fromClipboard:(E,D)=>s(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())&&o(E),parse:E=>w(E.text),compare:S,format:b,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:S,format:b,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:x().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:x().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,$=D&&X(D.options)?D.options():null;if(!$)return E.text;const P=String(E.text),k=$.find(q=>String(q.id)===P);if(k)return k.id;const N=P.trim().toLowerCase(),G=$.find(q=>String(q.label).toLowerCase()===N);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 j(E,D,$,P){const k=$.get(E);if(k)return k;P.includes(E)&&W(`circular data type extends chain: ${[...P,E].join(" → ")}`);const N=D[E];N||W(`unknown data type "${E}"`);let G=null;N.extends&&(G=j(N.extends,D,$,[...P,E]));const q={...G||{},...N,name:E,defaults:{...G&&G.defaults||{},...N.defaults||{}}};return q.base||(q.base=G&&G.base||"text"),q.storage||(q.storage=G&&G.storage||"object"),$.set(E,q),q}function F(E,D){const $={...v,...a};if(D&&typeof D.dataType=="function"&&typeof D.names=="function")for(const k of D.names("dataType")){const N=D.dataType(k);N&&($[k]=N)}if(_(E))for(const[k,N]of Object.entries(E))$[k]=N;const P=new Map;for(const k of R)j(k,$,P,[]);j("lookup",$,P,[]);for(const k of Object.keys($))j(k,$,P,[]);for(const k of P.values())f(k.operators);return P}function C(E,D){if(E.base==="text"&&(!E.compare||E.compare===v.text.compare)){const $=x(D);return(P,k)=>I(P)?I(k)?0:1:I(k)?-1:$.compare(String(P),String(k))}return E.compare||B}function T(E,D){return D?E.multiStorage||"multi":E.storage||"object"}function L(E){return H(String(E).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Le("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"),x=Q.infoOnce,B=Q.isNil,I=100;function _(W,H,V={}){const z=V.sampleSize??I,w=[];for(let S=0;S<W.length&&w.length<z;S++){const g=W[S];B(g)||typeof g=="number"&&Number.isNaN(g)||w.push(g)}if(w.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[S,g]of H){if(typeof g.matches!="function")continue;let l=!0;for(let d=0;d<w.length;d++)if(!g.matches(w[d])){l=!1;break}if(l)return{type:S,unanimous:!0,sampled:w.length}}return V.quiet||x(`infer:${V.colId||"?"}`,`column "${V.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,V,z,w={}){const S=w.sampleSize??I,g=[];for(let l=0;l<H.length&&g.length<S;l++){const d=V(H[l]);B(d)||typeof d=="number"&&Number.isNaN(d)||g.push(d)}return _(g,z,{...w,colId:W}).type}}),Le("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 V}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return z}});const Q=K("packages/core/src/internal/util.js"),x=Q.DEV,B=Q.fail,I=Q.isFunction,_=Q.warnOnce,X="*";function W(w){const S=w.value||{};if(!I(S.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const l=S.pure!==!1;return S.deps===X?{computed:!0,wholeRow:!0,deps:[],pure:l}:Array.isArray(S.deps)?{computed:!0,wholeRow:!1,deps:S.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 S=new Map;for(const m of w)S.set(m.id,m);const g=new Map,l=new Map,d=new Set,a=new Set,r=new Set,t=new Set;for(const m of w){const c=W(m);if(!c.computed){g.set(m.id,[]);continue}a.add(m.id),(c.pure?r:t).add(m.id),c.wholeRow&&d.add(m.id);const h=[],s=[];for(const p of c.deps)(S.has(p)?h:s).push(p);g.set(m.id,h),s.length&&l.set(m.id,s)}for(const m of r)for(const c of g.get(m))t.has(c)&&B(`pure computed column "${m}" depends on impure column "${c}". Mark it \`value.pure: false\` or make the dependency pure.`);const n=[],i=new Map,f=[],u=m=>{const c=i.get(m);if(c!=="done"){if(c==="open"){const h=f.indexOf(m);B(`circular column dependency: ${[...f.slice(h),m].join(" → ")}`)}i.set(m,"open"),f.push(m);for(const h of g.get(m)||[])S.has(h)&&u(h);f.pop(),i.set(m,"done"),n.push(m)}};for(const m of w)u(m.id);const o=new Map;for(const m of w)o.set(m.id,[]);for(const m of w)for(const c of g.get(m.id)||[]){const h=o.get(c);h&&!h.includes(m.id)&&h.push(m.id)}if(d.size)for(const m of w){if(a.has(m.id))continue;const c=o.get(m.id);for(const h of d)c.includes(h)||c.push(h)}return{order:n,dependents:o,pure:r,impure:t,computed:a,deps:g,wholeRow:d,external:l,index:S}}function V(w,S){const g=Array.isArray(S)?S:[S],l=new Set,d=[...g];for(;d.length;){const a=d.shift();for(const r of w.dependents.get(a)||[])l.has(r)||(l.add(r),d.push(r))}for(const a of g)l.delete(a);return w.order.filter(a=>l.has(a))}function z(w,S,g){if(!x)return w;const l=S instanceof Set?S:new Set(S);return new Proxy(w,{get(d,a){return typeof a=="string"&&!l.has(a)&&!Object.hasOwn(d,a)&&_(`undeclared:${g}:${a}`,`computed column "${g}" read undeclared dependency "${a}". Add it to \`value.deps\` or the value will go stale.`),d[a]}})}}),Le("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 V}}),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 d}});const Q=K("packages/core/src/internal/util.js"),x=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(a){if(a===null)return"\0n";if(a===void 0)return"\0u";const r=typeof a;if(r==="string")return a;if(r==="number"||r==="bigint"||r==="boolean")return String(a);if(a instanceof Date)return`\0d${a.getTime()}`;try{return`\0o${JSON.stringify(a)}`}catch{return"\0o?"}}function V(a){if(a.length===1)return H(a[0]);let r="";for(let t=0;t<a.length;t++)t&&(r+=W),r+=H(a[t]);return r}function z(a,r={}){const t=r.warn!==!1;if(I(a)){const n=a;return{stable:!0,fields:[],disabled:[],key(i,f){try{const u=n(i);return Array.isArray(u)?V(u):H(u)}catch(u){return x("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",u),`#${f??-1}`}},keyEmpty(i){try{const f=n(i);return Array.isArray(f)?f.length===0||f.some(_):_(f)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(a)&&a.length>0){const n=a.filter(u=>typeof u=="string"),i=n.map(u=>B(u)),f=i.length;return{stable:!0,fields:n,disabled:[],key(u){const o=new Array(f);for(let m=0;m<f;m++)o[m]=i[m](u);return V(o)},keyEmpty(u){for(let o=0;o<f;o++)if(_(i[o](u)))return!0;return!1},missingFields(u){const o=[];for(let m=0;m<f;m++)_(i[m](u))&&o.push(n[m]);return o}}}if(typeof a=="string"&&a.length>0){const n=B(a);return{stable:!0,fields:[a],disabled:[],key(i){return H(n(i))},keyEmpty(i){return _(n(i))},missingFields(i){return _(n(i))?[a]:[]}}}return t&&x("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(n,i){if(n===null||typeof n!="object")return`#${i??0}:${String(n)}`;let f=w.get(n);return f===void 0&&(f=`#${S++}`,w.set(n,f)),f}}}const w=new WeakMap;let S=0;function g(a,r){if(!a||a.stable===!1||!I(a.keyEmpty)||!Array.isArray(r)||r.length===0)return;let t=0,n=null,i;for(let m=0;m<r.length;m++){const c=r[m];a.keyEmpty(c)&&(t++,n===null&&(n=I(a.missingFields)?a.missingFields(c):[],i=c))}if(t===0)return;const f=a.fields.length?a.fields.join(","):"(function)",u=n&&n.length?n.join(", "):a.fields.length?a.fields.join(", "):"the rowKey function",o=i!==null&&typeof i=="object"?Object.keys(i).join(", ")||"(no fields)":String(i);x(`rowKey.emptyValue:${f}`,`rowKey ${u} is missing on ${t} of ${r.length} rows; the first such row has: ${o}. 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(a){return V(a)}function d(a){return a.split(W)}}),Le("packages/core/src/columns/lookup.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/internal/util.js"),x=Q.collator,B=Q.defaultCompare,I=Q.isFunction,_=Q.isNil,X=Q.warnOnce,H=K("packages/core/src/model/rowkey.js").compositeKey,V=", ",z="";function w(r,t,n,i){if(r===null||typeof r!="object")return{id:r,label:r==null?"":String(r)};const f=r[t],u=r[n],o={id:f,label:u==null?String(f??""):String(u)};r.disabled&&(o.disabled=!0),r.variant&&(o.variant=r.variant),r.icon&&(o.icon=r.icon);const m=i?r[i]:r.group;return m!==void 0&&(o.group=m),o}function S(r,t,n=0,i=[],f=[]){for(const u of r||[]){const o=u&&typeof u=="object"?u[t]:null;if(f.push({raw:u,depth:n,path:i}),Array.isArray(o)&&o.length){const m=String(u&&typeof u=="object"?u.label??u.name??u.id??"":u);S(o,t,n+1,[...i,m],f)}}return f}function g(r){return!!r&&typeof r=="object"&&!Array.isArray(r)&&I(r.router&&r.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,n={}){this.#e=t||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#c=x(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??V}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=x(t)}#h(t){const n=this.#e,i=n.valueKey||"id",f=n.labelKey||"label",u=n.childrenKey||"children";this.#o=S(t,u).map(o=>{const m=w(o.raw,i,f,n.groupKey);return o.depth&&(m.depth=o.depth,m.path=o.path),m}),this.#i=new Map,this.#s=new Map,this.#o.forEach((o,m)=>{this.#i.set(o.id,o),this.#s.set(o.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 n;try{n=t()}catch(i){return this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,i),this.#u=Promise.resolve([]),this.#u}return!n||!I(n.then)?(this.#h(n),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=n.then(i=>(this.#h(i),this.#r&&this.#r(this),this.#o),i=>(this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,i),[])),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 n=this.#e,i=n.valueKey||"id",f=n.labelKey||"label",u=n.groupKey,o=I(t.map)?t.map:null,m=h=>w(o?o(h):h,i,f,u).id,c=h=>this.#m(h,o,i,f,u);return t.router.subscribe(t.predicate,c,{rowKey:m}),this.#d=()=>{I(t.router.detach)&&t.router.detach(c)},this.#a="ready",Promise.resolve(this.#o)}#m(t,n,i,f,u){const o=t&&t.add||[],m=t&&t.update||[],c=t&&t.remove||[];if(!(!o.length&&!m.length&&!c.length)){for(const h of o)this.#g(h,n,i,f,u);for(const h of m)this.#g(h,n,i,f,u);for(const h of c){if(!this.#f.has(h))continue;const s=this.#f.get(h);this.#f.delete(h),this.#i.delete(s);const p=this.#o.findIndex(y=>y.id===s);p>=0&&this.#o.splice(p,1)}this.#s=new Map(this.#o.map((h,s)=>[h.id,s])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(t,n,i,f,u){const o=w(n?n(t):t,i,f,u);this.#f.set(H([o.id]),o.id);const m=this.#o.findIndex(c=>c.id===o.id);m>=0?this.#o[m]=o:this.#o.push(o),this.#i.set(o.id,o)}destroy(){this.#d&&(this.#d(),this.#d=null)}search(t,n){const i=this.#e;if(!I(i.search)){const o=String(t||"").toLowerCase();return Promise.resolve(o===""?this.#o:this.#o.filter(m=>m.label.toLowerCase().includes(o)))}const f=i.valueKey||"id",u=i.labelKey||"label";return Promise.resolve(i.search(t,n)).then(o=>(o||[]).map(m=>w(m,f,u,i.groupKey)))}option(t){return this.#i.get(t)}has(t){return this.#i.has(t)}label(t){if(_(t)||t==="")return"";const n=this.#i.get(t);if(n)return n.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 i=this.#e.unknownLabel;return I(i)?String(i(t)??""):typeof i=="string"?i:String(t)}text(t){if(this.multiple){const n=d(t);return n.length===0?"":n.map(i=>this.label(i)).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((i,f)=>B(i.id,f.id));const n=this.#c;return this.#o.slice().sort((i,f)=>n.compare(i.label,f.label))}comparator(){const t=this.sortBy,n=this.multiple,i=this.#c,f=this.#s;if(n&&t==="count")return(o,m)=>d(o).length-d(m).length;const u=n?o=>d(o)[0]:o=>o;return t==="value"?(o,m)=>B(u(o),u(m)):t==="optionOrder"?(o,m)=>{const c=f.has(u(o))?f.get(u(o)):Number.MAX_SAFE_INTEGER,h=f.has(u(m))?f.get(u(m)):Number.MAX_SAFE_INTEGER;return c-h}:(o,m)=>{const c=u(o),h=u(m);return _(c)?_(h)?0:1:_(h)?-1:i.compare(this.label(c),this.label(h))}}groupKey(t){return this.multiple?d(t).map(i=>String(i)).sort().join(z):_(t)?"":String(t)}countValues(t){return this.multiple?d(t).length:_(t)?0:1}contains(t,n,i){const f=this.multiple?d(t):_(t)?[]:[t],u=Array.isArray(n)?n:[n];switch(i){case"containsAll":return u.every(o=>f.includes(o));case"containsNone":return!u.some(o=>f.includes(o));default:return u.some(o=>f.includes(o))}}exportText(t,n="label"){return n==="value"?this.multiple?d(t).join(this.separator):_(t)?"":String(t):this.text(t)}exportColumns(){const t=this.multiple;return this.#o.map(n=>({id:n.id,label:n.label,has:i=>t?d(i).includes(n.id):i===n.id}))}}function d(r){return Array.isArray(r)?r:_(r)||r===""?[]:[r]}function a(r,t={}){const n=r.lookup;if(!n)return null;const i=new l(n,{colId:r.id,locale:t.locale,onChange:t.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&i.load(),i}}),Le("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 S}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),x=Q.getPath,B=Q.isFunction,I=Q.isNil,_=Q.Lru,X=Q.warnOnce,H=K("packages/core/src/columns/graph.js").depsProxy,V="\0";function z(r,t={}){const n=t.locale,i=t.grid??null,f=t.context,u=r.value&&r.value.format,o=r.formatter||null,m=r.dataType&&r.dataType.format,c=r.lookup||null,h=(s,p,y)=>({value:s,data:y,row:p,column:r,colId:r.id,grid:i,context:f,locale:n});if(B(u))return(s,p,y)=>{const O=u(h(s,p,y));return O==null?"":String(O)};if(o){if(c){const s=o.kind==="text";return(p,y,O)=>o(s?c.text(p):p,h(p,y,O))}return(s,p,y)=>o(s,h(s,p,y))}return B(m)?(s,p,y)=>{const O=m(h(s,p,y));return O==null?"":String(O)}:c?s=>c.text(s):s=>I(s)?"":typeof s=="string"?s:String(s)}function w(r,t){!r||!r.value||r.value.pure!==!1||X(`impure:${t}:${r.id}`,`column "${r.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${t}. The result is not stable across passes.`)}class S{#e;#t;#n;#r;#o;#i;#s=new _(4096);constructor(t){this.#e=t.columns instanceof Map?t.columns:new Map((t.columns||[]).map(n=>[n.id,n])),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 n=t&&t.rows?new Set([...t.rows].map(String)):null,i=t&&t.columns?[...t.columns]:null;if(!n&&!i){this.#s.clear();return}const f=i?this.#l(i):null;for(const u of[...this.#s.keys()]){const o=String(u).split(V);o.length===3&&(n&&!n.has(o[0])||f&&!f.has(o[2])||this.#s.delete(u))}}#l(t){const n=new Set,i=this.#t,f=[...t];for(;f.length;){const u=f.pop();if(!n.has(u)){n.add(u);for(const o of i?i.dependents.get(u)||[]:[])f.push(o)}}return n}value(t,n,i){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return;if(!f.computed)return this.#u(f,n,i);if(f.value.pure!==!1&&this.#i&&i&&i.physical!=null&&this.#i.has(f.id))return this.#i.get(f.id,i.physical);if(f.volatile)return this.compute(f,n,i);if(f.value.pure===!1)return this.compute(f,n,i);const u=`${this.#a(n,i)}${V}${f.id}`;if(this.#s.has(u))return this.#s.get(u);const o=this.compute(f,n,i);return this.#s.set(u,o),o}#a(t,n){return`${this.#o(t,n)}${V}${l(t)}`}#u(t,n,i){if(this.#i&&i&&i.physical!=null&&this.#i.has(t.id))return this.#i.get(t.id,i.physical);if(t.field)return t.read?t.read(n):x(n,t.field)}compute(t,n,i){const f=this.#t,u=f&&f.wholeRow.has(t.id);let o;if(u)o=n??{};else{o={};const c=f&&f.deps.get(t.id)||[];for(const s of c)o[s]=this.value(s,n,i);const h=f&&f.external.get(t.id)||[];for(const s of h)o[s]=x(n,s);o=H(o,[...c,...h],t.id)}const m={data:n,row:i,column:t,grid:this.#n,context:this.#r};return t.value.compute(o,m)}values(t,n){const i={},f=this.#t?this.#t.order:[...this.#e.keys()];for(const u of f)i[u]=this.value(u,t,n);return i}text(t,n,i){const f=typeof t=="string"?this.#e.get(t):t;return f?f.formatValue(this.value(f,n,i),i,n):""}key(t,n,i){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return"";const u=this.value(f,n,i);return B(f.value.key)?String(f.value.key(this.#c(f,u,n,i))):f.lookup?f.lookup.groupKey(u):I(u)?"":String(u)}quickFilterText(t,n,i){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return"";if(B(f.value.quickFilterText)){const u=this.value(f,n,i);return String(f.value.quickFilterText(this.#c(f,u,n,i))??"")}return this.text(f,n,i)}#c(t,n,i,f){return{value:n,data:i,row:f,column:t,colId:t.id,grid:this.#n,context:this.#r}}parse(t,n,i,f){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return n;const o={text:n,value:this.value(u,i,f),data:i,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(o):u.dataType&&B(u.dataType.parse)?u.dataType.parse(o):n}validate(t,n,i,f,u){const o=typeof t=="string"?this.#e.get(t):t;if(!o||!B(o.edit.validate))return!0;const m=o.edit.validate({value:n,oldValue:i,data:f,row:u,column:o,grid:this.#n,context:this.#r});return m===!0||m===void 0?!0:String(m)}apply(t,n,i,f){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return!1;const o=this.value(u,i,f);if(B(u.value.apply)){const m=u.value.apply({value:n,oldValue:o,data:i,row:f,column:u,grid:this.#n,context:this.#r});return this.#d(u,i,f),m!==!1}return u.field?o===n?!1:(u.write(i,n),this.#d(u,i,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,n,i,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 o=this.value(u,i,f),m=this.parse(u,n,i,f),c=this.validate(u,m,o,i,f);if(c!==!0)return{ok:!1,value:m,oldValue:o,changed:!1,error:c};const h=this.apply(u,m,i,f);return{ok:!0,value:m,oldValue:o,changed:h}}#d(t,n,i){if(this.#s.size===0)return;const f=this.#a(n,i);this.#s.delete(`${f}${V}${t.id}`);for(const u of this.#t?this.#t.dependents.get(t.id)||[]:[])this.#s.delete(`${f}${V}${u}`)}}function g(r,t){return t&&t.key!=null?String(t.key):l(r)}function l(r){if(r&&typeof r=="object"){let t=d.get(r);return t===void 0&&(t=`#${a++}`,d.set(r,t)),t}return String(r)}const d=new WeakMap;let a=0}),Le("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 V}}),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 S}}),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 d}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return o}});const x=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"]),V=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,S=3.5,g=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),l=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),d=Object.freeze({updates:"Updates",updatedAt:"Updated at",sinceUpdate:"Since update",delta:"Change",deltaPercent:"Change %",rate:"Rate of change",history:"History",firstValue:"Baseline",streak:"Streak",rank:"Rank",rankAsc:"Rank, ascending",rankChange:"Rank change",percentile:"Percentile",quartile:"Quartile",zScore:"Z-score",shareOfTotal:"Share of total",anomalyScore:"Anomaly score",anomalyFlag:"Anomaly",specStatus:"Spec status",rollingSum:"Rolling sum",rollingAvg:"Rolling average",rollingMin:"Rolling minimum",rollingMax:"Rolling maximum",windowCoverage:"Window coverage",cumulativeToDate:"Cumulative to date",periodOverPeriod:"Period over period",rollingQuantile:"Rolling quantile",windowApproximate:"Window approximate",tsTrend:"Trend",tsSeasonal:"Seasonal",tsResidual:"Seasonal residual",tsCoverage:"Decomposition coverage",tsSmoothed:"Smoothed",tsSmoothingAlpha:"Smoothing α",tsSmoothingBeta:"Smoothing β",fitPredicted:"Predicted",fitResidual:"Residual",fitInfluence:"Influence",fitStdResidual:"Std. residual",fitLeverage:"Leverage",fitCooksD:"Cook's D"});function a(m,c){if(!c)return null;const h=Number.isFinite(Number(c.lower))?Number(c.lower):null,s=Number.isFinite(Number(c.upper))?Number(c.upper):null;if(h===null&&s===null||!Number.isFinite(m))return null;if(h!==null&&m<h||s!==null&&m>s)return g.FAIL;const p=Number.isFinite(Number(c.warnLower))?Number(c.warnLower):null,y=Number.isFinite(Number(c.warnUpper))?Number(c.warnUpper):null;return p!==null&&m<p||y!==null&&m>y?g.WARN:g.PASS}function r(m,c,h){if(!c||typeof c!="object")return null;if(c.kind!=="time")return c.kind!==void 0&&x(`shadow.history.window.kind:${m}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${c.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 s=c.minutes!=null?Number(c.minutes)*6e4:Number(c.span);if(!(s>0))return x(`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:s,bucketMs:Math.max(1,Math.floor(s/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(c){this.#e=c.colId,this.#a=Math.max(2,c.depth||I),this.#u=Math.max(1,c.max||B),this.#c=c.now||(()=>Date.now()),this.#d=r(this.#e,c.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(c,h){const s=u(h);if(s===null)return;if(!this.#n.has(c)){this.#p=null,this.#m=null,this.#g(),this.#t.set(c,s),this.#n.set(c,s),this.#r.set(c,0),this.#o.set(c,this.#c()),this.#i.set(c,[s]),this.#d&&this.#f.set(c,[s]),this.#s.set(c,0);return}const p=this.#n.get(c);if(p===s)return;this.#p=null,this.#m=null,this.#n.set(c,s),this.#r.set(c,(this.#r.get(c)||0)+1),this.#o.set(c,this.#c());const y=this.#i.get(c)||[];y.push(s),y.length>this.#a&&y.splice(0,y.length-this.#a),this.#i.set(c,y);const O=Math.sign(s-p),A=this.#s.get(c)||0;this.#s.set(c,Math.sign(A)===O?A+O:O)}#g(){if(this.#n.size<this.#u)return;const c=this.#n.keys().next().value;c!==void 0&&(this.#t.delete(c),this.#n.delete(c),this.#r.delete(c),this.#o.delete(c),this.#i.delete(c),this.#f.delete(c),this.#s.delete(c),this.#l++)}rebase(){for(const[c,h]of this.#n)this.#t.set(c,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(c){const h=c instanceof Set?c:new Set(c);let s=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),s++);return s&&(this.#p=null,this.#m=null),s}advanceHistoryWindow(c=this.#c()){const h=this.#d;if(!h)return 0;const s=Math.floor(c/h.bucketMs),p=s-this.#h;if(!(p>0))return 0;const y=Math.min(p,this.#a);for(const[O,A]of this.#f){const b=this.#n.get(O);for(let v=0;v<y;v++)A.push(b);A.length>this.#a&&A.splice(0,A.length-this.#a)}return this.#h=s,p}read(c,h,s,p){switch(c){case"updates":return this.#r.has(h)?this.#r.get(h):0;case"updatedAt":{const y=this.#o.get(h);return y===void 0?null:new Date(y)}case"sinceUpdate":{const y=this.#o.get(h);return y===void 0?null:this.#c()-y}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 y=this.#t.get(h);return y?(this.#n.get(h)-y)/Math.abs(y)*100:null}case"rate":{const y=this.#i.get(h),O=this.#o.get(h);if(!y||y.length<2||O===void 0)return null;const A=this.#c()-O,b=y[y.length-1]-y[y.length-2];return A>0?b/A*1e3:b}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)?a(this.#n.get(h),p):null;default:return l.includes(c)?this.#j(c,h,s,p):null}}#y(c){if(c){if(this.#m&&this.#m.only===c)return this.#m.view;const h=this.#b(c);return this.#m={only:c,view:h},h}return this.#p?this.#p:(this.#p=this.#b(null),this.#p)}#b(c){const h=[];for(const[F,C]of this.#n)c&&!c.has(F)||h.push(C);const s=h.sort((F,C)=>F-C);let p=0,y=0,O=0,A=0;for(const F of s){A+=F,p++;const C=F-y;y+=C/p,O+=C*(F-y)}const b=[];for(const[F,C]of this.#t)c&&!c.has(F)||b.push(C);const v=p?n(s):0,R=s.map(F=>Math.abs(F-v)).sort((F,C)=>F-C),j=p?n(R):0;return{sorted:s,baseline:b.sort((F,C)=>F-C),sum:A,mean:p?y:0,sd:p>1?Math.sqrt(O/(p-1)):0,median:v,mad:j}}#j(c,h,s,p){if(!this.#n.has(h)||s&&!s.has(h))return null;const y=this.#n.get(h),O=this.#y(s),A=O.sorted.length;if(!A)return null;switch(c){case"rank":return A-f(O.sorted,y)+1;case"rankAsc":return i(O.sorted,y)+1;case"rankChange":{if(!this.#t.has(h)||!O.baseline.length)return null;const b=O.baseline.length-f(O.baseline,this.#t.get(h))+1,v=A-f(O.sorted,y)+1;return b-v}case"percentile":return f(O.sorted,y)/A*100;case"quartile":{const b=f(O.sorted,y)/A;return Math.min(4,Math.max(1,Math.ceil(b*4)))}case"zScore":return O.sd?(y-O.mean)/O.sd:null;case"anomalyScore":return O.mad?w*(y-O.median)/O.mad:null;case"anomalyFlag":{if(!O.mad)return null;const b=p&&Number.isFinite(Number(p.threshold))?Number(p.threshold):S;return Math.abs(w*(y-O.median)/O.mad)>b}case"shareOfTotal":return O.sum?y/O.sum*100:null;default:return null}}}function n(m){const c=m.length;if(!c)return 0;const h=(c-1)*.5,s=Math.floor(h),p=Math.ceil(h);return s===p?m[s]:m[s]+(h-s)*(m[p]-m[s])}function i(m,c){let h=0,s=m.length;for(;h<s;){const p=h+s>>1;m[p]<c?h=p+1:s=p}return h}function f(m,c){let h=0,s=m.length;for(;h<s;){const p=h+s>>1;m[p]<=c?h=p+1:s=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 c=typeof m=="number"?m:Number(m);return Number.isFinite(c)?c:null}function o(m){const c=[];for(const h of m||[]){const s=h.shadow;if(!s)continue;const p=typeof s=="string"?{kind:s}:s,y=p.kind;H.includes(y)&&(V.includes(y)||z.includes(y)||c.push({colId:h.id||h.field,of:p.of||h.field||h.id,kind:y,depth:p.depth,historyWindow:y==="history"?p.window:void 0}))}return c}}),Le("packages/core/src/columns/model.js",function(e,K){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return L}}),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"),x=Q.expand,B=Q.fail,I=Q.getPath,_=Q.humanise,X=Q.isFunction,W=Q.isObject,H=Q.merge,V=Q.pathGetter,z=Q.pathSetter,w=Q.toArray,S=Q.uid,g=Q.warnOnce,d=K("packages/core/src/format/index.js").compileFormat,a=K("packages/core/src/columns/datatypes.js"),r=a.comparatorFor,t=a.createTypeRegistry,n=a.storageKind,i=K("packages/core/src/columns/infer.js"),f=i.inferColumnType,u=i.DEFAULT_SAMPLE,o=K("packages/core/src/columns/graph.js"),m=o.buildGraph,c=o.affectedBy,s=K("packages/core/src/columns/lookup.js").createLookup,p=K("packages/core/src/columns/value.js"),y=p.compileDisplay,O=p.ValuePipeline,A=p.warnImpureUse,v=K("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,R=Object.freeze({geometry:"geometry",list:"list"}),j={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},F={centre:"center"},C=new Set(["start","center","end","left","right"]);function T(se){if(typeof se!="string")return;const ee=se.toLowerCase();return F[ee]?F[ee]:C.has(ee)?ee:void 0}function L(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=(de,he)=>{if(se[de]===void 0)return;const ge=x(se[de],he);ge&&E.includes(de)&&!W(se[de])&&delete ge.enabled,ee[de]=ge};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 $(se,ee){const ie={...se||{}},de=W(ee)&&W(ee.layout)&&ee.layout.width!==void 0;return ie.fit==="content"&&!de&&delete ie.width,ie}const P=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"]),k=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function N(se,ee,ie,de){const he=ie==="columnGroup"?"column group":"column";for(const ge of Object.keys(se))if(!ee.has(ge)){if(ge==="timeZone"&&ie==="column"){g("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${de}". 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:${ge}`,`'${ge}' is not a configuration key this grid recognises, so it had no effect on ${he} "${de}". 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,de={...se.defaults||{},...W(ie)?ie:{}},he={};return de.align&&(he.align=de.align,he.cell={align:de.align},he.header={align:de.align}),de.filter&&(he.filter=de.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:de.filter}),de.editor&&(he.edit=de.editor==="none"?{editor:null}:{editor:de.editor}),de.total&&(he.total=de.total),de.render&&(he.cell={...he.cell||{},render:de.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 de=ie.trim();de&&!ee.includes(de)&&ee.push(de)}return ee}class J{#e=new Map;#t=[];#n=[];#r=new WeakMap;#o;#i;#s;#l;#a;#u;#c(ee,ie,de){const he=this.#d(ee,ie,de);if(typeof he!="string"||!this.#f)return he??null;const ge=ie&&ie.totals&&ie.totals.implement;if(ge&&X(ge[he])){const ye=ge[he];return ye.totalName=he,ye}const Ee=this.#f.totalFn?.(he);return X(Ee)?Ee:he}#d(ee,ie,de){if(typeof ee!="string")return ee;const he=ie&&ie.totals&&ie.totals.supported;if(!Array.isArray(he)||he.includes(ee))return ee;const ge=he.length?he.join(", "):"none";return B(`column "${de}" is typed ${ie.name||"a type"}, for which the total "${ee}" is not meaningful. Supported: ${ge}. Aggregating it anyway would produce a confident wrong number.`),ee}#f;#h;#p;#m;#g;#y;#b=!1;#j;#w;constructor(ee={}){this.#i=D(ee.columnDefaults||{}),this.#s=ee.columnPresets||{},this.#a=ee.locale,this.#l=ee.timeZone,this.#u=L(ee.verticalAlign),this.#f=ee.registry||null,this.#h=ee.grid||null,this.#p=ee.context,this.#j=ee.sampleSize??u,this.#w=ee.onChange||null,this.#y=X(ee.rowKey)?ee.rowKey:void 0,this.#o=t(ee.dataTypes,this.#f);const{leaves:ie,groups:de}=le(ee.columns||[]);this.#n=de;for(const he of ie){he.facet!==void 0&&this.#r.set(he.def,he.facet);const ge=this.#S(he.def,null);if(ge.groupPath=he.path,this.#e.has(ge.id)){g(`columns.duplicate:${ge.id}`,`two columns resolve to the id '${ge.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=ge,this.#e.set(ge.id,ge),this.#t.push(ge.id)}this.#P(ee.stored||null)}#S(ee,ie){N(ee,P,"column",ee.id||ee.field||"(unnamed)"),G(ee);const de=D(ee),he=w(ee.preset),ge=he.map(je=>{const He=this.#s[je];return He?D(He):(g(`preset:${je}`,`unknown column preset "${je}"; ignoring`),{})}),Ee=this.#O(de,ge,ie),ye=this.#o.get(Ee)||this.#o.get("text");if(!this.#o.has(Ee)&&ee.type){const je=R[Ee];g(`type:${Ee}`,`unknown data type "${Ee}"; falling back to "text"`+(je?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${je}'.`:""))}const Ae=X(ye.items)?this.#C(de,ge,ee.id||ee.field||"(unnamed)"):null;let pe=j;pe=H(pe,this.#i),ee.type!==!1&&(pe=H(pe,q(ye,Ae)));for(const je of ge)pe=H(pe,je);this.#r.has(ee)&&(pe=H(pe,D({facet:this.#r.get(ee)}))),pe=H(pe,de);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 be=ee.id||ee.field||S("col");if(ee.shadow&&!X(pe.value&&pe.value.compute)){const je=typeof ee.shadow=="string"?{kind:ee.shadow}:ee.shadow,He=je.of||ee.field||be,Ze=v.includes(je.kind),rt=Ze?je.model||je:null,st=Ze&&rt?[...Array.isArray(rt.predictors)?rt.predictors:[],rt.response].filter(Boolean):null;pe.value={...pe.value||{},deps:st&&st.length?st:je.orderBy&&je.orderBy!==He?[He,je.orderBy]:[He],pure:!1,compute:(ht,yt)=>{const St=yt.grid&&yt.grid.statistics;if(!St)return null;const Ct=yt.row&&yt.row.key||St.keyOf(yt.data);if(!Ct)return null;if(Ze){if(!X(St.fitShadow))return null;const Tt=je.model?{...je.model,threshold:je.threshold}:je;return St.fitShadow(je.kind,Ct,Tt)}return St.shadow(He,je.kind,Ct,je.scope,je)}}}if(ee.running&&!X(pe.value&&pe.value.compute)){const je=typeof ee.running=="string"?{kind:ee.running}:ee.running,He=je.of||ee.field||be;pe.value={...pe.value||{},deps:[He],pure:!1,compute:(Ze,rt)=>{const st=rt.grid&&rt.grid.statistics;if(!st||!X(st.running))return null;const ht=rt.row&&rt.row.key||st.keyOf(rt.data);return ht?st.running(He,je.kind||"total",ht):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),Ie=X(pe.value&&pe.value.compute),Ve={id:be,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||be),type:ye.name,dataType:ye,itemType:Ae,nullable:pe.nullable!==!1,align:T(de.cell&&de.cell.align||de.align||pe.cell&&pe.cell.align||pe.align||ye.defaults&&ye.defaults.align)||"start",verticalAlign:L(de.cell&&de.cell.verticalAlign||de.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,ye,ee.id||ee.field||"(unnamed)"),groupTotal:pe.groupTotal===void 0?null:this.#c(pe.groupTotal,ye,ee.id||ee.field||"(unnamed)"),grandTotal:pe.grandTotal===void 0?null:this.#c(pe.grandTotal,ye,ee.id||ee.field||"(unnamed)"),tags:Y(pe.tags),typeOptions:pe.typeOptions??null,...W(pe[Ee])?{[Ee]:pe[Ee]}:{},layout:$(pe.layout,de),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:Ie,diff:ee.diff===void 0?void 0:!!ee.diff,read:Ne?V(Ne):null,write:Ne?z(Ne):null};Ve.cell.align=T(de.cell&&de.cell.align)||Ve.align,Ve.header.align=T(de.header&&de.header.align)||Ve.align;const Ye=pe.lookup||null;return Ve.lookup=Ye?s({id:be,lookup:Ye},{locale:this.#a,onChange:()=>{this.#w&&this.#w("lookup",{colId:be})}}):null,Ve.group.explode&&Ve.lookup&&Ve.lookup.multiple&&g(`explode:${be}`,`column "${be}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#v(Ve),Ve}#v(ee){ee.formatter=d(ee.format,ee.dataType,this.#a,this.#l,ee.id),ee.formatValue=y(ee,{locale:this.#a,grid:this.#h,context:this.#p}),ee.itemCompare=ee.itemType?r(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):r(ee.dataType,this.#a),ee.excel=ee.formatter&&ee.formatter.ooxml||ee.dataType&&ee.dataType.excel||"General",ee.storeKind=n(ee.dataType,!!(ee.lookup&&ee.lookup.multiple))}#C(ee,ie,de){let he=W(ee.typeOptions)?ee.typeOptions:null;for(let Ae=ie.length-1;!he&&Ae>=0;Ae--)W(ie[Ae].typeOptions)&&(he=ie[Ae].typeOptions);!he&&W(this.#i.typeOptions)&&(he=this.#i.typeOptions);const ge=he&&he.of!==void 0?he.of:"text",Ee=typeof ge=="string"?this.#o.get(ge):void 0;return Ee&&!X(Ee.items)&&Ee.storage!=="object"?Ee:(g(`type:of:${String(ge)}`,`column "${de}" names "${String(ge)}" 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"))}#O(ee,ie,de){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 de||(ee.lookup?"lookup":"text")}#P(ee){const ie=this.all();this.#m=m(ie),this.#g?this.#g.setGraph(this.#m):this.#g=new O({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:ee||null,rowKey:this.#y});const de=this.#g;for(const he of ie)he.getValue=(ge,Ee)=>de.value(he,ge,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 de=[];for(const he of ie)Array.isArray(he.columns)?de.push({...he,columns:ee(he.columns)}):he.column&&de.push(he.column);return de};return ee(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#o}affectedBy(ee){return c(this.#m,ee)}value(ee,ie,de){return this.#g.value(ee,ie,de)}text(ee,ie,de){return this.#g.text(ee,ie,de)}checkImpure(ee,ie){A(this.#e.get(ee),ie)}setLocale(ee){this.#a=ee;for(const ie of this.all())ie.lookup&&ie.lookup.setLocale(ee),this.#v(ie);this.#w&&this.#w("locale",{locale:ee})}infer(ee){const ie={};if(this.#b||!Array.isArray(ee)||ee.length===0)return ie;this.#b=!0;let de=!1;for(const he of this.all()){const ge=he.def;if(ge.type!==void 0||!he.field||he.computed||he.lookup||this.#M(he))continue;const Ee=he.read||(pe=>I(pe,he.field)),ye=f(he.id,ee,Ee,this.#o,{sampleSize:this.#j});if(ye===he.type)continue;ie[he.id]=ye;const Ae=this.#S(ge,ye);Ae.groupPath=he.groupPath,Ae.layout={...Ae.layout,...te(he.layout)},this.#e.set(he.id,Ae),ae(this.#n,he.id,Ae),de=!0}return de&&this.#P(null),ie}redecorate(ee,ie,de={}){const he=this.#e.get(ee);if(!he){g(`redecorate:${ee}`,`columns.decorate('${ee}', …): no column with id '${ee}'.`);return}const ge=he.def||{},Ee={...W(ge.cell)?ge.cell:{}};Ee.decoration=ie??void 0,de&&"variant"in de&&(Ee.variant=de.variant);const ye={...ge,cell:Ee};this.#r.has(ge)&&this.#r.set(ye,this.#r.get(ge));const Ae=this.#S(ye,he.type);return Ae.groupPath=he.groupPath,Ae.layout={...Ae.layout,...te(he.layout)},he.lookup&&he.lookup!==Ae.lookup&&X(he.lookup.destroy)&&he.lookup.destroy(),this.#e.set(ee,Ae),ae(this.#n,ee,Ae),this.#P(null),this.#w&&this.#w("decorate",{colId:ee}),Ae}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 de=this.#s[ie];if(de&&de.type)return!0}return!!this.#i.type}#E(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.#E(ee)){const ie=ee.dataType.toStorage,de={timeZone:this.#l,colId:ee.id,itemType:ee.itemType||null};return he=>ie(ee.read(he),de)}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 de=this.storeReader(ie);let he=null;!ie.computed&&!this.#E(ie)&&typeof ie.field=="string"&&!ie.lookup&&(he=ie.field);const ge={id:ie.id,kind:ie.storeKind,nullable:ie.nullable,read:de};he!==null&&(ge.field=he),ie.lookup&&(ge.dictionary=ie.lookup.dictionary()),ee.push(ge)}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 de={applied:[],skipped:[]},he=Array.isArray(ee)?ee:ee&&ee.columns||[],ge=!Array.isArray(ee)&&ee&&ee.columnOrder||null;for(const ye of he){if(!ye||!ye.id){de.skipped.push({key:"?",reason:"no id"});continue}let Ae=this.#e.get(ye.id);if(!Ae){de.skipped.push({key:ye.id,reason:"unknown column"});continue}if(Object.hasOwn(ye,"decoration")||Object.hasOwn(ye,"variant")){const pe=Ae.cell?Ae.cell.decoration:void 0,we=ye.decoration??null,be=Object.hasOwn(ye,"variant"),Ne=be&&!oe(Ae.cell?Ae.cell.variant:void 0,ye.variant);(!oe(pe,we)||Ne)&&(this.redecorate(ye.id,we,be?{variant:ye.variant??void 0}:{}),Ae=this.#e.get(ye.id)||Ae)}ye.width!=null&&(Ae.layout.width=ye.width),ye.flex!=null&&(Ae.layout.flex=ye.flex),ye.hidden!=null&&(Ae.layout.hidden=!!ye.hidden),ye.pin!==void 0&&(Ae.layout.pin=ye.pin),ye.sort!==void 0&&(Ae.sort.direction=ye.sort),ye.sortIndex!=null&&(Ae.sort.order=ye.sortIndex),ye.groupIndex!=null&&(Ae.group.enabled=!0,Ae.group.index=ye.groupIndex),ye.pivotIndex!=null&&(Ae.pivot.enabled=!0,Ae.pivot.index=ye.pivotIndex),ye.total!==void 0&&(Ae.total=ye.total),ye.groupTotal!==void 0&&(Ae.groupTotal=ye.groupTotal),ye.grandTotal!==void 0&&(Ae.grandTotal=ye.grandTotal),de.applied.push(ye.id)}const Ee=ge||(ie&&ie.keepOrder?[]:he.map(ye=>ye&&ye.id).filter(Boolean));if(Ee.length){const ye=Ee.filter(pe=>this.#e.has(pe)),Ae=this.#t.filter(pe=>!ye.includes(pe));this.#t=[...ye,...Ae]}return this.#w&&this.#w("state",de),de}move(ee,ie){this.#T(ee,ie)&&(this.#L(),this.#w&&this.#w("move",{id:ee,to:ie}))}reorder(ee){const ie={applied:[],skipped:[]},de=[];let he=0;for(const ge of Array.isArray(ee)?ee:[]){const Ee=he++;this.#T(ge,Ee)&&(ie.applied.push(ge),de.push({id:ge,to:Ee}))}if(!de.length)return ie;if(this.#L(),this.#w)for(const ge of de)this.#w("move",ge);return ie}#T(ee,ie){const de=this.#t.indexOf(ee);if(de===-1||Math.max(0,Math.min(Number(ie)||0,this.#t.length-1))===de)return!1;const ge=this.#e.get(ee);if(ge.layout.movable===!1||ge.layout.lockPosition)return g(`move:${ee}`,`column "${ee}" is not movable; the move was ignored`),!1;const Ee=this.#N(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(de,1),this.#t.splice(Math.max(0,Math.min(ie,this.#t.length)),0,ee),!0)}#N(ee,ie){if(!this.#n||!this.#n.length)return null;const de=this.#t.filter(ye=>ye!==ee),he=Math.max(0,Math.min(ie,de.length)),ge=(ye,Ae)=>{if(Array.isArray(ye.columns)){for(const we of ye.columns)ge(we,Ae);return Ae}const pe=ye.column?ye.column.id:ye.id;return pe&&Ae.push(pe),Ae},Ee=ye=>{for(const Ae of ye){if(!Array.isArray(Ae.columns))continue;if(Ae.marryChildren===!0){const we=ge(Ae,[]),be=we.includes(ee),Ne=we.map(Ie=>de.indexOf(Ie)).filter(Ie=>Ie>=0);if(Ne.length){const Ie=Math.min(...Ne),Ve=Math.max(...Ne);if(be?he<Ie||he>Ve+1:he>Ie&&he<=Ve)return Ae.id}}const pe=Ee(Ae.columns);if(pe)return pe}return null};return Ee(this.#n)}#L(){const ee=new Map(this.#t.map((he,ge)=>[he,ge])),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 ge=1/0;for(const Ee of he.columns)ge=Math.min(ge,ie(Ee));return ge},de=he=>{he.sort((ge,Ee)=>ie(ge)-ie(Ee));for(const ge of he)Array.isArray(ge.columns)&&de(ge.columns)};de(this.#n)}#B(ee){const ie=de=>{for(let he=0;he<de.length;he++){const ge=de[he];if(Array.isArray(ge.columns)){const Ee=ie(ge.columns);if(Ee)return Ee}else if(ge.column&&ge.column.id===ee)return de.splice(he,1)[0]}return null};return ie(this.#n)}#_(ee){const ie=[];for(let de=ee.length-1;de>=0;de--){const he=ee[de];Array.isArray(he.columns)&&(ie.push(...this.#_(he.columns)),he.columns.length===0&&(ie.push(he.id),ee.splice(de,1)))}return ie}#z(){const ee=(ie,de,he)=>{for(const ge of ie)Array.isArray(ge.columns)?ee(ge.columns,[...de,ge.id]):ge.column&&(ge.column.groupPath=de)};ee(this.#n,[])}#$(ee){const ie=new Set(ee),de=this.#t.filter(ye=>ie.has(ye));if(!de.length)return;const he=Math.min(...de.map(ye=>this.#t.indexOf(ye))),ge=this.#t.slice(0,he).filter(ye=>!ie.has(ye)),Ee=this.#t.slice(he).filter(ye=>!ie.has(ye));this.#t=[...ge,...de,...Ee]}#q(ee){const ie=[],de=he=>{if(Array.isArray(he.columns))for(const ge of he.columns)de(ge);else he.column&&ie.push(he.column.id)};return de(ee),ie}#I(ee){const ie=de=>{for(const he of de){if(!Array.isArray(he.columns))continue;if(he.id===ee)return{node:he,parent:de};const ge=ie(he.columns);if(ge)return ge}return null};return ie(this.#n)}groupColumns(ee,ie={}){const de=w(ee).filter(Ae=>this.#e.has(Ae));if(!de.length)return g("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Ae of de)if(this.#e.get(Ae).layout.lockPosition)return g(`columns.group.locked:${Ae}`,`column "${Ae}" is position-locked and cannot be grouped.`),null;const he=ie.groupId?this.#I(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 ge=null;if(!he&&ie.id!=null&&(ge=String(ie.id),this.#I(ge)||this.#e.has(ge)))return g(`columns.group.idtaken:${ge}`,`band id "${ge}" is already in use; nothing was grouped.`),null;const Ee=de.map(Ae=>this.#B(Ae)).filter(Boolean);if(!Ee.length)return null;let ye;if(he)he.node.columns.push(...Ee),ye=he.node.id;else{const Ae={id:ge||S("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,Ae),ye=Ae.id}return this.#_(this.#n),this.#$(de),this.#z(),this.#L(),this.#w&&this.#w("columngroup",{action:"formed",groupId:ye,ids:de}),ye}ungroupColumn(ee){const ie=this.#e.get(ee);if(!ie){g(`columns.ungroup.unknown:${ee}`,`no column "${ee}" to ungroup.`);return}const de=ie.groupPath||[];if(!de.length)return;const he=de[de.length-1],ge=this.#I(he);if(!ge)return;const Ee=this.#B(ee);if(!Ee)return;const ye=ge.parent.indexOf(ge.node);ge.parent.splice(ye+1,0,Ee);const Ae=this.#_(this.#n),pe=this.#q(ge.node);if(pe.length){this.#$(pe);const we=Math.max(...pe.map(Ne=>this.#t.indexOf(Ne))),be=this.#t.filter(Ne=>Ne!==ee);be.splice(we+1,0,ee),this.#t=be}this.#z(),this.#L(),this.#w&&this.#w("columngroup",{action:"removed",id:ee,dissolved:Ae})}renameGroup(ee,ie){const de=this.#I(ee);if(!de){g(`columns.group.rename:${ee}`,`no band "${ee}" to rename.`);return}de.node.title=String(ie??""),this.#w&&this.#w("columngroup",{action:"renamed",groupId:ee,title:de.node.title})}dissolveGroup(ee){const ie=this.#I(ee);if(!ie){g(`columns.group.dissolve:${ee}`,`no band "${ee}" to dissolve.`);return}const de=ie.parent.indexOf(ie.node);ie.parent.splice(de,1,...ie.node.columns),this.#z(),this.#L(),this.#w&&this.#w("columngroup",{action:"dissolved",groupId:ee})}moveGroup(ee,ie){const de=this.#I(ee);if(!de){g(`columns.group.move:${ee}`,`no band "${ee}" to move.`);return}const he=de.parent,ge=he.indexOf(de.node);ge!==-1&&(he.splice(ge,1),he.splice(Math.max(0,Math.min(ie,he.length)),0,de.node),this.#W(),this.#z(),this.#w&&this.#w("columngroup",{action:"moved",groupId:ee,to:ie}))}#W(){const ee=[],ie=he=>{for(const ge of he)Array.isArray(ge.columns)?ie(ge.columns):ge.column&&ee.push(ge.column.id)};ie(this.#n);const de=new Set(ee);this.#t=[...ee,...this.#t.filter(he=>!de.has(he))]}groupTree(){const ee=de=>de.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(de=>de&&typeof de=="object")?ie:[]}applyGroupTree(ee){if(!Array.isArray(ee))return;const ie=new Set,de=ge=>{const Ee=[];for(const ye of ge)if(ye&&typeof ye=="object"&&Array.isArray(ye.columns)){const Ae=de(ye.columns);if(!Ae.length)continue;Ee.push({id:ye.id||S("grp"),title:ye.title||"",collapsible:ye.collapsible===!0,openByDefault:ye.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Ae})}else if(typeof ye=="string"){const Ae=this.#e.get(ye);Ae&&!ie.has(ye)&&(ie.add(ye),Ee.push({column:Ae,path:[]}))}return Ee},he=de(ee);for(const ge of this.#t){if(ie.has(ge))continue;const Ee=this.#e.get(ge);Ee&&he.push({column:Ee,path:[]})}this.#n=he,this.#z(),this.#L(),this.#w&&this.#w("columngroup",{action:"applied"})}show(ee){this.#H(ee,!1)}hide(ee){this.#H(ee,!0)}#H(ee,ie){const de=[];for(const he of w(ee)){const ge=this.#e.get(he);if(ge){if(ie&&ge.layout.lockVisible){g(`lockVisible:${he}`,`column "${he}" is \`layout.lockVisible\` and cannot be hidden`);continue}ge.layout.hidden!==ie&&(ge.layout.hidden=ie,de.push(he))}}de.length&&this.#w&&this.#w("visible",{ids:de,hidden:ie})}pin(ee,ie){const de=this.#e.get(ee);de&&(de.layout.pin=ie??null,this.#w&&this.#w("pin",{id:ee,side:de.layout.pin}))}pinMany(ee){const ie={};for(const[he,ge]of ee){const Ee=this.#e.get(he);Ee&&(Ee.layout.pin=ge??null,ie[he]=Ee.layout.pin)}const de=Object.keys(ie);de.length&&this.#w&&this.#w("pin",{ids:de,pins:ie})}#U(ee,ie){const de=ee.layout.min??0,he=ee.layout.max;let ge=Math.max(de,ie);return he!=null&&(ge=Math.min(he,ge)),ee.layout.width=ge,ee.layout.flex=0,ge}resize(ee,ie){const de=this.#e.get(ee);if(!de)return;if(de.layout.resizable===!1){g(`resize:${ee}`,`column "${ee}" is not resizable; the resize was ignored`);return}const he=this.#U(de,ie);this.#w&&this.#w("resize",{id:ee,width:he})}resizeMany(ee){const ie={};for(const[he,ge]of ee){const Ee=this.#e.get(he);if(Ee){if(Ee.layout.resizable===!1){g(`resize:${he}`,`column "${he}" is not resizable; the resize was ignored`);continue}ie[he]=this.#U(Ee,ge)}}const de=Object.keys(ie);de.length&&this.#w&&this.#w("resize",{ids:de,widths:ie})}}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,de=ee??null;if(ie===de)return!0;if(ie===null||de===null)return!1;if(typeof ie!="object"||typeof de!="object")return ie===de;try{return JSON.stringify(ie)===JSON.stringify(de)}catch{return!1}}function le(se){const ee=[],ie=(he,ge,Ee)=>{const ye=[];for(const Ae of he){if(!W(Ae)){B("a column definition must be an object");continue}if(Array.isArray(Ae.columns)){N(Ae,k,"columnGroup",Ae.title||Ae.id||"(unnamed)");const pe={id:Ae.id||S("grp"),title:Ae.title||"",collapsible:Ae.collapsible===!0,openByDefault:Ae.openByDefault!==!1,showWhen:Ae.showWhen||"always",marryChildren:Ae.marryChildren===!0,header:Ae.header||{},def:Ae,columns:[]};pe.columns=ie(Ae.columns,[...ge,pe.id],Ae.facet!==void 0?Ae.facet:Ee),ye.push(pe)}else{const pe={def:Ae,path:ge,facet:Ee};ee.push(pe),ye.push(pe)}}return ye},de=ie(se,[],void 0);return{leaves:ee,groups:de}}function ae(se,ee,ie){for(const de of se){if(de.columns){if(ae(de.columns,ee,ie))return!0;continue}if(de.column&&de.column.id===ee)return de.column=ie,!0}return!1}}),Le("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 x=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_group",I=240,_=.5;function X(H){const{columns:V,groupBy:z}=H,w=z.map(l=>V.get(l)).filter(Boolean),S=w.length?w.map(l=>l.title||l.id).join(" > "):"Group",g=H.config&&H.config.autoGroupColumnWidth||I;return{id:B,field:null,title:S,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,d){return d&&d.group?d.groupValue:null},formatValue(l,d){if(!d||!d.group)return"";if(d.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";const a=w[Math.min(d.level||0,w.length-1)];return a&&typeof a.formatValue=="function"?a.formatValue(l,d):l==null?"":String(l)}}}function W(H,V,z){!H.length||z<100||V<z*_||x(`grouping.cardinality:${H.join(",")}`,`grouping by ${H.join(", ")} produced ${V} 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.`)}}),Le("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",x=44;function B(_){const X=_.selection||{},W=_.config&&_.config.selectionColumnWidth||x;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,V){return V?V.selected:!1},formatValue(){return""}}}const I=B}),Le("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 V}});const x=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,S=w&&typeof w=="object"?w:{},g=Number.isFinite(S.start)?S.start:1,l=Number.isFinite(S.width)?S.width:W((z.maxNumber||0)+g),d=x(z.rank)?z.rank:()=>null;return{id:B,field:null,title:typeof S.title=="string"?S.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:S.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(a,r){const t=d(r);return t==null?null:t-1+g},formatValue(a){return a==null?"":String(a)}}}const V=H}),Le("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"),x=Q.isFunction,B=Q.warnOnce,I=240,_=10;function X(V){if(!V)return null;const z=V===!0?{}:V;return z.enabled===!1?null:!x(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:x(z.rows)?z.rows:null,height:z.height??I,cacheLimit:Number.isFinite(z.cacheLimit)?Math.max(0,z.cacheLimit):_,isMaster:x(z.isMaster)?z.isMaster:null,target:z.target||null,onCreate:x(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=x(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 x(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||!x(z))return;let w=!1;for(const S of[...this.#t])z(S)||(this.#t.delete(S),w=!0);w&&this.#o()}signature(){return`${this.#r}`}set(z){this.#t.clear();const w=Array.isArray(z)?z:[];for(const S of this.inline?w:w.slice(0,1))this.#t.add(S);this.#o()}#o(){this.#r++,this.#n()}}const H=W}),Le("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 V}}),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 d}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return a}});const Q=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),x=3e-12,B=1e-300;function I(r){if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-I(1-r);const t=r-1;let n=.9999999999998099;const i=t+7.5;for(let f=0;f<Q.length;f++)n+=Q[f]/(t+f+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(i)-i+Math.log(n)}function _(r,t,n){const i=r+t,f=r+1,u=r-1;let o=1,m=1-i*n/f;Math.abs(m)<B&&(m=B),m=1/m;let c=m;for(let h=1;h<=300;h++){const s=2*h;let p=h*(t-h)*n/((u+s)*(r+s));m=1+p*m,Math.abs(m)<B&&(m=B),o=1+p/o,Math.abs(o)<B&&(o=B),m=1/m,c*=m*o,p=-(r+h)*(i+h)*n/((r+s)*(f+s)),m=1+p*m,Math.abs(m)<B&&(m=B),o=1+p/o,Math.abs(o)<B&&(o=B),m=1/m;const y=m*o;if(c*=y,Math.abs(y-1)<x)break}return c}function X(r,t,n){if(!(r>0)||!(t>0)||!Number.isFinite(n))return Number.NaN;if(n<=0)return 0;if(n>=1)return 1;const i=Math.exp(I(r+t)-I(r)-I(t)+r*Math.log(n)+t*Math.log(1-n));return n<(r+1)/(r+t+2)?i*_(r,t,n)/r:1-i*_(t,r,1-n)/t}function W(r){if(!(r>0)||!(r<1))return r===0?-1/0:r===1?1/0:Number.NaN;const t=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],n=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],i=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],f=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],u=.02425;let o,m,c;r<u?(o=Math.sqrt(-2*Math.log(r)),c=(((((i[0]*o+i[1])*o+i[2])*o+i[3])*o+i[4])*o+i[5])/((((f[0]*o+f[1])*o+f[2])*o+f[3])*o+1)):r<=1-u?(o=r-.5,m=o*o,c=(((((t[0]*m+t[1])*m+t[2])*m+t[3])*m+t[4])*m+t[5])*o/(((((n[0]*m+n[1])*m+n[2])*m+n[3])*m+n[4])*m+1)):(o=Math.sqrt(-2*Math.log(1-r)),c=-(((((i[0]*o+i[1])*o+i[2])*o+i[3])*o+i[4])*o+i[5])/((((f[0]*o+f[1])*o+f[2])*o+f[3])*o+1));const s=(.5*H(-c/Math.SQRT2)-r)*Math.sqrt(2*Math.PI)*Math.exp(c*c/2);return c-s/(1+c*s/2)}function H(r){const t=Math.abs(r),n=2/(2+t),i=4*n-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,o=0,m;for(let h=f.length-1;h>0;h--)m=o,o=i*o-u+f[h],u=m;const c=n*Math.exp(-t*t+.5*(f[0]+i*o)-u);return r>=0?c:2-c}function V(r){return .5*H(-r/Math.SQRT2)}function z(r,t){if(!(t>0)||!Number.isFinite(r))return Number.NaN;const n=.5*X(t/2,.5,t/(t+r*r));return r>0?1-n:n}function w(r,t){if(!(r>0)||!(r<1)||!(t>0))return Number.NaN;if(t>1e7)return W(r);let n=-1e4,i=1e4,f=W(r);const u=I(t/2)+I(.5)-I((t+1)/2);for(let o=0;o<60;o++){const m=z(f,t);m<r?n=f:i=f;const c=Math.exp(-((t+1)/2)*Math.log(1+f*f/t)-u)/Math.sqrt(t),h=c>0?(m-r)/c:0;if(Math.abs(h)<1e-12)break;const s=f-h;if(f=s>n&&s<i&&Number.isFinite(s)?s:(n+i)/2,i-n<1e-12)break}return f}function S(r,t){let n=r,i=1/r,f=i;for(let u=0;u<300&&(n+=1,f*=t/n,i+=f,!(Math.abs(f)<Math.abs(i)*x));u++);return i*Math.exp(-t+r*Math.log(t)-I(r))}function g(r,t){let n=t+1-r,i=1/B,f=1/n,u=f;for(let o=1;o<=300;o++){const m=-o*(o-r);n+=2,f=m*f+n,Math.abs(f)<B&&(f=B),i=n+m/i,Math.abs(i)<B&&(i=B),f=1/f;const c=f*i;if(u*=c,Math.abs(c-1)<x)break}return Math.exp(-t+r*Math.log(t)-I(r))*u}function l(r,t){return!(r>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<r+1?S(r,t):1-g(r,t)}function d(r,t){return t>0?l(t/2,r/2):Number.NaN}function a(r,t){const n=d(r,t);return Number.isNaN(n)?Number.NaN:Math.min(1,Math.max(0,1-n))}}),Le("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 x}}),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,V=Array.from({length:H},()=>new Array(H).fill(0));for(let z=0;z<H;z++)for(let w=0;w<=z;w++){let S=W[z][w];for(let g=0;g<w;g++)S-=V[z][g]*V[w][g];if(z===w){if(!(S>0))return null;V[z][w]=Math.sqrt(S)}else V[z][w]=S/V[w][w]}return V}function x(W,H){const V=W.length,z=new Array(V).fill(0);for(let S=0;S<V;S++){let g=H[S];for(let l=0;l<S;l++)g-=W[S][l]*z[l];z[S]=g/W[S][S]}const w=new Array(V).fill(0);for(let S=V-1;S>=0;S--){let g=z[S];for(let l=S+1;l<V;l++)g-=W[l][S]*w[l];w[S]=g/W[S][S]}return w}function B(W){const H=W.length,V=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 S=x(W,w);for(let g=0;g<H;g++)V[g][z]=S[g]}return V}function I(W,H,V){const z=W.length,w=z?W[0].length:0,S=Array.from({length:w},()=>new Array(w).fill(0)),g=new Array(w).fill(0);for(let l=0;l<z;l++){const d=V?V[l]:1,a=W[l];for(let r=0;r<w;r++){const t=d*a[r];g[r]+=t*H[l];for(let n=r;n<w;n++)S[r][n]+=t*a[n]}}for(let l=0;l<w;l++)for(let d=0;d<l;d++)S[l][d]=S[d][l];return{xtwx:S,xtwy:g}}function _(W,H){return W.map(V=>V.reduce((z,w,S)=>z+w*H[S],0))}function X(W,H){let V=0;for(let z=0;z<W.length;z++){let w=0;for(let S=0;S<W.length;S++)w+=H[z][S]*W[S];V+=W[z]*w}return V}}),Le("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 x}}),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 V}}),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 S}});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 d=l-this.#t;this.#t+=d/this.#e,this.#n+=d*(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 d=this.#e+l.#e,a=l.#t-this.#t;this.#t+=a*(l.#e/d),this.#n+=l.#n+a*a*(this.#e*l.#e/d),this.#e=d}mean(){return this.#e?this.#t:null}variance(){return this.#e>1?this.#n/(this.#e-1):null}varianceP(){return this.#e?this.#n/this.#e:null}stddev(){const l=this.variance();return l===null?null:Math.sqrt(l)}stddevP(){const l=this.varianceP();return l===null?null:Math.sqrt(l)}}class x{#e=[];#t=0;#n;#r;constructor(l,d=Math.random){if(!(l>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(l),this.#r=d}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#t}get size(){return this.#e.length}add(l){if(!Number.isFinite(l))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(l);return}const d=Math.floor(this.#r()*this.#t);d<this.#n&&(this.#e[d]=l)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let l=0;for(const d of this.#e)l+=d;return l/this.#e.length}quantile(l){const d=this.#e.length;if(!d)return null;const a=this.#e.slice().sort((i,f)=>i-f);if(d===1)return a[0];const r=(d-1)*Math.min(1,Math.max(0,l)),t=Math.floor(r),n=Math.ceil(r);return t===n?a[t]:a[t]+(r-t)*(a[n]-a[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 a=new DataView(new ArrayBuffer(8));return a.setFloat64(0,g===0?0:g),B(a.getUint32(0)^a.getUint32(4))}const l=typeof g=="string"?g:String(g);let d=2166136261;for(let a=0;a<l.length;a++)d^=l.charCodeAt(a),d=Math.imul(d,16777619);return B(d)}class _{#e;#t;#n;constructor(l=14){const d=Math.floor(l);if(d<4||d>16)throw new RangeError("HLL precision must be 4..16");this.#e=d,this.#t=1<<d,this.#n=new Uint8Array(this.#t)}static errorBoundFor(l=14){const d=1<<Math.floor(l),a=1.04/Math.sqrt(d);return Object.freeze({kind:"probabilistic",metric:"relative",value:a,statement:`distinct count within ~${(a*100).toFixed(2)}% relative standard error (m=${d} buckets)`})}errorBound(){return _.errorBoundFor(this.#e)}add(l){const d=I(l),a=d&this.#t-1,r=d>>>this.#e|1<<32-this.#e;let t=1,n=r;for(;(n&1)===0;)t++,n>>>=1;t>this.#n[a]&&(this.#n[a]=t)}count(){const l=this.#t,d=32-this.#e,a=new Float64Array(d+2);for(let n=0;n<l;n++)a[this.#n[n]]++;let r=l*H(1-a[d+1]/l);for(let n=d;n>=1;n--)r=.5*(r+a[n]);r+=l*W(a[0]/l);const t=X*l*l/r;return Math.round(t)}}const X=.5/Math.log(2);function W(g){if(g===1)return 1/0;let l=1,d=g,a;do g*=g,a=d,d+=g*l,l+=l;while(d!==a);return d}function H(g){if(g===0||g===1)return 0;let l=1,d=1-g,a;do g=Math.sqrt(g),a=d,l*=.5,d-=(1-g)**2*l;while(d!==a);return d/3}class V{#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 d=l/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:d,statement:`each count overestimates the truth by at most N/m = ${d.toFixed(2)} (N=${l}, m=${this.#t})`})}get seen(){return this.#n}add(l){this.#n++;const d=this.#e.get(l);if(d){d.count++;return}if(this.#e.size<this.#t){this.#e.set(l,{count:1,error:0});return}let a,r=1/0;for(const[t,n]of this.#e)n.count<r&&(r=n.count,a=t);this.#e.delete(a),this.#e.set(l,{count:r+1,error:r})}top(l=this.#t){return[...this.#e.entries()].map(([a,r])=>({item:a,count:r.count,error:r.error})).sort((a,r)=>r.count-a.count).slice(0,Math.max(0,Math.floor(l)))}}class z{#e;#t=[[]];#n=0;#r;#o;constructor(l=200,d=Math.random){this.#e=Math.max(8,Math.floor(l)),this.#r=d,this.#o=2/3}static errorBoundFor(l=200){const d=1/Math.max(8,Math.floor(l));return Object.freeze({kind:"probabilistic",metric:"rank",value:d,statement:`queried quantile's true rank within ~${(d*100).toFixed(2)}% of N of the requested rank (k=${l})`})}errorBound(){return z.errorBoundFor(this.#e)}get count(){return this.#n}#i(l){const a=this.#t.length-1-l,r=Math.ceil(this.#e*this.#o**a);return Math.max(2,r)}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 d=this.#t[l];d.sort((t,n)=>t-n),l+1>=this.#t.length&&this.#t.push([]);const a=this.#t[l+1],r=this.#r()<.5?0:1;for(let t=r;t<d.length;t+=2)a.push(d[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 d=0;d<this.#t.length;d++){const a=1<<d;for(const r of this.#t[d])l.push({v:r,w:a})}return l}quantile(l){const d=this.#l();if(!d.length)return null;d.sort((n,i)=>n.v-i.v);let a=0;for(const n of d)a+=n.w;const r=Math.min(1,Math.max(0,l))*a;let t=0;for(const n of d)if(t+=n.w,t>=r)return n.v;return d[d.length-1].v}rank(l){let d=0;for(let a=0;a<this.#t.length;a++){const r=1<<a;for(const t of this.#t[a])t<=l&&(d+=r)}return d}}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"})}),S={Welford:Q,Reservoir:x,HyperLogLog:_,SpaceSaving:V,KLL:z,hash32:I,SKETCH_BOUNDS:w}}),Le("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 n}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return i}}),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 o}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return L}}),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 $}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return N}}),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 de}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return Ae}}),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 be}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return st}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return St}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Dt}}),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 fe}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return We}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return qe}});const Q=K("packages/core/src/compute/handle.js"),x=Q.presenceReader,B=Q.valueReader,I=K("packages/core/src/compute/special.js"),_=I.studentTQuantile,X=I.studentT,W=I.normalQuantile,H=I.normalCdf,V=I.chiSquareUpperTail,z=K("packages/core/src/compute/linalg.js"),w=z.cholesky,S=z.choleskySolve,g=z.choleskyInverse,l=z.normalEquations,d=z.quadForm,r=K("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,t=5e3,n=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"}),i=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 f(ve){const Se=ve==="sum"||ve==="avg"||ve==="countValues"||ve==="min"||ve==="max"?"maintained":Object.prototype.hasOwnProperty.call(n,ve)?n[ve]:null,me=Object.prototype.hasOwnProperty.call(i,ve)?i[ve]:null;return{stat:ve,exact:Se,approximate:me}}function u(ve,Se){const me=Se.length,Ce=new Float64Array(me);let Me=0;if(ve&&(ve.kind==="float64"||ve.kind==="int32")){const De=ve.values,Oe=x(ve);for(let xe=0;xe<me;xe++){const Ue=Se[xe];if(Oe&&Oe(Ue)!==1)continue;const Je=De[Ue];Number.isNaN(Je)||(Ce[Me++]=Je)}return Ce.subarray(0,Me)}const _e=B(ve);for(let De=0;De<me;De++){const Oe=_e(Se[De]);if(Oe==null||Oe==="")continue;const xe=typeof Oe=="number"?Oe:Number(Oe);Number.isFinite(xe)&&(Ce[Me++]=xe)}return Ce.subarray(0,Me)}function o(ve,Se){const me=new Map,Ce=B(ve);let Me=0;for(let _e=0;_e<Se.length;_e++){const De=Ce(Se[_e]);if(De==null||De===""||typeof De=="number"&&Number.isNaN(De))continue;const Oe=typeof De=="object"?String(De):De;me.set(Oe,(me.get(Oe)||0)+1),Me++}const ze=[...me.values()].sort((_e,De)=>De-_e);return{counts:ze,total:Me,distinct:ze.length}}function m(ve){return ve.total>0?ve.counts.map(Se=>Se/ve.total):[]}function c(ve,Se){const me=o(ve,Se);if(!me.total)return null;let Ce=0;for(const Me of m(me))Ce+=Me*Me;return Ce}function h(ve,Se){const me=o(ve,Se);if(!me.total)return null;let Ce=0;for(const Me of m(me))Me>0&&(Ce-=Me*Math.log2(Me));return Ce}function s(ve,Se){const me=o(ve,Se);if(!me.total||me.distinct<2)return me.total?1:null;let Ce=0;for(const Me of m(me))Me>0&&(Ce-=Me*Math.log2(Me));return Ce/Math.log2(me.distinct)}function p(ve,Se,me=3){const Ce=o(ve,Se);if(!Ce.total)return null;const Me=Math.max(1,Math.floor(me));let ze=0;for(let _e=0;_e<Math.min(Me,Ce.counts.length);_e++)ze+=Ce.counts[_e];return ze/Ce.total}function y(ve,Se){const me=u(ve,Se),Ce=me.length;if(!Ce)return null;const Me=me.slice().sort();if(Me[0]<0)return null;let ze=0,_e=0;for(let De=0;De<Ce;De++)ze+=Me[De],_e+=(De+1)*Me[De];return ze===0?0:2*_e/(Ce*ze)-(Ce+1)/Ce}function O(ve){let Se=0,me=0,Ce=0;for(let Me=0;Me<ve.length;Me++){const ze=ve[Me];Se++;const _e=ze-me;me+=_e/Se,Ce+=_e*(ze-me)}return{n:Se,mean:me,m2:Ce}}function A(ve,Se){const me=ve.length;if(!me)return NaN;if(me===1)return ve[0];const Ce=(me-1)*Math.min(1,Math.max(0,Se)),Me=Math.floor(Ce),ze=Math.ceil(Ce);return Me===ze?ve[Me]:ve[Me]+(Ce-Me)*(ve[ze]-ve[Me])}function b(ve,Se){if(!ve.length)return NaN;const me=ve.slice().sort();return A(me,Se)}function v(ve,Se){const me=B(ve);let Ce=0,Me=0,ze=0;for(let _e=0;_e<Se.length;_e++){const De=me(Se[_e]);if(De==null||De==="")continue;const Oe=String(De).toUpperCase();Oe==="PASS"?Ce++:Oe==="FAIL"?Me++:Oe==="WARN"&&ze++}return{pass:Ce+ze,fail:Me,warn:ze,judged:Ce+ze+Me}}const R=Object.freeze({hhi:(ve,Se)=>c(ve,Se),entropy:(ve,Se)=>h(ve,Se),evenness:(ve,Se)=>s(ve,Se),top3Share:(ve,Se)=>p(ve,Se,3),top10Share:(ve,Se)=>p(ve,Se,10),gini:(ve,Se)=>y(ve,Se),trimmedMean:(ve,Se)=>L(u(ve,Se),.1),winsorizedMean:(ve,Se)=>E(u(ve,Se),.1),robustOutliers:(ve,Se)=>D(u(ve,Se),3.5),jarqueBera:(ve,Se)=>$(u(ve,Se)),variance:(ve,Se)=>{const{n:me,m2:Ce}=O(u(ve,Se));return me>1?Ce/(me-1):null},varianceP:(ve,Se)=>{const{n:me,m2:Ce}=O(u(ve,Se));return me>0?Ce/me:null},stddev:(ve,Se)=>{const{n:me,m2:Ce}=O(u(ve,Se));return me>1?Math.sqrt(Ce/(me-1)):null},stddevP:(ve,Se)=>{const{n:me,m2:Ce}=O(u(ve,Se));return me>0?Math.sqrt(Ce/me):null},median:(ve,Se)=>{const me=u(ve,Se);return me.length?b(me,.5):null},p25:(ve,Se)=>{const me=u(ve,Se);return me.length?b(me,.25):null},p75:(ve,Se)=>{const me=u(ve,Se);return me.length?b(me,.75):null},p90:(ve,Se)=>{const me=u(ve,Se);return me.length?b(me,.9):null},p95:(ve,Se)=>{const me=u(ve,Se);return me.length?b(me,.95):null},p99:(ve,Se)=>{const me=u(ve,Se);return me.length?b(me,.99):null},iqr:(ve,Se)=>{const me=u(ve,Se);if(!me.length)return null;const Ce=me.slice().sort();return A(Ce,.75)-A(Ce,.25)},mad:(ve,Se)=>{const me=u(ve,Se);if(!me.length)return null;const Ce=b(me,.5),Me=new Float64Array(me.length);for(let ze=0;ze<me.length;ze++)Me[ze]=Math.abs(me[ze]-Ce);return b(Me,.5)},range:(ve,Se)=>{const me=u(ve,Se);if(!me.length)return null;let Ce=1/0,Me=-1/0;for(let ze=0;ze<me.length;ze++)me[ze]<Ce&&(Ce=me[ze]),me[ze]>Me&&(Me=me[ze]);return Me-Ce},distinct:(ve,Se)=>{const me=B(ve),Ce=new Set;for(let Me=0;Me<Se.length;Me++){const ze=me(Se[Me]);ze==null||ze===""||Ce.add(ze instanceof Date?ze.getTime():ze)}return Ce.size},mode:(ve,Se)=>{const me=B(ve),Ce=new Map;for(let _e=0;_e<Se.length;_e++){const De=me(Se[_e]);if(De==null||De==="")continue;const Oe=De instanceof Date?De.getTime():De;Ce.set(Oe,(Ce.get(Oe)||0)+1)}let Me=null,ze=1;for(const[_e,De]of Ce)De>ze&&(ze=De,Me=_e);return Me},skewness:(ve,Se)=>{const me=u(ve,Se),{n:Ce,mean:Me,m2:ze}=O(me);if(Ce<3||ze<=0)return null;const _e=Math.sqrt(ze/(Ce-1));let De=0;for(let Oe=0;Oe<me.length;Oe++)De+=((me[Oe]-Me)/_e)**3;return Ce/((Ce-1)*(Ce-2))*De},kurtosis:(ve,Se)=>{const me=u(ve,Se),{n:Ce,mean:Me,m2:ze}=O(me);if(Ce<4||ze<=0)return null;const _e=Math.sqrt(ze/(Ce-1));let De=0;for(let Ue=0;Ue<me.length;Ue++)De+=((me[Ue]-Me)/_e)**4;const Oe=Ce*(Ce+1)/((Ce-1)*(Ce-2)*(Ce-3)),xe=3*(Ce-1)**2/((Ce-2)*(Ce-3));return Oe*De-xe},geomean:(ve,Se)=>{const me=u(ve,Se);if(!me.length)return null;let Ce=0;for(let Me=0;Me<me.length;Me++){if(me[Me]<=0)return null;Ce+=Math.log(me[Me])}return Math.exp(Ce/me.length)},harmean:(ve,Se)=>{const me=u(ve,Se);if(!me.length)return null;let Ce=0;for(let Me=0;Me<me.length;Me++){if(me[Me]===0)return null;Ce+=1/me[Me]}return me.length/Ce},sumSquares:(ve,Se)=>{const me=u(ve,Se);let Ce=0;for(let Me=0;Me<me.length;Me++)Ce+=me[Me]*me[Me];return Ce},passRate:(ve,Se)=>{const{pass:me,judged:Ce}=v(ve,Se);return Ce?me/Ce:null},failureCount:(ve,Se)=>v(ve,Se).fail}),j=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function F(ve,Se,me){const Ce=B(ve),Me=B(Se);let ze=0,_e=0;for(let De=0;De<me.length;De++){const Oe=me[De],xe=Number(Ce(Oe)),Ue=Number(Me(Oe));!Number.isFinite(xe)||!Number.isFinite(Ue)||(ze+=xe*Ue,_e+=Ue)}return _e===0?null:ze/_e}function C(ve,Se,me){const Ce=B(ve);let Me=null,ze=me?-1/0:1/0;for(let _e=0;_e<Se.length;_e++){const De=Se[_e],Oe=Number(Ce(De));Number.isFinite(Oe)&&(me?Oe>ze:Oe<ze)&&(ze=Oe,Me=De)}return Me}function T(ve,Se,me){const Ce=B(ve),Me=B(Se);let ze=0,_e=0,De=0,Oe=0,xe=0,Ue=0;for(let it=0;it<me.length;it++){const mt=me[it],wt=Number(Ce(mt)),dt=Number(Me(mt));!Number.isFinite(wt)||!Number.isFinite(dt)||(ze++,_e+=wt,De+=dt,Oe+=wt*wt,xe+=dt*dt,Ue+=wt*dt)}if(ze<2)return null;const Je=ze*Ue-_e*De,Qe=Math.sqrt((ze*Oe-_e*_e)*(ze*xe-De*De));if(Qe===0)return null;const at=Je/Qe;return Math.max(-1,Math.min(1,at))}function L(ve,Se=.1){const me=ve.length;if(!me)return null;const Ce=Array.from(ve).sort((De,Oe)=>De-Oe),Me=Math.floor(me*Math.min(.49,Math.max(0,Se))),ze=Ce.slice(Me,me-Me);if(!ze.length)return A(Ce,.5);let _e=0;for(const De of ze)_e+=De;return _e/ze.length}function E(ve,Se=.1){const me=ve.length;if(!me)return null;const Ce=Array.from(ve).sort((Oe,xe)=>Oe-xe),Me=Math.floor(me*Math.min(.49,Math.max(0,Se))),ze=Ce[Me],_e=Ce[me-1-Me];let De=0;for(const Oe of Ce)De+=Math.min(_e,Math.max(ze,Oe));return De/me}function D(ve,Se=3.5){if(!ve.length)return null;const Ce=Array.from(ve).sort((Oe,xe)=>Oe-xe),Me=A(Ce,.5),ze=Ce.map(Oe=>Math.abs(Oe-Me)).sort((Oe,xe)=>Oe-xe),_e=A(ze,.5);if(_e===0)return null;let De=0;for(const Oe of Ce)Math.abs(.6745*(Oe-Me)/_e)>Se&&De++;return De}function $(ve){const Se=ve.length;if(Se<8)return null;let me=0;for(const Oe of ve)me+=Oe;me/=Se;let Ce=0,Me=0,ze=0;for(const Oe of ve){const xe=Oe-me;Ce+=xe*xe,Me+=xe*xe*xe,ze+=xe*xe*xe*xe}if(Ce/=Se,Me/=Se,ze/=Se,Ce===0)return null;const _e=Me/Ce**1.5,De=ze/(Ce*Ce)-3;return Se/6*(_e*_e+De*De/4)}function P(ve,Se,me){const Ce=[];let Me=0;for(let Oe=0;Oe<ve.length;Oe++){const xe=Number(ve[Oe]),Ue=Number(Se[Oe]);!Number.isFinite(xe)||!Number.isFinite(Ue)||Ue<=0||(Ce.push([xe,Ue]),Me+=Ue)}if(!Ce.length||Me<=0)return null;if(Ce.sort((Oe,xe)=>Oe[0]-xe[0]),Ce.length===1)return Ce[0][0];const ze=[];let _e=0;for(const[,Oe]of Ce)ze.push((_e+Oe/2)/Me),_e+=Oe;const De=Math.max(0,Math.min(1,me));if(De<=ze[0])return Ce[0][0];if(De>=ze[ze.length-1])return Ce[Ce.length-1][0];for(let Oe=1;Oe<ze.length;Oe++){if(De>ze[Oe])continue;const xe=ze[Oe]-ze[Oe-1],Ue=xe>0?(De-ze[Oe-1])/xe:0;return Ce[Oe-1][0]+(Ce[Oe][0]-Ce[Oe-1][0])*Ue}return Ce[Ce.length-1][0]}function k(ve,Se,me){const Ce=B(ve),Me=B(Se),ze=new Float64Array(me.length),_e=new Float64Array(me.length);let De=0;for(let Oe=0;Oe<me.length;Oe++){const xe=me[Oe],Ue=Number(Ce(xe)),Je=Number(Me(xe));!Number.isFinite(Ue)||!Number.isFinite(Je)||(ze[De]=Ue,_e[De]=Je,De++)}return{xs:ze.subarray(0,De),ys:_e.subarray(0,De),n:De}}function N(ve,Se,me,Ce=!1){const{xs:Me,ys:ze,n:_e}=k(ve,Se,me);if(_e<2)return null;let De=0,Oe=0;for(let Ue=0;Ue<_e;Ue++)De+=Me[Ue],Oe+=ze[Ue];De/=_e,Oe/=_e;let xe=0;for(let Ue=0;Ue<_e;Ue++)xe+=(Me[Ue]-De)*(ze[Ue]-Oe);return xe/(Ce?_e:_e-1)}function G(ve,Se,me){const{xs:Ce,ys:Me,n:ze}=k(ve,Se,me);if(ze<2)return null;let _e=0,De=0;for(let wt=0;wt<ze;wt++)_e+=Ce[wt],De+=Me[wt];_e/=ze,De/=ze;let Oe=0,xe=0,Ue=0;for(let wt=0;wt<ze;wt++){const dt=Ce[wt]-_e,Pt=Me[wt]-De;Oe+=dt*dt,xe+=dt*Pt,Ue+=Pt*Pt}if(Oe===0)return null;const Je=xe/Oe,Qe=De-Je*_e,at=Ue===0?1:Math.max(0,Math.min(1,xe*xe/(Oe*Ue))),it=Math.max(0,Ue-Je*xe),mt=ze>2?Math.sqrt(it/(ze-2)/Oe):0;return{slope:Je,intercept:Qe,r2:at,stdError:mt,n:ze}}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,Se,me){const{xtwx:Ce,xtwy:Me}=l(ve,Se,me),ze=w(Ce);if(!ze)return null;const _e=S(ze,Me),De=g(ze),Oe=oe(ve,_e),xe=Se.map((Ue,Je)=>Ue-Oe[Je]);return{beta:_e,cov:De,fitted:Oe,residuals:xe}}function oe(ve,Se){return ve.map(me=>me.reduce((Ce,Me,ze)=>Ce+Me*Se[ze],0))}function le(ve,Se){const me=ve.length,Ce=ve.map(xe=>xe[Se]),Me=ve.map(xe=>[1,...xe.filter((Ue,Je)=>Je!==Se)]),ze=ne(Me,Ce,null);if(!ze)return 1;const _e=Ce.reduce((xe,Ue)=>xe+Ue,0)/me;let De=0,Oe=0;for(let xe=0;xe<me;xe++)De+=ze.residuals[xe]**2,Oe+=(Ce[xe]-_e)**2;return Oe===0?1:Math.max(0,Math.min(1,1-De/Oe))}function ae(ve){const Se=[...ve].sort((Me,ze)=>Me-ze),me=se(Se),Ce=ve.map(Me=>Math.abs(Me-me)).sort((Me,ze)=>Me-ze);return se(Ce)/.6745}function se(ve){const Se=ve.length;if(!Se)return 0;const me=Math.floor(Se/2);return Se%2?ve[me]:(ve[me-1]+ve[me])/2}function ee(ve,Se,me={}){const Ce=me.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 Me=Array.isArray(Se)?Se.length:0,ze=Me&&Array.isArray(ve[0])?ve[0].length:0,_e=ze+1;if(!(Me>_e))return null;for(let jt=0;jt<Me;jt++){if(!Number.isFinite(Se[jt])||!Array.isArray(ve[jt])||ve[jt].length!==ze)return null;for(let It=0;It<ze;It++)if(!Number.isFinite(ve[jt][It]))return null}let De=null;if(Ce==="wls"){if(De=me.weights,!Array.isArray(De)||De.length!==Me)return null;for(let jt=0;jt<Me;jt++)if(!(De[jt]>0)||!Number.isFinite(De[jt]))return null}const Oe=ve.map(jt=>[1,...jt]);let xe,Ue=null;if(Ce==="robust"){if(xe=ne(Oe,Se,null),!xe)return null;for(let jt=0;jt<50;jt++){const It=ae(xe.residuals);if(!(It>0))break;const Ht=xe.residuals.map(Yt=>{const Jt=Math.abs(Yt/It);return Jt<=te?1:te/Jt}),Wt=ne(Oe,Se,Ht);if(!Wt)return null;const Qt=Wt.beta.reduce((Yt,Jt,on)=>Math.max(Yt,Math.abs(Jt-xe.beta[on])),0);if(xe=Wt,Ue=Ht,Qt<1e-10)break}}else if(xe=ne(Oe,Se,De),!xe)return null;const Je=Ce==="robust"?Ue:De,{beta:Qe,cov:at,fitted:it,residuals:mt}=xe;let wt=0,dt=0,Pt=0;for(let jt=0;jt<Me;jt++){const It=Je?Je[jt]:1;wt+=It*mt[jt]**2,dt+=It,Pt+=It*Se[jt]}const Ft=Pt/dt;let Ge=0;for(let jt=0;jt<Me;jt++){const It=Je?Je[jt]:1;Ge+=It*(Se[jt]-Ft)**2}const ft=Me-_e,ot=wt/ft,lt=Ge===0?1:Math.max(0,Math.min(1,1-wt/Ge)),Ot=1-(1-lt)*(Me-1)/ft,Nt=Array.isArray(me.names)&&me.names.length===ze?me.names:ve[0].map((jt,It)=>`x${It+1}`),gt=Ct(me.confidence),Rt=ft>0?_(1-(1-gt)/2,ft):1/0,Ut=Qe.map((jt,It)=>{const Ht=Math.sqrt(Math.max(0,ot*at[It][It])),Wt=Ht>0?jt/Ht:jt===0?0:1/0,Qt=Number.isFinite(Wt)?2*(1-X(Math.abs(Wt),ft)):0,Yt=Number.isFinite(Rt)?Rt*Ht:null;return{name:It===0?"(intercept)":Nt[It-1],estimate:jt,stdError:Ht,t:Wt,p:Math.max(0,Math.min(1,Qt)),lower:Yt===null?null:jt-Yt,upper:Yt===null?null:jt+Yt}}),tn=new Array(Me),an=new Array(Me);for(let jt=0;jt<Me;jt++){const It=Je?Je[jt]:1,Ht=Math.max(0,Math.min(1,It*d(Oe[jt],at)));tn[jt]=Ht;const Wt=(1-Ht)**2;an[jt]=Wt>0&&ot>0?mt[jt]**2/(_e*ot)*(Ht/Wt):null}const bn=ve[0].map((jt,It)=>{if(ze<2)return 1;const Ht=le(ve,It);return Ht>=1?1/0:1/(1-Ht)});let ln=null;{const jt=mt.map(Ht=>Ht*Ht),It=ne(Oe,jt,null);if(It){const Ht=jt.reduce((en,fn)=>en+fn,0)/Me;let Wt=0,Qt=0;for(let en=0;en<Me;en++)Wt+=It.residuals[en]**2,Qt+=(jt[en]-Ht)**2;const Yt=Qt===0?0:Math.max(0,Math.min(1,1-Wt/Qt)),Jt=Me*Yt,on=V(Jt,ze);ln={statistic:Jt,df:ze,p:on,heteroscedastic:on<.05}}}let Zt=null;if(ze===1){const jt=ve.map((It,Ht)=>Ht).sort((It,Ht)=>ve[It][0]-ve[Ht][0]);Zt={confidence:gt,points:jt.map(It=>{const Ht=Oe[It],Wt=Math.sqrt(Math.max(0,ot*d(Ht,at)));return{x:ve[It][0],yhat:it[It],lower:it[It]-Rt*Wt,upper:it[It]+Rt*Wt}})}}return{method:Ce,coefficients:Ut,r2:lt,adjR2:Ot,n:Me,df:ft,sigma2:ot,fitted:it,residuals:mt,leverage:tn,cooksD:an,vif:bn,heteroscedasticity:ln,band:Zt,weights:Je?[...Je]:null}}function ie(ve){const Se=ve.length,me=Array.from({length:Se},(ze,_e)=>_e).sort((ze,_e)=>ve[ze]-ve[_e]),Ce=new Float64Array(Se);let Me=0;for(;Me<Se;){let ze=Me;for(;ze+1<Se&&ve[me[ze+1]]===ve[me[Me]];)ze++;const _e=(Me+ze)/2+1;for(let De=Me;De<=ze;De++)Ce[me[De]]=_e;Me=ze+1}return Ce}const de=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function he(ve){const Se=[.01,.05,.1],me=[de["1%"],de["5%"],de["10%"]];if(ve<=me[0]){const ze=(Math.log(Se[1])-Math.log(Se[0]))/(me[1]-me[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(Se[0])+ze*(ve-me[0]))))}if(ve>=me[2]){const ze=(Math.log(Se[2])-Math.log(Se[1]))/(me[2]-me[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(Se[2])+ze*(ve-me[2]))))}const Ce=ve<me[1]?0:1,Me=(ve-me[Ce])/(me[Ce+1]-me[Ce]);return Math.exp(Math.log(Se[Ce])+Me*(Math.log(Se[Ce+1])-Math.log(Se[Ce])))}function ge(ve,Se,me,Ce){const Me=me-Ce,ze=Ce+3,_e=new Array(Me),De=new Array(Me);let Oe=!0,xe=Ce;for(let it=0;it<Me;it++){const mt=Ce+it,wt=new Float64Array(ze);wt[0]=1,wt[1]=it+1,wt[2]=ve[mt];for(let dt=1;dt<=Ce;dt++)wt[2+dt]=Se[mt-dt];for(let dt=1;dt<ze;dt++)Number.isFinite(wt[dt])||(xe=Math.min(xe,dt-3));_e[it]=wt,De[it]=Se[mt],Number.isFinite(De[it])||(Oe=!1)}if(!Oe)return 0;const{xtwx:Ue,xtwy:Je}=l(_e,De,null);let Qe=0,at=1/0;for(let it=0;it<=xe;it++){const mt=it+3;if(!(Me>mt))continue;const wt=new Array(mt);for(let lt=0;lt<mt;lt++)wt[lt]=Ue[lt].slice(0,mt);const dt=w(wt);if(!dt)continue;const Pt=S(dt,Je.slice(0,mt));let Ft=0;for(let lt=0;lt<Me;lt++){const Ot=_e[lt];let Nt=0;for(let gt=0;gt<mt;gt++)Nt+=Ot[gt]*Pt[gt];Ft+=(De[lt]-Nt)**2}const ft=Ft/(Me-mt)*(Me-mt);if(!(ft>0))continue;const ot=Me*Math.log(ft/Me)+2*mt;ot<at&&(at=ot,Qe=it)}return Qe}function Ee(ve,Se={}){const me=[];for(let at=0;at<ve.length;at++){const it=Number(ve[at]);Number.isFinite(it)&&me.push(it)}const Ce=me.length,Me=Ce-1;if(Ce<8||Me<6)return null;const ze=new Array(Me);for(let at=0;at<Me;at++)ze[at]=me[at+1]-me[at];let _e=Number.isFinite(Se.maxlag)?Math.floor(Se.maxlag):Math.ceil(12*(Ce/100)**.25);_e=Math.max(0,Math.min(_e,Math.floor((Me-5)/2)));const De=(at,it)=>{const mt=[],wt=[];for(let dt=it;dt<Me;dt++){const Pt=[dt-it+1,me[dt]];for(let Ft=1;Ft<=at;Ft++)Pt.push(ze[dt-Ft]);mt.push(Pt),wt.push(ze[dt])}return ee(mt,wt,{method:"ols"})},Oe=ge(me,ze,Me,_e),xe=De(Oe,Oe);if(!xe||!xe.coefficients[2])return null;const Ue=xe.coefficients[2].t,Je=he(Ue),Qe=Ue<de["5%"];return{statistic:Ue,usedLag:Oe,nobs:Me-Oe,criticalValues:{...de},pValue:Je,pApproximate:!0,stationary:Qe,verdict:Qe?"stationary":"non-stationary",regression:"ct"}}function ye(ve,Se={}){const me=[];for(let Qe=0;Qe<ve.length;Qe++){const at=Number(ve[Qe]);Number.isFinite(at)&&me.push(at)}const Ce=me.length;if(Ce<3)return null;let Me=Number.isFinite(Se.maxlag)?Math.floor(Se.maxlag):Math.min(10,Ce-1);Me=Math.max(1,Math.min(Me,Ce-1));let ze=0;for(const Qe of me)ze+=Qe;ze/=Ce;const _e=me.map(Qe=>Qe-ze);let De=0;for(const Qe of _e)De+=Qe*Qe;De/=Ce;const Oe=new Array(Me+1).fill(0);Oe[0]=1;for(let Qe=1;Qe<=Me;Qe++){let at=0;for(let it=Qe;it<Ce;it++)at+=_e[it]*_e[it-Qe];Oe[Qe]=De>0?at/Ce/De:0}const xe=new Array(Me+1).fill(0);xe[0]=1;let Ue=[];for(let Qe=1;Qe<=Me;Qe++){let at=Oe[Qe];for(let dt=1;dt<Qe;dt++)at-=Ue[dt-1]*Oe[Qe-dt];let it=1;for(let dt=1;dt<Qe;dt++)it-=Ue[dt-1]*Oe[dt];const mt=it!==0?at/it:0,wt=new Array(Qe);for(let dt=1;dt<Qe;dt++)wt[dt-1]=Ue[dt-1]-mt*Ue[Qe-1-dt];wt[Qe-1]=mt,xe[Qe]=mt,Ue=wt}const Je=1.96/Math.sqrt(Ce);return{acf:Oe,pacf:xe,bounds:{upper:Je,lower:-Je},n:Ce,nlags:Me,approximate:!0}}function Ae(ve,Se,me){const{xs:Ce,ys:Me,n:ze}=k(ve,Se,me);if(ze<2)return null;const _e=ie(Ce),De=ie(Me);let Oe=0,xe=0;for(let at=0;at<ze;at++)Oe+=_e[at],xe+=De[at];Oe/=ze,xe/=ze;let Ue=0,Je=0,Qe=0;for(let at=0;at<ze;at++){const it=_e[at]-Oe,mt=De[at]-xe;Ue+=it*mt,Je+=it*it,Qe+=mt*mt}return Je===0||Qe===0?null:Math.max(-1,Math.min(1,Ue/Math.sqrt(Je*Qe)))}function pe(ve,Se,me){const{xs:Ce,ys:Me,n:ze}=k(ve,Se,me);if(ze<2||ze>t)return null;let _e=0,De=0,Oe=0,xe=0;for(let Qe=0;Qe<ze;Qe++)for(let at=Qe+1;at<ze;at++){const it=Math.sign(Ce[Qe]-Ce[at]),mt=Math.sign(Me[Qe]-Me[at]),wt=it*mt;wt>0?_e++:wt<0?De++:it===0&&mt===0||(it===0?Oe++:xe++)}const Ue=_e+De+xe,Je=_e+De+Oe;return Ue===0||Je===0?null:(_e-De)/Math.sqrt(Ue*Je)}function we(ve,Se={}){const me=ve.length;if(me<2)return null;const Ce=ve[0],Me=ve[me-1],ze=[];for(let dt=1;dt<me;dt++){const Pt=ve[dt-1];Pt!==0&&ze.push((ve[dt]-Pt)/Math.abs(Pt))}let _e=null;if(ze.length>1){let dt=0;for(const Ft of ze)dt+=Ft;dt/=ze.length;let Pt=0;for(const Ft of ze)Pt+=(Ft-dt)**2;_e=Math.sqrt(Pt/(ze.length-1))}const De=Number(Se.periodsPerYear)>0?Number(Se.periodsPerYear):null;let Oe=ve[0],xe=0,Ue=0,Je=0,Qe=0;for(let dt=1;dt<me;dt++){if(ve[dt]>Oe){Oe=ve[dt],xe=dt;continue}if(Oe<=0)continue;const Pt=(Oe-ve[dt])/Oe;Pt>Ue&&(Ue=Pt,Je=xe,Qe=dt)}let at=null;if(me>2){let dt=0;for(let Ge=0;Ge<me;Ge++)dt+=ve[Ge];dt/=me;let Pt=0,Ft=0;for(let Ge=0;Ge<me;Ge++){const ft=ve[Ge]-dt;Ft+=ft*ft,Ge>0&&(Pt+=ft*(ve[Ge-1]-dt))}at=Ft>0?Pt/Ft:null}let it=0,mt=0;for(const dt of ze)dt>0?it++:dt<0&&mt++;let wt=null;if(Ce>0&&Me>0){const dt=(Me/Ce)**(1/(me-1))-1;wt=De?(1+dt)**De-1:dt}return{n:me,first:Ce,last:Me,change:Me-Ce,changePercent:Ce===0?null:(Me-Ce)/Math.abs(Ce)*100,volatility:_e,annualisedVolatility:_e!==null&&De?_e*Math.sqrt(De):null,growth:wt,maxDrawdown:Ue,maxDrawdownFrom:Je,maxDrawdownTo:Qe,autocorrelation:at,upDays:it,downDays:mt}}const be=1.128,Ne=3.267;function Ie(ve){const Se=ve.length;if(Se<2)return null;const me=[];for(let Me=1;Me<Se;Me++)me.push(Math.abs(ve[Me]-ve[Me-1]));const Ce=me.reduce((Me,ze)=>Me+ze,0)/me.length;return{ranges:me,centre:Ce,upper:Ne*Ce,lower:0}}function Ve(ve){const Se=ve.length;if(Se<2)return null;let me=0;for(let Me=1;Me<Se;Me++)me+=Math.abs(ve[Me]-ve[Me-1]);const Ce=me/(Se-1);return{sigma:Ce/be,meanRange:Ce}}function Ye(ve,Se){const me=ve.length;if(me<2||!Se)return null;const Ce=Number.isFinite(Number(Se.lower))?Number(Se.lower):null,Me=Number.isFinite(Number(Se.upper))?Number(Se.upper):null;if(Ce===null&&Me===null)return null;let ze=0;for(let it=0;it<me;it++)ze+=ve[it];ze/=me;let _e=0;for(let it=0;it<me;it++)_e+=(ve[it]-ze)**2;const De=Math.sqrt(_e/(me-1)),Oe=Ve(ve),xe=Oe?Oe.sigma:null,Ue=it=>{if(!it||it<=0)return{index:null,k:null};const wt=Ce!==null&&Me!==null?(Me-Ce)/(6*it):null,dt=Me!==null?(Me-ze)/(3*it):1/0,Pt=Ce!==null?(ze-Ce)/(3*it):1/0;return{index:wt,k:Math.min(dt,Pt)}},Je=Ue(xe),Qe=Ue(De);let at=0;for(let it=0;it<me;it++){if(Ce!==null&&ve[it]<Ce){at++;continue}Me!==null&&ve[it]>Me&&at++}return{n:me,mean:ze,lower:Ce,upper:Me,target:Number.isFinite(Number(Se.target))?Number(Se.target):null,sigmaWithin:xe,sigmaOverall:De,cp:Je.index,cpk:Je.k,pp:Qe.index,ppk:Qe.k,outOfSpec:at,defectRate:me?at/me:null}}function je(ve){const Se=ve.length;if(Se<2)return null;const me=Ve(ve);if(!me||!(me.sigma>0))return null;let Ce=0;for(let Me=0;Me<Se;Me++)Ce+=ve[Me];return Ce/=Se,{centre:Ce,sigma:me.sigma,upper:Ce+3*me.sigma,lower:Ce-3*me.sigma}}function He(ve,Se){if(!Se||!(Se.sigma>0))return[];const me=ve.length,{centre:Ce,sigma:Me}=Se,ze=De=>(ve[De]-Ce)/Me,_e=[];for(let De=0;De<me;De++){if(Math.abs(ze(De))>3&&_e.push({index:De,rule:1,description:"beyond three sigma"}),De>=2)for(const Oe of[1,-1]){let xe=0;for(let Ue=De-2;Ue<=De;Ue++)ze(Ue)*Oe>2&&xe++;if(xe>=2){_e.push({index:De,rule:2,description:"two of three past two sigma"});break}}if(De>=4)for(const Oe of[1,-1]){let xe=0;for(let Ue=De-4;Ue<=De;Ue++)ze(Ue)*Oe>1&&xe++;if(xe>=4){_e.push({index:De,rule:3,description:"four of five past one sigma"});break}}if(De>=7)for(const Oe of[1,-1]){let xe=!0;for(let Ue=De-7;Ue<=De;Ue++)if(ze(Ue)*Oe<=0){xe=!1;break}if(xe){_e.push({index:De,rule:4,description:"eight in a row on one side"});break}}}return _e}function Ze(ve,Se){if(!Se||!(Se.sigma>0))return[];const me=ve.length,{centre:Ce,sigma:Me}=Se,ze=Oe=>(ve[Oe]-Ce)/Me,_e=(Oe,xe,Ue,Je)=>{for(const Qe of[1,-1]){let at=0;for(let it=Oe;it<=xe;it++)ze(it)*Qe>Ue&&at++;if(at>=Je)return!0}return!1},De=[];for(let Oe=0;Oe<me;Oe++){if(Math.abs(ze(Oe))>3&&De.push({index:Oe,rule:1,description:"beyond three sigma"}),Oe>=8)for(const xe of[1,-1]){let Ue=!0;for(let Je=Oe-8;Je<=Oe;Je++)if(ze(Je)*xe<=0){Ue=!1;break}if(Ue){De.push({index:Oe,rule:2,description:"nine in a row on one side"});break}}if(Oe>=5)for(const xe of[1,-1]){let Ue=!0;for(let Je=Oe-4;Je<=Oe;Je++)if((ve[Je]-ve[Je-1])*xe<=0){Ue=!1;break}if(Ue){De.push({index:Oe,rule:3,description:xe>0?"six rising":"six falling"});break}}if(Oe>=13){let xe=!0;for(let Ue=Oe-12;Ue<=Oe;Ue++){const Je=ve[Ue]-ve[Ue-1],Qe=ve[Ue+1<=Oe?Ue+1:Ue]-ve[Ue];if(Ue+1>Oe)break;if(Je===0||Qe===0||Je>0==Qe>0){xe=!1;break}}xe&&De.push({index:Oe,rule:4,description:"fourteen alternating"})}if(Oe>=2&&_e(Oe-2,Oe,2,2)&&De.push({index:Oe,rule:5,description:"two of three past two sigma"}),Oe>=4&&_e(Oe-4,Oe,1,4)&&De.push({index:Oe,rule:6,description:"four of five past one sigma"}),Oe>=14){let xe=!0;for(let Ue=Oe-14;Ue<=Oe;Ue++)if(Math.abs(ze(Ue))>=1){xe=!1;break}xe&&De.push({index:Oe,rule:7,description:"fifteen within one sigma"})}if(Oe>=7){let xe=!0;for(let Ue=Oe-7;Ue<=Oe;Ue++)if(Math.abs(ze(Ue))<=1){xe=!1;break}xe&&De.push({index:Oe,rule:8,description:"eight beyond one sigma"})}}return De}const rt=Object.freeze(["westernElectric","nelson"]);function st(ve,Se,me="westernElectric"){return String(me)==="nelson"?Ze(ve,Se):He(ve,Se)}function ht(ve,Se,me){let Ce=0;for(let Me=0;Me<ve.length;Me++)(ve[Me]<Se||ve[Me]>me)&&Ce++;return Ce}function yt(ve,Se,me,Ce=20){const Me=ve.length;if(!Me)return[];const ze=ve[0],_e=ve[Me-1];if(_e===ze)return[{from:ze,to:_e,count:Me}];const De=me-Se,Oe=1.5*De;let xe=De>0?Math.max(ze,Se-Oe):ze,Ue=De>0?Math.min(_e,me+Oe):_e;Ue>xe||(xe=ze,Ue=_e);const Je=De>0?2*De/Math.cbrt(Me):(Ue-xe)/(Math.ceil(Math.log2(Me))+1),Qe=Je>0?Math.min(Ce,Math.max(1,Math.ceil((Ue-xe)/Je))):1,at=(Ue-xe)/Qe,it=[];for(let mt=0;mt<Qe;mt++)it.push({from:xe+mt*at,to:xe+(mt+1)*at,count:0});for(let mt=0;mt<Me;mt++){const wt=Math.min(Qe-1,Math.max(0,Math.floor((ve[mt]-xe)/at)));it[wt].count++}return it[0].from=ze,it[Qe-1].to=_e,it}const St=.95;function Ct(ve){const Se=Number(ve);return Number.isFinite(Se)&&Se>0&&Se<1?Se:St}function Tt(ve,Se=St){const me=ve.length;if(me<2)return null;let Ce=0;for(let Ue=0;Ue<me;Ue++)Ce+=ve[Ue];const Me=Ce/me;let ze=0;for(let Ue=0;Ue<me;Ue++){const Je=ve[Ue]-Me;ze+=Je*Je}const _e=Math.sqrt(ze/(me-1)),De=Ct(Se),xe=_(1-(1-De)/2,me-1)*_e/Math.sqrt(me);return{mean:Me,lower:Me-xe,upper:Me+xe,margin:xe,n:me,confidence:De}}function Et(ve,Se,me=St){const Ce=Number(ve),Me=Number(Se);if(!(Me>0)||!(Ce>=0)||Ce>Me)return null;const ze=Ct(me),_e=W(1-(1-ze)/2),De=Ce/Me,Oe=_e*_e,xe=1+Oe/Me,Ue=(De+Oe/(2*Me))/xe,Je=_e/xe*Math.sqrt(De*(1-De)/Me+Oe/(4*Me*Me));return{proportion:De,lower:Math.max(0,Ue-Je),upper:Math.min(1,Ue+Je),n:Me,confidence:ze}}function Bt(ve,Se=St){if(!ve||!(ve.n>2)||!Number.isFinite(ve.stdError))return null;const me=Ct(Se),Me=_(1-(1-me)/2,ve.n-2)*ve.stdError;return{slope:ve.slope,lower:ve.slope-Me,upper:ve.slope+Me,margin:Me,confidence:me}}function Dt(ve,Se,me=St){const Ce=Number(ve),Me=Number(Se);if(!Number.isFinite(Ce)||!(Me>1))return null;const ze=Ct(me),De=W(1-(1-ze)/2)*Math.sqrt(1/(9*Me)+Ce*Ce/(2*(Me-1)));return{index:Ce,lower:Ce-De,upper:Ce+De,margin:De,n:Me,confidence:ze}}function ct(ve,Se){return!ve||!(ve.sd>0)||!Number.isFinite(Se)||!Number.isFinite(ve.mean)?null:(Se-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 fe(ve,Se){const me=new Map,Ce=B(ve);let Me=0;for(let ze=0;ze<Se.length;ze++){const _e=Ce(Se[ze]);if(_e==null||_e===""||typeof _e=="number"&&Number.isNaN(_e))continue;const De=_e instanceof Date?_e.getTime():typeof _e=="object"?String(_e):_e;me.set(De,(me.get(De)||0)+1),Me++}return{map:me,total:Me}}function ke(ve,Se,me,Ce){if(!(Se>0)||!(Ce>0))return null;let Me=0;const ze=new Set(ve.keys());for(const _e of me.keys())ze.add(_e);for(const _e of ze){const De=(ve.get(_e)||0)/Se,Oe=(me.get(_e)||0)/Ce;Me+=Math.abs(De-Oe)}return Me/2}const Re=10;function We(ve,Se,me){if(me&&me.numeric){const De=u(ve,Se),{n:Oe,mean:xe}=O(De),Ue=Oe>0?ct({mean:me.mean,sd:me.sd},xe):null;return{measure:"standardizedMeanDifference",magnitude:Ue,distance:Ue===null?0:nt(Ue),direction:Ue===null?0:Math.sign(Ue),subsetN:Oe,populationN:me.n||0,reliable:Oe>=Re}}const{map:Me,total:ze}=fe(ve,Se),_e=ke(Me,ze,me.map,me.total);return{measure:"categoricalTotalVariation",magnitude:_e,distance:_e===null?0:_e,direction:0,subsetN:ze,populationN:me.total||0,reliable:ze>=Re}}function $e(ve,Se){if(ve&&(ve.kind==="float64"||ve.kind==="int32"))return!0;const me=B(ve);let Ce=0,Me=0;for(let ze=0;ze<Se.length&&Ce<200;ze++){const _e=me(Se[ze]);if(_e==null||_e==="")continue;if(_e instanceof Date)return!1;Ce++;const De=typeof _e=="number"?_e:Number(_e);Number.isFinite(De)&&Me++}return Ce===0?!1:Me/Ce>=.9}function qe(ve,Se){if($e(ve,Se)){const Me=u(ve,Se),{n:ze,mean:_e,m2:De}=O(Me);return{numeric:!0,mean:_e,sd:ze>0?Math.sqrt(De/ze):0,n:ze}}const{map:me,total:Ce}=fe(ve,Se);return{numeric:!1,map:me,total:Ce}}}),Le("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 o}}),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 s}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return y}});const Q=K("packages/core/src/internal/util.js"),x=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"),V=H.STAT_FNS,z=H.STAT_LABELS;function w(O){return!!O&&(O.kind==="float64"||O.kind==="int32")}function S(O,A){const b=A.length;let v=0;if(w(O)){const j=O.values,F=_(O);if(!F){for(let C=0;C<b;C++){const T=j[A[C]];Number.isNaN(T)||(v+=T)}return v}for(let C=0;C<b;C++){const T=A[C];if(F(T)===1){const L=j[T];Number.isNaN(L)||(v+=L)}}return v}const R=W(O);for(let j=0;j<b;j++){const F=f(R(A[j]));F!==null&&(v+=F)}return v}S.kernel=!0;function g(O,A){const b=A.length;let v=0;if(w(O)){const j=O.values,F=_(O);if(!F){for(let C=0;C<b;C++)Number.isNaN(j[A[C]])||v++;return v}for(let C=0;C<b;C++){const T=A[C];F(T)===1&&!Number.isNaN(j[T])&&v++}return v}const R=W(O);for(let j=0;j<b;j++){const F=R(A[j]);F!=null&&!(typeof F=="number"&&Number.isNaN(F))&&v++}return v}g.kernel=!0;function l(O,A){return A.length}l.kernel=!0;function d(O,A){const b=g(O,A);return b===0?null:S(O,A)/b}d.kernel=!0;function a(O,A,b,v){const R=A.length;if(w(O)){const T=O.values,L=_(O);let E=null;if(!L){for(let D=0;D<R;D++){const $=T[A[D]];Number.isNaN($)||(E===null||(b<0?$<E:$>E))&&(E=$)}return E}for(let D=0;D<R;D++){const $=A[D];if(L($)===0)continue;const P=T[$];Number.isNaN(P)||(E===null||(b<0?P<E:P>E))&&(E=P)}return E}const j=W(O),F=X(v);let C=null;for(let T=0;T<R;T++){const L=j(A[T]);L==null||typeof L=="number"&&Number.isNaN(L)||(C===null||(b<0?F(L,C)<0:F(L,C)>0))&&(C=L)}return C}function r(O,A,b){return a(O,A,-1,b&&b.locale)}r.kernel=!0;function t(O,A,b){return a(O,A,1,b&&b.locale)}t.kernel=!0;function n(O,A){return A.length===0?null:W(O)(A[0])}n.kernel=!0;function i(O,A){return A.length===0?null:W(O)(A[A.length-1])}i.kernel=!0;function f(O){if(typeof O=="number")return Number.isNaN(O)?null:O;if(O==null||O===""||typeof O=="boolean")return null;if(O instanceof Date)return O.getTime();const A=Number(O);return Number.isNaN(A)?null:A}const u={sum:S,min:r,max:t,avg:d,count:l,first:n,last:i,countValues:g,...V},o=Object.freeze({...z,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function m(O){return O?typeof O=="string"?o[O]||O:"Total":""}const c=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function h(O){const A=O&&O.dataType&&O.dataType.totals&&O.dataType.totals.supported;if(Array.isArray(A))return A.slice();const b=c.filter(v=>v in u);for(const v of Object.keys(u))b.includes(v)||b.push(v);return b}function s(O,A){return typeof A!="string"?!0:h(O).includes(A)}function p(O,A){const b=W(O),v=[];for(let R=0;R<A.length;R++){const j=b(A[R]);j!=null&&v.push(j)}return v}function y(O,A,b,v){const R=A||[];if(typeof b=="string"){const j=u[b];return j?j(O,R,v):(B(`total:${b}`,`unknown total function "${b}"; register it in config.totalFns`),null)}return x(b)?b.kernel===!0?b(O,R,v):b(p(O,R),v||{}):null}}),Le("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 x=K("packages/core/src/compute/sketch.js").Welford;class B{#e;#t;#n=[];#r;#o;constructor(H,V=0,z=Date.now){if(H!=="count"&&H!=="time"&&H!=="session")throw new RangeError(`unknown window kind: ${H}`);if((H==="count"||H==="time")&&!(V>0))throw new RangeError(`a ${H} window needs a positive span`);this.#e=H,this.#t=Math.floor(V),this.#r=z,this.#o=z()}get size(){return this.#n.length}push(H,V=this.#r()){Number.isFinite(H)&&(this.#n.push({t:V,v:H}),this.#i(V))}#i(H){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const V=H-this.#t;for(;this.#n.length&&this.#n[0].t<V;)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 V=new x;let z=0,w=1/0,S=-1/0;for(const{v:g}of this.#n)z+=g,g<w&&(w=g),g>S&&(S=g),V.add(g);return{over:H,count:this.#n.length,sum:z,mean:V.mean(),min:w,max:S,variance:V.variance(),stddev:V.stddev()}}reduce(H){const V=this.aggregate(),z={sum:V.sum,avg:V.mean,mean:V.mean,min:V.min,max:V.max,count:V.count,variance:V.variance,stddev:V.stddev};if(!(H in z))throw new RangeError(`unknown windowed aggregate: ${H}`);return{value:z[H],over:V.over}}}const I=Object.freeze(["count","time","session"]);function _(W,H=Date.now){const V=W.kind==="time"&&W.minutes!=null?W.minutes*6e4:W.span??0;return new B(W.kind,V,H)}const X={Window:B,WINDOW_KINDS:I,openWindow:_}}),Le("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 V}}),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 d}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const x=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(o,m,c,h){if(o.kind==="count"){const s=Math.max(1,Math.floor(o.span||0));return{coverage:Math.min(1,m/s),partial:m<s}}if(o.kind==="time"){const s=o.minutes!=null?o.minutes*6e4:o.span||0;if(!(s>0))return{coverage:1,partial:!1};const p=c-h;return{coverage:Math.min(1,p/s),partial:p<s}}return{coverage:null,partial:!1}}function W(o,m){const c=x(m),h=new Map,s=o.length?o[0].at:0;for(let p=0;p<o.length;p++){const{key:y,at:O,value:A}=o[p];Number.isFinite(A)&&c.push(A,O);const b=c.aggregate(),v=X(m,b.count,O,s);y!=null&&h.set(String(y),{sum:b.sum,avg:b.mean,min:b.min,max:b.max,count:b.count,coverage:v.coverage,partial:v.partial})}return h}function H(o){const m=new Map;let c=0;for(const{key:h,value:s}of o)Number.isFinite(s)&&(c+=s),h!=null&&m.set(String(h),c);return m}function V(o,m=1){const c=new Map,h=Math.max(1,Math.floor(m));for(let s=0;s<o.length;s++){const{key:p,value:y}=o[s];if(p==null)continue;const O=s>=h?o[s-h].value:null,A=Number.isFinite(y)?y:null,b=Number.isFinite(O)?O:null;c.set(String(p),A!==null&&b!==null?A-b:null)}return c}const z=4096;function w(o){let m=o>>>0;return()=>{m+=1831565813;let c=m;return c=Math.imul(c^c>>>15,c|1),c^=c+Math.imul(c^c>>>7,c|61),((c^c>>>14)>>>0)/4294967296}}function S(o,m){const c=o.length;if(c===1)return o[0];const h=(c-1)*m,s=Math.floor(h),p=Math.ceil(h);return s===p?o[s]:o[s]+(h-s)*(o[p]-o[s])}function g(o,m,c={}){const h=Math.min(1,Math.max(0,c.q==null?.5:c.q)),s=Math.max(1,Math.floor(c.cap==null?z:c.cap)),p=w(c.seed==null?2654435769:c.seed),y=new Map,O=o.length?o[0].at:0;if(m.kind==="session"){const b=new I(200,p);let v=0;for(const{key:R,value:j}of o)Number.isFinite(j)&&(b.add(j),v++),R!=null&&y.set(String(R),{value:v?b.quantile(h):null,approx:v>0,count:v,coverage:null,partial:!1});return y}const A=x(m);for(const{key:b,at:v,value:R}of o){Number.isFinite(R)&&A.push(R,v);const j=A.values(),F=j.length;let C=null,T=!1;if(F)if(F<=s)C=S([...j].sort((E,D)=>E-D),h);else{const E=new I(200,p);for(const D of j)E.add(D);C=E.quantile(h),T=!0}const L=X(m,F,v,O);b!=null&&y.set(String(b),{value:C,approx:T,count:F,coverage:L.coverage,partial:L.partial})}return y}function l(o,m){const c=o.length,h=new Array(c).fill(null),s=Math.floor(m/2),p=m%2===0;for(let y=0;y<c;y++){if(y-s<0||y+s>=c)continue;let O=0,A=!0;if(p)for(let b=-s;b<=s;b++){const v=o[y+b];if(!Number.isFinite(v)){A=!1;break}O+=b===-s||b===s?v*.5:v}else for(let b=-s;b<=s;b++){const v=o[y+b];if(!Number.isFinite(v)){A=!1;break}O+=v}A&&(h[y]=O/m)}return h}function d(o,m){const c=new Map,h=Math.floor(Number(m&&m.period));if(!(h>=2))return c;const s=m&&m.model==="multiplicative",p=o.length,y=o.map(T=>Number.isFinite(T.value)?T.value:null),O=l(y,h),A=new Array(p).fill(null);for(let T=0;T<p;T++){const L=O[T],E=y[T];L===null||E===null||(s?L!==0&&(A[T]=E/L):A[T]=E-L)}const b=new Array(h).fill(0),v=new Array(h).fill(0);for(let T=0;T<p;T++){if(A[T]===null)continue;const L=T%h;b[L]+=A[T],v[L]+=1}const R=s?1:0,j=b.map((T,L)=>v[L]?T/v[L]:R),F=j.reduce((T,L)=>T+L,0)/h,C=s?j.map(T=>F!==0?T/F:1):j.map(T=>T-F);for(let T=0;T<p;T++){const{key:L}=o[T];if(L==null)continue;const E=O[T],D=C[T%h],$=y[T];let P=null;E!==null&&$!==null&&(P=s?E*D!==0?$/(E*D):null:$-E-D),c.set(String(L),{trend:E,seasonal:$===null?null:D,residual:P,coverage:E===null?0:1,partial:E===null})}return c}function a(o,m,c,h=80){const s=(Math.sqrt(5)-1)/2;let p=m,y=c,O=y-s*(y-p),A=p+s*(y-p),b=o(O),v=o(A);for(let R=0;R<h;R++)b<v?(y=A,A=O,v=b,O=y-s*(y-p),b=o(O)):(p=O,O=A,b=v,A=p+s*(y-p),v=o(A));return(p+y)/2}const r=1e-4,t=1-1e-4;function n(o,m){const c=o.length,h=new Array(c).fill(null),s=new Array(c).fill(null);let p=null,y=0;for(let O=0;O<c;O++){const A=o[O];if(!Number.isFinite(A)){p!==null&&(s[O]=p,h[O]=p);continue}if(p===null){p=A,s[O]=A,h[O]=A;continue}s[O]=p,y+=(A-p)**2,p=m*A+(1-m)*p,h[O]=p}return{smoothed:h,fitted:s,sse:y}}function i(o,m,c){const h=o.length,s=new Array(h).fill(null),p=new Array(h).fill(null);let y=null,O=null,A=0;for(let b=0;b<h;b++){const v=o[b];if(!Number.isFinite(v)){y!==null&&(y+=O,s[b]=y);continue}if(y===null){y=v,s[b]=v;continue}if(O===null){O=v-y;const F=y+O;p[b]=F,A+=(v-F)**2;const C=y;y=m*v+(1-m)*(C+O),O=c*(y-C)+(1-c)*O,s[b]=y;continue}const R=y+O;p[b]=R,A+=(v-R)**2;const j=y;y=m*v+(1-m)*(j+O),O=c*(y-j)+(1-c)*O,s[b]=y}return{smoothed:s,fitted:p,sse:A}}function f(o,m={}){const c=new Map,h=m.method==="holt",s=o.map(R=>Number.isFinite(R.value)?R.value:null),p=s.filter(R=>R!==null).length,y=R=>Math.min(t,Math.max(r,R)),O=()=>{for(const{key:R}of o)R!=null&&c.set(String(R),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return c};if(p<(h?2:1))return O();let A=Number.isFinite(m.alpha)?y(m.alpha):null,b=h&&Number.isFinite(m.beta)?y(m.beta):null;if(h){if(A===null||b===null){let R=A===null?.5:A,j=b===null?.5:b;for(let F=0;F<6;F++)A===null&&(R=a(C=>i(s,C,j).sse,r,t)),b===null&&(j=a(C=>i(s,R,C).sse,r,t));A=A===null?R:A,b=b===null?j:b}}else A===null&&(A=a(R=>n(s,R).sse,r,t));const v=h?i(s,A,b):n(s,A);for(let R=0;R<o.length;R++){const{key:j}=o[R];j!=null&&c.set(String(j),{smoothed:v.smoothed[R],fitted:v.fitted[R],alpha:A,beta:h?b:null,sse:v.sse})}return c}const u={ROLLING_WINDOW_FIELDS:_,QUANTILE_SPAN_CAP:z,rollingWindow:W,rollingQuantile:g,cumulativeToDate:H,periodOverPeriod:V,seasonalDecompose:d,exponentialSmoothing:f}}),Le("packages/core/src/compute/compare.js",function(e,K){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return V}}),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 S}}),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"),x=Q.numbers,B=Q.moments,I=Q.frequencyMap,_=Q.categoricalDistance,X=Q.normalTotalVariation,W=Q.isNumericColumn,H=Q.SUBSET_RELIABILITY_FLOOR,V=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function z(d,a){if(!d||!a||!(d.n>0)||!(a.n>0)||!Number.isFinite(d.mean)||!Number.isFinite(a.mean))return null;const r=(d.n*d.sd*d.sd+a.n*a.sd*a.sd)/(d.n+a.n);return r>0?(d.mean-a.mean)/Math.sqrt(r):null}function w(d,a){const r=x(d,a),{n:t,mean:n,m2:i}=B(r),f=t>0?Math.sqrt(i/t):0;return{mean:n,sd:f,n:t}}function S(d,a,r,t){return W(d,a)&&W(r,t)}function g(d,a,r,t){if(S(d,a,r,t)){const u=w(d,a),o=w(r,t),m=z(u,o);return{measure:V.numeric,magnitude:m,distance:m===null?0:X(m),direction:m===null?0:Math.sign(m),nA:u.n,nB:o.n,reliable:u.n>=H&&o.n>=H}}const n=I(d,a),i=I(r,t),f=_(n.map,n.total,i.map,i.total);return{measure:V.categorical,magnitude:f,distance:f===null?0:f,direction:0,nA:n.total,nB:i.total,reliable:n.total>=H&&i.total>=H}}function l(d,a,r={}){const t=new Set(d.columns),n=new Set(a.columns),i=d.columns.filter(c=>n.has(c)),f=Array.isArray(r.columns)&&r.columns.length?i.filter(c=>r.columns.includes(c)):i,u=d.indices(),o=a.indices(),m=[];for(const c of f){const h=d.handle(c),s=a.handle(c);if(!h||!s)continue;const p=g(h,u,s,o);m.push({column:c,name:d.name&&d.name(c)||a.name&&a.name(c)||c,measure:p.measure,magnitude:p.magnitude,distance:p.distance,direction:p.direction,nA:p.nA,nB:p.nB,reliable:p.reliable})}return m.sort((c,h)=>h.distance-c.distance||Math.abs(h.magnitude||0)-Math.abs(c.magnitude||0)),{ranked:m,nA:u.length,nB:o.length,unmatched:{onlyA:d.columns.filter(c=>!n.has(c)),onlyB:a.columns.filter(c=>!t.has(c))},measures:V}}}),Le("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 V}}),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 S}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u}});const x=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,V=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function z(o){if(!o.length)return null;const c=Array.from(o,Number).sort((y,O)=>y-O),h=x(c,.5),s=c.map(y=>Math.abs(y-h)).sort((y,O)=>y-O),p=x(s,.5);return{median:h,mad:p}}function w(o,m={}){const c=Number.isFinite(m.threshold)?m.threshold:X,h=o.length,s=new Array(h).fill(null),p=new Array(h).fill(!1),y=[];for(let b=0;b<h;b++){const v=Number(o[b]);Number.isFinite(v)&&y.push(v)}if(!y.length)return{median:null,mad:null,threshold:c,scores:s,flags:p,flagged:0};const O=z(y);if(O.mad===0)return{median:O.median,mad:0,threshold:c,scores:s,flags:p,flagged:0};let A=0;for(let b=0;b<h;b++){const v=Number(o[b]);if(!Number.isFinite(v))continue;const R=_*(v-O.median)/O.mad;s[b]=R,Math.abs(R)>c&&(p[b]=!0,A++)}return{median:O.median,mad:O.mad,threshold:c,scores:s,flags:p,flagged:A}}function S(o,m={}){const c=Number.isFinite(m.k)?m.k:W,h=[];for(let A=0;A<o.length;A++){const b=Number(o[A]);Number.isFinite(b)&&h.push(b)}if(!h.length)return null;const s=h.sort((A,b)=>A-b),p=x(s,.25),y=x(s,.75),O=y-p;return{q1:p,q3:y,iqr:O,lower:p-c*O,upper:y+c*O,k:c}}function g(o,m){if(m<=0)return 0;const c=I(o);if(m<o+1){let b=o,v=1/o,R=v;for(let j=0;j<1e3&&(b+=1,R*=m/b,v+=R,!(Math.abs(R)<Math.abs(v)*1e-15));j++);return v*Math.exp(-m+o*Math.log(m)-c)}const h=1e-300;let s=m+1-o,p=1/h,y=1/s,O=y;for(let b=1;b<1e3;b++){const v=-b*(b-o);s+=2,y=v*y+s,Math.abs(y)<h&&(y=h),p=s+v/p,Math.abs(p)<h&&(p=h),y=1/y;const R=y*p;if(O*=R,Math.abs(R-1)<1e-15)break}return 1-Math.exp(-m+o*Math.log(m)-c)*O}function l(o,m){return o<=0?0:g(m/2,o/2)}function d(o,m=H){if(!(m>0)||!(m<1))return NaN;let c=0,h=Math.max(1,o);for(;l(h,o)<m;)h*=2;for(let s=0;s<200;s++){const p=(c+h)/2;if(l(p,o)<m?c=p:h=p,h-c<1e-10)break}return(c+h)/2}function a(o){const m=o.length,c=o.map((h,s)=>{const p=h.slice();for(let y=0;y<m;y++)p.push(s===y?1:0);return p});for(let h=0;h<m;h++){let s=h;for(let y=h+1;y<m;y++)Math.abs(c[y][h])>Math.abs(c[s][h])&&(s=y);if(Math.abs(c[s][h])<1e-12)return null;if(s!==h){const y=c[s];c[s]=c[h],c[h]=y}const p=c[h][h];for(let y=0;y<2*m;y++)c[h][y]/=p;for(let y=0;y<m;y++){if(y===h)continue;const O=c[y][h];if(O!==0)for(let A=0;A<2*m;A++)c[y][A]-=O*c[h][A]}}return c.map(h=>h.slice(m))}function r(o,m){const c=o.length,h=new Array(m).fill(0);for(const y of o)for(let O=0;O<m;O++)h[O]+=y[O];for(let y=0;y<m;y++)h[y]/=c;const s=Array.from({length:m},()=>new Array(m).fill(0));for(const y of o)for(let O=0;O<m;O++){const A=y[O]-h[O];for(let b=O;b<m;b++)s[O][b]+=A*(y[b]-h[b])}const p=c>1?c-1:1;for(let y=0;y<m;y++)for(let O=y;O<m;O++)s[y][O]/=p,s[O][y]=s[y][O];return{mean:h,cov:s}}function t(o,m={}){const c=Number.isFinite(m.p)?m.p:H,h=Number.isFinite(m.ridge)?m.ridge:1e-6,s=o.length;if(!s)return null;const p=o[0].length;if(!p)return null;const y=new Array(s).fill(null),O=new Array(s).fill(null),A=new Array(s).fill(!1),b=[],v=[];for(let D=0;D<s;D++){const $=o[D];let P=$.length===p;const k=new Array(p);for(let N=0;P&&N<p;N++){const G=Number($[N]);Number.isFinite(G)?k[N]=G:P=!1}P&&(b.push(D),v.push(k))}const R=p,j=d(R,c);if(v.length<=p)return{center:[],df:R,cutoff:j,singular:!0,used:v.length,distances:y,squared:O,flags:A,flagged:0};const{mean:F,cov:C}=r(v,p);let T=a(C),L=!1;if(!T){L=!0;let D=0;for(let k=0;k<p;k++)D+=C[k][k];const $=D/p*h||h,P=C.map((k,N)=>k.map((G,q)=>N===q?G+$:G));if(T=a(P),!T)return{center:F,df:R,cutoff:j,singular:!0,used:v.length,distances:y,squared:O,flags:A,flagged:0}}let E=0;for(let D=0;D<v.length;D++){const $=v[D],P=new Array(p);for(let G=0;G<p;G++)P[G]=$[G]-F[G];let k=0;for(let G=0;G<p;G++){let q=0;for(let Y=0;Y<p;Y++)q+=T[G][Y]*P[Y];k+=P[G]*q}k<0&&(k=0);const N=b[D];O[N]=k,y[N]=Math.sqrt(k),k>j&&(A[N]=!0,E++)}return{center:F,df:R,cutoff:j,singular:L,used:v.length,distances:y,squared:O,flags:A,flagged:E}}const n=20,i=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function f(o,m={}){const c=m.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",h=Number.isFinite(m.windowLen)&&m.windowLen>=1?Math.floor(m.windowLen):n,s=Number.isFinite(m.threshold)?m.threshold:X,p=Number.isFinite(m.k)?m.k:W,y=Number.isFinite(m.minPeriods)&&m.minPeriods>=1?Math.floor(m.minPeriods):h,O=o.length,A=new Array(O).fill(null),b=new Array(O).fill(!1);let v=0;for(let R=0;R<O;R++){const j=Number(o[R]);if(!Number.isFinite(j))continue;const F=Math.max(0,R-h+1),C=[];for(let T=F;T<=R;T++){const L=Number(o[T]);Number.isFinite(L)&&C.push(L)}if(!(C.length<y))if(c==="rollingIqr"){const T=S(C,{k:p});if(!T)continue;(j<T.lower||j>T.upper)&&(b[R]=!0,v++)}else{const T=z(C);if(!T||T.mad===0)continue;const L=_*(j-T.median)/T.mad;A[R]=L,Math.abs(L)>s&&(b[R]=!0,v++)}}return{method:c,windowLen:h,minPeriods:y,threshold:s,k:p,scores:A,flags:b,flagged:v}}function u(o={}){const m=o||{},c=m.field;if(typeof c!="string"||!c)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const h=m.method||"modifiedZScore";if(!(V.includes(h)||i.includes(h))||h==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${h}'`);const p=typeof m.orderBy=="string"?m.orderBy:null,y=m.latest===!0,O=i.includes(h),A=b=>Number(b==null?NaN:b[c]);return b=>{const v=Array.isArray(b)?b.slice():[...b];p&&v.sort((T,L)=>{const E=T?.[p],D=L?.[p];return E===D?0:E==null?-1:D==null?1:E<D?-1:1});const R=v.map(A);let j,F;if(O)({flags:j,scores:F}=f(R,{method:h,windowLen:m.windowLen,threshold:m.threshold,k:m.k,minPeriods:m.minPeriods}));else if(h==="iqr"){const T=S(R,{k:m.k});j=R.map(L=>T?Number.isFinite(L)&&(L<T.lower||L>T.upper):!1),F=R.map(()=>null)}else({flags:j,scores:F}=w(R,{threshold:m.threshold}));if(y){const T=j.length-1;return T<0||!j[T]?!1:{method:h,field:c,flagged:[{row:v[T],score:F[T]}]}}const C=[];for(let T=0;T<j.length;T++)j[T]&&C.push({row:v[T],score:F[T]});return C.length?{method:h,field:c,flagged:C}:!1}}}),Le("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 r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Q=K("packages/core/src/compute/special.js"),x=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 V(m){const c=[];for(let h=0;h<m.length;h++){const s=m[h];if(s!==null&&typeof s=="object"){const p=Number.isFinite(s.at)?s.at:h,y=Number.isFinite(s.value)?s.value:null;c.push({at:p,value:y})}else c.push({at:h,value:Number.isFinite(s)?Number(s):null})}return c}function z(m){const c=m.filter(O=>O.value!==null),h=c[0],s=c[c.length-1],p=s.at-h.at,y=c.length>1&&p>0?p/(c.length-1):1;return{lastAt:s.at,step:y}}function w(m){return Math.min(H,Math.max(W,m))}function S(m,c=W,h=H,s=80){const p=(Math.sqrt(5)-1)/2;let y=c,O=h,A=O-p*(O-y),b=y+p*(O-y),v=m(A),R=m(b);for(let j=0;j<s;j++)v<R?(O=b,b=A,R=v,A=O-p*(O-y),v=m(A)):(y=A,A=b,v=R,b=y+p*(O-y),R=m(b));return(y+O)/2}function g(m,c){let h=null,s=0,p=0;for(let y=0;y<m.length;y++){const O=m[y];if(O!==null){if(h===null){h=O;continue}s+=(O-h)**2,p+=1,h=c*O+(1-c)*h}}return{level:h,sse:s,m:p}}function l(m,c,h){let s=null,p=null,y=0,O=0;for(let A=0;A<m.length;A++){const b=m[A];if(b===null){s!==null&&p!==null&&(s+=p);continue}if(s===null){s=b;continue}p===null&&(p=b-s);const v=s+p;y+=(b-v)**2,O+=1;const R=s;s=c*b+(1-c)*(R+p),p=h*(s-R)+(1-h)*p}return{level:s,trend:p,sse:y,m:O}}function d(m,c,h,s,p){const y=m.length;if(y<2*c)return null;const O=L=>{let E=0,D=0;for(let $=L;$<L+c&&$<y;$++)m[$]!==null&&(E+=m[$],D+=1);return D?E/D:null},A=O(0),b=O(c);if(A===null||b===null)return null;let v=A,R=(b-A)/c;const j=new Array(c).fill(0);for(let L=0;L<c;L++)j[L]=m[L]===null?0:m[L]-v;const F=j.reduce((L,E)=>L+E,0)/c;for(let L=0;L<c;L++)j[L]-=F;let C=0,T=0;for(let L=c;L<y;L++){const E=L%c,D=j[E],$=m[L];if($===null){v+=R;continue}const P=v+R+D;C+=($-P)**2,T+=1;const k=v;v=h*($-D)+(1-h)*(v+R),R=s*(v-k)+(1-s)*R,j[E]=p*($-v)+(1-p)*D}return{level:v,trend:R,season:j,phase:(y-1)%c,sse:C,count:T}}function a(m,c,h){let s=1;for(const y of c)s+=y*y;const p=Math.sqrt(m*s);return{se:p,margin:h*p}}function r(m,c={}){if(!m||typeof m.length!="number"||m.length===0)return null;const h=X.includes(c.method)?c.method:"linear",s=Math.max(1,Math.floor(Number(c.horizon)||1)),p=Number.isFinite(c.confidence)&&c.confidence>0&&c.confidence<1?c.confidence:.95,y=1-(1-p)/2,O=V(m),A=O.map(C=>C.value),b=A.filter(C=>C!==null),v=b.length,{lastAt:R,step:j}=v?z(O):{lastAt:0,step:1},F=C=>R+C*j;return h==="linear"?t(O,v,s,p,y,F):h==="movingAverage"?n(b,v,s,p,y,c,F):h==="ses"?i(A,v,s,p,y,c,F):h==="holt"?f(A,v,s,p,y,c,F):u(A,v,s,p,y,c,F)}function t(m,c,h,s,p,y){if(c<2)return null;let O=0,A=0;for(const $ of m)$.value!==null&&(O+=$.at,A+=$.value);O/=c,A/=c;let b=0,v=0,R=0;for(const $ of m){if($.value===null)continue;const P=$.at-O,k=$.value-A;b+=P*P,v+=P*k,R+=k*k}if(b===0)return null;const j=v/b,F=A-j*O,C=R===0?1:Math.max(0,Math.min(1,v*v/(b*R))),T=Math.max(0,R-j*v),L=c>2?Math.sqrt(T/(c-2)):null,E=c>2?B(p,c-2):null,D=[];for(let $=1;$<=h;$++){const P=y($),k=F+j*P;let N=null,G=null,q=null,Y=null,J=null;if(L!==null){const te=1/c+(P-O)**2/b,ne=L*Math.sqrt(1+te),oe=L*Math.sqrt(te);J=ne,N=k-E*ne,G=k+E*ne,q=k-E*oe,Y=k+E*oe}D.push({step:$,at:P,mean:k,lower:N,upper:G,lowerMean:q,upperMean:Y,se:J})}return{method:"linear",horizon:h,confidence:s,n:c,sigma:L,r2:C,params:{slope:j,intercept:F},points:D}}function n(m,c,h,s,p,y,O){if(c<1)return null;const A=Math.max(1,Math.min(c,Math.floor(Number(y.windowLen)||c))),b=m.slice(c-A);let v=0;for(const L of b)v+=L;const R=v/A;let j=null,F=null;if(A>1){let L=0;for(const D of b)L+=(D-R)**2;j=Math.sqrt(L/(A-1))*Math.sqrt(1+1/A),F=B(p,A-1)}const C=j===null?null:F*j,T=[];for(let L=1;L<=h;L++)T.push({step:L,at:O(L),mean:R,lower:C===null?null:R-C,upper:C===null?null:R+C,se:j});return{method:"movingAverage",horizon:h,confidence:s,n:c,sigma:j===null?null:j,params:{windowLen:A},points:T}}function i(m,c,h,s,p,y,O){if(c<1)return null;let A=Number.isFinite(y.alpha)?w(y.alpha):null;A===null&&(A=S(F=>g(m,F).sse));const b=g(m,A),v=x(p),R=b.m>0?b.sse/b.m:null,j=[];for(let F=1;F<=h;F++){const C=b.level;let T=null,L=null,E=null;if(R!==null){const D=[];for(let P=1;P<F;P++)D.push(A);const $=a(R,D,v);E=$.se,T=C-$.margin,L=C+$.margin}j.push({step:F,at:O(F),mean:C,lower:T,upper:L,se:E})}return{method:"ses",horizon:h,confidence:s,n:c,sigma:R===null?null:Math.sqrt(R),params:{alpha:A},points:j}}function f(m,c,h,s,p,y,O){if(c<2)return null;let A=Number.isFinite(y.alpha)?w(y.alpha):null,b=Number.isFinite(y.beta)?w(y.beta):null;if(A===null||b===null){let T=A===null?.5:A,L=b===null?.5:b;for(let E=0;E<6;E++)A===null&&(T=S(D=>l(m,D,L).sse)),b===null&&(L=S(D=>l(m,T,D).sse));A=A===null?T:A,b=b===null?L:b}const v=l(m,A,b),R=x(p),j=v.m>0?v.sse/v.m:null,F=A*b,C=[];for(let T=1;T<=h;T++){const L=v.level+T*v.trend;let E=null,D=null,$=null;if(j!==null){const P=[];for(let N=1;N<T;N++)P.push(A+N*F);const k=a(j,P,R);$=k.se,E=L-k.margin,D=L+k.margin}C.push({step:T,at:O(T),mean:L,lower:E,upper:D,se:$})}return{method:"holt",horizon:h,confidence:s,n:c,sigma:j===null?null:Math.sqrt(j),params:{alpha:A,beta:b},points:C}}function u(m,c,h,s,p,y,O){const A=Math.floor(Number(y.period));if(!(A>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(c<2*A)return null;let b=Number.isFinite(y.alpha)?w(y.alpha):null,v=Number.isFinite(y.beta)?w(y.beta):null,R=Number.isFinite(y.gamma)?w(y.gamma):null;const j=($,P,k)=>{const N=d(m,A,$,P,k);return N?N.sse:1/0};if(b===null||v===null||R===null){let $=b===null?.5:b,P=v===null?.5:v,k=R===null?.5:R;for(let N=0;N<8;N++)b===null&&($=S(G=>j(G,P,k))),v===null&&(P=S(G=>j($,G,k))),R===null&&(k=S(G=>j($,P,G)));b=b===null?$:b,v=v===null?P:v,R=R===null?k:R}const F=d(m,A,b,v,R);if(!F)return null;const C=x(p),T=F.count>0?F.sse/F.count:null,L=b*v,E=R*(1-b),D=[];for(let $=1;$<=h;$++){const P=F.season[(F.phase+$)%A],k=F.level+$*F.trend+P;let N=null,G=null,q=null;if(T!==null){const Y=[];for(let te=1;te<$;te++)Y.push(b+te*L+(te%A===0?E:0));const J=a(T,Y,C);q=J.se,N=k-J.margin,G=k+J.margin}D.push({step:$,at:O($),mean:k,lower:N,upper:G,se:q})}return{method:"holtWinters",horizon:h,confidence:s,n:c,sigma:T===null?null:Math.sqrt(T),params:{alpha:b,beta:v,gamma:R,period:A},points:D}}const o={FORECAST_METHODS:X,forecast:r}}),Le("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 o}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return C}});const x=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,V=_.categoricalDistance,z=_.isNumericColumn,w=_.jarqueBera,S=_.proportionInterval,g=_.SUBSET_RELIABILITY_FLOOR,d=K("packages/core/src/compute/compare.js").pooledStandardMeanDifference,a=K("packages/core/src/compute/special.js"),r=a.studentT,t=a.studentTQuantile,n=a.normalCdf,i=a.normalQuantile,f=a.chiSquareUpperTail,u=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),o=.05,m=2e6;function c(T){const L=Number(T);return Number.isFinite(L)&&L>0&&L<1?L:.95}function h(T){const{n:L,mean:E,m2:D}=W(T);return{mean:E,sd:L>0?Math.sqrt(D/L):0,n:L}}function s(T,L){const E=T.length;if(E<2)return 0;let D=0;for(let $=0;$<E;$++){const P=T[$]-L;D+=P*P}return D/(E-1)}function p(T,L){return{name:"pooledStandardMeanDifference",value:d(h(T),h(L))}}function y(T,L,E){const D=T.length,$=L.length;if(D<2||$<2)return null;const P=c(E),{mean:k}=W(T),{mean:N}=W(L),G=s(T,k),q=s(L,N),Y=G/D+q/$;if(!(Y>0))return null;const J=Math.sqrt(Y),te=(k-N)/J,ne=G/D*(G/D)/(D-1),oe=q/$*(q/$)/($-1),le=Y*Y/(ne+oe),ae=Math.min(1,Math.max(0,2*(1-r(Math.abs(te),le)))),se=k-N,ee=t(1-(1-P)/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:P,method:"welch-t (difference of means)"},effectSize:p(T,L),nA:D,nB:$,reliable:D>=g&&$>=g,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function O(T){const L=T.length;if(L===0)return Number.NaN;const E=L>>1;return L%2?T[E]:(T[E-1]+T[E])/2}function A(T,L,E){const D=T.length,$=L.length,P=D*$;if(P===0||P>m)return null;const k=new Float64Array(P);let N=0;for(let ne=0;ne<D;ne++)for(let oe=0;oe<$;oe++)k[N++]=T[ne]-L[oe];k.sort();const G=O(k),q=Math.sqrt(D*$*(D+$+1)/12),Y=i(1-(1-E)/2);let J=Math.round(P/2-Y*q);J>=0||(J=0);const te=Math.floor((P-1)/2);return J>te&&(J=te),{estimate:G,lower:k[J],upper:k[P-1-J],confidence:E,method:"hodges-lehmann (normal approximation)"}}function b(T,L,E){const D=T.length,$=L.length;if(D<1||$<1)return null;const P=c(E),k=D+$,N=new Array(k);for(let ae=0;ae<D;ae++)N[ae]={v:T[ae],g:0};for(let ae=0;ae<$;ae++)N[D+ae]={v:L[ae],g:1};N.sort((ae,se)=>ae.v-se.v);let G=0,q=0,Y=0;for(;Y<k;){let ae=Y;for(;ae<k&&N[ae].v===N[Y].v;)ae++;const se=ae-Y,ee=(Y+1+ae)/2;for(let ie=Y;ie<ae;ie++)N[ie].g===0&&(G+=ee);q+=se*se*se-se,Y=ae}const J=G-D*(D+1)/2,te=D*$/2,ne=D*$/12*(k+1-q/(k*(k-1)));let oe=1;if(ne>0){const ae=Math.max(0,Math.abs(J-te)-.5);oe=Math.min(1,2*n(-ae/Math.sqrt(ne)))}const le=A(T,L,P);return{test:u.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:oe,interval:le,effectSize:p(T,L),nA:D,nB:$,reliable:D>=g&&$>=g,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function v(T,L,E,D,$){const P=S(T,L,$),k=S(E,D,$);if(!P||!k)return null;const N=P.proportion-k.proportion,G=N-Math.sqrt((P.proportion-P.lower)**2+(k.upper-k.proportion)**2),q=N+Math.sqrt((P.upper-P.proportion)**2+(k.proportion-k.lower)**2);return{lower:G,upper:q}}function R(T,L,E,D,$,P={}){if(!(L>0)||!(D>0))return null;const k=new Set([...T.keys(),...E.keys()]),N=k.size;if(N<2)return null;const G=L+D;let q=0;for(const oe of k){const le=T.get(oe)||0,ae=E.get(oe)||0,se=le+ae,ee=L*se/G,ie=D*se/G;ee>0&&(q+=(le-ee)*(le-ee)/ee),ie>0&&(q+=(ae-ie)*(ae-ie)/ie)}const Y=N-1,J=f(q,Y);let te=null;P.category!==void 0&&k.has(P.category)?te=P.category:N===2&&([te]=[...k]);let ne=null;if(te!==null){const oe=v(T.get(te)||0,L,E.get(te)||0,D,c($));oe&&(ne={estimate:(T.get(te)||0)/L-(E.get(te)||0)/D,lower:oe.lower,upper:oe.upper,confidence:c($),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:V(T,L,E,D)},nA:L,nB:D,reliable:L>=g&&D>=g,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function j(T){return T==null||T===""||typeof T=="number"&&Number.isNaN(T)?null:T instanceof Date?T.getTime():typeof T=="object"?String(T):T}function F(T,L,E){if(E===u.WELCH||E===u.MANN_WHITNEY)return{test:E,chosenBy:"override",reason:`caller override: ${E}`};const D=w(T),$=w(L),P=D===null?null:Math.exp(-D/2),k=$===null?null:Math.exp(-$/2);return P!==null&&P<o||k!==null&&k<o?{test:u.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${o})`}:{test:u.WELCH,chosenBy:"auto",reason:P!==null||k!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function C(T,L,E,D={}){if(!T||!L)return null;const $=c(D.confidence),P=I(L);let k;if(Array.isArray(D.groups)&&D.groups.length===2)k=[j(D.groups[0]),j(D.groups[1])];else{const{map:ae}=H(L,E),se=[...ae.entries()].sort((ee,ie)=>ie[1]-ee[1]).slice(0,2).map(ee=>ee[0]);if(se.length<2)return x("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;k=se}const[N,G]=k;if(N===null||G===null||N===G)return x("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=j(P(E[ae]));se===N?q.push(E[ae]):se===G&&Y.push(E[ae])}if(q.length===0||Y.length===0)return x("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(T,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(T,q),se=H(T,Y);ne=R(ae.map,ae.total,se.map,se.total,$,{category:D.category})}else{if((J===u.WELCH||J===u.MANN_WHITNEY)&&!te)return x("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const ae=X(T,q),se=X(T,Y),ee=F(ae,se,J);oe=ee.chosenBy,le=ee.reason,ne=ee.test===u.MANN_WHITNEY?b(ae,se,$):y(ae,se,$)}return ne?{...ne,chosenBy:oe,reason:le,groups:[N,G]}:(x("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Le("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",x=36;function B(_){const X=_.config&&_.config.detailColumnWidth||x;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}),Le("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 x=K("packages/core/src/internal/util.js").isFunction,B="__lattice_tree",I=260;function _(W){const H=W.tree||{},V=W.config&&W.config.treeColumnWidth||I,z=()=>(W.columns&&x(W.columns.visible)?W.columns.visible():[]).find(l=>!l.generated)||null,w=(g,l)=>{if(l&&l.group)return l.groupValue;if(x(H.label))return H.label(g,l);if(typeof H.label=="string")return g==null?null:g[H.label];const d=z();return d&&x(d.getValue)?d.getValue(g,l):null},S=()=>{if(H.title)return H.title;const g=typeof H.label=="string"?W.columns&&x(W.columns.get)?W.columns.get(H.label):null:z();return g&&(g.title||g.id)||"Hierarchy"};return{id:B,get title(){return S()},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:V,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 d=z();if(d&&x(d.formatValue))return d.formatValue(g,l)}return String(g)}}}const X=_}),Le("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 x=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_pivot",I=500;function _(V){const{pivot:z,valueColumns:w,config:S}=V,g=z&&z.paths||[],l=V.separator||S&&S.pivot&&S.pivot.separator||" | ",d=S&&S.pivot&&S.pivot.maxColumns||I;if(!g.length||!w.length)return{tree:[],leaves:[],error:null};const a=X(S),r=g.length*w.length+(a?w.length:0);if(r>d){const i=`pivot would generate ${r} columns, above the limit of ${d}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return x(`pivot.maxColumns:${r}`,i),{tree:[],leaves:[],error:i}}const t=[],n=[];for(const i of g){const f=[];for(const u of w){const o=H(i,u,l);f.push(o),n.push(o)}f.length===1?(f[0].title=String(i),t.push(f[0])):t.push({id:`${B}:group:${i}`,title:String(i),columns:f,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(a){const i=w.map(u=>W(u,S));n.push(...i);const f=S&&S.pivot&&S.pivot.totalsLabel||"Total";if(i.length===1)i[0].title=f,a==="before"?t.unshift(i[0]):t.push(i[0]);else{const u={id:`${B}:group:__totals`,title:f,columns:i,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};a==="before"?t.unshift(u):t.push(u)}}return{tree:t,leaves:n,error:null}}function X(V){const z=V&&V.pivot&&V.pivot.groupTotals;return z==="before"||z==="after"?z:null}function W(V,z){return{id:`${B}:__total${z&&z.pivot&&z.pivot.separator||" | "}${V.id}`,field:null,title:V.title||V.id,type:V.type,dataType:V.dataType,nullable:!0,align:V.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:V.id,total:!0},value:{pure:!0},cell:{align:V.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:V.total,lookup:null,layout:{width:V.layout&&V.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,S){const g=S&&S.totals;return g&&Object.hasOwn(g,V.id)?g[V.id]:null},formatValue(w,S){return w==null?"":V.formatValue?V.formatValue(w,S):String(w)}}}function H(V,z,w){return{id:`${B}:${V}${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:V,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(S,g){return S==null?"":z.formatValue?z.formatValue(S,g):String(S)}}}}),Le("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 S}});const Q=K("packages/core/src/compute/handle.js"),x=Q.dictSize,B=Q.identity,I=Q.presenceReader,_=Q.rowCount,X=Q.valueReader,W="",H="\0",V=1<<20;function z(g,l,d,a){const r=g.length,t=g.map(m=>X(m)),n=Array.isArray(a)&&a.some(Boolean),i=n?t.map((m,c)=>a[c]?h=>a[c](m(h)):m):t;if(!n&&r>0&&g.every(m=>m&&m.kind==="dictionary"&&m.dict)){const m=g.map(h=>x(h.dict)+1);let c=1;for(let h=0;h<r;h++)c*=m[h];if(c<=Number.MAX_SAFE_INTEGER){const h=g.map(O=>O.values),s=g.map(O=>I(O)),p=O=>{let A=0;for(let b=0;b<r;b++){const v=s[b],R=v&&v(O)===0?m[b]-1:h[b][O];A=A*m[b]+R}return A},y=new Float64Array(d);for(let O=0;O<d;O++)y[O]=p(l[O]);return{packed:y,strings:null,product:c,readers:i,keyOf:p}}}const u=m=>{let c="";for(let h=0;h<r;h++){const s=i[h](m);c+=(h===0?"":W)+(s==null?H:String(s))}return c},o=new Array(d);for(let m=0;m<d;m++)o[m]=u(l[m]);return{packed:null,strings:o,product:1/0,readers:i,keyOf:u}}function w(g,l,d,a){const r=new Uint32Array(a+1);for(let f=0;f<d;f++)r[l[f]+1]++;for(let f=0;f<a;f++)r[f+1]+=r[f];const t=new Uint32Array(d),n=r.slice(0,a);for(let f=0;f<d;f++)t[n[l[f]]++]=g[f];const i=new Array(a);for(let f=0;f<a;f++)i[f]=t.subarray(r[f],r[f+1]);return i}function S(g,l,d={}){const a=g||[],r=l||B(_(a[0],d)),t=r.length;if(a.length===0||t===0)return{keys:[],buckets:[]};const{packed:n,strings:i,product:f,readers:u}=z(a,r,t,d.project),o=new Uint32Array(t);let m=0,c=null;if(n&&f<=Math.max(1024,Math.min(V,t*4))){const y=f,O=new Int32Array(y).fill(-1);for(let A=0;A<t;A++)O[n[A]]=0;for(let A=0;A<y;A++)O[A]===0&&(O[A]=m++);for(let A=0;A<t;A++)o[A]=O[n[A]];c=new Float64Array(m);for(let A=0;A<y;A++)O[A]>=0&&(c[O[A]]=A)}else if(n){const y=new Map;for(let O=0;O<t;O++){const A=n[O];let b=y.get(A);b===void 0&&(b=m++,y.set(A,b)),o[O]=b}c=new Float64Array(m);for(const[O,A]of y)c[A]=O}else{const y=new Map;for(let O=0;O<t;O++){const A=i[O];let b=y.get(A);b===void 0&&(b=m++,y.set(A,b)),o[O]=b}}const h=w(r,o,t,m),s=new Array(m);for(let y=0;y<m;y++){const O=h[y][0],A=new Array(u.length);for(let b=0;b<u.length;b++)A[b]=u[b](O);s[y]=A}const p={keys:s,buckets:h};return c&&(p.packed=c),p}}),Le("packages/core/src/compute/pivot.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return V}}),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 S}}),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 x=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,V="|",z="/",w=2e3;function S(f,u,o){return`${f}${V}${u}${V}${o}`}function g(f,u){let o="";for(let m=0;m<f.length;m++){const c=f[m];o+=(m===0?"":u)+(c==null?"":String(c))}return o}function l(f,u,o={}){const m=o.separator||z,c=u.length,{keyOf:h,readers:s}=X(f,u,0),p=new Map,y=[],O=[];for(let C=0;C<c;C++){const T=u[C],L=h(T);if(p.has(L))continue;p.set(L,y.length),O.push(L);const E=new Array(s.length);for(let D=0;D<s.length;D++)E[D]=s[D](T);y.push(E)}const A=I(o.locale),b=y.map((C,T)=>T);b.sort((C,T)=>{const L=y[C],E=y[T];for(let D=0;D<L.length;D++){const $=d(L[D],E[D],A);if($!==0)return $}return C-T});const v=new Array(b.length),R=new Array(b.length),j=new Map;for(let C=0;C<b.length;C++){const T=b[C];v[C]=y[T],R[C]=g(y[T],m),j.set(O[T],C)}return{keys:v,paths:R,idOf:C=>{const T=j.get(h(C));return T===void 0?-1:T}}}function d(f,u,o){const m=f==null,c=u==null;return m||c?m&&c?0:m?1:-1:o(f,u)}function a(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 o=typeof f.handle=="function"?f.handle:null;if(!o)return u.length&&x("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,c=[];for(const h of u){const s=o(h);s&&c.push({colId:h,handle:s,fn:m?m(h):"sum"})}return c}function r(f,u,o){if(Array.isArray(f)){const m=o||{};return{...m,pivotHandles:f,order:u||null,groups:m.groups||null}}return f||{}}function t(f,u,o){const m=r(f,u,o),c=m.separator||z,h=a(m),s=m.maxColumns===void 0?w:m.maxColumns,p=m.groups&&m.groups.buckets?m.groups:null,y=p?p.buckets:[m.order||new Uint32Array(0)],O=m.groupPaths||(p?p.keys.map(L=>g(L,c)):[""]),A=i(y),{keys:b,paths:v,idOf:R}=l(m.pivotHandles||[],A,m),j=v.length*Math.max(1,h.length),F=n(v,h,c);if(s&&j>s){const L=new Map;return{keys:b,paths:v,fields:F,groupPaths:O,columns:j,values:L,cells:L,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${j} columns, above pivot.maxColumns of ${s}. Narrow the pivot columns or raise the limit.`,columns:j,maxColumns:s}}}const C=new Map,T=v.length;for(let L=0;L<y.length;L++){const E=y[L],D=O[L]===void 0?"":O[L],$=E.length;if($===0)continue;const P=new Int32Array($),k=new Uint32Array(T+1);for(let q=0;q<$;q++){const Y=R(E[q]);P[q]=Y,Y>=0&&k[Y+1]++}for(let q=0;q<T;q++)k[q+1]+=k[q];const N=new Uint32Array($),G=k.slice(0,T);for(let q=0;q<$;q++){const Y=P[q];Y>=0&&(N[G[Y]++]=E[q])}for(let q=0;q<T;q++){const Y=k[q],J=k[q+1];if(J===Y)continue;const te=N.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(S(D,v[q],oe.colId),le)}}}return{keys:b,paths:v,fields:F,groupPaths:O,columns:j,values:C,cells:C,error:null}}function n(f,u,o){if(u.length===0)return f.slice();const m=[];for(const c of f)for(const h of u)m.push(`${c}${o}${h.colId}`);return m}function i(f){if(f.length===1)return f[0]||new Uint32Array(0);let u=0;for(const c of f)u+=c?c.length:0;const o=new Uint32Array(u);let m=0;for(const c of f)!c||c.length===0||(o.set(c,m),m+=c.length);return o}}),Le("packages/core/src/store/bitset.js",function(e,K){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return x}});const Q=8;class x{static#e=new Uint8Array(256);static{for(let I=1;I<256;I++)x.#e[I]=x.#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,_=x.#e;let X=0;for(let W=0;W<I.length;W++)X+=_[I[W]];return X}and(I){const _=I instanceof x?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 x?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 x(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 x(_.length);for(let W=0;W<_.length;W++)_[W]&&X.set(W);return X}}}),Le("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"),x=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,V=new Array(H);for(let g=0;g<H;g++)V[g]=g;const z=x(X).compare,w=this.#e;V.sort((g,l)=>this.#s(w[g],w[l],z));const S=new Uint32Array(H);for(let g=0;g<H;g++)S[V[g]]=g;return this.#r=S,this.#o=this.#n,this.#i=W,S}#s(X,W,H){return typeof X=="string"&&typeof W=="string"?H(X,W):B(X,W)}}}),Le("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,V=new Int32Array(Math.max(1,this.#r)),z=new Uint32Array(I+1);let w=0;for(let S=0;S<H;S++){if(B[S]===_)continue;const g=W[S],l=W[S+1];z[B[S]]=w;for(let d=g;d<l;d++)V[w++]=X[d];z[B[S]+1]=w}this.#e=V,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]),V=new Int32Array(Math.max(1,this.#r+H)),z=new Uint32Array(X.length);let w=0;for(let S=0;S<W;S++){if(z[S]=w,S===B)for(let g=0;g<I.length;g++)V[w++]=I[g]|0;else for(let g=X[S];g<X[S+1];g++)V[w++]=_[g];z[S+1]=w}this.#e=V,this.#t=z,this.#r=w}}}),Le("packages/core/src/compute/sort.js",function(e,K){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/compute/handle.js"),x=Q.bitReader,B=Q.dictRanks,I=Q.dictSize,_=Q.identity,X=Q.isMissing,W=Q.presenceReader,H=Q.rowCount,V=Q.valueComparator,z=Q.valueReader,w=new Uint32Array(0),S=new ArrayBuffer(8),g=new Float64Array(S),l=new Uint32Array(S),d=(g[0]=-1,(l[1]&2147483648)!==0?1:0),a=d===1?0:1;function r(E,D){g[0]=E;let $=l[d],P=l[a];($&2147483648)!==0?($=~$>>>0,P=~P>>>0):$=($^2147483648)>>>0,D[0]=P,D[1]=$}function t(E,D,$,P){if(P<2)return E;const k=new Uint32Array(256*8);for(let oe=0;oe<P;oe++){const le=D[oe],ae=$[oe];k[le&255]++,k[256+(le>>>8&255)]++,k[512+(le>>>16&255)]++,k[768+(le>>>24&255)]++,k[1024+(ae&255)]++,k[1280+(ae>>>8&255)]++,k[1536+(ae>>>16&255)]++,k[1792+(ae>>>24&255)]++}let N=E,G=D,q=$,Y=new Uint32Array(P),J=new Uint32Array(P),te=new Uint32Array(P);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(k[le+he]===P){ee=!0;break}if(ee)continue;let ie=0;for(let he=0;he<256;he++)ne[he]=ie,ie+=k[le+he];for(let he=0;he<P;he++){const ge=G[he],Ee=q[he],ye=(se?Ee:ge)>>>ae&255,Ae=ne[ye]++;Y[Ae]=N[he],J[Ae]=ge,te[Ae]=Ee}let de=N;N=Y,Y=de,de=G,G=J,J=de,de=q,q=te,te=de}return N}function n(E,D,$){if($<2)return E;const P=new Uint32Array(256*4);for(let J=0;J<$;J++){const te=D[J];P[te&255]++,P[256+(te>>>8&255)]++,P[512+(te>>>16&255)]++,P[768+(te>>>24&255)]++}let k=E,N=D,G=new Uint32Array($),q=new Uint32Array($);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(P[te+se]===$){oe=!0;break}if(oe)continue;let le=0;for(let se=0;se<256;se++)Y[se]=le,le+=P[te+se];for(let se=0;se<$;se++){const ee=N[se],ie=Y[ee>>>ne&255]++;G[ie]=k[se],q[ie]=ee}let ae=k;k=G,G=ae,ae=N,N=q,q=ae}return k}function i(E,D,$,P){const k=new Uint32Array(P+1);for(let q=0;q<$;q++)k[D[q]]++;let N=0;for(let q=0;q<=P;q++){const Y=k[q];k[q]=N,N+=Y}const G=new Uint32Array($);for(let q=0;q<$;q++)G[k[D[q]]++]=E[q];return G}function f(E,D,$,P){return $<2?E:P<=65536||P<=$*2?i(E,D,$,P):n(E,D,$)}function u(E,D){return E.length===D&&E.byteOffset===0?E:Uint32Array.prototype.slice.call(E,0,D)}function o(E,D,$=!1){const P=D||_(E.length),k=P.length;if(k<2)return Uint32Array.from(P);const N=new Uint32Array(k),G=new Uint32Array(k),q=new Uint32Array(k),Y=new Uint32Array(k),J=new Uint32Array(2);let te=0,ne=0;for(let ae=0;ae<k;ae++){const se=P[ae],ee=E[se];if(Number.isNaN(ee)){Y[ne++]=se;continue}r(ee,J),$?(G[te]=~J[0]>>>0,q[te]=~J[1]>>>0):(G[te]=J[0],q[te]=J[1]),N[te++]=se}const oe=t(N.subarray(0,te),G.subarray(0,te),q.subarray(0,te),te);if(ne===0)return u(oe,te);const le=new Uint32Array(k);return le.set(oe.subarray(0,te),0),le.set(Y.subarray(0,ne),te),le}function m(E,D,$=!1){const P=D||_(E.length),k=P.length;if(k<2)return Uint32Array.from(P);const N=Uint32Array.from(P),G=new Uint32Array(k);for(let q=0;q<k;q++){const Y=(E[N[q]]^2147483648)>>>0;G[q]=$?~Y>>>0:Y}return u(n(N,G,k),k)}function c(E,D,$={}){const P=D||_(H(E,$)),k=P.length;if(k<2)return Uint32Array.from(P);const N=B(E.dict,$.locale),G=E.values,q=W(E),Y=Math.max(I(E.dict),N.length),J=Y,te=Uint32Array.from(P),ne=new Uint32Array(k),oe=!!$.descending;for(let le=0;le<k;le++){const ae=te[le];let se=q&&q(ae)===0?J:N[G[ae]];se===void 0&&(se=J),ne[le]=oe?J-se:se}return u(f(te,ne,k,Y+1),k)}function h(E,D,$){const P=D.length;let k=Uint32Array.from(D);if(P<2)return k;let N=new Uint32Array(P);for(let G=1;G<P;G<<=1){for(let Y=0;Y<P;Y+=G<<1){const J=Math.min(Y+G,P),te=Math.min(Y+(G<<1),P);let ne=Y,oe=J,le=Y;for(;ne<J&&oe<te;)N[le++]=$(E[k[ne]],E[k[oe]])<=0?k[ne++]:k[oe++];for(;ne<J;)N[le++]=k[ne++];for(;oe<te;)N[le++]=k[oe++]}const q=k;k=N,N=q}return k}function s(E,D,$){const P=x(E.values),k=D.length,N=new Uint32Array(k),G=$?1:0;let q=0;for(let Y=0;Y<k;Y++)P(D[Y])===G&&(N[q++]=D[Y]);for(let Y=0;Y<k;Y++)P(D[Y])!==G&&(N[q++]=D[Y]);return N}function p(E,D){const $=E.values,P=E.kind;if((P==="object"||P===void 0)&&(Array.isArray($)||ArrayBuffer.isView($))&&!E.presence)return $;const N=z(E),G=new Array(H(E)||0);for(let q=0;q<D.length;q++){const Y=D[q];G[Y]=N(Y)}return G}function y(E,D){for(let $=0;$<D.length;$++)if(typeof E[D[$]]!="string")return!1;return!0}function O(E,D,$,P,k){const N=E.length,G=Uint32Array.from(E);if(N<2||P<1)return G;const q=new Uint32Array(N),Y=P-1;for(let J=0;J<N;J++){const te=$[D[J]];q[J]=k?Y-te:te}return u(f(G,q,N,P),N)}function A(E,D,$){const P=V($),k=new Array(D);for(let G=0;G<D;G++)k[G]=G;k.sort((G,q)=>P(E[G],E[q])||G-q);const N=new Uint32Array(D);for(let G=0;G<D;G++)N[k[G]]=G;return N}function b(E,D,$){const P=D.length,k=new Map,N=[],G=new Uint32Array(P);for(let J=0;J<P;J++){const te=E[D[J]];let ne=k.get(te);ne===void 0&&(ne=N.length,k.set(te,ne),N.push(te)),G[J]=ne}const q=N.length,Y=A(N,q,$.locale);return O(D,G,Y,q,!!$.descending)}function v(E,D,$){const P=p(E,D);if(D.length>=2&&y(P,D)){const G=E.stringRank;return G&&G.version===E.version&&G.usable(D,P,$.locale)?G.sort(D,$):b(P,D,$)}const k=V($.locale),N=$.descending?(G,q)=>k(q,G):k;return h(P,D,N)}function R(E,D,$){const P=p(E,D),k=$.compare,G=!!$.descending?(q,Y)=>-k(q,Y,void 0,void 0,!0):(q,Y)=>k(q,Y,void 0,void 0,!1);return h(P,D,G)}function j(E,D){const $=D.length,P=W(E),k=E.values,N=E.kind==="float64"&&!!k,G=E.kind==="object"||E.kind==="multi"||E.kind===void 0;if(!P&&!N&&!G)return{present:D,absent:w};const q=new Uint32Array($),Y=new Uint32Array($);let J=0,te=0;if(P&&N)for(let ne=0;ne<$;ne++){const oe=D[ne];P(oe)===1&&!Number.isNaN(k[oe])?q[J++]=oe:Y[te++]=oe}else if(N&&!P)for(let ne=0;ne<$;ne++){const oe=D[ne];Number.isNaN(k[oe])?Y[te++]=oe:q[J++]=oe}else if(P&&!G)for(let ne=0;ne<$;ne++){const oe=D[ne];P(oe)===1?q[J++]=oe:Y[te++]=oe}else{const ne=z(E);for(let oe=0;oe<$;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 F(E,D,$){if(D.length===0)return E;const P=new Uint32Array(E.length+D.length);return $?(P.set(D,0),P.set(E,D.length)):(P.set(E,0),P.set(D,E.length)),P}function C(E,D,$={}){const P=D||_(H(E,$));if(!E||P.length<2)return Uint32Array.from(P);const{present:k,absent:N}=j(E,P);if(k.length===0)return Uint32Array.from(P);const G=!!$.descending;let q;if(typeof $.compare=="function")q=R(E,k,$);else switch(E.kind){case"float64":q=o(E.values,k,G);break;case"int32":q=m(E.values,k,G);break;case"dictionary":q=c(E,k,$);break;case"bitset":q=s(E,k,G);break;default:q=v(E,k,$);break}return F(q,N,!!$.nullsFirst)}function T(E,D,$,P={}){const k=D||[],N=k.length&&(k[0].handle||L(E,k[0].col))||E&&E[0];let G=$||_(H(N,P));for(let q=k.length-1;q>=0;q--){const Y=k[q],J=Y.handle||L(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:P.locale,compare:Y.compare}))}return G instanceof Uint32Array?G:Uint32Array.from(G)}function L(E,D){if(!(!E||D===void 0)){for(let $=0;$<E.length;$++)if(E[$]&&E[$].id===D)return E[$]}}}),Le("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"),x=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 V=0;V<H.length;V++)W+=H[V].length*2+24;return W}#d(W,H){const V=this.#t.get(W);if(V!==void 0)return V;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 V=H|0;this.#e=[],this.#t=new Map,this.#o=0,this.#l=!1,this.#a=null,this.#u=-1,this.#n=new Uint32Array(V);for(let z=0;z<V;z++){const w=W[z],S=typeof w=="string"?this.#d(w,!1):-1;this.#n[z]=S<0?0:S}this.#r=V}append(W,H,V){const z=(H|0)+(V|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 S=W[w],g=typeof S=="string"?this.#d(S,!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 V=x(this.#e,this.#e.length,W);return this.#a=V,this.#u=this.#o,this.#c=H,V}usable(W,H,V){if(this.#l||this.#e.length===0)return!1;const z=this.#n,w=this.#e,S=this.#r;for(let g=0;g<W.length;g++){const l=W[g];if(l>=S||w[z[l]]!==H[l])return!1}return!0}sort(W,H){const V=this.ranks(H.locale),z=this.#e.length,w=W.length,S=new Uint32Array(w),g=this.#n;for(let l=0;l<w;l++)S[l]=g[W[l]];return B(W,S,V,z,!!H.descending)}}}),Le("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 n}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return c}});const Q=K("packages/core/src/internal/util.js"),x=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,S=K("packages/core/src/store/stringrank.js").StringRankIndex,g=4294967295,l=1024,d=5e3,a=.2,r=new Set(["float64","int32","bitset","dictionary","object","multi"]);function t(h){return h==null}function n(h){if(typeof h=="number")return h;if(h instanceof Date)return h.getTime();if(typeof h=="boolean")return h?1:0;const s=Number(h);return Number.isNaN(s)&&typeof h=="string"?Date.parse(h):s}function i(h){const s=n(h);return Number.isFinite(s)?s|0:0}function f(h){return t(h)?[]:Array.isArray(h)?h:[h]}function u(h,s){switch(h.kind){case"float64":case"int32":return h.buf[s];case"bitset":return h.bits.get(s)===1;case"dictionary":return h.dict.valueOf(h.buf[s]);case"multi":{const p=h.mv.at(s),y=new Array(p.length);for(let O=0;O<p.length;O++)y[O]=h.dict.valueOf(p[O]);return y}default:return h.buf[s]}}function o(h,s){switch(h.kind){case"float64":case"int32":return h.values[s];case"bitset":return(h.values[s>>3]&1<<(s&7))!==0;case"dictionary":return(h.table||[])[h.values[s]];case"multi":{const p=h.offsets[s],y=h.offsets[s+1],O=h.table||[],A=new Array(y-p);for(let b=p;b<y;b++)A[b-p]=O[h.values[b]];return A}default:return h.values[s]}}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;#y=0;#b=0;#j=null;#w=null;#S=!1;constructor(s,p){this.#e=s.id;const y=r.has(s.kind)?s.kind:"object";s.kind&&!r.has(s.kind)&&x(`store.kind.${s.id}`,`column "${s.id}" declares unknown storage kind "${s.kind}"; falling back to object`),this.#n=y,this.#t=y,this.#r=s.nullable!==!1,this.#s=s.dictionary??null,this.#i=p,this.#o=B(s.read)?s.read:I(s.field||s.id),this.#h=s.stringRankIndex!=="off",this.#p=typeof s.stringRankMaxDistinct=="number"?s.stringRankMaxDistinct:0,this.#j=new Map}get id(){return this.#e}get kind(){return this.#l?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#S?null:this.#l?this.#t==="bitset"?this.#u.words:this.#t==="multi"?this.#c.values:this.#a:this.#E().values}get presence(){return this.#S||!this.#r?null:this.#l?this.#g:this.#E().presence}get dict(){return this.#S||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#S||!this.#h||this.kind!=="object")return null;const s=this.values,p=this.#i.physical();if(!s||p===0)return null;if(this.#f===null){if(typeof s[0]!="string")return null;const y=new S(this.#v());return y.build(s,p),y.version=this.#b,this.#f=y,this.#m=this.#b,y.capped?null:y}return this.#f.length<p&&this.#f.append(s,this.#f.length,p-this.#f.length),this.#f.version=this.#b,this.#m=this.#b,this.#f.capped?null:this.#f}#v(){return this.#p}#C(){this.#f=null,this.#m=-1}get offsets(){return this.#S||!this.#l||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#b}get bytes(){let s=0;return this.#a&&(s+=this.#a.byteLength??this.#a.length*8),this.#u&&(s+=this.#u.bytes),this.#c&&(s+=this.#c.bytes),this.#g&&(s+=this.#g.bytes),this.#d&&(s+=this.#d.bytes),this.#j&&(s+=this.#j.size*24),s}get(s){if(!this.#S&&!(s<0||s>=this.#i.physical())){if(!this.#l)return this.#M(s);if(this.#r&&this.#g.get(s)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[s];case"bitset":return this.#u.get(s)===1;case"dictionary":return this.#d.valueOf(this.#a[s]);case"multi":{const p=this.#c.at(s),y=new Array(p.length);for(let O=0;O<p.length;O++)y[O]=this.#d.valueOf(p[O]);return y}default:return this.#a[s]}}}set(s,p){this.#S||(this.#l?this.#P(s,p):this.#j.set(s,p===void 0?null:p),this.#f&&this.#C(),this.#b++)}read(s){return this.#o(s)}appendColumn(s,p,y){if(this.#S||y<=0)return;if(!this.#l){this.#b++;return}const O=this.#o,A=this.#r,b=this.#g;let v=!1;switch(this.#t){case"float64":{const R=this.#a;for(let j=0;j<y;j++){const F=O(s[j]);if(typeof F=="number"){A&&b.set(p+j),R[p+j]=F;continue}const C=F==null;A?b.assign(p+j,!C):C&&(v=!0),R[p+j]=C?NaN:n(F)}break}case"int32":{const R=this.#a;for(let j=0;j<y;j++){const F=O(s[j]),C=F==null;A?b.assign(p+j,!C):C&&(v=!0),R[p+j]=C?0:i(F)}break}case"bitset":{const R=this.#u;for(let j=0;j<y;j++){const F=O(s[j]),C=F==null;A?b.assign(p+j,!C):C&&(v=!0),R.assign(p+j,!C&&!!F)}break}case"dictionary":{const R=this.#a,j=this.#d;for(let F=0;F<y;F++){const C=O(s[F]),T=C==null;A?b.assign(p+F,!T):T&&(v=!0),R[p+F]=T?0:j.codeOf(C)}break}case"multi":{const R=this.#c,j=this.#d;for(let F=0;F<y;F++){const C=O(s[F]),T=C==null;A?b.assign(p+F,!T):T&&(v=!0);const L=f(C),E=new Array(L.length);for(let D=0;D<L.length;D++)E[D]=j.codeOf(L[D]);R.write(p+F,E)}break}default:{const R=this.#a;for(let j=0;j<y;j++){const F=O(s[j]),C=F==null;A?b.assign(p+j,!C):C&&(v=!0),R[p+j]=C?null:F}break}}v&&x(`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,y),this.#f.version=this.#b+1,this.#m=this.#b+1),this.#b++}appendPacked(s,p,y){if(this.#S||y<=0||!s)return;if(!this.#l){this.#b++;return}const O=this.#g,A=s.presence;if(O)if(A)for(let v=0;v<y;v++)O.assign(p+v,(A[v>>3]&1<<(v&7))!==0);else for(let v=0;v<y;v++)O.set(p+v);const b=s.kind===this.#t;if(b&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(s.values,p),this.#b++;return}if(b&&this.#t==="bitset"){const v=s.values;for(let R=0;R<y;R++)this.#u.assign(p+R,(v[R>>3]&1<<(R&7))!==0);this.#b++;return}if(b&&this.#t==="dictionary"){const v=s.table||[],R=new Uint32Array(v.length);for(let T=0;T<v.length;T++)R[T]=this.#d.codeOf(v[T]);const j=s.values,F=this.#a,C=O;for(let T=0;T<y;T++){if(C&&(A&&(A[T>>3]&1<<(T&7))===0)){F[p+T]=0;continue}F[p+T]=R[j[T]]??0}this.#b++;return}if(b&&this.#t==="multi"){const v=s.table||[],R=new Uint32Array(v.length);for(let C=0;C<v.length;C++)R[C]=this.#d.codeOf(v[C]);const j=s.values,F=s.offsets;for(let C=0;C<y;C++){const T=F[C],L=F[C+1],E=new Array(L-T);for(let D=T;D<L;D++)E[D-T]=R[j[D]]??0;this.#c.write(p+C,E)}this.#b++;return}for(let v=0;v<y;v++){const R=A?(A[v>>3]&1<<(v&7))===0:s.kind==="object"?s.values[v]===null:!1;this.#P(p+v,R?null:o(s,v))}this.#b++}touch(){this.#b++}columnarise(s,p){if(this.#l||this.#S)return;const y=new Array(p);for(let O=0;O<p;O++)y[O]=this.#M(O);this.#t=this.#n,this.#l=!0,this.#O(s);for(let O=0;O<p;O++)this.#P(O,y[O]);this.#j.clear(),this.#w=null,this.#C(),this.#b++}grow(s){if(!(!this.#l||this.#S||s<=this.#y)){switch(this.#t){case"float64":case"int32":case"dictionary":{const p=new this.#a.constructor(s);p.set(this.#a),this.#a=p;break}case"bitset":this.#u.grow(s);break;case"multi":break;default:this.#a.length=s;break}this.#g&&this.#g.grow(s),this.#y=s,this.#b++}}convert(s){if(this.#S||!r.has(s)||(this.#n=s,!this.#l||s===this.#t))return!1;const p={kind:this.#t,buf:this.#a,bits:this.#u,mv:this.#c,dict:this.#d},y=this.#i.physical(),O=this.#g;this.#t=s,this.#O(this.#y);for(let A=0;A<y;A++){const b=O!==null&&O.get(A)===0;b&&s!=="multi"||this.#P(A,b?null:u(p,A))}return this.#C(),this.#b++,!0}compact(s,p,y){if(!this.#S){if(this.#C(),!this.#l){const O=this.#j;if(O.size){const A=new Map;for(const[b,v]of O)s[b]!==g&&A.set(s[b],v);this.#j=A}this.#w=null,this.#b++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const O=this.#a;for(let A=0;A<p;A++)s[A]!==g&&(O[s[A]]=O[A]);if(this.#t==="object")for(let A=y;A<p;A++)O[A]=void 0;break}case"bitset":{const O=this.#u;for(let A=0;A<p;A++)s[A]!==g&&O.assign(s[A],O.get(A)===1);for(let A=y;A<p;A++)O.clear(A);break}case"multi":this.#c.compact(s,y,g);break;default:break}if(this.#g){const O=this.#g;for(let A=0;A<p;A++)s[A]!==g&&O.assign(s[A],O.get(A)===1);for(let A=y;A<p;A++)O.clear(A)}this.#b++}}release(){this.#S||(this.#S=!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.#j=new Map,this.#w=null,this.#y=0,this.#b++)}#O(s){const p=Math.max(1,s);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.#y=p}#P(s,p){const y=t(p);switch(this.#r?this.#g.assign(s,!y):y&&x(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[s]=y?NaN:n(p);break;case"int32":this.#a[s]=y?0:i(p);break;case"bitset":this.#u.assign(s,!y&&!!p);break;case"dictionary":this.#a[s]=y?0:this.#d.codeOf(p);break;case"multi":{const O=f(p),A=new Array(O.length);for(let b=0;b<O.length;b++)A[b]=this.#d.codeOf(O[b]);this.#c.write(s,A);break}default:this.#a[s]=y?null:p;break}}#M(s){if(this.#j.has(s))return this.#j.get(s);const p=this.#o(this.#i.rowAt(s));return p===void 0?null:p}#E(){if(this.#w&&this.#w.version===this.#b)return this.#w;const s=this.#i.physical(),p=new Array(s),y=this.#r?new X(s):null;for(let O=0;O<s;O++){const A=this.#M(O);p[O]=A,y&&!t(A)&&y.set(O)}return this.#w={version:this.#b,values:p,presence:y},this.#w}}class c{#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(s,p={}){this.#e=Array.isArray(s)?s:[],this.#f=Math.max(1,p.initialCapacity??l),this.#c=p.retainSource!==!1,this.#d=this.#c?p.columnarBelow??d:0,this.#h=p.compactRatio??a;const y={rowAt:O=>this.#r[O],physical:()=>this.#o};for(const O of this.#e){if(!O||!O.id)continue;if(this.#t.has(O.id)){x(`store.dup.${O.id}`,`duplicate column id "${O.id}" in the store schema; ignoring the second`);continue}const A=new m(O,y);this.#t.set(O.id,A),this.#n.push(A)}this.#d<=0&&this.#y()}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 s=this.#a.bytes+this.#r.length*8;for(const p of this.#n)s+=p.bytes;return s}append(s){const p=this.#o;if(this.#p||!s)return{from:p,to:p};const y=s.length|0;if(y===0)return{from:p,to:p};if(this.#c)for(let A=0;A<y;A++)this.#r[p+A]=s[A];if(this.#o=p+y,this.#s+=y,this.#a.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#y();else for(const A of this.#n)A.touch();return{from:p,to:this.#o}}this.#m(this.#o);const O=this.#n;for(let A=0;A<O.length;A++)O[A].appendColumn(s,p,y);return{from:p,to:this.#o}}appendPacked(s,p){const y=this.#o;if(this.#p||!s)return{from:y,to:y};const O=s.count|0;if(O===0)return{from:y,to:y};if(this.#c&&p)for(let b=0;b<O;b++)this.#r[y+b]=p[b];this.#o=y+O,this.#s+=O,this.#a.grow(this.#o),this.#u||this.#y(),this.#m(this.#o);const A=new Map;for(const b of s.columns)A.set(b.id,b);for(const b of this.#n){const v=A.get(b.id);v?b.appendPacked(v,y,O):b.grow(this.#i)}return{from:y,to:this.#o}}source(s){if(this.#c)return this.#r[s];if(!(s<0||s>=this.#o))return this.#g(s)}setSource(s,p){this.#p||s<0||s>=this.#o||this.#c&&(this.#r[s]=p)}get(s,p){const y=this.#t.get(s);return y?y.get(p):void 0}set(s,p,y){if(this.#p||p<0||p>=this.#o)return;const O=this.#t.get(s);if(!O){x(`store.set.${s}`,`set() on unknown column "${s}"`);return}O.set(p,y)}remove(s){return this.#p||s<0||s>=this.#o||this.#a.get(s)===1?!1:(this.#a.set(s),this.#l++,this.#s--,!0)}live(s){return s<0||s>=this.#o?!1:this.#a.get(s)===0}compact(s={}){if(this.#p||this.#l===0||!s.force&&this.#l/this.#o<this.#h)return null;const p=this.#o,y=new Uint32Array(p);let O=0;for(let A=0;A<p;A++)y[A]=this.#a.get(A)===1?g:O++;for(const A of this.#n)A.compact(y,p,O);if(this.#c){const A=this.#r;for(let b=0;b<p;b++)y[b]!==g&&(A[y[b]]=A[b]);A.length=O}return this.#o=O,this.#s=O,this.#l=0,this.#a=new X(Math.max(this.#i,O)),y}column(s){return this.#t.get(s)}columns(){return this.#n.slice()}liveIndices(){const s=new Uint32Array(this.#s);if(this.#l===0){for(let y=0;y<this.#o;y++)s[y]=y;return s}let p=0;for(let y=0;y<this.#o;y++)this.#a.get(y)===0&&(s[p++]=y);return s}convert(s,p){const y=this.#t.get(s);return y?y.convert(p):!1}destroy(){if(!this.#p){this.#p=!0;for(const s of this.#n)s.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(s){if(s<=this.#i)return;let p=this.#i||this.#f;for(;p<s;)p*=2;for(const y of this.#n)y.grow(p);this.#a.grow(p),this.#i=p}#g(s){const p={};for(const y of this.#n)p[y.id]=y.get(s);return p}#y(){if(this.#u)return;let s=this.#f;for(;s<this.#o;)s*=2;this.#u=!0,this.#i=s,this.#a.grow(s);for(const p of this.#n)p.columnarise(s,this.#o)}}}),Le("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,x=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??x}get bytes(){return this.#r}mask(H){const V=new Uint8Array(this.#i(H),0,H);return V.fill(0),V}indices(H){return new Uint32Array(this.#i(H*4),0,H)}release(H){if(!H||!H.buffer)return!1;const V=H.buffer;if(!this.#t.has(V))return!1;this.#t.delete(V),this.#o.released++;const z=V.byteLength;let w=this.#e.get(z);return w||this.#e.set(z,w=[]),w.length>=this.#n||(w.push(V),this.#r+=z),!0}releaseAll(H){for(const V of H)this.release(V)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(H){const V=B(H),z=this.#e.get(V);this.#o.acquired++;let w;return z&&z.length?(w=z.pop(),this.#r-=V,this.#o.reused++):w=new ArrayBuffer(V),this.#t.add(w),w}}function _(){return X??=new I,X}let X=null}),Le("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 x}}),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(X){return!!X&&typeof X.compare!="function"}function B(X){if(!X)return!0;for(let W=0;W<X.length;W++)if(!x(X[W]))return!1;return!0}function I(X,W){const H=X.col!==void 0?X.col:X.handle&&X.handle.id,V=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(V)}}function _(X,W){const H=X||[],V=new Array(H.length);for(let z=0;z<H.length;z++)V[z]=I(H[z],W);return V}}),Le("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 V}}),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 S}}),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 r}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const Q=K("packages/core/src/compute/handle.js"),x=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,V=50,z=1e4;function w(A,b){if(!A)return"none";const v=b;if(v&&(v.multi===!0||typeof v.items=="function"))return"category";const R=b&&b.base;if(R==="date"||R==="datetime"||R==="time"||R==="dateString")return"date";switch(A.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 S(A){const b=A.values,v=A.kind;if((v==="float64"||v==="int32")&&b)return j=>b[j];const R=B(A);return j=>g(R(j))}function g(A){if(typeof A=="number")return A;if(A instanceof Date)return A.getTime();if(A==null||A==="")return NaN;if(typeof A=="boolean")return A?1:0;if(typeof A=="string"){const b=Number(A);if(Number.isFinite(b))return b;const v=Date.parse(A);return Number.isFinite(v)?v:NaN}return NaN}function l(A,b,v,R=V){if(!A)return{cardinality:0,exact:!0};if(A.dict)return{cardinality:I(A.dict),exact:!0};if(A.kind==="bitset")return{cardinality:2,exact:!0};const j=B(A),F=b?b.length:v,C=new Set;for(let T=0;T<F;T++){const L=j(b?b[T]:T);if(L!=null&&(C.add(L),C.size>R))return{cardinality:C.size,exact:!1}}return{cardinality:C.size,exact:!0}}const d=36e5,a=864e5;function r(A,b=H){const v=Number.isFinite(A)&&A>0?A:0,R=Math.max(1,b)*2;return v/d<=R?"hour":v/a<=R?"day":v/(7*a)<=R?"week":v/(30*a)<=R?"month":v/(91*a)<=R?"quarter":"year"}function t(A,b){if(!Number.isFinite(A))return NaN;const v=new Date(A);switch(b){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 n(A,b){const v=new Date(A);switch(b){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 i(A,b,v){const R=S(A),j=x(A),F=b?b.length:v;let C=1/0,T=-1/0,L=0,E=0;for(let D=0;D<F;D++){const $=b?b[D]:D;if(j&&!j($)){L++;continue}const P=R($);if(!Number.isFinite(P)){L++;continue}P<C&&(C=P),P>T&&(T=P),E++}return{min:C,max:T,nulls:L,finite:E}}function f(A,b,v,R){const j=S(A),F=x(A),C=b?b.length:v,T=C>R?C/R:1,L=[];for(let D=0;D<C;D+=T){const $=b?b[Math.floor(D)]:Math.floor(D);if(F&&!F($))continue;const P=j($);Number.isFinite(P)&&L.push(P)}const E=Float64Array.from(L);return E.sort(),E}function u(A,b,v,R={}){const j=R.kind||w(A,R.type);return j==="none"||!A?{kind:"none",buckets:[],suppressed:"type"}:j==="boolean"?o(A,b,v):j==="category"?m(A,b,v,R):c(A,b,v,j,R)}function o(A,b,v){const R=x(A);let j=0;if(R){const C=b?b.length:v;for(let T=0;T<C;T++)R(b?b[T]:T)||j++}const F=[{value:!1,label:"false"},{value:!0,label:"true"}];return j>0&&F.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:F}}function m(A,b,v,R){const j=R.cardinalityLimit??V,{cardinality:F}=l(A,b,v,j);if(F>j&&(R.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:F};const C=B(A),T=b?b.length:v,L=new Map;let E=0;for(let N=0;N<T;N++){const G=C(b?b[N]:N);if(G==null||G===""){E++;continue}if(Array.isArray(G)){if(!G.length){E++;continue}for(const q of G)L.set(q,(L.get(q)||0)+1);continue}L.set(G,(L.get(G)||0)+1)}let D=[...L.entries()];R.order==="alpha"?D.sort((N,G)=>String(N[0]).localeCompare(String(G[0]))):D.sort((N,G)=>G[1]-N[1]);let $=0,P=0;if(D.length>j){P=D.length-j;for(let N=j;N<D.length;N++)$+=D[N][1];D=D.slice(0,j)}const k=D.map(([N])=>({value:N,label:String(N)}));return $>0&&k.push({remainder:!0,label:`Other (${P} values)`}),E>0&&k.push({null:!0,label:"Empty"}),{kind:"category",buckets:k,cardinality:F}}function c(A,b,v,R,j){const{min:F,max:C,nulls:T,finite:L}=i(A,b,v);if(!L)return{kind:R,buckets:T?[{null:!0,label:"Empty"}]:[],empty:!0};const E=Math.max(1,Math.floor(j.buckets||H));let D=[];if(R==="date"){const P=W.includes(j.granularity)?j.granularity:r(C-F,E);let k=t(F,P);for(;k<=C&&D.length<4096;){const N=n(k,P);if(!(N>k))break;D.push({from:k,to:N}),k=N}return{kind:R,buckets:h(D,T),granularity:P}}const $=X.includes(j.strategy)?j.strategy:"equal";if($==="quantile"){const P=f(A,b,v,z);if(P.length){const k=[P[0]];for(let N=1;N<E;N++){const G=P[Math.min(P.length-1,Math.floor(N/E*P.length))];G>k[k.length-1]&&k.push(G)}k.push(C);for(let N=0;N<k.length-1;N++)D.push({from:k[N],to:k[N+1]})}}else if($==="log"&&F>0){const P=Math.log10(F),N=(Math.log10(C)-P)/E||1;for(let G=0;G<E;G++)D.push({from:10**(P+G*N),to:10**(P+(G+1)*N)})}if(!D.length){const P=(C-F)/E||1;for(let k=0;k<E;k++)D.push({from:F+k*P,to:F+(k+1)*P})}return D[D.length-1].to=C,{kind:R,buckets:h(D,T),strategy:$,min:F,max:C}}function h(A,b){return b>0?[...A,{null:!0,label:"Empty"}]:A}function s(A,b,v,R,j){const F=R&&R.buckets||[],C=j&&j.length>=F.length?j.subarray(0,F.length):new Uint32Array(F.length);if(C.fill(0),!A||!F.length)return C;const T=F.length-1,L=!!F[T]&&F[T].null===!0,E=b?b.length:v;if(R.kind==="boolean"){const N=B(A);for(let G=0;G<E;G++){const q=N(b?b[G]:G);if(q==null){L&&C[T]++;continue}C[q?1:0]++}return C}if(R.kind==="category"){const N=new Map;for(let Y=0;Y<F.length;Y++)!F[Y].null&&!F[Y].remainder&&N.set(F[Y].value,Y);const G=F.findIndex(Y=>Y.remainder),q=B(A);for(let Y=0;Y<E;Y++){const J=q(b?b[Y]:Y);if(J==null||J===""){L&&C[T]++;continue}if(Array.isArray(J)){if(!J.length){L&&C[T]++;continue}for(const ne of J){const oe=N.get(ne);oe!==void 0?C[oe]++:G>=0&&C[G]++}continue}const te=N.get(J);te!==void 0?C[te]++:G>=0&&C[G]++}return C}const D=L?F.length-1:F.length,$=new Float64Array(D+1);for(let N=0;N<D;N++)$[N]=F[N].from;$[D]=D?F[D-1].to:0;const P=S(A),k=x(A);for(let N=0;N<E;N++){const G=b?b[N]:N;if(k&&!k(G)){L&&C[T]++;continue}const q=P(G);if(!Number.isFinite(q)){L&&C[T]++;continue}const Y=p($,D,q);Y>=0&&C[Y]++}return C}function p(A,b,v){if(!b||v<A[0])return-1;if(v>=A[b])return v===A[b]?b-1:-1;let R=0,j=b-1;for(;R<j;){const F=R+j+1>>>1;v>=A[F]?R=F:j=F-1}return R}function y(A,b,v,R={}){const j=R.bounds||u(A,R.boundsIndices??b,v,R);return{bounds:j,counts:s(A,b,v,j)}}const O=y}),Le("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 S}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return t}});const x=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,V=W.DEFAULT_PATH_SEPARATOR,z=W.DEFAULT_MAX_COLUMNS,w="";function S(n,i,f={}){const u=f.separator||V,o=n||[],m=i instanceof Uint32Array?i:Uint32Array.from(i||[]),c=m.length;if(o.length===0)return{tuples:[[]],paths:[w],buckets:[m]};const{keyOf:h,readers:s}=X(o,m,0),p=new Map,y=[],O=[],A=[];for(let C=0;C<c;C++){const T=m[C],L=h(T);let E=p.get(L);if(E===void 0){E=y.length,p.set(L,E),O.push(L);const D=new Array(s.length);for(let $=0;$<s.length;$++)D[$]=s[$](T);y.push(D),A.push([])}A[E].push(T)}const b=x(f.locale),v=y.map((C,T)=>T);v.sort((C,T)=>{const L=y[C],E=y[T];for(let D=0;D<L.length;D++){const $=g(L[D],E[D],b);if($!==0)return $}return C-T});const R=new Array(v.length),j=new Array(v.length),F=new Array(v.length);for(let C=0;C<v.length;C++){const T=v[C];R[C]=y[T],j[C]=H(y[T],u),F[C]=Uint32Array.from(A[T])}return{tuples:R,paths:j,buckets:F}}function g(n,i,f){const u=n==null,o=i==null;return u||o?u&&o?0:u?1:-1:f(n,i)}function l(n,i,f){const u=[];for(let o=0;o<n.length;o++)f.has(n[o])&&u.push(n[o]);return Uint32Array.from(u)}function d(n,i,f,u){return{value:i.length?I(n,i,f,u):null,leaves:i,count:i.length}}function a(n){const i=n&&n.opts||{},f=i.separator||V,u=i.totalContext||{locale:i.locale},o=(n.measures||[]).filter(j=>j&&j.handle),m=n.leaves instanceof Uint32Array?n.leaves:Uint32Array.from(n.leaves||[]),c=S(n.rowHandles||[],m,{...i,separator:f}),h=S(n.columnHandles||[],m,{...i,separator:f}),s=i.maxColumns===void 0?z:i.maxColumns,p=h.paths.length*Math.max(1,o.length),y=new Map;if(s&&p>s)return{rowAxis:c,columnAxis:h,measures:o.map(j=>({colId:j.colId,fn:j.fn})),body:y,rowMargin:y,columnMargin:y,grand:y,columns:p,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${p} columns, above pivot.maxColumns of ${s}. Narrow the pivot columns or raise the limit.`,columns:p,maxColumns:s}};const O=new Map,A=new Map,b=new Map,v=new Map,R=h.buckets.map(j=>new Set(j));for(let j=0;j<h.paths.length;j++){const F=h.buckets[j],C=h.paths[j];for(const T of o)b.set(t(C,T.colId),d(T.handle,F,T.fn,u))}for(let j=0;j<c.paths.length;j++){const F=c.buckets[j],C=c.paths[j];for(const T of o)A.set(t(C,T.colId),d(T.handle,F,T.fn,u));for(let T=0;T<h.paths.length;T++){const L=l(F,h.buckets[T],R[T]);if(L.length===0)continue;const E=h.paths[T];for(const D of o)O.set(r(C,E,D.colId),d(D.handle,L,D.fn,u))}}for(const j of o)v.set(j.colId,d(j.handle,m,j.fn,u));return{rowAxis:c,columnAxis:h,measures:o.map(j=>({colId:j.colId,fn:j.fn})),body:O,rowMargin:A,columnMargin:b,grand:v,columns:p,error:null}}function r(n,i,f){return`${n}\0${i}\0${f}`}function t(n,i){return`${n}\0${i}`}}),Le("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 d}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return a}});const x=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="",V="\0";function z(n,i){const f=i.includes(".")?x(n,i):n?.[i];return f===void 0?null:f}function w(n,i,f={}){const u=i||[];let o=n.map((m,c)=>c);if(u.length===0)return o;for(let m=u.length-1;m>=0;m--)o=S(n,o,u[m],f);return o}function S(n,i,f,u){const o=f.locale!==void 0?f.locale:u.locale,m=_(o),c=f.descending!==void 0?!!f.descending:f.dir==="desc",h=[],s=[];for(const O of i){const A=z(n[O],f.col);I(A)?s.push(O):h.push(O)}const p=new Map;for(let O=0;O<h.length;O++)p.set(h[O],O);const y=(O,A)=>{const b=z(n[O],f.col),v=z(n[A],f.col);let R;return typeof f.compare=="function"?(R=f.compare(b,v,n[O],n[A],c),c&&(R=-R)):R=c?m(v,b):m(b,v),R!==0?R:p.get(O)-p.get(A)};return h.sort(y),f.nullsFirst?s.concat(h):h.concat(s)}function g(n,i,f={}){const u=[];for(let o=0;o<n.length;o++)l(n[o],i,f,o)&&u.push(o);return u}function l(n,i,f,u){if(!i)return!0;if(Array.isArray(i.conditions)){const o=i.conditions.filter(c=>c!=null);if(o.length===0)return!0;if(i.op==="or")return o.some(c=>l(n,c,f,u));const m=o.every(c=>l(n,c,f,u));return i.op==="not"?!m:m}return i.col===void 0&&typeof f.custom=="function"?!!f.custom(i,n,u):W(z(n,i.col),i,f.locale)}function d(n,i,f,u){const o=f||n.map((s,p)=>p),m=new Map,c=[],h=[];for(const s of o){const p=i.map((A,b)=>{const v=z(n[s],A);return u&&u[b]?u[b](v):v}),y=p.map(A=>A==null?V:String(A)).join(H);let O=m.get(y);O===void 0&&(O=c.length,m.set(y,O),c.push(p),h.push([])),h[O].push(s)}return{keys:c,buckets:h}}function a(n,i,f={}){const u=_(f.locale),o=n.filter(c=>!I(c)),m=o.map(r).filter(c=>c!==null);switch(i){case"count":return n.length;case"countValues":return o.length;case"sum":return m.reduce((c,h)=>c+h,0);case"avg":return o.length===0?null:m.reduce((c,h)=>c+h,0)/o.length;case"min":return o.length===0?null:o.reduce((c,h)=>u(h,c)<0?h:c);case"max":return o.length===0?null:o.reduce((c,h)=>u(h,c)>0?h:c);case"first":return n.length===0?null:t(n[0]);case"last":return n.length===0?null:t(n[n.length-1]);default:return null}}function r(n){if(typeof n=="number")return Number.isNaN(n)?null:n;if(n==null||n===""||typeof n=="boolean")return null;if(n instanceof Date)return n.getTime();const i=Number(n);return Number.isNaN(i)?null:i}function t(n){return n===void 0?null:n}}),Le("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 x=K("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return x.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return x.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return x.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return x.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return x.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 V=K("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return V.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return V.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return V.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return V.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return V.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return V.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 S=K("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return S.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return S.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return S.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 d=K("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return d.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return d.forecast}})}),Le("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 V}}),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"),x=Q.warnOnce,B=Q.isFunction,I=32,_="\0";function X(d){return new W(d)}class W{#e;#t;constructor(a){this.#e=B(a&&a.rowKey)?a.rowKey:null;const r=a&&a.config?a.config.rowHeight:void 0;this.#t=typeof r=="number"||B(r)?r:I}get keyed(){return this.#e!==null}keyOf(a,r){if(this.#e){const t=this.#e(a);if(t!=null)return String(t)}else x("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${r}`}heightOf(a){return B(this.#t)?Number(this.#t(a))||I:this.#t}leaf(a,r,t=0,n=null){const i={key:this.keyOf(a,r),data:a,level:t,parent:n,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:r};return i.height=this.heightOf(i),i}group(a){const r={key:g(a.keyPath||a.path),data:null,level:a.level,parent:a.parent||null,children:[],group:!0,expanded:a.expanded!==!1,leafCount:a.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:a.column,groupValue:a.value,groupPath:a.path,hasChildren:a.hasChildren!==!1};return a.totals&&(r.totals=a.totals),r.height=this.heightOf(r),r}footer(a){const r={key:`${a.key}${_}footer`,data:null,level:a.level,parent:a,group:!0,footer:!0,expanded:!1,leafCount:a.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:a.groupColumn,groupValue:a.groupValue,groupPath:a.groupPath,hasChildren:!1,totals:a.totals};return r.height=this.heightOf(r),r}detail(a,r){return{key:`${a.key}${_}detail`,data:a.data,level:a.level+1,parent:a,group:!1,detail:!0,expanded:!1,leafCount:0,height:r,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:a.key}}grandTotal(a,r){const t={key:`${_}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:r,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:a};return t.height=this.heightOf(t),t}skeleton(a,r=0,t=!1){const n={key:`${_}pending${_}${a}`,data:null,level:r,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:a,selected:!1,physical:null,pending:!0};return t&&(n.loadError=!0),n.height=this.heightOf(n),n}}function H(d,a,r,t){return{key:`${_}pinned${_}${r}${_}${a}`,data:d,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,pinned:r}}function V(d,a){return new Proxy([],{get(r,t,n){if(t==="length")return d();if(typeof t=="string"){const i=Number(t);if(Number.isInteger(i)&&i>=0)return a(i)}return Reflect.get(r,t,n)},has(r,t){if(typeof t=="string"){const n=Number(t);if(Number.isInteger(n)&&n>=0)return n<d()}return Reflect.has(r,t)}})}function z(d){return d==null?"":String(d)}const w="";function S(d){if(d==null)return w;const a=String(d);return a.startsWith(w)?w+a:a}function g(d){const a=d||[];let r="g";for(let t=0;t<a.length;t++)r+=_+S(a[t]);return r}function l(d){const a=new Array(d.length),r=[];for(let t=0;t<d.length;t++)r.push(d[t]),a[t]=g(r);return a}}),Le("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"),x=Q.isFunction,B=Q.warnOnce;class I{#e;#t;#n;#r=new Map;#o=0;constructor(W,H,V){this.#e=W,this.#t=H,this.#n=x(V)?V:()=>!1}get store(){const W=this.#e.store;return W&&x(W.column)?W:null}invalidate(){this.#o++}handle(W){const H=this.store;if(H){const S=H.column(W);if(S)return S}const V=this.#r.get(W);if(V&&V.builtAt===this.#o)return V.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&&x(H.get)?H.get(W):void 0}#s(W){const H=this.#t()||[],V=H.length,z=new Array(V),w=x(W.getValue)?g=>W.getValue(g):g=>g?.[W.field||W.id];for(let g=0;g<V;g++)z[g]=H[g]===void 0?void 0:w(H[g]);const S=this.#o;return{id:W.id,kind:"object",nullable:!1,values:z,presence:null,dict:null,offsets:null,get(g){return z[g]},version:S}}}function _(X,W,H){return new I(X,W,H)}}),Le("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 V}});const x=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=x(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 S=0;S<w.length;S++){const g=W(w[S]);g!==null&&this.#u(g)}this.#s=!0}seedColumn(w,S,g){this.#a();for(let l=0;l<g.length;l++){const d=g[l];if(S&&S(d)===0)continue;const a=w[d];Number.isNaN(a)||this.#u(a)}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 S=this.#t+w;this.#n+=Math.abs(this.#t)>=Math.abs(w)?this.#t-S+w:w-S+this.#t,this.#t=S,this.#r++,w<this.#o&&(this.#o=w),w>this.#i&&(this.#i=w)}#c(w){const S=this.#t-w;this.#n+=Math.abs(this.#t)>=Math.abs(w)?this.#t-S-w:-w-S+this.#t,this.#t=S,this.#r--}update(w,S){if(!this.#s)return!1;const g=W(w),l=W(S);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 V=H}),Le("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 V}}),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 n}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return i}}),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 o}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return b}});const x=K("packages/core/src/internal/util.js").warnOnce,B="source.remote.hostFilter",I="source.where.pageRelative";function _(j,F){!Array.isArray(j)||!j.length||x(I,`filters.where (${j.join(", ")}) runs over the rows the ${F} 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(j){const F=(j||{}).config;!F||!F.hostFilter||x(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(j,F){x(`${W}:${j}`,`filters.where("${j}") is registered but the ${F} 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 V="source.where.overThreshold";function z(j,F,C,T){!Array.isArray(j)||!j.length||x(`${V}:${F}`,`filters.where (${j.join(", ")}) is not applied to the ${F} 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 ${T.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 S(j){let F=w.get(j);return F||(F=new Intl.DateTimeFormat("en-US",{timeZone:j,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),w.set(j,F)),F}function g(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function l(j,F){const C=S(F).formatToParts(new Date(j)),T={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const L of C)L.type==="year"?T.y=+L.value:L.type==="month"?T.m=+L.value:L.type==="day"?T.d=+L.value:L.type==="hour"?T.h=+L.value%24:L.type==="minute"?T.mi=+L.value:L.type==="second"&&(T.s=+L.value);return T}function d(j,F){const C=l(j,F);return Date.UTC(C.y,C.m-1,C.d,C.h,C.mi,C.s)-Math.floor(j/1e3)*1e3}function a(j,F,C,T){const L=Date.UTC(j,F-1,C),E=L-d(L,T);return L-d(E,T)}function r(j,F,C){const T=new Date(Date.UTC(j.y,j.m-1,j.d+F));return a(T.getUTCFullYear(),T.getUTCMonth()+1,T.getUTCDate(),C)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function n(j,F){if(typeof j!="string")return null;const C=j.trim().toLowerCase().replace(/[\s_-]+/g,""),T=/^last(\d*|n)days?$/.exec(C);if(T){const L=T[1]==="n"?"":T[1],E=Number(L||F);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 i(j,F={}){const C=n(j,F.n);if(!C)return null;const T=F.tz||g(),L=F.now instanceof Date?F.now.getTime():typeof F.now=="number"?F.now:Date.now(),E=l(L,T),D=a(E.y,E.m,E.d,T),$=r(E,1,T);let P=D,k=$;switch(C.kind){case"today":break;case"yesterday":P=r(E,-1,T),k=D;break;case"lastNDays":k=F.includeToday?$:D,P=r(E,F.includeToday?-(C.n-1):-C.n,T);break;case"thisWeek":{const N=Number.isFinite(F.weekStartsOn)?Number(F.weekStartsOn):1,q=(new Date(Date.UTC(E.y,E.m-1,E.d)).getUTCDay()-N+7)%7;P=r(E,-q,T),k=r(E,-q+7,T);break}case"thisMonth":P=a(E.y,E.m,1,T),k=a(E.m===12?E.y+1:E.y,E.m===12?1:E.m+1,1,T);break;case"thisQuarter":case"quarterToDate":{const N=Math.floor((E.m-1)/3)*3+1;P=a(E.y,N,1,T),k=C.kind==="quarterToDate"?$:N===10?a(E.y+1,1,1,T):a(E.y,N+3,1,T);break}case"thisYear":case"yearToDate":P=a(E.y,1,1,T),k=C.kind==="yearToDate"?$:a(E.y+1,1,1,T);break;default:return null}return{from:new Date(P).toISOString(),to:new Date(k).toISOString(),bounds:"[)",tz:T,relative:C.kind==="lastNDays"?`last${C.n}Days`:C.kind,n:C.n}}function f(j){if(!j||typeof j!="object")return null;const F=j.value;if(F&&typeof F=="object"&&!Array.isArray(F)&&"relative"in F)return{token:String(F.relative),n:typeof F.n=="number"?F.n:void 0};if(j.op==="relative"&&typeof j.value=="string")return{token:j.value,n:void 0};const C=j.meta;return C&&typeof C.relative=="string"&&j.value===void 0?{token:C.relative,n:typeof C.n=="number"?C.n:void 0}:null}function u(){return`Known tokens: ${t.filter(F=>F!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function o(j){const F=f(j);return F?n(F.token,F.n)!==null:!1}function m(j,F={}){const C=f(j);if(!C)return j;const T=i(C.token,{...F,n:C.n});return T?{...j,type:j.type||"date",op:"between",value:[T.from,T.to],bounds:j.bounds||T.bounds,meta:{...j.meta||{},relative:T.relative,tz:T.tz}}:(x(`source.relative.${C.token}`,`unknown relative date token "${C.token}"; sending the condition unresolved.`,u()),j)}function c(j){return!!j&&typeof j=="object"&&Array.isArray(j.conditions)}function h(j,F){if(j){if(c(j)){for(const C of j.conditions)h(C,F);return}F(j)}}function s(j,F){if(!j)return null;if(!c(j))return F(j);const C=j;let T=!1;const L=[];for(const E of C.conditions){const D=s(E,F);D!==E&&(T=!0),D&&L.push(D)}return!T&&L.length===C.conditions.length?j:L.length?{...C,conditions:L}:null}function p(j){if(!j)return null;if(!c(j))return j;const F=j,C=[];for(const T of F.conditions){const L=p(T);L&&C.push(L)}return C.length?{op:F.op,conditions:C}:null}function y(j){const F=p(j);return F?c(F)&&F.op==="and"?F:{op:"and",conditions:[F]}:null}function O(j){const F=(j||[]).filter(Boolean);return F.length?{op:"and",conditions:F}:null}function A(j,F={}){const C=s(j,T=>m(T,F));return y(C)}function b(j){const F=v(j.filters??null);return JSON.stringify([F,j.sort??null,j.quick??"",j.groupBy??null,j.pivotBy??null,R(j.context)])}function v(j){if(!j)return null;if(c(j)){const T=j;return{op:T.op,conditions:T.conditions.map(v)}}const F=j,C=F.meta&&typeof F.meta.relative=="string"?F.meta.relative:f(F)?.token;return{col:F.col,op:F.op,bounds:F.bounds??null,caseSensitive:F.caseSensitive??!1,value:C?`rel:${C}`:F.value??null}}function R(j){if(j==null)return null;try{return JSON.parse(JSON.stringify(j))}catch{return x("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Le("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 S}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,I="",_="\0tree:";function X(l,d){return{physical:l,key:d,level:0,children:[],value:void 0}}function W(l,d){const a=[],r=new Map;for(let t=0;t<l.length;t++){const n=l[t],i=d.pathOf(n),f=Array.isArray(i)?i.map(o=>String(o)):[];if(!f.length){const o=X(n,d.keyOf(n));a.push(o);continue}let u=null;for(let o=0;o<f.length;o++){const m=f.slice(0,o+1).join(I),c=o===f.length-1;let h=r.get(m);h&&c&&h.physical===-1&&(h.physical=n,h.key=d.keyOf(n)),h||(h=X(c?n:-1,c?d.keyOf(n):_+m),h.level=o,h.value=f[o],r.set(m,h),u?u.children.push(h):a.push(h)),u=h}}return{roots:a,nodes:r}}function H(l,d){const a=new Map,r=[];for(let f=0;f<l.length;f++){const u=l[f],o=d.keyOf(u),m=X(u,o);a.set(o,m);const c=d.parentOf(u);c!=null&&c!==""&&r.push({node:m,parent:String(c)})}let t=null;const n=new Map;for(const{node:f,parent:u}of r){const o=a.get(u);if(o){n.set(f.key,o);continue}d.orphans&&d.orphans!=="root"&&(t||(t=X(-1,`${_}orphans`),t.value=d.orphans),n.set(f.key,t))}const i=[];for(const f of a.values()){const u=n.get(f.key);u?u.children.push(f):i.push(f)}return t&&t.children.length&&i.push(t),{roots:V(i,a,d.orphans,t),nodes:a}}function V(l,d,a,r){const t=new Set,n=[...l];for(;n.length;){const m=n.pop();if(!t.has(m.key)){t.add(m.key);for(const c of m.children)n.push(c)}}const i=[];for(const m of d.values())t.has(m.key)||i.push(m);if(!i.length)return l;const f=!!a&&a!=="root";B("tree.cycle",`tree.parentKey produced ${i.length} row(s) inside a parent cycle; `+(f?`they are shown under "${a}".`:"they are shown at the root."));for(const m of i)m.children=m.children.filter(c=>t.has(c.key));if(!f)return[...l,...i];let u=r;const o=[...l];return u||(u=X(-1,`${_}orphans`),u.value=a,o.push(u)),u.children.push(...i),o}function z(l){let d=0;const a=(r,t)=>{for(const n of r)n.level=t,t>d&&(d=t),n.children.length&&a(n.children,t+1)};return a(l,0),d}function w(l,d){if(!l||typeof l!="object")return null;const a=l.path,r=l.parentKey,t=x(l.hasChildren)?n=>!!l.hasChildren(d.dataAt(n)):null;if(x(a))return{mode:"path",pathOf:n=>a(d.dataAt(n)),keyOf:d.keyOf,declaresChildren:t};if(r!=null){const n=x(r)?r:i=>i?.[r];return{mode:"parentKey",parentOf:i=>n(d.dataAt(i)),keyOf:d.keyOf,orphans:l.orphans||"root",declaresChildren:t}}return B("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function S(l,d){const a=d.mode==="path"?W(l,d):H(l,d),r=z(a.roots);return{...a,depth:r}}function g(l,d){const a=new Map,r=t=>{for(let n=0;n<t.length;n++){const i=t[n];if(i.physical>=0){const f=d?d(i.physical):!1,u=f&&i.children.length===0;a.set(i.physical,{level:i.level,posinset:n+1,setsize:t.length,hasChildren:i.children.length>0||f,lazy:u})}i.children.length&&r(i.children)}};return r(l),a}}),Le("packages/core/src/source/memory.js",function(e,K){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return A}}),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 $}});const Q=K("packages/core/src/internal/util.js"),x=Q.Lru,B=Q.warnOnce,I=Q.fail,_=Q.isFunction,X=Q.defaultCompare,W=Q.mergeRow,H=K("packages/core/src/source/rows.js"),V=H.createRowFactory,z=H.groupKey,w=H.groupPathElement,S=H.groupPrefixKeys,g=H.lazyRowView,d=K("packages/core/src/source/handles.js").createHandleProvider,a=K("packages/core/src/compute/incremental.js"),r=a.RunningTotal,t=a.isIncremental,i=K("packages/core/src/compute/handle.js").presenceReader,f=K("packages/core/src/source/filterwire.js"),u=f.querySignature,o=f.mapConditions,m=f.resolveRelativeCondition,c=K("packages/core/src/source/tree.js"),h=c.buildTree,s=c.resolveTree,p=c.indexTree,y=Object.freeze(["filter","sort","group","total","pivot","flatten"]),O=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function A(P){const k=P&&typeof P=="object"?P.reason:null;return typeof k=="string"&&O.includes(k)}const b=Object.freeze([]);function v(P,k){if(!P)return null;const N=k==="grand"?P.grandTotal:P.groupTotal;return N??P.total}function R(P){return!!P&&!P.running}function j(P){if(P)return P.value&&_(P.value.compare)?P.value.compare:_(P.compare)?P.compare:void 0}function F(P){const k=P&&P.dataType;return!k||!_(k.items)?null:{items:k.items,type:P.itemType&&P.itemType.name||"text"}}function C(P){return!!P&&(typeof P=="object"||typeof P=="function")&&_(P.then)}const T=new Uint32Array(0),L=4096;function E(P,k){return new $(P,k)}function D(P,k){if(k==="regex")try{const N=new RegExp(P,"iu");return G=>N.test(G)}catch{return N=>N.includes(P)}if(k==="fuzzy"){const N=[...P].filter(G=>G!==" ");return N.length?G=>{let q=0;for(let Y=0;Y<G.length&&q<N.length;Y++)G[Y]===N[q]&&q++;return q===N.length}:()=>!0}if(k==="words"){const N=P.split(/\s+/).filter(Boolean);return N.length?G=>N.every(q=>G.includes(q)):()=>!0}return N=>N.includes(P)}class ${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=$.#g();static#g(){return{slots:[],groupHeadings:b,unnumbered:b,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#y=new Map;#b=null;#j=new Map;#w=-1;#S=[];#v=new Map;#C=-1;#O=[];#P=null;#M=null;#E=null;#T=null;#N=null;#L=null;#B=null;#_=null;#z=Symbol("unset");#$=new Map;#q=null;get#I(){return this.#m.slots}set#I(k){this.#m.slots=k}get#W(){return this.#m.inlineLeaves}set#W(k){this.#m.inlineLeaves=k}get#H(){return this.#m.groupHeadings}set#H(k){this.#m.groupHeadings=k}get#U(){return this.#m.unnumbered}set#U(k){this.#m.unnumbered=k}get#he(){return this.#m.pivot}set#he(k){this.#m.pivot=k}constructor(k,N){this.#t=k||{mode:"memory"},this.#e=N||{};const G=this.#e.config||{};this.#n=this.#t.rows||G.rows||[],this.#i=V(this.#e),this.#s=d(this.#e,()=>this.#n,()=>this.#r),this.#h=new x(Number(G.rowCacheSize)||L);for(const q of y)this.#l.set(q,{key:null,result:null,id:0,computed:!1})}count(){this.#D();const k=this.#ie();return k?k.length:this.#I.length}#ie(){const k=Number(this.#V("pageSize",0))||0;if(k<=0)return null;const N=this.#I.length,G=Math.max(1,Math.ceil(N/k)),Y=Math.min(Math.max(0,Number(this.#V("page",0))||0),G-1)*k;return{offset:Y,length:Math.max(0,Math.min(k,N-Y))}}pageInfo(){this.#D();const k=Number(this.#V("pageSize",0))||0,N=this.#I.length;if(k<=0)return{page:0,pageSize:0,total:N,pageCount:1};const G=Math.max(1,Math.ceil(N/k));return{page:Math.min(Math.max(0,Number(this.#V("page",0))||0),G-1),pageSize:k,total:N,pageCount:G}}totalCount(){return this.#de().length}matchCount(){return this.#D(),this.#m.matchCount}at(k){this.#D();const N=this.#ie();if(N)return k<0||k>=N.length?void 0:this.#Fe(N.offset+k,k);if(!(k<0||k>=this.#I.length))return this.#Fe(k,k)}byKey(k){this.#D(),this.#p||this.#Te();const N=this.#p.get(k);if(N!==void 0)return this.#je(N);for(let G=0;G<this.#I.length;G++){const q=this.#I[G];if(typeof q!="number"&&q&&q.key===k)return this.#Fe(G)}}loaded(k){return k>=0&&k<this.count()}hint(k,N){}display(){return this.#D(),this.#q||(this.#q=this.#Mt()),this.#q}invalidateQuickText(){this.#$.clear(),this.invalidate("filter")}invalidate(k){const N=y.indexOf(k);N<0&&I(`unknown pipeline stage "${k}"; expected one of ${y.join(", ")}`);for(let G=N;G<y.length;G++){const q=this.#l.get(y[G]);q.key=null,q.computed=!1}this.#q=null}apply(k){const N=[],G={added:[],updated:[],removed:[],rejected:N};if(!k)return G;let q=!1;const Y=new Set;if(k.remove&&k.remove.length)for(const J of k.remove){const te=this.#me(J);if(te===void 0){N.push({operation:"remove",id:this.#we(J),reason:"unknown-id"});continue}G.removed.push(this.#i.keyOf(this.#r?this.#ue(te):this.#n[te],te)),this.#r||(this.#n[te]=void 0),this.#h.delete(te),this.#$.delete(te),q=!0}if(k.update&&k.update.length){const J=this.#j.size||this.#Ke()?this.#Xe():null,te=this.#v.size?this.#kt():null,ne=te&&te.length?this.#Xe():null;for(const oe of k.update){const le=this.#me(oe);if(le===void 0){N.push({operation:"update",id:this.#Ee(oe),reason:"unknown-id"});continue}const ae=this.#r?this.#o&&this.#o.has(le)?this.#o.get(le):this.#ue(le):this.#n[le],se=W(ae,oe);for(const ee of this.#te(ae,se))Y.add(ee);if(this.#r||(this.#n[le]=se),J&&this.#Tt(J,le,ae,se),ne&&this.#lt(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.#$.delete(le),G.updated.push(this.#je(le))}}if(k.add&&k.add.length&&this.#r){typeof k.at=="number"&&k.at<this.#Me()&&(this.#h.clear(),this.#$.clear()),this.#p=null;for(const J of k.add){const te=this.#se(this.#Ee(J));te!==void 0&&G.added.push(this.#je(te))}q=!0}else if(k.add&&k.add.length){const J=typeof k.at=="number"?k.at:this.#n.length,te=this.#n.length;let ne=k.add===this.#n?k.add.slice():k.add;if(this.#i.keyed){const oe=[];for(const le of ne){const ae=this.#Ee(le);if(this.#me(ae)!==void 0){N.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.#$.clear();for(let oe=0;oe<ne.length;oe++)G.added.push(this.#je(J>=te?te+oe:J+oe));q=!0}return this.#u++,q&&(this.#p=null,this.#nt()),this.#s.invalidate(),this.#q=null,q||this.#Z(Y)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#Qe("rows:changed",{companion:!0,added:G.added.length,updated:G.updated.length,removed:G.removed.length}),this.#o=null,G}groupHeadingsAt(k){this.#D();const N=this.#H;if(!N.length||!Number.isInteger(k)||k<0)return b;let G=0,q=N.length-1,Y=-1;for(;G<=q;){const te=G+q>>1;N[te].at<=k?(Y=te,G=te+1):q=te-1}if(Y<0)return b;const J=[];for(let te=N[Y].row;te;te=te.parent)J.push(te);return J.reverse(),J}unnumberedRowCount(k){this.#D();const N=this.#U;if(!N.length||!Number.isInteger(k)||k<0)return 0;let G=0,q=N.length-1,Y=-1;for(;G<=q;){const J=G+q>>1;N[J].at<=k?(Y=J,G=J+1):q=J-1}return Y+1}moveRow(k,N){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(k)||!Number.isInteger(N)||k<0||k>=G.length)return!1;const q=Math.max(0,Math.min(G.length-1,N));if(q===k)return!1;const[Y]=G.splice(k,1);return G.splice(q,0,Y),this.#u++,this.#c++,this.#p=null,this.#h.clear(),this.#$.clear(),this.#nt(),this.#s.invalidate(),this.#q=null,this.invalidate("filter"),this.#Qe("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(k){this.#ye(),this.#u++,this.#c++,this.#p=null,this.#$.clear(),this.#h.clear(),this.#nt(),this.#s.invalidate(),this.invalidate("filter"),this.#Qe("model:changed",{reason:"reload"})}destroy(){this.#ye(),this.#h.clear(),this.#$.clear(),this.#p=null,this.#I=[],this.#W=null,this.#q=null,this.#nt();for(const k of y)this.#l.set(k,{key:null,result:null,id:0,computed:!1})}#ye(){for(const{controller:k}of this.#y.values())try{k.abort()}catch{}this.#y.clear()}setRows(k){this.#n=k||[],this.#r=!1,this.#u++,this.#c++,this.#p=null,this.#$.clear(),this.#h.clear(),this.#nt(),this.#s.invalidate(),this.invalidate("filter")}notePriorRows(k){this.#o=k||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#$.clear(),this.#s.invalidate()}data(){if(!this.#r)return this.#n;const k=this.#e.store;if(!k||!_(k.source))return this.#n;const N=k.physical||0,G=new Array(N);for(let q=0;q<N;q++)G[q]=k.live&&!k.live(q)?void 0:k.source(q);return G}#Ie(){const k=this.#V("detail",null);return!k||!_(k.isOpen)||k.inline===!1?null:k}#be(){const k=(this.#e.config||{}).tree;return this.#z!==k&&(this.#z=k,this.#_=s(k,{dataAt:N=>this.#ue(N),keyOf:N=>this.#i.keyOf(this.#ue(N),N)})),this.#_}#pe(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#pe())return null;this.#D();const k=this.#m.grand;return k?this.#i.grandTotal(k,this.#et(this.#m.grandLeaves)):null}pivot(){return this.#D(),this.#he}pivotMatrix(){this.#D();const k=this.#m.groupLeaves,N=(this.#e.compute||{}).pivotMatrix;if(!_(N))return null;const G=this.#V("groupBy",[]),q=this.#V("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.#Xe().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 N({rowHandles:G.map(te=>this.#s.handle(te)).filter(Boolean),columnHandles:q.map(te=>this.#s.handle(te)).filter(Boolean),measures:Y,leaves:k||new Uint32Array(0),opts:{locale:J.locale,separator:(J.pivot||{}).separator,maxColumns:(J.pivot||{}).maxColumns}})}keysForLeaves(k){const N=[];if(!k)return N;for(let G=0;G<k.length;G++){const q=this.#je(k[G]);q&&q.key!=null&&N.push(String(q.key))}return N}leavesOf(k){this.#D();const N=this.#l.get("group"),G=N&&N.result;if(!G||!G.nodes)return[];const q=G.nodes.get(k);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.#je(te.leaves[oe]))};return J(q),Y}#we(k){return typeof k=="string"?k:this.#Ee(k)}#Ee(k){try{return this.#i.keyOf(k,-1)}catch{return"(unkeyed)"}}#me(k){if(typeof k=="string")return this.#se(k);if(this.#i.keyed){const G=this.#i.keyOf(k,-1),q=this.#se(G);if(q!==void 0)return q}if(this.#r)return;const N=this.#n.indexOf(k);return N>=0?N:void 0}#se(k){return this.#p||this.#Te(),this.#p.get(k)}#Te(){this.#p=new Map;const k=this.#Me(),N=this.#e.store,G=N&&_(N.live)?q=>N.live(q):null;for(let q=0;q<k;q++){if(G&&!G(q))continue;const Y=this.#ue(q);Y!==void 0&&this.#p.set(this.#i.keyOf(Y,q),q)}}#te(k,N){const G=[];for(const q of this.#K())this.#ze(q)&&this.#ne(q,k,N,new Set)&&G.push(q);return G}#ne(k,N,G,q){if(q.has(k))return!1;q.add(k);const Y=this.#ze(k);if(!Y)return!1;const J=Y.value&&Y.value.deps;return Array.isArray(J)&&J.length?J.some(te=>this.#ne(String(te),N,G,q)):_(Y.getValue)?!Object.is(Y.getValue(N),Y.getValue(G)):!1}#K(){const k=new Set;for(const G of this.#V("sort",[]))k.add(G.col);for(const G of this.#V("groupBy",[]))k.add(G);const N=G=>{if(G){if(Array.isArray(G.conditions)){G.conditions.forEach(N);return}G.col&&k.add(G.col)}};return N(this.#V("filters",null)),[...k]}#Z(k){if(!k.size)return!1;if(this.#V("quick",""))return!0;for(const N of this.#K())if(k.has(N))return!0;return!1}#D(){if(!this.#a){this.#a=!0;try{this.#Ne()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#Ne(){const k=this.#J("filter",()=>this.#G(),()=>this.#Oe()),N=this.#ee(k),G=this.#J("group",()=>this.#ge(),()=>this.#Ge(N)),q=this.#J("total",()=>this.#ve(),()=>this.#Ve(G));this.#J("pivot",()=>this.#k(),()=>this.#jt(G)),this.#J("flatten",()=>this.#Se(),()=>this.#He(G)),this.#Ue(G,q)}#ee(k){const N=this.#l.get("sort"),G=this.#le();if(N.computed&&N.key===G&&!this.#y.has("sort"))return N.result;const q=this.#y.get("sort");return q&&q.key===G?N.result:N.result&&this.#Pe(k)?(this.#Ce(k,G),N.result):this.#J("sort",()=>G,()=>this.#Re(k))}#ae(){if(this.#b===null){const k=this.#e.pipelineWorker,N=_(k)?k():null;this.#b=N||!1}return this.#b||null}#ce(){const k=this.#V("sort",[]);if(!Array.isArray(k)||!k.length)return null;const N=(this.#e.config||{}).locale,G=[],q=[];for(const Y of k){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:N}),q.push(te)}return G.length?{entries:G,handles:q,locale:N}:null}#Pe(k){if(this.#fe())return!1;const N=this.#ae();if(!N)return!1;const G=Number(N.threshold);return Number.isFinite(G)&&k.length<G?!1:!!this.#ce()}#Ce(k,N){const G=this.#ae(),q=G&&this.#ce();if(!q){this.#J("sort",()=>N,()=>this.#Re(k));return}const Y=new AbortController;this.#y.set("sort",{key:N,controller:Y});const J=q.entries.length===1?G.sortColumn(q.handles[0],k,{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]})),k,{signal:Y.signal,key:"sort"});if(!C(J)){this.#y.delete("sort"),this.#J("sort",()=>N,()=>J);return}J.then(te=>this.#Y(N,te),te=>this.#x("sort",N,te))}#Y(k,N){const G=this.#y.get("sort");if(!(!G||G.key!==k)){if(this.#le()!==k){this.#y.delete("sort");return}this.#y.delete("sort"),this.#J("sort",()=>k,()=>N),this.#q=null,this.#D(),this.#Qe("model:changed",{reason:O[0]})}}#x(k,N,G){const q=this.#y.get(k);if(!(!q||q.key!==N)&&(this.#y.delete(k),!(G&&G.name==="AbortError")&&k==="sort"&&this.#le()===N)){const Y=this.#J("filter",()=>this.#G(),()=>this.#Oe());this.#J("sort",()=>N,()=>this.#Re(Y)),this.#q=null,this.#D(),B("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",G),this.#Qe("model:changed",{reason:O[1]})}}#Ue(k,N){const G=k&&k.leaves?k.leaves.length:this.#m.slots.length;this.#m.matchCount=G,this.#m.grand=N&&N.grand||null,this.#m.grandLeaves=k&&k.leaves?k.leaves.length:0,this.#m.groupLeaves=k&&k.leaves?k.leaves:null}#J(k,N,G){const q=this.#l.get(k),Y=N();return q.computed&&q.key===Y||(q.result=G(),q.key=Y,q.computed=!0,q.id++,k==="flatten"&&(this.#q=null)),q.result}#R(k){return this.#l.get(k).id}#G(){const k=(this.#e.config||{}).hostFilter,N=k&&_(k.active)&&k.active()?1:0,G=this.#V("where",null),q=G?G.version:0,Y=this.#gt("filter.sig",`${this.#ct()}`,()=>u({filters:this.#V("filters",null),quick:this.#V("quick",""),quickMode:this.#V("quickMode","contains")}));return`${this.#c}|${Y}|${N}|${q}`}#le(){const k=this.#fe();return`${this.#R("filter")}|${JSON.stringify(this.#V("sort",[]))}`+(k?`|manual:${k.version}`:"")}#fe(){const k=this.#V("rowOrder",null);return k&&Array.isArray(k.keys)?k:null}#oe(k,N){this.#p||this.#Te();const G=this.#p,q=this.#Me(),Y=N.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(N.keys[te]);ne!==void 0&&(J[ne]=te)}return Uint32Array.from(k).sort((te,ne)=>J[te]-J[ne])}orderedKeys(){this.#p||this.#Te();const k=this.#p,N=new Map;for(const[te,ne]of k)N.set(ne,te);const G=Uint32Array.from([...N.keys()]).sort(),q=this.#fe(),Y=q?this.#oe(G,q):this.#Re(G),J=new Array(Y.length);for(let te=0;te<Y.length;te++)J[te]=N.get(Y[te]);return J}#ge(){const k=this.#V("pivotBy",[]).length>0?"p":"u";return`${this.#R("sort")}|${JSON.stringify(this.#V("groupBy",[]))}|${k}`}#ve(){const k=this.#qe()?"f":"a",N=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#R("group")}|${JSON.stringify(this.#V("totals",[]))}|${k}${N}|${this.#u}`}#k(){return`${this.#R("group")}|${JSON.stringify(this.#V("pivotBy",[]))}`}#Se(){const N=this.#We()||!this.#pe()?this.#R("total"):"x",G=`${this.#ct()}`,q=this.#gt("flatten.keys",G,()=>{const J=this.#V("expanded",null);return J?[...J].sort().join(""):"*"}),Y=this.#gt("flatten.detail",G,()=>{const J=this.#V("detail",null);return J&&_(J.signature)?J.signature():""});return`${N}|${this.#R("pivot")}|${q}|${Y}`}#We(){const k=this.#V("groupBy",[]);return Array.isArray(k)&&k.length>0}stageState(){const k=[];for(const[N,G]of this.#l){const q=G.result;k.push({stage:N,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 k}facetIndices(k){return this.#Oe(k||null)}facetRows(k){const N=this.facetIndices(k),G=[];for(let q=0;q<N.length;q++){const Y=this.#je(N[q]);Y&&G.push(Y)}return G}invalidateRows(){this.#h.clear(),this.#$.clear(),this.#q=null}invalidateHandles(){this.#s.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#de()}filteredIndices(){const k=this.#l.get("filter");if(k&&k.computed&&k.key===this.#G())return k.result||this.#de();this.#D();const N=this.#l.get("filter");return(N&&N.computed?N.result:null)||this.#de()}unfilteredRows(){const k=this.#de(),N=[];for(let G=0;G<k.length;G++){const q=this.#je(k[G]);q&&N.push(q)}return N}#Oe(k=null){const N=this.#de(),G=this.#V("filters",null),q=k?this.#ot("pruneColumn")(G,k):G,Y=this.#it(q),J=String(this.#V("quick","")||"").trim().toLowerCase(),te=J?D(J,String(this.#V("quickMode","contains")||"contains")):null,ne=(this.#e.config||{}).hostFilter,oe=!!(ne&&_(ne.active)&&ne.active()),le=this.#V("where",null),ae=!!(le&&le.active);if(!Y&&!J&&!oe&&!ae)return N;let se=null;Y&&(se=this.#ot("evaluateFilters")(Y,{handle:he=>this.#s.handle(he),count:this.#Me(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:he=>F(this.#ze(he))}));const ee=new Uint32Array(N.length);let ie=0;for(let de=0;de<N.length;de++){const he=N[de];if(!(se&&!se[he])&&!(te&&!this.#ut(he,te))){if(oe||ae){const ge=this.#je(he);if(oe&&!ne.passes(ge)||ae&&!le.passes(ge.data,ge.key))continue}ee[ie++]=he}}if(se){const de=(this.#e.compute||{}).releaseMask;_(de)&&de({pool:this.#e.pool},se)}return ee.subarray(0,ie)}handleFor(k){return this.#s.handle(k)}#Re(k){const N=this.#fe();if(N)return this.#oe(k,N);const G=this.#V("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 k;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}".`),k;const ne=this.#ze(J.col);return this.#ot("sortColumn")(te,k,{descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:q,compare:j(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:j(this.#ze(J.col))})}return Y.length?this.#ot("sortMulti")(Y.map(J=>J.handle),Y,k):k}#Ge(k){const N=this.#V("groupBy",[]),G=this.#be();if(G&&!N.length){const de=h(k,G);return this.#L=p(de.roots,G.declaresChildren),{roots:null,leaves:k,nodes:new Map,tree:de}}if(this.#L=null,G&&N.length&&B("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!N.length)return{roots:null,leaves:k,nodes:new Map};const q=(this.#e.config||{}).timeZone,Y=[],J=[];let te=!1;for(const de of N){const he=this.#s.handle(de);if(!he){B(`source.group.${de}`,`grouping ignores unknown column "${de}".`);continue}Y.push(he);const ge=this.#ze(de),Ee=ge&&ge.dataType;if(Ee&&_(Ee.groupProjector)){const ye=ge.typeOptions&&ge.typeOptions.timeZone||q||void 0,Ae=Ee.groupProjector(ge,ye);J.push(Ae||null),Ae&&(te=!0)}else J.push(null)}if(!Y.length)return{roots:null,leaves:k,nodes:new Map};const{keys:ne,buckets:oe}=this.#ot("groupByColumns")(Y,k,{locale:(this.#e.config||{}).locale,project:te?J:void 0}),le=this.#V("pivotBy",[]).length>0,ae=[],se=new Map;for(let de=0;de<oe.length;de++){const he=ne[de];let ge=null;const Ee=[];for(let ye=0;ye<he.length;ye++){Ee.push(w(he[ye]));const Ae=z(Ee),pe=ye===he.length-1;let we=se.get(Ae);if(!we){const be=this.#i.group({path:[...Ee],column:N[ye],value:he[ye],level:ye,parent:ge,expanded:le&&pe?!1:this.#pt(Ae,{key:Ae,column:N[ye],value:he[ye],level:ye,path:[...Ee]}),hasChildren:!(le&&pe)});we={row:be,leaves:null},se.set(Ae,we),ge?ge.children.push(be):ae.push(be)}we.row.leafCount+=oe[de].length,ye===he.length-1&&(we.leaves=oe[de]),ge=we.row}}const ee=this.#V("sort",[])||[],ie=(de,he)=>{if(!de||de.length<2){if(de)for(const Ae of de)ie(Ae.children,he+1);return}const ge=N[he],Ee=ee.find(Ae=>Ae.col===ge),ye=Ee&&Ee.dir==="desc"?-1:1;de.sort((Ae,pe)=>ye*X(Ae.groupValue,pe.groupValue));for(const Ae of de)ie(Ae.children,he+1)};return ie(ae,0),{roots:ae,leaves:k,nodes:se,keys:ne,buckets:oe}}#Ze(k,N){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.#rt(N,Uint32Array.from(te),null);J.physical>=0?G.set(J.physical,ne):q.set(J.key,ne)}return te};for(const J of k.roots)Y(J);return{byPhysical:G,byKey:q}}#Ve(k){const N=this.#Xe();if(!N.length)return this.#M=null,this.#E=null,{grand:null};const G={id:this.#R("group"),columns:N.map(ee=>ee.id).join("")},q=this.#M&&this.#M.id===G.id&&this.#M.columns===G.columns,Y=this.#Ke()&&q?this.#P:null,J=Y?N.filter(ee=>Y.has(ee.id)):N,te=q?this.#E:null,ne=this.#qe()?null:this.#tt(),oe=this.#ke(N),le=ee=>{const ie=k.nodes.get(ee.key);let de=ie&&ie.leaves?ie.leaves:null;if(ee.children&&ee.children.length){const Ee=ee.children.map(le);let ye=0;for(const we of Ee)ye+=we.length;const Ae=new Uint32Array(ye);let pe=0;for(const we of Ee)Ae.set(we,pe),pe+=we.length;de=Ae}de=de||new Uint32Array(0);const he=ne?ne.get(ee.key)||T:de,ge=this.#at(ee,Y?J:N,he,oe);return ee.totals=Y?{...ee.totals,...ge}:ge,de};if(k.roots&&J.length)for(const ee of k.roots)le(ee);if(this.#B=k.tree?this.#Ze(k.tree,N):null,this.#M=G,this.#P=this.#Ke()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#S.length=0,this.#E=null,{grand:null};const se=ne?this.#Ye():k.leaves;return this.#E=this.#_e(N,se,Y,te),{grand:this.#E}}#_e(k,N,G,q){const Y={},J=this.#R("group");J!==this.#w&&(this.#Ot(),this.#w=J);const te=this.#S;this.#S=[];for(const ne of k){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.#rt([ne],N,null,"grand")[ne.id];continue}let ae=this.#j.get(ne.id);if((!ae||ae.fn!==le)&&(ae=new r(le),this.#j.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,i(oe),N),Y[ne.id]=ae.valid?ae.value():this.#rt([ne],N,null,"grand")[ne.id]}return Y}#ke(k){const N=this.#R("group");N!==this.#C&&(this.#v.clear(),this.#C=N);const G=new Map;for(const Y of k){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.#O.length=0,G;const q=this.#O;this.#O=[];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.#Le(ie,ae,se,null);for(const ie of te)oe&&oe.has(ie)||this.#Le(ie,ae,null,ee);for(const ie of J)le&&!le.has(ie)||this.#Le(ie,ae,se,ee)}}return G}#Le(k,N,G,q){const Y=this.#v.get(k),J=Y&&Y.get(N);!J||!J.valid||J.update(G,q)||J.invalidate()}#at(k,N,G,q){if(!q||!q.size)return this.#rt(N,G,k);const Y={};let J=null,te=this.#v.get(k.key);for(const ne of N){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.#v.set(k.key,te));let ae=te.get(ne.id);if((!ae||ae.fn!==oe.fn)&&(ae=new r(oe.fn),te.set(ne.id,ae)),ae.valid||ae.seedColumn(le.values,i(le),G),ae.valid){Y[ne.id]=ae.value();continue}(J||(J=[])).push(ne)}return J&&Object.assign(Y,this.#rt(J,G,k)),Y}#Tt(k,N,G,q){const Y=!this.#qe()||this.#St(N);for(const J of k){const te=J.getValue;if(!_(te))continue;const ne=te(G),oe=te(q);Object.is(ne,oe)||(this.#P&&this.#P.add(J.id),Y&&this.#j.has(J.id)&&this.#S.push({colId:J.id,before:ne,after:oe}))}}#kt(){const k=this.#V("groupBy",[]),N=[];for(const G of k){const q=this.#ze(G);q&&N.push(q)}return N}#re(k,N){const G=new Array(k.length);for(let q=0;q<k.length;q++){const Y=k[q].getValue;G[q]=w(_(Y)?Y(N):void 0)}return G}#lt(k,N,G,q,Y){if(this.#qe()&&!this.#St(G))return;const J=S(this.#re(k,q)),te=S(this.#re(k,Y)),ne=J.length!==te.length||J.some((le,ae)=>le!==te[ae]),oe=[];for(const le of N){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.#O.push({beforeKeys:J,afterKeys:te,colDeltas:oe})}#St(k){const N=this.#l.get("filter"),G=N&&N.computed?N.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===k)return!0;te<k?q=J+1:Y=J-1}return!1}#qe(){return(this.#e.config||{}).totalFilteredOnly!==!1}#et(k){return this.#qe()?k:this.#Ye().length}#Ye(){return(!this.#T||this.#T.version!==this.#c)&&(this.#T={version:this.#c,indices:this.#de()}),this.#T.indices}#tt(){const k=this.#V("groupBy",[]),N=`${this.#c}|${JSON.stringify(k)}`;if(this.#N&&this.#N.key===N)return this.#N.map;const G=new Map,q=[];for(const Y of k){const J=this.#s.handle(Y);J&&q.push(J)}if(q.length){const Y=this.#Ye(),{keys:J,buckets:te}=this.#ot("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 de=0;de<te[oe].length;de++)ie.push(te[oe][de])}}for(const[oe,le]of ne)G.set(oe,Uint32Array.from(le))}return this.#N={key:N,map:G},G}#Ke(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#nt(){this.#Ot(),this.#A(),this.#P=null,this.#M=null,this.#E=null}#Ot(){this.#j.clear(),this.#S.length=0,this.#w=-1}#A(){this.#v.clear(),this.#O.length=0,this.#C=-1}#jt(k){const N=this.#V("pivotBy",[]);if(!N.length)return this.#he=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.#he=null,null;const q=N.map(J=>this.#s.handle(J)).filter(Boolean),Y=this.#Xe();return this.#he=G(q,k.leaves,{groups:k.keys&&k.buckets?{keys:k.keys,buckets:k.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.#he}#He(k){const N=this.#l.get("total").result,G=!!(this.#e.config||{}).groupFooter,q=this.#Ie();if(k.tree)return this.#At(k,N,q);if(!k.roots&&!q){if(N&&N.grand&&!this.#pe()){const le=this.#i.grandTotal(N.grand,this.#et(k.leaves.length));if(this.#W===k.leaves&&Array.isArray(this.#I))this.#I[this.#I.length-1]=le;else{const ae=Array.from(k.leaves);ae.push(le),this.#I=ae,this.#W=k.leaves}this.#U=[{at:this.#I.length-1}]}else this.#W=null,this.#I=k.leaves,this.#U=b;return this.#H=b,this.#I}const Y=[],J=[],te=[],ne=le=>{if(Y.push(le),!q)return;const ae=this.#je(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(!k.roots){for(let le=0;le<k.leaves.length;le++)ne(k.leaves[le]);return N&&N.grand&&!this.#pe()&&(te.push({at:Y.length}),Y.push(this.#i.grandTotal(N.grand,this.#et(k.leaves.length)))),this.#W=null,this.#H=b,this.#U=te.length?te:b,this.#I=Y,Y}const oe=(le,ae,se)=>{if(le.expanded=le.hasChildren===!1?!1:this.#pt(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=k.nodes.get(le.key),ie=ee&&ee.leaves?ee.leaves:null;if(ie)for(let de=0;de<ie.length;de++)ne(ie[de])}G&&le.totals&&(te.push({at:Y.length}),Y.push(this.#i.footer(le)))}};for(let le=0;le<k.roots.length;le++)oe(k.roots[le],le,k.roots.length);return N&&N.grand&&!this.#pe()&&(te.push({at:Y.length}),Y.push(this.#i.grandTotal(N.grand,this.#et(k.leaves.length)))),this.#H=J,this.#U=te,this.#I=Y,Y}#de(){const k=this.#e.store;if(k&&_(k.liveIndices))return k.liveIndices();const N=new Uint32Array(this.#n.length);let G=0;for(let q=0;q<this.#n.length;q++)this.#n[q]!==void 0&&(N[G++]=q);return N.subarray(0,G)}#Me(){const k=this.#e.store;return k&&typeof k.physical=="number"?k.physical:this.#n.length}#ue(k){const N=this.#e.store;return N&&_(N.source)?N.source(k):this.#n[k]}#Fe(k,N=k){const G=this.#I[k];if(typeof G!="number")return G.index=N,G;const q=this.#je(G);return q.index=N,q}#je(k){let N=this.#h.get(k);N||(N=this.#i.leaf(this.#ue(k),k),this.#h.set(k,N));const G=this.#L?this.#L.get(k):null;if(G){N.level=G.level,N.posinset=G.posinset,N.setsize=G.setsize,N.hasChildren=G.hasChildren,N.expanded=G.hasChildren&&!G.lazy&&this.#pt(N.key);const q=this.#B?this.#B.byPhysical.get(k):void 0;q?N.totals=q:N.totals&&(N.totals=null)}else N.hasChildren&&(N.level=0,N.hasChildren=!1,N.expanded=!1,N.posinset=void 0,N.setsize=void 0);return N}#At(k,N,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.#pt(ne.key);if(ne.physical>=0){if(q.push(ne.physical),G&&G.isOpen(this.#je(ne.physical).key)){const le=this.#je(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 k.tree.roots)te(ne);return N&&N.grand&&!this.#pe()&&(Y.push({at:q.length}),q.push(this.#i.grandTotal(N.grand,this.#et(k.leaves.length)))),this.#W=null,this.#H=b,this.#U=Y.length?Y:b,this.#I=q,q}#Mt(){return g(()=>this.count(),k=>this.at(k))}#ut(k,N){let G=this.#$.get(k);if(G===void 0){const q=this.#ue(k),Y=this.#st(),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.#V("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.#$.set(k,G)}return N(G)}#Xe(){const k=this.#V("totals",[]),N=k&&k.length?new Set(k):null;return this.#st().filter(G=>N?N.has(G.id):!!(G.total||G.groupTotal||G.grandTotal))}#rt(k,N,G,q="group"){const Y={},J=(this.#e.compute||{}).total;for(const te of k){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(N.length);for(let ae=0;ae<N.length;ae++)le[ae]=ne.get(N[ae]);Y[te.id]=oe(le,{row:G,column:te,grid:this.#e.grid||null,context:this.#V("context",null),valueAt:(ae,se)=>{const ee=this.#s.handle(ae);return ee&&se>=0&&se<N.length?ee.get(N[se]):null}})}else _(J)&&(Y[te.id]=J(ne,N,oe))}return Y}#it(k){if(!k)return k;const N=this.#e.config||{},G={tz:N.timeZone,weekStartsOn:N.weekStartsOn};return o(k,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:N.timeZone||void 0}:Y;if(te)return{...Y,type:"datetime",timeZone:N.timeZone||void 0};const ne=J&&(J.dataType?.base||J.type);return ne?{...Y,type:ne}:Y})}#pt(k,N){const G=this.#V("expanded",null);return G?_(G.has)?G.has(k,N):Array.prototype.includes.call(G,k):!0}#V(k,N){if(k==="context"||!_(this.#e.stateVersion))return this.#Nt(k,N);const G=this.#mt(k),q=this.#d.get(k);if(q&&q.version===G)return q.value;const Y=this.#Nt(k,N);return this.#d.set(k,{version:G,value:Y}),Y}#Nt(k,N){const G=this.#e.state;if(G&&_(G[k])){const q=G[k]();return q??N}return N}#ct(){const k=this.#e.stateVersion;return _(k)?k():0}#$t(){const k=this.#e.columnsVersion,N=this.#e.permissionsVersion;return`${_(k)?k():0}|${_(N)?N():0}`}#mt(k){return k==="totals"?this.#$t():`${this.#ct()}`}#gt(k,N,G){if(!_(this.#e.stateVersion))return G();const q=this.#f.get(k);if(q&&q.version===N)return q.key;const Y=G();return this.#f.set(k,{version:N,key:Y}),Y}#ot(k){const N=(this.#e.compute||{})[k];return _(N)||I(`ctx.compute.${k} is required by the memory source pipeline`),N}#st(){const k=this.#e.columns;return k&&_(k.all)?k.all():[]}#ze(k){const N=this.#e.columns;return N&&_(N.get)?N.get(k):void 0}#Qe(k,N){const G=this.#e.emit;_(G)&&G(k,N)}}}),Le("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 x}}),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 x{#e;constructor(W,H,V,z){this.#e=W,this.key=H,this.controller=V,this.signal=V.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 V=this.#e.get(W);V&&!V.signal.aborted&&V.controller.abort(new Q(W,H));const z=new x(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 V=this.#e.get(W);V&&V.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"}}),Le("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 x}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return I}});const Q=100,x=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)||x))}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)}}}),Le("packages/core/src/source/pagewindow.js",function(e,K){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return Q}});function Q(x,B,I,_){const X=Math.floor(Number(x)||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 V=Math.max(1,Math.ceil(H/X)),z=Math.min(W,V-1),w=z*X;return{page:z,pageSize:X,offset:w,length:Math.max(0,Math.min(X,H-w)),pageCount:V,total:H}}return{page:W,pageSize:X,offset:W*X,length:X,pageCount:Math.max(W+2,Math.ceil(H/X)),total:null}}}),Le("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 o}});const Q=K("packages/core/src/internal/util.js"),x=Q.Lru,B=Q.isFunction,I=Q.warnOnce,_=Q.settleDebounce,X=K("packages/core/src/source/abort.js"),W=X.createAbortScope,H=X.isAbortError,V=K("packages/core/src/source/blockcache.js"),z=V.BlockCache,w=V.DEFAULT_PAGE_SIZE,S=V.DEFAULT_MAX_CACHED_PAGES,l=K("packages/core/src/source/rows.js").createRowFactory,d=K("packages/core/src/source/filterwire.js"),a=d.wireFilters,r=d.querySignature,t=d.warnHostFilterNotApplied,i=K("packages/core/src/source/pagewindow.js").pageWindow,f=120;function u(m,c){return new o(m,c)}class o{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(c,h){this.#e=c||{mode:"paged"},this.#t=h||{},this.#n=new z({pageSize:this.#e.pageSize||w,maxCachedPages:this.#e.maxCachedPages||S}),this.#o=l(this.#t),this.#i=new x(this.#n.pageSize*4),this.#h=_((s,p)=>this.#w(s,p),f),this.#d=this.#P(),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 c=this.#b();return c?c.length:this.#y()}#y(){if(this.#C(),this.#l!==null)return this.#l;const c=Math.max(this.#c,this.#n.loadedExtent());return this.#u?c:c+this.#n.pageSize}matchCount(){return this.#y()}totalCount(){return this.#y()}pageInfo(){const c=this.#b();if(!c){const h=this.#y();return{page:0,pageSize:0,total:this.exact()?h:null,pageCount:1,counting:!1}}return{page:c.page,pageSize:c.pageSize,total:c.total,pageCount:c.pageCount,counting:c.total===null&&this.#r.size>0&&this.#c===0&&this.#n.loadedExtent()===0}}#b(){const c=this.#y(),h=i(this.#E("pageSize",0),this.#E("page",0),c,this.exact());if(!h)return this.#g="",null;const s=`${this.#m}:${h.offset}:${h.length}`;if(s!==this.#g&&!this.#p&&(this.#g=s,h.length>0)){const p=h.offset+h.length-1;this.#f={start:h.offset,end:p},this.#w(h.offset,p)}return h}at(c){const h=this.#b();if(h){if(c<0||c>=h.length)return;const s=this.#j(h.offset+c);return s&&(s.index=c),s}return this.#j(c)}#j(c){if(c<0||c>=this.#y())return;const h=this.#i.get(c);if(h&&(h.data!==null||!this.#n.rowLoaded(c)))return h;const s=this.#n.rowAt(c);if(s===void 0){const y=this.#o.skeleton(c,0,this.#n.erroredAt(c));return this.#i.set(c,y),y}const p=this.#o.leaf(s,c);return p.index=c,this.#i.set(c,p),this.#s.set(p.key,c),p}byKey(c){const h=this.#s.get(c);return h===void 0?void 0:this.#j(h)}loaded(c){const h=this.#b();return h?c>=0&&c<h.length&&this.#n.rowLoaded(h.offset+c):this.#n.rowLoaded(c)}loadedCount(){this.#C();let c=0;for(const h of this.#n.ids()){if(!this.#n.loaded(h))continue;const s=this.#n.fillOf(h);typeof s=="number"&&(c+=s)}return c}residentRows(){this.#C();const c=this.#b(),h=c?c.offset:0,s=c?c.offset+c.length:1/0,p=[],y=this.#n.ids().sort((O,A)=>O-A);for(const O of y){if(!this.#n.loaded(O))continue;const{start:A}=this.#n.rangeOf(O),b=this.#n.fillOf(O)||0;for(let v=A;v<A+b;v++){if(v<h||v>=s)continue;const R=this.#i.peek(v);if(R&&R.data!==null&&R.data!==void 0){p.push(R);continue}const j=this.#n.rowAt(v);if(j===void 0)continue;const F=this.#o.leaf(j,v);F.index=v,this.#i.set(v,F),this.#s.set(F.key,v),p.push(F)}}return p}hint(c,h){if(this.#p)return;const s=this.#C();let p=Math.max(0,Math.floor(c)),y=Math.max(p,Math.floor(h));const O=this.#b();if(O){if(O.length===0)return;p=O.offset,y=O.offset+O.length-1}this.#f={start:p,end:y},this.#n.protect(p,y);for(const A of this.#n.evict())this.#v(A);this.#h(p,y),s&&this.#h.flush()}#w(c,h){if(this.#p)return;this.#n.protect(c,h);const s=this.#n.blockOf(c),p=this.#n.blockOf(h);for(let y=s;y<=p&&!(this.#l!==null&&y*this.#n.pageSize>=this.#l);y++)this.#n.has(y)||this.#S(y)}apply(c){const h={added:[],updated:[],removed:[]};if(!c)return h;if(c.update)for(const s of c.update){const p=this.#o.keyOf(s,-1),y=this.#s.get(p);if(y===void 0)continue;const O=this.#o.leaf(s,y);O.index=y,this.#i.set(y,O),h.updated.push(O)}return(c.add&&c.add.length||c.remove&&c.remove.length)&&this.reload(),h}reload(c){this.#O("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#S(c){if(!B(this.#e.fetch))return;const h=this.#r.begin(`block:${c}`);this.#n.begin(c,h);const{start:s,end:p}=this.#n.rangeOf(c),y=this.#d;try{const O=await this.#e.fetch({range:{start:s,end:p},sort:this.#E("sort",[]),filters:a(this.#E("filters",null),this.#M()),quick:this.#E("quick","")||void 0,context:this.#E("context",null),signal:h.signal});if(!h.current||y!==this.#d||this.#p)return;h.settle();const A=O&&O.rows||[];this.#n.fill(c,A);for(let v=0;v<A.length;v++)this.#i.delete(s+v);const b=O&&typeof O.total=="number"?O.total:O&&typeof O.count=="number"?O.count:null;b!==null?(this.#l=b,this.#u=!0):A.length<this.#n.pageSize?(this.#u=!0,this.#l=s+A.length):this.#c=Math.max(this.#c,s+A.length),this.#T("model:changed",{reason:"page",block:c,from:s,to:s+A.length}),this.#T("rows:changed",{companion:!0,reason:"page",block:c,from:s,to:s+A.length}),this.#l!==null&&this.#l!==this.#a&&(this.#a=this.#l,this.#T("source:total",{total:this.#l,groupPath:[]}))}catch(O){if(h.settle(),H(O))return;this.#n.failed(c,O);for(let A=s;A<p;A++)this.#i.delete(A);this.#T("model:changed",{reason:"page-error",block:c,range:{start:s,end:p}}),this.#T("source:error",{error:O,block:c,range:{start:s,end:p}})}}#v(c){const{start:h,end:s}=this.#n.rangeOf(c);for(let p=h;p<s;p++){const y=this.#i.peek(p);y&&this.#s.delete(y.key),this.#i.delete(p)}}#C(){const c=this.#P();return c===this.#d?!1:(this.#d=c,this.#O("query"),!0)}#O(c){this.#r.abortAll(c),this.#n.clear(),this.#i.clear(),this.#s.clear(),this.#l=null,this.#a=null,this.#u=!1,this.#c=0,this.#m++,this.#T("model:changed",{reason:c})}#P(){return r({filters:this.#E("filters",null),sort:this.#E("sort",[]),quick:this.#E("quick",""),context:this.#E("context",null)})}#M(){const c=this.#t.config||{};return{tz:c.timeZone,weekStartsOn:c.weekStartsOn}}#E(c,h){const s=this.#t.state;if(s&&B(s[c])){const p=s[c]();return p??h}return h}#T(c,h){const s=this.#t.emit;B(s)&&s(c,h)}}}),Le("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 x}}),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 V}});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 x(){const z=new Set;for(const[w,S]of Object.entries(Q))S.pushable&&z.add(w);return z}function B(z,w,S){let g=z.split("%c").join(w);return S!==void 0&&(g=g.split("%w").join(S)),g}function I(z){const w=z||{},S=w.default==="engine"||w.default==="engine-if-identical"?w.default:"client",g={};if(w.overrides&&typeof w.overrides=="object")for(const[l,d]of Object.entries(w.overrides))(d==="engine"||d==="client")&&(g[l]=d);return{default:S,overrides:g}}function _(z,w){const S=Q[z];if(!S||!S.pushable)return"client";const g=w.overrides[z];return g==="engine"||g==="client"?g:w.default==="client"?"client":w.default==="engine-if-identical"?S.class==="identical"?"engine":"client":"engine"}function X(z,w){const S=I(w),g=[],l=[];for(const d of z||[]){const a=Q[d.fn],r=_(d.fn,S),t={id:d.id,col:d.col,fn:d.fn,class:a?a.class:"fallback"};d.weight!==void 0&&(t.weight=d.weight),d.params!==void 0&&(t.params=d.params),r==="engine"?g.push(t):(t.reason=a&&!a.pushable?a.note||"the engine cannot express this stat":"client by config",l.push(t))}return{engine:g,client:l,config:S}}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 V(){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.":"")}))}}),Le("packages/core/src/source/pushdown.js",function(e,K){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return n}}),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 c}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return k}});const Q=K("packages/core/src/internal/util.js"),x=Q.defaultCompare,B=Q.isFunction,I=Q.toArray,_=Q.warnOnce,X=K("packages/core/src/source/filterwire.js"),W=X.isGroup,H=X.warnWherePageRelative,V=X.warnWhereOverThreshold,z=K("packages/core/src/source/aggregates.js"),w=z.resolveAggregatePlan,S=z.groupKeysPushable,g=z.STAT_PUSHDOWN,d=K("packages/core/src/source/abort.js").SupersededError,a=1e3;function r(N){const G=N&&N.signal;if(!G||!G.aborted)return;const q=G.reason;throw q instanceof Error?q:new d("","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 n(N){if(!N||typeof N!="object")return!1;const G=N.returning==="row"||N.returning==="key"?N.returning:"none";return{append:N.append===!0,update:N.update===!0,delete:N.delete===!0,returning:G}}function i(N,G){if(!N||typeof G!="string")return;if(!G.includes("."))return N[G];let q=N;for(const Y of G.split(".")){if(q===null||typeof q!="object")return;q=q[Y]}return q}function f(N){if(N===!0)return!0;if(!N||typeof N!="object")return!1;const G=N;return G.enabled===!1?!1:G.enabled===!0||B(G.commit)}function u(N){const G={...t,...N||{}};return G.operators=new Set(G.operators||[]),G.mutate=n(G.mutate),G}function o(N,G){return!N||!N.op||!G.operators.size?!1:G.operators.has(N.op)}function m(N,G){if(!N)return{pushed:null,residual:null};if(!G.filter)return{pushed:null,residual:N};if(G.filter==="term"){if(W(N)){const te=N.conditions||[];if(String(N.op)!=="and")return{pushed:null,residual:N};const ne=te.findIndex(le=>!W(le)&&o(le,G));if(ne<0)return{pushed:null,residual:N};const oe=te.filter((le,ae)=>ae!==ne);return{pushed:te[ne],residual:oe.length?{op:"and",conditions:oe}:null}}return o(N,G)?{pushed:N,residual:null}:{pushed:null,residual:N}}if(!W(N))return o(N,G)?{pushed:N,residual:null}:{pushed:null,residual:N};if(String(N.op)!=="and")return(N.conditions||[]).every(ne=>W(ne)?m(ne,G).residual===null:o(ne,G))?{pushed:N,residual:null}:{pushed:null,residual:N};const q=[],Y=[];for(const te of N.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}(o(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 c="__lattice_leaves";function h(N){return N.aggregates?N.aggregates instanceof Set?N.aggregates:new Set(I(N.aggregates)):new Set}function s(N){const G=h(N);return G.size?G.has("count")?N.filter!=="tree"||!N.operators||!N.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(N,G,q,Y,J,te,ne){const oe=Array.isArray(N.groupBy)?N.groupBy:[],le=Array.isArray(N.groupPath)?N.groupPath:[],ae=Array.isArray(N.groupValues)?N.groupValues:null;if(!G.group){const se=s(G);if(se)return se}return S(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 y="pushdown:pivot-unsupported",O="pushdown:group-unsupported",A=Symbol("lattice.remote.ungroupedLevel");function b(N,G,q,Y,J,te){const ne=Array.isArray(N.pivotBy)?N.pivotBy:[],oe=Array.isArray(N.groupBy)?N.groupBy:[],le=Array.isArray(N.groupPath)?N.groupPath:[],ae=Array.isArray(N.groupValues)?N.groupValues:null;return G.pivot?S(ne)?oe.length&&!S(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(N,G,q=!1){const Y=m(N.filters||null,G),J=[];Y.residual&&J.push("filter");const te=N.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=N.quick?String(N.quick):"",le=!oe||!!G.quick;le||J.push("quick");const ae=N.where&&N.where.active?N.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(N.groupBy)&&N.groupBy.length>0,de=ie?p(N,G,Y,ne,le,ae,ee):"",he=N.pivotMode!==!1&&Array.isArray(N.pivotBy)&&N.pivotBy.length>0,ge=he?b(N,G,Y,ne,le,ae):"",Ee=he&&ge==="";he&&!Ee&&J.push("pivot");const ye=he?Ee&&ie:ie&&de==="";ie&&!he&&!ye&&J.push("group");const Ae=(ye||Ee)&&Array.isArray(N.groupValues)?N.groupValues.length:0,pe=ye||he?!1:ee||!!(se.filters||se.sort||se.quick||se.where)||!G.range;return{pushed:{...N,filters:Y.pushed,sort:ne?te:[],quick:le?oe:"",range:pe?null:N.range},residual:se,needsAll:pe,unpushed:J,full:ee,grouped:ye,groupLevel:Ae,groupReason:he?"":de,pivoted:Ee,pivotReason:ge}}function R(N){const G=Array.isArray(N.totals)?N.totals:[],q=N.totalFns&&typeof N.totalFns=="object"?N.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 j=Object.freeze({items:N=>N==null?[]:Array.isArray(N)?N:[N]});function F(N,G,q){if(!G)return N;let Y=N;if(G.filters&&B(q.evaluateFilters)){const J=Y,te={count:Y.length,handle:le=>({id:le,get:ae=>i(J[ae],le)}),itemwise:le=>J.some(ae=>Array.isArray(i(ae,le)))?j: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=>i(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(N){return JSON.stringify({filters:N.filters||null,sort:N.sort||[],quick:N.quick||"",groupBy:N.groupBy||[],groupPath:N.groupPath||[],context:N.context??null})}function T(N){if(!N||typeof N!="object")return 16;let G="";try{G=JSON.stringify(N)}catch{return 200}return G.length*2+64}function L(N){const G=N||{};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(N){return Number.isFinite(N)&&N>=0?N:E}function $(N){return!!N&&B(N.then)}async function P(N){if(!N||N.total!==void 0||!$(N.pendingTotal))return N;const G=await N.pendingTotal,{pendingTotal:q,...Y}=N;return typeof G=="number"?{...Y,total:G}:Y}function k(N={}){const G=N.adapter;if(!G||!B(G.execute))return _("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...N,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))},$e=>{throw te=null,$e})),te):null,oe=L(N.fullDataset),le=!!N.allowPartialResults,ae=D(N.whereRowLimit);let se=null;const ee=N.aggregates;let ie=null,de=null,he=null,ge=null,Ee=null,ye,Ae=null,pe=0,we=null;const be=()=>!oe.enabled||!ie?null:(we!==ie.key&&(pe++,we=ie.key),{rows:ie.rows,version:pe}),Ne=async $e=>{const qe=$e.where&&$e.where.active?$e.where:null;if(!qe)return{request:$e,probe:null};const{where:ve,...Se}=$e,me=v(Se,q,oe.enabled);if(me.needsAll)return{request:$e,probe:null};const Ce=C(me.pushed);let Me=null;return(!se||se.key!==Ce)&&(q.total?(r($e),Me=await P(await G.execute(me.pushed,$e)),se={key:Ce,size:Me&&typeof Me.total=="number"?Me.total:null}):se={key:Ce,size:null}),se.size!==null&&se.size<ae?{request:$e,probe:null}:(V(qe.names,J,se.size,ae),{request:Se,probe:Me})},Ie=async($e,qe)=>{Ae=null;const ve=R($e.pushed);he={engine:ve.engine,client:ve.client,groupBy:$e.pushed.groupBy},ve.client.length&&_(`source.pushdown.group.totals.${J}.${ve.client.map(Ce=>Ce.id).join(".")}`,`the ${J} adapter cannot compute the group subtotal for ${ve.client.map(Ce=>`"${Ce.id}" (${Ce.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 Se=await G.executeGroupLevel($e.pushed,ve.engine,qe)||{};let me=Se.rows||[];return!q.range&&qe.range&&(me=me.slice(qe.range.start,qe.range.end)),He(Se),Se.total===void 0?{rows:me}:{rows:me,total:Se.total}},Ve=new Map,Ye=64,je=async($e,qe)=>{Ae=null;const ve=$e.pushed,Se=ve.groupBy,me=Array.isArray(ve.groupValues)?ve.groupValues:[],Ce=me.length,Me=[...ve.filters?[ve.filters]:[],...Se.slice(0,Ce).map((ot,lt)=>({col:ot,op:"eq",value:me[lt]===void 0?null:me[lt],caseSensitive:!0}))],ze=Me.length===0?null:Me.length===1?Me[0]:{op:"and",conditions:Me},_e=qe.range?qe.range.start:0;if(Ce>=Se.length){const ot={...ve,filters:ze,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},lt=await P(await G.execute(ot,qe))||{};let Ot=lt.rows||[];return!q.range&&qe.range&&(Ot=Ot.slice(qe.range.start,qe.range.end)),typeof lt.total=="number"?{rows:Ot,total:lt.total}:{rows:Ot}}const De=Se[Ce],Oe=R(ve),xe=h(q),Ue=Oe.engine.filter(ot=>xe.has(ot.fn)),Je=[...Oe.engine.filter(ot=>!xe.has(ot.fn)).map(ot=>({id:ot.id,fn:ot.fn,class:ot.class,reason:`the ${J} adapter does not compute "${ot.fn}"`})),...Oe.client];he={engine:Ue,client:Je,groupBy:Se},Je.length&&_(`source.pushdown.group.totals.${J}.${Je.map(ot=>ot.id).join(".")}`,`the ${J} adapter cannot compute the group subtotal for ${Je.map(ot=>`"${ot.id}" (${ot.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=[...Ue.map(ot=>({id:ot.id,col:ot.col,fn:ot.fn})),{id:c,col:De,fn:"count"}],at={...ve,filters:ze,range:null},it=JSON.stringify([C(at),me,De,Qe]);let mt=_e>0?Ve.get(it):void 0;if(!mt){for(mt=Promise.resolve(G.executeGroupedAggregates(at,[De],Qe)),Ve.delete(it),Ve.set(it,mt);Ve.size>Ye;)Ve.delete(Ve.keys().next().value);mt.catch(()=>{Ve.get(it)===mt&&Ve.delete(it)})}const wt=await mt||[];r(qe);const dt=ot=>{const lt={};for(const Ot of Ue)lt[Ot.id]=ot?ot[Ot.id]:void 0;return lt},Pt=(ve.sort||[]).find(ot=>ot&&ot.col===De),Ft=Pt&&Pt.dir==="desc"?-1:1,Ge=wt.filter(ot=>ot&&ot.level===1).map(ot=>({[De]:ot.keys[0]===void 0?null:ot.keys[0],leafCount:Number(ot.values&&ot.values[c])||0,totals:dt(ot.values)})).sort((ot,lt)=>Ft*x(ot[De],lt[De]));if(Ce===0){const ot=wt.find(Ot=>Ot&&Ot.level===0),lt=ot?Number(ot.values&&ot.values[c]):NaN;He({matchCount:Number.isFinite(lt)?lt:Ge.reduce((Ot,Nt)=>Ot+Nt.leafCount,0),...ot?{grand:dt(ot.values)}:{}})}const ft=qe.range?qe.range.end:Ge.length;return{rows:Ge.slice(_e,ft),total:Ge.length}},He=$e=>{typeof $e.matchCount=="number"&&(ge=$e.matchCount,Ee=$e.grand?{totals:$e.grand,leafCount:$e.matchCount}:null,ye===void 0&&B(G.unfilteredCount)&&(ye=null,Promise.resolve(G.unfilteredCount()).then(qe=>{ye=typeof qe=="number"?qe:null}).catch(qe=>{_(`source.pushdown.group.unfiltered.${J}`,`the ${J} adapter could not count the unfiltered set (${qe&&qe.message?qe.message:qe}), so "N of M" falls back to the display count for its denominator.`)})))},Ze=async($e,qe)=>{Ae=null;const ve=R($e.pushed);he={engine:ve.engine,client:ve.client,groupBy:$e.pushed.groupBy,pivotBy:$e.pushed.pivotBy},ve.client.length&&_(`source.pushdown.pivot.totals.${J}.${ve.client.map(ze=>ze.id).join(".")}`,`the ${J} adapter cannot compute the pivot cells for ${ve.client.map(ze=>`"${ze.id}" (${ze.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 Se=await G.executePivotLevel($e.pushed,ve.engine,qe)||{};let me=Se.rows||[];!q.range&&qe.range&&(me=me.slice(qe.range.start,qe.range.end)),He(Se);const Ce=Se.pivot&&typeof Se.pivot=="object"?Se.pivot:{},Me={cells:Array.isArray(Ce.cells)?Ce.cells:[],...Array.isArray(Ce.axis)?{axis:Ce.axis}:{}};return Se.total===void 0?{rows:me,pivot:Me}:{rows:me,total:Se.total,pivot:Me}},rt=$e=>{_(`source.pushdown.pivot.${J}.${$e}`,`pushdown:pivot-unsupported: the ${J} adapter cannot pivot this query because ${$e}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const qe=new Error(`[lattice] ${y}: the ${J} adapter cannot pivot this query because ${$e}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw qe.code=y,qe.reason=$e,qe},st=($e,qe)=>{const ve={key:qe,state:"pending",value:null};return Ae=ve,$e.then(Se=>(Ae===ve&&(Ae={key:qe,state:"settled",value:typeof Se=="number"?Se:null}),Se),Se=>{throw Ae===ve&&(Ae={key:qe,state:"failed",value:null}),Se})};let ht=0,yt=[];const St=()=>ht===0?null:new Promise($e=>{const qe=setTimeout($e,a);yt.push(()=>{clearTimeout(qe),$e()})});let Ct;const Tt=async $e=>{const qe=ne();qe&&await qe;const Se=$e&&$e.pivotMode!==!1&&Array.isArray($e.pivotBy)&&$e.pivotBy.length>0?{request:$e,probe:null}:await Ne($e);r($e);let me=v(Se.request,q,oe.enabled);if(q.group&&me.grouped&&!me.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.`),me=v(Se.request,{...q,group:!1,aggregates:null},oe.enabled)),me.pivoted&&!B(G.executePivotLevel)&&(me=v(Se.request,{...q,pivot:!1},oe.enabled),me.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),me.grouped&&!me.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\`.`),me=v(Se.request,{...q,aggregates:null},oe.enabled)),de=me,me.pivoted)return Ze(me,$e);if(me.pivotReason&&rt(me.pivotReason),me.grouped)return q.group?Ie(me,$e):je(me,$e);const Me=!!me.groupReason&&!me.full;Me?_(`source.pushdown.group-unsupported.${J}.${me.groupReason}`,`pushdown:group-unsupported: the ${J} adapter was not asked to group this query because ${me.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.`):me.groupReason&&_(`source.pushdown.group.${J}.${me.groupReason}`,`the ${J} adapter was not asked to group this query because ${me.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 ze=Qe=>Me?{...Qe,[A]:!0}:Qe;if(!me.needsAll){const Qe=Se.probe||await G.execute(me.pushed,$e),at=Qe.rows||[];return $(Qe.pendingTotal)&&Qe.total===void 0?ze({rows:at,pendingTotal:st(Qe.pendingTotal,C(me.pushed))}):(Ae=null,!q.total&&Qe.total===void 0?ze({rows:at}):ze({rows:at,total:Qe.total??at.length}))}me.unpushed.length&&_(`source.pushdown.residual.${J}.${me.unpushed.join(".")}`,`the ${J} adapter cannot push ${me.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 _e=C(me.pushed);if(!ie||ie.key!==_e){const Qe=await P(await G.execute(me.pushed,$e));Ae=null;const at=Qe.rows||[];if(me.full){const it=typeof Qe.total=="number"?Math.max(Qe.total,at.length):at.length;if(it>oe.maxRows)throw new Error(`[lattice] fullDataset refused: the ${J} adapter's matching set is ${it.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 mt=at.length*T(at[0]);if(mt>oe.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${J} adapter's matching set is an estimated ${Math.round(mt/(1024*1024)).toLocaleString()} MB across ${at.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"&&at.length<Qe.total){const it=!!(me.residual.filters||me.residual.quick||me.residual.sort&&me.residual.sort.length);if(it&&!le)throw new Error(`[lattice] the ${J} adapter returned ${at.length} of ${Qe.total} matching rows when asked for the whole result, and the query has residual ${me.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.`);it?_(`source.pushdown.partial.residual.${J}`,`the ${J} adapter returned ${at.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 ${at.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:_e,rows:at,total:typeof Qe.total=="number"?Qe.total:null}}let De=me;if(me.residual.where){const Qe=ie.total??ie.rows.length;if(Qe>=ae){V(me.residual.where.names,J,Qe,ae);const{where:at,...it}=Se.request;De=v(it,q,oe.enabled),de=De}}const Oe=ie.total!==null&&ie.rows.length>=ie.total,xe=F(ie.rows,{...De.residual,whole:Oe},N.compute||{}),Ue=$e.range?$e.range.start:0,Je=$e.range?$e.range.end:xe.length;return ze({rows:xe.slice(Ue,Je),total:xe.length})},Et=async($e,qe,ve)=>{const me=ve&&ve.waitForPage&&Ct&&B(Ct.pageForegroundIdle)?Ct.pageForegroundIdle():St();me&&await me;const Ce=ne();Ce&&await Ce;const Me=v($e,q,oe.enabled);de=Me;const ze=w(qe,ee),_e=Array.isArray($e.groupBy)?$e.groupBy:[],De=_e.length>0,Oe=!Me.residual.filters&&!Me.residual.quick,xe=!De||S(_e,q.buckets);let Ue=ze.engine,Je=ze.client;if(q.aggregates&&Ue.length){const mt=q.aggregates instanceof Set?q.aggregates:new Set(I(q.aggregates)),wt=Ue.filter(dt=>!mt.has(dt.fn));wt.length&&(Ue=Ue.filter(dt=>mt.has(dt.fn)),Je=[...wt.map(dt=>({...dt,reason:`the ${J} adapter does not compute "${dt.fn}"`})),...Je])}const Qe=mt=>{Je=[...Ue.map(wt=>({...wt,reason:mt})),...Je],Ue=[]};Ue.length&&!Oe?Qe(Me.residual.quick&&!Me.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):Ue.length&&!xe&&Qe("a grouping key the engine cannot form forces all-client (no mixed provenance)");let at={},it;return Ue.length&&(B(De?G.executeGroupedAggregates:G.executeAggregates)?De?it=await G.executeGroupedAggregates(Me.pushed,_e,Ue)||[]:at=await G.executeAggregates(Me.pushed,Ue)||{}:(_(`source.pushdown.aggregates.${J}${De?".grouped":""}`,`the ${J} adapter cannot compute ${De?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),Qe(`adapter cannot compute ${De?"grouped ":""}aggregates`))),he={engine:Ue,client:Je,...De?{groupBy:_e}:{}},{values:at,engine:Ue,client:Je,...it!==void 0?{groups:it}:{}}},Bt=async $e=>{ht++;try{return await Tt($e)}finally{if(ht--,ht===0&&yt.length){const qe=yt;yt=[];for(const ve of qe)ve()}}},Dt=f(N.edit),ct=N.edit&&typeof N.edit=="object"&&B(N.edit.commit);let nt=N.edit;if(Dt&&!ct)if(q.mutate&&q.mutate.update){const $e=qe=>{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 ve={kind:"update",key:String(qe.key),patch:{[qe.colId]:qe.value}};return G.mutate(ve,qe.request||{})};nt={...N.edit===!0?{}:N.edit,commit:$e}}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 fe=Dt&&q.mutate&&(q.mutate.append||q.mutate.delete)?{append:q.mutate.append===!0,remove:q.mutate.delete===!0,returning:q.mutate.returning,mutate:($e,qe)=>G.mutate($e,qe||{})}:null,ke=async $e=>{const qe=ne();qe&&await qe;const{range:ve,signal:Se,export:me,...Ce}=$e||{},Me={...Ce,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:v(Me,q,oe.enabled),signal:Se}};async function*Re($e,qe={}){const{plan:ve,signal:Se}=await ke($e),me=Math.max(1,Math.floor(Number(qe.pageSize))||5e3),Ce={signal:Se,stream:!0};if(!ve.needsAll)for(let _e=0;;_e+=me){r(Ce);const De=await G.execute({...ve.pushed,range:{start:_e,end:_e+me}},Ce);De&&$(De.pendingTotal)&&De.pendingTotal.then(null,()=>{});const Oe=De&&De.rows||[];if(Oe.length&&(yield Oe),Oe.length<me)return}r(Ce);const Me=await P(await G.execute({...ve.pushed,range:void 0},Ce)),ze=F(Me&&Me.rows||[],{...ve.residual,whole:!0},N.compute||{});for(let _e=0;_e<ze.length;_e+=me)yield ze.slice(_e,_e+me)}return Ct={...N,edit:nt,rowMutate:fe,mode:"remote",fetch:Bt,foregroundIdle:St,aggregate:Et,countMatching:async $e=>{const{plan:qe,signal:ve}=await ke($e);if(!qe.needsAll&&q.total){r({signal:ve});const me=await P(await G.execute({...qe.pushed,range:{start:0,end:0}},{signal:ve}));if(me&&typeof me.total=="number")return me.total}let Se=0;for await(const me of Re($e))Se+=me.length;return Se},streamMatching:Re,lastPlan:()=>de?{...de,...he?{aggregates:he}:{},...Ae?{total:{deferred:!0,state:Ae.state,value:Ae.value}}:{}}:null,fullFrame:be,counts:()=>({match:ge,total:ye??null,pending:!!Ae&&Ae.state==="pending"}),grandTotals:()=>Ee},Ct}}),Le("packages/core/src/source/remote.js",function(e,K){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/internal/util.js"),x=Q.Lru,B=Q.isFunction,I=Q.warnOnce,_=Q.settleDebounce,X=K("packages/core/src/source/abort.js"),W=X.createAbortScope,H=X.isAbortError,V=K("packages/core/src/source/blockcache.js"),z=V.BlockCache,w=V.DEFAULT_PAGE_SIZE,S=V.DEFAULT_MAX_CACHED_PAGES,g=K("packages/core/src/source/rows.js"),l=g.createRowFactory,d=g.groupKey,a=K("packages/core/src/source/filterwire.js"),r=a.wireFilters,t=a.querySignature,n=a.warnHostFilterNotApplied,f=K("packages/core/src/source/pagewindow.js").pageWindow,o=K("packages/core/src/source/memory.js").MemorySource,c=K("packages/core/src/compute/handle.js").valueComparator,h=K("packages/core/src/compute/pivot.js"),s=h.pivotKey,p=h.joinPath,y=h.DEFAULT_PATH_SEPARATOR,A=K("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,b=1,v=120,R=1e3;function j(L,E,D){for(let $=0;$<Math.max(L.length,E.length);$++){const P=L[$],k=E[$],N=P==null,G=k==null;if(N||G){if(N&&G)continue;return N?1:-1}const q=D(P,k);if(q!==0)return q}return 0}function F(L,E){return new T(L,E)}class C{constructor(E,D,$,P){this.path=E,this.keyPath=P||E,this.values=[],this.level=D,this.key=d(this.keyPath),this.cache=new z($),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 T{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=[];#y=!1;#b=0;#j="";#w=null;#S=-1;constructor(E,D){this.#e=E||{mode:"remote"},this.#t=D||{},B(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#B(),this.unfilteredIndices=()=>this.#_(),this.handleFor=G=>this.#z(G),this.display=()=>this.#$(),this.grandTotalRow=()=>this.#I(),this.unfilteredRows=()=>this.#U(),this.facetIndices=G=>this.#q(G));const $=this.#e.counts;B($)&&(this.matchCount=()=>this.#W("match"),this.totalCount=()=>this.#W("total"));const P=this.#e.grandTotals;B(P)&&(this.grandTotalRow=()=>this.#H());const k=this.#e.foregroundIdle;B(k)&&(this.foregroundIdle=()=>this.#we(k),this.#e.pageForegroundIdle=()=>this.#y?this.#we(k):null);const N=this.#e;B(N.countMatching)&&B(N.streamMatching)&&(this.selectionQuery=()=>this.#he(),this.countMatching=G=>N.countMatching(G),this.streamMatching=(G,q)=>N.streamMatching(G,q),this.loadedRows=()=>this.#ie(),this.resident=()=>this.#N()!==null),this.#n={pageSize:this.#e.pageSize||w,maxCachedPages:this.#e.maxCachedPages||S},this.#l=l(this.#t),this.#a=new x(this.#n.pageSize*4),this.#h=_((G,q)=>this.#E(G,q),v),this.#r=new C([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#f=this.#ce(),B(this.#e.fetch)||I("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#Ue()}count(){const E=this.#O();return E?E.length:this.#v()}#v(){const E=this.#N();return E?E.count():(this.#ee(),this.#te(this.#r))}#C(){if(this.#N())return!0;const E=D=>{if(D.count===null&&!D.complete)return!1;for(const $ of D.children.values())if(this.#Pe($.key)&&!E($))return!1;return!0};return E(this.#r)}pageInfo(){const E=this.#O(),D=this.totalPending();if(!E){const $=this.#v();return{page:0,pageSize:0,total:this.#C()?$: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}}#O(){const E=this.#v(),D=f(this.#R("pageSize",0),this.#R("page",0),E,this.#C());if(!D)return this.#j="",null;const $=`${this.#b}:${D.offset}:${D.length}`;return $!==this.#j&&!this.#p&&(this.#j=$,D.length>0&&!this.#N()&&this.#E(D.offset,D.offset+D.length-1)),D}at(E){const D=this.#O();if(D){if(E<0||E>=D.length)return;const $=this.#P(D.offset+E);return $&&($.index=E),$}return this.#P(E)}#P(E){const D=this.#N();if(D)return D.at(E);if(this.#ee(),E<0||E>=this.#v())return;const $=this.#K(this.#r,E);if(!$)return;const P=this.#Z($.node,$.local);return P&&(P.index=E),P||this.#l.skeleton(E,$.node.level,$.node.cache.erroredAt($.local))}byKey(E){const D=this.#N();if(D)return D.byKey(E);const $=this.#u.get(E);if(!$)return;const P=$.lastIndexOf(":"),k=this.#o.get($.slice(0,P));return k&&this.#Z(k,Number($.slice(P+1)))||void 0}loaded(E){const D=this.#O();if(D){if(E<0||E>=D.length)return!1;E+=D.offset}const $=this.#N();if($)return $.loaded(E);if(E<0||E>=this.#v())return!1;const P=this.#K(this.#r,E);return!!P&&P.node.cache.rowLoaded(P.local)}hint(E,D){if(this.#p)return;this.#y=!0;const $=this.#ee();let P=Math.max(0,Math.floor(E)),k=Math.max(P,Math.floor(D));const N=this.#O();if(N){if(N.length===0)return;P=N.offset,k=N.offset+N.length-1}for(const[G,q]of this.#M(P,k)){G.cache.protect(q.min,q.max);for(const Y of G.cache.evict())this.#Ne(G,Y)}this.#h(P,k),$&&this.#h.flush()}#M(E,D){const $=this.#v(),P=new Map;for(let k=E;k<=D&&k<$;k++){const N=this.#K(this.#r,k);if(!N)continue;const G=P.get(N.node);G?(G.min=Math.min(G.min,N.local),G.max=Math.max(G.max,N.local)):P.set(N.node,{min:N.local,max:N.local})}return P.size||P.set(this.#r,{min:E,max:E}),P}#E(E,D){if(!this.#p)for(const[$,P]of this.#M(E,D)){$.cache.protect(P.min,P.max);const k=$.cache.blockOf(P.min),N=$.cache.blockOf(P.max);for(let G=k;G<=N&&!($.count!==null&&G*$.cache.pageSize>=$.count);G++)$.cache.has(G)||this.#Ie($,G)}}apply(E){const D={added:[],updated:[],removed:[]};if(!E)return D;if(E.update)for(const $ of E.update){const P=this.#u.get(this.#l.keyOf($,-1));if(!P)continue;this.#a.delete(P);const k=P.lastIndexOf(":"),N=this.#o.get(P.slice(0,k));if(!N)continue;const G=Number(P.slice(k+1)),q=N.cache.blockOf(G);if(!N.cache.loaded(q))continue;const{start:Y}=N.cache.rangeOf(q),J=[];for(let ne=Y;ne<Y+N.cache.pageSize;ne++){const oe=N.cache.rowAt(ne);if(oe===void 0)break;J.push(ne===G?$:oe)}N.cache.fill(q,J);const te=this.#Z(N,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.#G("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#s.abortAll("destroyed"),this.#ae(),this.#o.clear(),this.#i.clear(),this.#w&&B(this.#w.destroy)&&this.#w.destroy(),this.#w=null}expand(E){this.#i.has(E)||(this.#i.add(E),this.#G("group:toggled",{key:E,expanded:!0}),this.#G("model:changed",{reason:"expand",key:E}))}collapse(E){this.#i.delete(E)&&(this.#G("group:toggled",{key:E,expanded:!1}),this.#G("model:changed",{reason:"collapse",key:E}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}pivot(){this.#ee();const E=this.#d;if(!E||!E.keys.size||!this.#R("pivotBy",[]).length)return null;if(!E.result){const D=c((this.#t.config||{}).locale),$=[...E.keys.entries()].sort((k,N)=>j(k[1],N[1],D)),P=$.map(([k])=>k);E.result={keys:$.map(([,k])=>k),paths:P,fields:this.#se(P),groupPaths:[],columns:P.length*Math.max(1,this.#Ce().length),values:E.cells,cells:E.cells,error:null}}return E.result}invalidateHandles(){this.#w&&(B(this.#w.invalidateHandles)&&this.#w.invalidateHandles(),B(this.#w.invalidate)&&this.#w.invalidate("filter"))}#T(){const E=this.#e.fullFrame;return B(E)?E():null}#N(){const E=this.#T();return E?(this.#w||(this.#w=new o({mode:"memory"},this.#L())),E.version!==this.#S&&(this.#w.setRows(E.rows),this.#S=E.version),this.#w):null}#L(){const E=this.#t,D=E.state||{};return{...E,state:{...D,page:()=>0,pageSize:()=>0}}}#B(){const E=this.#N();return E?E.filteredIndices():new Uint32Array(0)}#_(){const E=this.#N();return E?E.unfilteredIndices():new Uint32Array(0)}#z(E){const D=this.#N();return D?D.handleFor(E):void 0}#$(){const E=this.#N();return E?E.display():[]}#q(E){const D=this.#N();return D&&B(D.facetIndices)?D.facetIndices(E):new Uint32Array(0)}#I(){const E=this.#N();return E&&B(E.grandTotalRow)?E.grandTotalRow():null}#W(E){const D=this.#N();if(D){const N=E==="match"?D.matchCount:D.totalCount;if(B(N))return N.call(D)}const $=this.#e.counts,P=B($)?$():null,k=P?P[E]:null;return typeof k=="number"?k:this.#v()}#H(){const E=this.#N();if(E&&B(E.grandTotalRow))return E.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const $=this.#e.grandTotals,P=B($)?$():null;return!P||!P.totals?null:this.#l.grandTotal(P.totals,P.leafCount||0)}#U(){const E=this.#N();if(E&&B(E.unfilteredRows))return E.unfilteredRows();const D=[],$=this.count();for(let P=0;P<$;P++){const k=this.at(P);k&&D.push(k)}return D}#he(){const E=this.#R("quick",""),D={protocol:b,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:r(this.#R("filters",null),this.#J()),sort:this.#R("sort",[]),context:this.#R("context",null)};E&&(D.quick=E);const $=this.#R("where",null);return $&&$.active&&(D.where=$),D}#ie(){const E=this.#R("groupBy",[]).length,D=[];for(const $ of this.#o.values())if(!($.level!==E&&!$.flat))for(const P of $.cache.ids()){if(!$.cache.loaded(P))continue;const{start:k,end:N}=$.cache.rangeOf(P);for(let G=k;G<N&&$.cache.rowLoaded(G);G++){const q=this.#Z($,G);q&&!q.group&&D.push(q)}}return D}loadedCount(){const E=this.#N();if(E){const P=E.matchCount();return typeof P=="number"?P:E.count()}this.#ee();const D=this.#R("groupBy",[]).length;let $=0;for(const P of this.#o.values())if(!(P.level!==D&&!P.flat))for(const k of P.cache.ids()){if(!P.cache.loaded(k))continue;const N=P.cache.fillOf(k);typeof N=="number"&&($+=N)}return $}residentRows(){const E=this.#N();return E?E.display():this.#R("groupBy",[]).length>0?null:(this.#ee(),this.#ie())}#ye(E,D,$){const{start:P,end:k}=E.cache.rangeOf(D),N=this.#R("groupBy",[]),G=this.#R("pivotBy",[]),q=this.#R("quick",""),Y=this.#Ce(),J={protocol:b,range:{start:P,end:k},groupPath:E.path,groupValues:E.values,groupBy:N,totals:Y,totalFns:this.#Y(Y),pivotBy:G,pivotMode:G.length>0,filters:r(this.#R("filters",null),this.#J()),sort:this.#R("sort",[]),context:this.#R("context",null),signal:$};q&&(J.quick=q);const te=this.#R("where",null);return te&&te.active&&(J.where=te),J}async#Ie(E,D){if(!B(this.#e.fetch))return;if(!this.#m){this.#m=!0;const N=this.#g;this.#g=[],queueMicrotask(()=>{for(const G of N)G()})}const $=this.#s.begin(`${E.key}:${D}`);E.cache.begin(D,$);const P=this.#f,{start:k}=E.cache.rangeOf(D);try{const N=await this.#e.fetch(this.#ye(E,D,$.signal));if(!$.current||P!==this.#f||this.#p)return;$.settle();const G=N&&N.rows||[];if(!!(N&&N[A])&&!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}:${k+te}`);const Y=N&&typeof N.count=="number"?N.count:N&&typeof N.total=="number"?N.total:null,J=N&&B(N.pendingTotal?.then)?N.pendingTotal:null;Y!==null?(E.count=Y,E.complete=!0):G.length<E.cache.pageSize?(E.count=k+G.length,E.complete=!0):J&&(E.counting=!0,E.announced=null),N&&Array.isArray(N.pivotFields)&&this.#Ee(N.pivotFields),N&&N.pivot&&typeof N.pivot=="object"&&this.#Te(N.pivot),this.#G("model:changed",{reason:"page",groupPath:E.path,block:D}),this.#G("rows:changed",{companion:!0,reason:"page",groupPath:E.path,block:D}),this.#pe(E),J&&this.#be(E,J,P)}catch(N){if($.settle(),H(N))return;E.cache.failed(D,N),E.failed=!0;const{end:G}=E.cache.rangeOf(D);for(let q=k;q<G;q++)this.#a.delete(`${E.key}:${q}`);this.#G("model:changed",{reason:"page-error",groupPath:E.path,block:D}),this.#G("source:error",{error:N,groupPath:E.path,block:D})}}async#be(E,D,$){let P;try{P=await D}catch(k){if($!==this.#f||this.#p)return;E.counting=!1,H(k)||(E.failed=!0),H(k)||this.#G("source:error",{error:k,groupPath:E.path});return}$!==this.#f||this.#p||(E.counting=!1,typeof P=="number"&&(E.count=P,E.complete=!0,this.#pe(E),this.#G("model:changed",{reason:"total",count:P,groupPath:E.path})))}#pe(E){typeof E.count!="number"||!E.complete||E.announced!==E.count&&(E.announced=E.count,this.#G("source:total",{total:E.count,groupPath:E.path}))}#we(E){if(this.#p)return null;this.#ee();const D=this.#m?null:new Promise(G=>{this.#g.push(G),setTimeout(G,R)}),$=E();if(!D&&!$)return null;const P=(async()=>{D&&await D;for(let G=E();G;G=E())await G})();let k;const N=new Promise(G=>{k=setTimeout(G,R)});return Promise.race([P,N]).then(()=>clearTimeout(k))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#N())return!1;this.#ee();const E=this.#r;return E.count===null&&!E.complete&&E.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#Ee(E){E.length===this.#c.length&&E.every((D,$)=>D===this.#c[$])||(this.#c=E,this.#G("column:pivoted",{pivotFields:E,remote:!0}))}#me(){const E=this.#t.config||{};return E.pivot&&E.pivot.separator||y}#se(E){const D=this.#me(),$=this.#Ce();if(!$.length)return E.slice();const P=[];for(const k of E)for(const N of $)P.push(`${k}${D}${N}`);return P}#Te(E){const D=this.#me();this.#d||(this.#d={keys:new Map,cells:new Map,result:null});const $=this.#d;let P=!1;const k=G=>{const q=Array.isArray(G)?G:[G],Y=p(q,D);return $.keys.has(Y)||($.keys.set(Y,q),P=!0),Y},N=this.#R("groupBy",[]).length>0;for(const G of Array.isArray(E.axis)?E.axis:[])k(G);for(const G of Array.isArray(E.cells)?E.cells:[]){if(!G||typeof G!="object")continue;const q=k(G.pivot);if(N&&!(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||{}))$.cells.set(s(Y,q,J),te)}$.result=null,P&&this.#Ee((this.pivot()||{fields:[]}).fields)}#te(E){let D=this.#ne(E);for(const $ of E.children.values())this.#Pe($.key)&&(D+=this.#te($));return D}#ne(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.#R("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}#K(E,D){let $=D,P=0;const k=[...E.children.entries()].filter(([,G])=>this.#Pe(G.key)).sort((G,q)=>G[0]-q[0]);for(const[G,q]of k){const Y=G-P+1;if($<Y)return{node:E,local:P+$};$-=Y,P=G+1;const J=this.#te(q);if($<J)return this.#K(q,$);$-=J}const N=this.#ne(E);return P+$<N?{node:E,local:P+$}:null}#Z(E,D){const $=`${E.key}:${D}`,P=this.#a.get($);if(P)return P;const k=E.cache.rowAt(D);if(k===void 0)return null;const N=this.#R("groupBy",[]);let G;if(E.level<N.length&&!E.flat){const q=N[E.level],Y=this.#d!==null&&E.level===N.length-1&&this.#R("pivotBy",[]).length>0,J=this.#x(k,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(k.leafCount)||0,expanded:Y?!1:this.#Pe(d(oe)),...Y?{hasChildren:!1}:{}}),G.totals=this.#D(k),G.data=k,!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(k,D,E.level,E.row);return this.#a.set($,G),this.#u.set(G.key,$),G}#D(E){const D=E||{};if(D.totals&&typeof D.totals=="object")return D.totals;const $={};for(const P of this.#Ce())Object.hasOwn(D,P)&&($[P]=D[P]);return $}#Ne(E,D){const{start:$,end:P}=E.cache.rangeOf(D);for(let k=$;k<P;k++){const N=`${E.key}:${k}`,G=this.#a.peek(N);G&&this.#u.delete(G.key),this.#a.delete(N)}}#ee(){const E=this.#ce();return E===this.#f?!1:(this.#f=E,this.#s.abortAll("query"),this.#ae(),this.#m=!1,this.#G("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}#ce(){const E=this.#R("where",null);return`${t({filters:this.#R("filters",null),sort:this.#R("sort",[]),quick:this.#R("quick",""),groupBy:this.#R("groupBy",[]),pivotBy:this.#R("pivotBy",[]),context:this.#R("context",null)})}|${E?E.version:0}`}#Pe(E){const D=this.#R("expanded",null);return D?B(D.has)?D.has(E):Array.prototype.includes.call(D,E):this.#i.has(E)}#Ce(){const E=this.#R("totals",[]);if(E&&E.length)return[...E];const D=this.#t.columns;return!D||!B(D.all)?[]:D.all().filter($=>!!$.total).map($=>$.id)}#Y(E){const D=this.#t.columns,$={};if(!D||!B(D.get))return $;for(const P of E){const k=D.get(P);if(!k)continue;const N=k.groupTotal!=null?k.groupTotal:k.total;typeof N=="string"&&($[P]=N)}return $}#x(E,D){const $=this.#t.columns,P=$&&B($.get)?$.get(D):void 0;return P&&B(P.getValue)?P.getValue(E):E?.[D]}#Ue(){n(this.#t)}#J(){const E=this.#t.config||{};return{tz:E.timeZone,weekStartsOn:E.weekStartsOn}}#R(E,D){const $=this.#t.state;if($&&B($[E])){const P=$[E]();return P??D}return D}#G(E,D){const $=this.#t.emit;B($)&&$(E,D)}}}),Le("packages/core/src/source/gapbuffer.js",function(e,K){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return x}});const Q=64;class x{#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 x(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}}}),Le("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 S}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return r}});const Q=K("packages/core/src/internal/util.js"),x=Q.now,B=Q.nextFrame,I=Q.infoOnce,_=Q.warnOnce,X=Q.isFunction,W=Q.pathGetter,V=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,n={}){if(n.multi)return"multi";if(t.length===0)return"object";let i=0,f=0,u=0,o=0,m=0;for(let h=0;h<t.length;h++){const s=t[h];typeof s=="number"?i++:typeof s=="boolean"?f++:typeof s=="string"?u++:s instanceof Date?o++:Array.isArray(s)&&m++}const c=t.length;return i===c?"float64":f===c?"bitset":o===c?"float64":u===c?"text":m===c?"multi":"object"}function S(t,n,i){return n<=0||t<i*n?"dictionary":"object"}function g(t,n,i){const f=new Map,u=new Map;for(const b of t){if(b.computed)continue;const v=X(b.read)?b.read:W(b.field||b.id);u.set(b.id,v),f.set(b.id,v)}const o=n?.order??[],m=n?.fns??{},c=n?.deps??{},h=n?.wrapDeps??null,s=o.filter(b=>X(m[b])),p=s.some(b=>c[b]==="*");let y=new WeakMap;const O=b=>{const v={};if(p)for(const[R,j]of u)v[R]=j(b);for(const R of s){const j=c[R];let F;if(j==="*")F=v;else{F={};const C=j||[];for(let T=0;T<C.length;T++){const L=C[T];F[L]=L in v?v[L]:u.get(L)?.(b)}}v[R]=m[R](h?h(F,R):F,{data:b,row:null,column:null,grid:null,context:i})}return v},A=b=>{if(b===null||typeof b!="object"&&typeof b!="function")return O(b);let v=y.get(b);return v===void 0&&(v=O(b),y.set(b,v)),v};for(const b of s)f.set(b,v=>A(v)[b]);return{readers:f,reset(){y=new WeakMap}}}class l{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(n,i){this.spec=n,this.read=i,this.kind="object",this.inferred=!1,this.nullable=n.nullable!==!1}}class d{#e;#t=[];#n=null;#r;#o=0;#i;#s=!1;#l=!1;#a=0;#u;constructor(n,i={},f={}){this.#e=Array.isArray(n)?n:Array.from(n||[]),this.#i={...z,...f};const u=i.columns??[];this.#r=g(u,i.computed??null,i.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(u,i.computed??null),this.#n=new V(this.#t.map(o=>({id:o.spec.id,kind:o.kind,nullable:o.nullable,read:o.read,dictionary:o.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 n=x(),{chunkMs:i,chunkRows:f}=this.#i,u=this.#e.length;do{const o=Math.min(this.#o+f,u);this.#n.append(this.#e.slice(this.#o,o)),this.#d(this.#o,o),this.#o=o,this.#r.reset(),this.#h(!1)}while(this.#o<u&&x()-n<i);return this.#a+=x()-n,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(n=>({id:n.spec.id,kind:n.kind,nullable:n.nullable,read:n.read,dictionary:n.spec.dictionary})),decisions:this.#t.map(n=>({id:n.spec.id,kind:n.kind,nullable:n.nullable,inferred:n.inferred,distinct:n.candidate||n.change?this.#f(n):null,change:n.change,reason:n.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#c(n,i){const f=this.#e,u=Math.min(this.#i.sampleSize,f.length),o=this.#i.dictionaryRatio,m=i?.pure instanceof Set?i.pure:new Set(i?.pure??i?.order??[]);for(const c of n){if(!c||!c.id)continue;if(c.computed&&(c.pure===!1||i&&!m.has(c.id))){_(`ingest.impure.${c.id}`,`column "${c.id}" is an impure computed column and is not materialised into the store`);continue}const h=this.#r.readers.get(c.id)??(X(c.read)?c.read:W(c.field||c.id)),s=new l(c,h);if(c.kind)s.kind=c.kind,s.reason="declared by the caller";else if(c.dictionary)s.kind=c.multi?"multi":"dictionary",s.reason="value table supplied (lookup column)";else{const p=[];for(let O=0;O<u&&p.length<this.#i.sampleSize;O++){const A=h(f[O]);A!=null&&p.push(A)}s.inferred=!0;const y=w(p,{multi:c.multi});if(y==="text"){const O=new Set(p).size;s.kind=S(O,p.length,o),s.candidate=this.#u,s.reason=`sampled ${O} distinct in ${p.length}`}else s.kind=y,s.reason=`inferred from ${p.length} sampled values`,y==="object"&&p.length&&I(`ingest.mixed.${c.id}`,`column "${c.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);s.kind==="object"&&s.candidate&&(s.distinct=new Set(p))}this.#t.push(s)}}#d(n,i){const f=this.#e;for(const u of this.#t){if(!u.candidate||!u.distinct)continue;const o=u.distinct;for(let m=n;m<i;m++){const c=u.read(f[m]);c!=null&&o.add(c)}}}#f(n){if(n.distinct)return n.distinct.size;const i=this.#n.column(n.spec.id);return i?.dict?i.dict.size:0}#h(n){const i=this.#i.dictionaryRatio,f=this.#e.length;for(const u of this.#t){if(!u.candidate)continue;const o=this.#f(u);if(u.kind==="dictionary"&&o>=i*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=`${o} distinct values is at or above ${i*100}% of ${f} rows`;continue}if(u.kind==="object"&&o>=i*f){u.candidate=!1,u.distinct=null,u.reason=`${o} distinct values is at or above ${i*100}% of ${f} rows`;continue}n&&u.kind==="object"&&o<i*f&&(this.#n.convert(u.spec.id,"dictionary"),u.kind="dictionary",u.change=u.change==="demoted"?null:"promoted",u.reason=`${o} distinct values is below ${i*100}% of ${f} rows`,u.distinct=null),n&&(u.candidate=!1)}}}async function a(t,n={},i={}){const f=new d(t,n,i),u=i.scheduler?.frame??B;for(;f.slice();)await new Promise(o=>{u(o)});return f.result()}function r(t,n={},i={}){const f=new d(t,n,{...i,chunkMs:1/0});for(;f.slice(););return f.result()}}),Le("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 d}});const x=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,V=new Set(["float64","int32","bitset","dictionary","object","multi"]);function z(a){if(!Array.isArray(a)||a.length===0)return!1;for(const r of a)if(!r||typeof r.id!="string"||typeof r.field!="string"||r.field===""||r.kind&&!V.has(r.kind))return!1;return!0}function w(a){const r=H(a);return Number.isFinite(r)?r|0:0}function S(a){return a==null?[]:Array.isArray(a)?a:[a]}function g(a,r,t,n){if(a.kind)return a.kind;const i=[];for(let o=0;o<r.length&&i.length<X.sampleSize;o++){const m=r[o];m!=null&&i.push(m)}const f=I(i,{multi:a.multi});if(f!=="text")return f;const u=new Set(i).size;return _(u,i.length,n)}function l(a,r,t={}){const n=r.length|0,i=t.dictionaryRatio??X.dictionaryRatio,f=[];for(const u of a){const o=x(u.field||u.id),m=u.nullable!==!1,c=new Array(n);for(let O=0;O<n;O++){const A=o(r[O]);c[O]=A===void 0?null:A}const h=g(u,c,n,i),s=m?new Uint8Array(n+7>>3):null,p=O=>{s&&(s[O>>3]|=1<<(O&7))};let y;switch(h){case"float64":{const O=new Float64Array(n);for(let A=0;A<n;A++){const b=c[A],v=b===null;v||p(A),O[A]=v?NaN:H(b)}y={id:u.id,kind:h,nullable:m,values:O,presence:s,offsets:null,table:null};break}case"int32":{const O=new Int32Array(n);for(let A=0;A<n;A++){const b=c[A],v=b===null;v||p(A),O[A]=v?0:w(b)}y={id:u.id,kind:h,nullable:m,values:O,presence:s,offsets:null,table:null};break}case"bitset":{const O=new Uint8Array(n+7>>3);for(let A=0;A<n;A++){const b=c[A],v=b===null;v||p(A),!v&&b&&(O[A>>3]|=1<<(A&7))}y={id:u.id,kind:h,nullable:m,values:O,presence:s,offsets:null,table:null};break}case"dictionary":{const O=new Uint32Array(n),A=[],b=new Map;for(let v=0;v<n;v++){const R=c[v];if(R===null){O[v]=0;continue}p(v);let j=b.get(R);j===void 0&&(j=A.length,A.push(R),b.set(R,j)),O[v]=j}y={id:u.id,kind:h,nullable:m,values:O,presence:s,offsets:null,table:A};break}case"multi":{const O=[],A=new Map,b=new Uint32Array(n+1),v=[];for(let R=0;R<n;R++){const j=c[R];b[R]=v.length,j===null||p(R);const C=S(j);for(let T=0;T<C.length;T++){const L=C[T];let E=A.get(L);E===void 0&&(E=O.length,O.push(L),A.set(L,E)),v.push(E)}}b[n]=v.length,y={id:u.id,kind:h,nullable:m,values:Int32Array.from(v),presence:s,offsets:b,table:O};break}default:{const O=new Array(n);for(let A=0;A<n;A++){const b=c[A];b!==null&&p(A),O[A]=b}y={id:u.id,kind:"object",nullable:m,values:O,presence:s,offsets:null,table:null};break}}f.push(y)}return{count:n,columns:f}}function d(a){const r=[];if(!a||!Array.isArray(a.columns))return r;const t=n=>{ArrayBuffer.isView(n)&&n.buffer&&!r.includes(n.buffer)&&r.push(n.buffer)};for(const n of a.columns)t(n.values),t(n.presence),t(n.offsets);return r}}),Le("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 j}});const Q=K("packages/core/src/internal/util.js"),x=Q.Lru,B=Q.isFunction,I=Q.now,_=Q.nextFrame,X=Q.cancelFrame,W=Q.whenIdle,H=Q.defaultCompare,V=Q.warnOnce,z=Q.infoOnce,w=Q.getPath,S=K("packages/core/src/source/abort.js"),g=S.createAbortScope,l=S.isAbortError,d=K("packages/core/src/source/rows.js"),a=d.createRowFactory,r=d.lazyRowView,n=K("packages/core/src/source/gapbuffer.js").GapBuffer,f=K("packages/core/src/source/memory.js").createMemorySource,o=K("packages/core/src/source/filterwire.js").querySignature,c=K("packages/core/src/store/columnpack.js").isPortableSchema,h=25e4,s=Symbol("lattice.stream.storeBacked"),p=8,y=.1,O=1e3,A=50;function b(F){return Math.min(O,Math.max(A,Math.floor(F/4)))}function v(F){if(F instanceof Date)return F.getTime();if(typeof F=="number")return Number.isFinite(F)?F:NaN;if(typeof F=="string"){const C=F.trim();if(!C)return NaN;const T=Date.parse(C);return Number.isNaN(T)?Number(C):T}return NaN}function R(F,C){return new j(F,C)}class j{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;#y=null;#b=null;#j=!1;#w=!1;#S=!1;#v=!1;#C="";#O=0;#P=0;#M=0;#E=null;#T=1/0;#N=!1;#L=null;#B=null;#_=null;#z=null;#$=!1;#q=0;#I=0;#W=!1;constructor(C,T){this.#e=C||{mode:"stream"},this.#t=T||{},this.#s=a(this.#t),this.#l=new x(4096),this.#C=this.#_e();const L=(this.#t.config||{}).ingest;this.#$=!!L&&L.retainSource===!1,B(this.#e.open)||V("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.#z=setInterval(()=>{this.#v||this.reload()},E),this.#z&&B(this.#z.unref)&&this.#z.unref()),this.#U()}#H(){const C=Number(this.#e.maxAge);return Number.isFinite(C)&&C>0?C:0}#U(){const C=this.#H();if(!C)return;const T=this.#e.ageBy;B(T)?this.#B=T:typeof T=="string"&&T?this.#B=L=>w(L,T):this.#B=null,this.#E=[],this.#L=setInterval(()=>{this.#v||this.#he()&&(this.#ee(),this.#fe())},b(C)),this.#L&&B(this.#L.unref)&&this.#L.unref()}#he(){const C=this.#H();return!C||!this.#E?!1:this.#N?!0:this.#T<Date.now()-C*(1+y)}#ie(C,T){if(!this.#E)return;const L=this.#B?v(this.#B(T)):Date.now();this.#E[C]=L,Number.isNaN(L)||(L<this.#T&&(this.#T=L),L<Date.now()-this.#H()&&(this.#N=!0))}#ye(){return this.#ke("groupBy",[]).length>0?!0:!!this.#ke("pivotMode",!1)&&this.#ke("pivotBy",[]).length>0}#Ie(){if(this.#g||this.#v)return;const C=this.#ye();if(C&&!this.#y){this.#y=f({mode:"memory",rows:this.#n},this.#be()),this.#j=!1;return}!C&&this.#y&&(this.#y.destroy(),this.#y=null)}#be(){if(this.#b)return this.#b;const C=this,T={liveIndices:()=>C.#pe(),live:L=>C.#n[L]!==void 0,source:L=>C.#Se(L),get physical(){return C.#n.length}};return this.#$&&(T.column=L=>{const E=C.#t.store;return E&&B(E.column)?E.column(L):void 0}),this.#b=Object.create(this.#t,{store:{value:T,enumerable:!0,configurable:!0}}),this.#b}#pe(){const C=new Uint32Array(this.#n.length);let T=0;for(let L=0;L<this.#n.length;L++)this.#n[L]!==void 0&&(C[T++]=L);return C.subarray(0,T)}#we(){return this.#g?this.#g:this.#y?(this.#j&&(this.#j=!1,this.#y.setRows(this.#n)),this.#y):null}invalidate(C="filter"){if(this.#g){this.#g.invalidate(C);return}this.#Ie(),this.#y&&this.#y.invalidate(C),(C==="filter"||C==="sort")&&this.#Ce()}count(){const C=this.#we();return C?C.count():this.#r?this.#r.length:this.#O}matchCount(){const C=this.#we();return C&&B(C.matchCount)?C.matchCount():this.#r?this.#r.length:this.#O}totalCount(){const C=this.#we();return C&&B(C.totalCount)?C.totalCount():this.#O}unfilteredRows(){const C=this.#we();if(C&&B(C.unfilteredRows))return C.unfilteredRows();const T=[];for(let L=0;L<this.#n.length;L++){if(!this.#n[L])continue;const E=this.#Oe(L);E&&T.push(E)}return T}at(C){const T=this.#we();if(T)return T.at(C);if(C<0||C>=this.count())return;const L=this.#r?this.#r.at(C):C,E=this.#Oe(L);return E.index=C,E}byKey(C){const T=this.#we();if(T)return T.byKey(C);const L=this.#a.get(C);return L===void 0?void 0:this.#Oe(L)}leavesOf(C){const T=this.#we();return T&&B(T.leavesOf)?T.leavesOf(C):[]}loaded(C){return C>=0&&C<this.count()}hint(C,T){if(this.#g){this.#g.hint(C,T);return}this.#Ee(),this.#p=Math.max(0,Math.floor(C))}#Ee(){this.#v||this.#_e()===this.#C||this.reload()}display(){const C=this.#we();return C?C.display():r(()=>this.count(),T=>this.at(T))}apply(C){if(this.#g)return this.#g.apply(C);const T={added:[],updated:[],removed:[]};if(!C)return T;if(C.update){let L=!1;for(const E of C.update){const D=this.#a.get(this.#s.keyOf(E,-1));if(D===void 0)continue;const $=this.#Ue(D);this.#$?this.#We(D,E):this.#n[D]=E,this.#l.delete(D),this.#J(D,$),this.#E&&(this.#ie(D,E),L=!0),this.#j=!0,T.updated.push(this.#Oe(D))}L&&this.#ee()}if(C.add&&C.add.length){const L=this.#D(C.add);for(const E of L)T.added.push(this.#Oe(E))}return C.remove&&C.remove.length&&V("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#fe(),T}reload(C){this.#u.abortAll("reload"),this.#Ve(),this.#y&&(this.#y.destroy(),this.#y=null),this.#j=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#O=0,this.#P=0,this.#M=0,this.#E&&(this.#E=[]),this.#T=1/0,this.#N=!1,this.#w=!1,this.#S=!1,this.#c={loaded:0,estimated:void 0},this.#C=this.#_e(),this.#Le("model:changed",{reason:"reload"}),this.start()}destroy(){this.#v=!0,this.#z!==null&&(clearInterval(this.#z),this.#z=null),this.#L!==null&&(clearInterval(this.#L),this.#L=null),this.#E=null,this.#u.abortAll("destroyed"),this.#Ve(),this.#d!==null&&(this.#k(this.#d),this.#d=null),this.#y&&(this.#y.destroy(),this.#y=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#S||this.#v||!B(this.#e.open))return;this.#S=!0;const C=this.#u.begin("stream");this.#Ce(),this.#Ie();let T;try{T=this.#e.open({sort:this.#ke("sort",[]),filters:this.#ke("filters",null),quick:this.#ke("quick","")||void 0,context:this.#ke("context",null),signal:C.signal})}catch(E){this.#Le("source:error",{error:E});return}const L=B(T[Symbol.asyncIterator])?T[Symbol.asyncIterator]():T[Symbol.iterator]();this.#_=L;try{for(;;){const E=await L.next();if(!C.current||this.#v)return;if(E.done){this.#le();return}if(await this.#me(E.value,C),!C.current||this.#v)return;if(E.value&&E.value.done){this.#le();return}if(await this.#oe(),!C.current||this.#v)return}}catch(E){if(l(E))return;this.#Le("source:error",{error:E})}finally{C.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#w,live:this.#O,evicted:this.#P}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const C=this.#we();C&&(B(C.invalidateHandles)&&C.invalidateHandles(),B(C.invalidate)&&C.invalidate("sort"))}renderCount(){return this.#f}ingestStats(){return{worker:this.#q,inline:this.#I,storeBacked:this.#$}}#me(C,T){if(!C)return;const L=C.rows;if(L&&L.length&&this.#Te(L))return this.#ne(C,T);const E=I();L&&L.length&&(this.#D(L),this.#I++),this.#se(C),this.#h+=I()-E,this.#fe()}#se(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)}#Te(C){if(this.#W||this.#g)return!1;const T=this.#K();if(!T)return!1;const L=this.#t.store;if(!L||!B(L.appendPacked))return!1;const E=this.#Z();return!E||!c(E)?(this.#W=!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<T.threshold?!1:!this.#te(C)}#te(C){if(!this.#s.keyed)return!1;const T=new Set;for(let L=0;L<C.length;L++){const E=this.#s.keyOf(C[L],this.#n.length+L);if(E!=null){if(T.has(E)||this.#a.has(E))return!0;T.add(E)}}return!1}async#ne(C,T){const L=C.rows,E=this.#K(),D=this.#Z();let $;try{$=await E.columnize(D,L,{key:"ingest:stream",signal:T&&T.signal})}catch(q){if(l(q)||(V("source.stream.columnize","worker columnization failed; columnizing on the main thread",q),this.#W=!0,T&&(!T.current||this.#v)))return;this.#D(L),this.#I++,this.#se(C),this.#fe();return}if(T&&(!T.current||this.#v))return;const P=this.#t.store,k=this.#$?void 0:L,{from:N}=P.appendPacked($,k),G=$.count|0;for(let q=0;q<G;q++){const Y=N+q,J=L[q],te=this.#s.keyed?this.#s.keyOf(J,Y):null;if(this.#n[Y]=this.#$?s:J,this.#O++,this.#ie(Y,J),te!==null&&this.#a.set(te,Y),!this.#r||!this.#Y(Y))continue;const ne=this.#R(Y);this.#r.insert(ne,Y),ne<=this.#p&&this.#m++}this.#j=!0,this.#ee(),this.#q++,this.#se(C),this.#fe()}#K(){const C=this.#t.ingestWorker;return B(C)?C():null}#Z(){const C=this.#t.storeSchema;return B(C)?C():null}#D(C){const T=[],L=this.#t.store,E=new Array(C.length),D=[],$=new Set;for(let k=0;k<C.length;k++){const N=this.#s.keyed?this.#s.keyOf(C[k],this.#n.length+D.length):null;E[k]=N,!(N!==null&&(this.#a.has(N)||$.has(N)))&&(N!==null&&$.add(N),D.push(C[k]))}let P=D.length&&L&&B(L.append)?L.append(D).from:this.#n.length;for(let k=0;k<C.length;k++){const N=C[k],G=E[k];if(G!==null&&this.#a.has(G)){const J=this.#a.get(G),te=this.#Ue(J);this.#$||(this.#n[J]=N,L&&B(L.setSource)&&L.setSource(J,N)),this.#We(J,N),this.#l.delete(J),this.#ie(J,N),this.#J(J,te);continue}const q=P++;if(this.#n[q]=this.#$?s:N,this.#O++,this.#ie(q,N),G!==null&&this.#a.set(G,q),T.push(q),!this.#r||!this.#Y(q))continue;const Y=this.#R(q);this.#r.insert(Y,q),Y<=this.#p&&this.#m++}return this.#j=!0,this.#ee(),T}#Ne(C){const T=this.#n[C];let L=!1;if(this.#r){const P=this.#Pe(C);P>=0&&P<=this.#p&&(L=!0)}else C<=this.#p&&(L=!0);const E=T===s?this.#Se(C):T,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.#E&&(this.#E[C]=NaN),this.#l.delete(C);const $=this.#t.store;return $&&B($.remove)&&$.remove(C),this.#O--,L}#ee(){let C=0,T=0;const L=this.#ce();C+=L.dropped,T+=L.aboveAnchor;const E=this.#ae();C+=E.dropped,T+=E.aboveAnchor,C&&(this.#j=!0,this.#P+=C,this.#Ce(),this.#m-=T,this.#Le("stream:evicted",{evicted:C,total:this.#P,live:this.#O}))}#ae(){const C=this.#e.maxRows;if(!Number.isFinite(C)||C<=0||this.#O<=C)return{dropped:0,aboveAnchor:0};const T=Math.max(1,Math.floor(C*(1-y)));let L=0,E=0;for(;this.#O>T&&this.#M<this.#n.length;){const D=this.#M++;this.#n[D]!==void 0&&(this.#Ne(D)&&E++,L++)}return{dropped:L,aboveAnchor:E}}#ce(){const C=this.#H();if(!C||!this.#E||!this.#he())return{dropped:0,aboveAnchor:0};const T=Date.now()-C;let L=0,E=0,D=1/0;for(let $=this.#M;$<this.#n.length;$++){if(this.#n[$]===void 0)continue;const P=this.#E[$];if(!(Number.isNaN(P)||P===void 0)){if(P>=T){P<D&&(D=P);continue}this.#Ne($)&&E++,L++}}for(this.#T=D,this.#N=!1;this.#M<this.#n.length&&this.#n[this.#M]===void 0;)this.#M++;return{dropped:L,aboveAnchor:E}}#Pe(C){if(!this.#r)return C;for(let T=0;T<this.#r.length;T++)if(this.#r.at(T)===C)return T;return-1}#Ce(){this.#o=this.#ke("sort",[]),this.#i=this.#ke("filters",null);const C=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#H()>0,T=this.#ke("where",null),L=(this.#t.config||{}).hostFilter,E=!!(T&&T.active)||!!(L&&B(L.active)&&L.active());if(!(C||this.#o.length>0||!!this.#i||!!this.#ke("quick","")||E)){this.#r=null;return}this.#r=new n(Math.max(64,this.#n.length+64));for(let $=0;$<this.#n.length;$++)this.#n[$]!==void 0&&this.#Y($)&&this.#r.insert(this.#R($),$)}#Y(C){const T=this.#Se(C);if(this.#i&&!this.#x(this.#i,T))return!1;const L=String(this.#ke("quick","")||"").toLowerCase();if(L&&!this.#Ge(T).includes(L))return!1;const E=(this.#t.config||{}).hostFilter;if(E&&B(E.active)&&E.active()&&!E.passes(this.#Oe(C)))return!1;const D=this.#ke("where",null);if(D&&D.active){const $=this.#Oe(C);if(!D.passes($.data,$.key))return!1}return!0}#x(C,T){if(!C)return!0;const L=C;if(Array.isArray(L.conditions))return L.op==="or"?L.conditions.some($=>this.#x($,T)):L.op==="not"?!L.conditions.some($=>this.#x($,T)):L.conditions.every($=>this.#x($,T));const E=C,D=(this.#t.compute||{}).testValue;return B(D)?!!D(this.#Re(T,E.col),E,(this.#t.config||{}).locale):(V("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.#Pe(C);let T=0,L=this.#r.length;for(;T<L;){const E=T+L>>>1;this.#G(this.#r.at(E),C)<0?T=E+1:L=E}for(let E=T;E<this.#r.length;E++){const D=this.#r.at(E);if(D===C)return E;if(this.#G(D,C)>0)break}return this.#Pe(C)}#J(C,T){if(!this.#r||!this.#o.length)return;const L=this.#Y(C);if(T>=0&&this.#r.at(T)===C)this.#r.removeAt(T),T<=this.#p&&this.#m--;else if(T>=0)return;if(!L)return;const E=this.#R(C);this.#r.insert(E,C),E<=this.#p&&this.#m++}#R(C){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let T=0,L=this.#r.length;for(;T<L;){const E=T+L>>>1;this.#G(C,this.#r.at(E))<0?L=E:T=E+1}return T}#G(C,T){const L=this.#Se(C),E=this.#Se(T);for(const D of this.#o){const $=this.#Ze(D.col),P=this.#Re(L,D.col),k=this.#Re(E,D.col),G=($&&$.value&&B($.value.compare)?$.value.compare:H)(P,k);if(G!==0)return D.dir==="desc"?-G:G}return 0}#le(){this.#w=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const C=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:h;!this.#$&&this.#n.length<C&&(this.#g=f({mode:"memory",rows:this.#n},this.#t),this.#L!==null&&(clearInterval(this.#L),this.#L=null),this.#y&&(this.#y.destroy(),this.#y=null)),this.#fe(),this.#Le("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:C})}#fe(){this.#d!==null||this.#v||(this.#d=this.#ve(()=>{this.#d=null,this.#f++;const C=this.#m;this.#m=0,this.#h=0,this.#Le("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#f}),this.#Le("model:changed",{reason:"stream",shiftAboveViewport:C,anchor:this.#p}),this.#Le("rows:changed",{companion:!0,reason:"stream"})}))}#oe(){return this.#f===0||this.#h<this.#ge()?Promise.resolve():(this.#h=0,new Promise(C=>{const T=(this.#t.scheduler||{}).idle;B(T)?T(()=>C()):W(()=>C())}))}#ge(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:p}#ve(C){const T=this.#t.scheduler||{};return B(T.frame)?T.frame(C):_(C)}#k(C){const T=this.#t.scheduler||{};B(T.cancel)?T.cancel(C):X(C)}#Se(C){const T=this.#n[C];if(T!==void 0&&T!==s)return T;if(T===void 0)return;const L=this.#t.store;return L&&B(L.source)?L.source(C):void 0}#We(C,T){const L=this.#t.store;if(!L||!B(L.set))return;const E=this.#Z();if(Array.isArray(E))for(const D of E){if(!D||!D.id)continue;const $=B(D.read)?D.read:P=>w(P,D.field||D.id);L.set(D.id,C,$(T))}}#Oe(C){let T=this.#l.get(C);return T||(T=this.#s.leaf(this.#Se(C),C),this.#l.set(C,T)),T}#Re(C,T){const L=this.#Ze(T);return L&&B(L.getValue)?L.getValue(C):C?.[T]}#Ge(C){const T=this.#t.columns,L=T&&B(T.all)?T.all():[],E=[];for(const D of L){const $=B(D.getValue)?D.getValue(C):void 0;$!=null&&$!==""&&E.push(String($))}return E.join(" ").toLowerCase()}#Ze(C){const T=this.#t.columns;return T&&B(T.get)?T.get(C):void 0}#Ve(){const C=this.#_;if(this.#_=null,C&&B(C.return))try{C.return()}catch{}}#_e(){return o({context:this.#ke("context",null)})}#ke(C,T){const L=this.#t.state;if(L&&B(L[C])){const E=L[C]();return E??T}return T}#Le(C,T){const L=this.#t.emit;B(L)&&L(C,T)}}}),Le("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"),x=Q.warnOnce,B=Q.isObject,I=Q.isFunction,_=Q.getPath,W=K("packages/core/src/source/abort.js").isAbortError,H=500,V=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),z=Symbol("lattice.url.skip");function w(c,h={}){const s=B(h)?h:{},p=I(s.fetch)?s.fetch:typeof globalThis<"u"&&I(globalThis.fetch)?globalThis.fetch:null,y=s.format==="json"||s.format==="ndjson"?s.format:void 0,O=typeof s.rowsPath=="string"&&s.rowsPath?s.rowsPath:void 0,A=I(s.map)?s.map:void 0,b=B(s.headers)?s.headers:void 0,v=Number.isFinite(s.batchSize)&&s.batchSize>0?Math.floor(s.batchSize):H,R=s.lenient===!0,j=Number.isFinite(s.poll)&&s.poll>0?Math.floor(s.poll):void 0,F=typeof c=="string"&&c.length>0;F||x("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*C(L={}){if(!F)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const E=L&&L.signal;let D;try{D=await p(c,b?{signal:E,headers:b}:{signal:E})}catch(k){throw W(k)?k:new Error(`[lattice] createUrlSource: request to ${c} failed — ${k&&k.message||k}`)}if(!D||!D.ok){const k=D?D.status:"no response";throw new Error(`[lattice] createUrlSource: ${k} for ${c}`)}const $=S(c,y,D),P=D.body&&I(D.body.getReader)?D.body.getReader():null;try{if(!P){const G=await D.text();($||d(G,c))==="ndjson"?yield*f(null,null,G,0,D,c,v,R):yield*i(G,c,O,A);return}const k=new TextDecoder("utf-8");if($==="json"){yield*i(await n(P,k,""),c,O,A);return}if($==="ndjson"){yield*f(P,k,"",0,D,c,v,R);return}const N=await a(P,k,c);N.format==="json"?yield*i(await n(P,k,N.seed),c,O,A):yield*f(P,k,N.seed,N.bytes,D,c,v,R)}finally{if(P&&I(P.cancel))try{await P.cancel()}catch{}}}const T={mode:"stream",open:C,autoStart:s.autoStart!==!1};return j!==void 0&&(T.poll=j),Number.isFinite(s.maxRows)&&(T.maxRows=s.maxRows),Number.isFinite(s.maxAge)&&(T.maxAge=s.maxAge),(typeof s.ageBy=="string"||I(s.ageBy))&&(T.ageBy=s.ageBy),Number.isFinite(s.coalesceMs)&&(T.coalesceMs=s.coalesceMs),Number.isFinite(s.promoteToMemoryBelow)&&(T.promoteToMemoryBelow=s.promoteToMemoryBelow),T}function S(c,h,s){if(h)return h;const p=g(c);if(p)return p;const y=s&&s.headers&&I(s.headers.get)?s.headers.get("content-type"):null;return l(y)}function g(c){const h=String(c).split(/[?#]/)[0].toLowerCase();if(h.endsWith(".ndjson")||h.endsWith(".jsonl"))return"ndjson";if(h.endsWith(".json"))return"json"}function l(c){if(!c)return;const h=c.split(";")[0].trim().toLowerCase();if(V.has(h))return"ndjson";if(h==="application/json"||h==="text/json"||h.endsWith("+json"))return"json"}function d(c,h){const s=c.replace(/^\s+/,""),p=r(s);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 a(c,h,s){let p="",y=0;for(;;){const{value:A,done:b}=await c.read();if(A&&(y+=A.byteLength,p+=h.decode(A,{stream:!0})),b){p+=h.decode();break}const v=p.replace(/^\s+/,"");if(v){if(v[0]==="[")return{format:"json",seed:p,bytes:y};if(v[0]!=="{"||p.indexOf(`
8
8
  `)!==-1)break}}const O=r(p.replace(/^\s+/,""));if(O==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${s} — pass opts.format: 'json' | 'ndjson'.`);return{format:O,seed:p,bytes:y}}function r(c){if(!c||c[0]==="[")return"json";if(c[0]!=="{")return"error";const h=c.indexOf(`
9
9
  `);if(h===-1)return"json";let s=c.slice(0,h);return s.endsWith("\r")&&(s=s.slice(0,-1)),t(s)?"ndjson":"json"}function t(c){try{return JSON.parse(c),!0}catch{return!1}}async function n(c,h,s){let p=s;for(;;){const{value:y,done:O}=await c.read();if(y&&(p+=h.decode(y,{stream:!0})),O)break}return p+=h.decode(),p}function*i(c,h,s,p){let y;try{y=JSON.parse(c)}catch(A){throw new Error(`[lattice] createUrlSource: ${h} is not valid JSON — ${A.message}`)}let O=s!==void 0?_(y,s):y;if(p&&(O=p(O)),!Array.isArray(O)){const A=s!==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${A}.`)}yield{rows:O,progress:{loaded:O.length,estimated:O.length}}}async function*f(c,h,s,p,y,O,A,b){const v=m(y);let R=s||"",j=p||0,F=0,C=0,T=[];function*L(){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=s.slice(0,b)+C+s.slice(v),this.#r(Math.max(b,p+(c?-O.length:O.length)),Math.max(b,y+F)),this.revalidate(),!0)}#r(c,h){const s=this.input;s&&(s.selectionStart=c,s.selectionEnd=h===void 0?c:h,W(s.setSelectionRange)&&s.setSelectionRange(s.selectionStart,s.selectionEnd))}format(c){const h=this.input;if(!h||this.language!=="json")return!1;const s=a(h.value);if(!s.ok)return this.revalidate(),!1;if(s.value===null&&h.value.trim()==="")return!1;try{const p=JSON.stringify(s.value,null,c===void 0?this.indent:c);return p===void 0?!1:(h.value=p,this.#r(p.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const c=this.input?this.input.value:"",h=i(c,this.language);this.lastResult=h;const s=this.errorNode;return s&&(s.textContent=h.ok?"":f(h),s.classList.toggle(w.errorOn,!h.ok)),this.input&&(h.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),h.ok||!s?this.input.removeAttribute("aria-errormessage"):(s.id||(s.id=H("lat-err")),this.input.setAttribute("aria-errormessage",s.id))),h}text(){return this.input?this.input.value:""}readValue(){const c=this.text();if(c.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return c;const s=a(c);return s.ok?s.value:c}checkValue(c){if(this.props.allowInvalid===!0)return!0;const h=this.revalidate();return h.ok?!0:f(h)}toClipboard(){return this.text()}fromClipboard(c){const h=c==null?"":String(c);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 c of this.#e)c();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const o=u}),Le("packages/dom/src/editors/unit.js",function(e,K){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return S}}),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"),x=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"),V=H.parseUnit,z=H.formatUnit,w=H.findUnit;function S(d,a){return z(d,a)}class g extends x{input=null;hint=null;opts=null;#e=[];buildOptions(){const a=this.props,r=this.params.column&&this.params.column.dataType||null,t=r&&r.unitConfig||{};return{system:a.system||t.system||"data",unit:a.unit??t.unit,binary:a.binary===!0||a.binary===void 0&&t.binary===!0,display:a.display??t.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const a=this.props;this.opts=this.buildOptions();const r=this.symbol(),t=`${this.id}-unit`,n=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:a.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":r?t:null}});n.value=S(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(n.value=this.params.key),this.input=n;const i=typeof a.step=="number"?a.step:0;return i>0&&this.#e.push(_(n,"keydown",f=>{f.key==="ArrowUp"?(W(f.preventDefault)&&f.preventDefault(),this.nudge(i)):f.key==="ArrowDown"&&(W(f.preventDefault)&&f.preventDefault(),this.nudge(-i))})),this.hint=I(this.doc,"span",{class:`${B.editor}__suffix`,text:r,attrs:{id:t,"aria-hidden":"true"}}),I(this.doc,"div",{class:`${B.editor}__unit`,children:[n,this.hint]})}symbol(){const a=w(this.opts.system,this.opts.unit);return a?a.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const a=this.input;a&&!this.params.key&&this.props.selectOnFocus!==!1&&W(a.select)&&a.select()}nudge(a){const r=V(this.input?this.input.value:"",this.opts);let t=(r??0)+a;const{min:n,max:i}=this.props;typeof n=="number"&&t<n&&(t=n),typeof i=="number"&&t>i&&(t=i),this.input&&(this.input.value=S(t,this.opts))}readValue(){const a=this.input?this.input.value:"";if(String(a).trim()==="")return null;const r=V(a,this.opts);if(r===null)return NaN;if(this.mode()!=="clamp")return r;const{min:t,max:n}=this.props;let i=r;return typeof t=="number"&&i<t&&(i=t),typeof n=="number"&&i>n&&(i=n),i}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(a){if(a===null)return!0;if(typeof a!="number"||Number.isNaN(a)){const r=this.symbol();return r?`Enter a value such as 10 ${r}`:"Enter a value"}if(this.mode()==="reject"){const{min:r,max:t}=this.props;if(typeof r=="number"&&a<r)return`Must be ${this.describe(r)} or more`;if(typeof t=="number"&&a>t)return`Must be ${this.describe(t)} or less`}return!0}describe(a){return z(a,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return z(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(a){const r=a==null?"":String(a);if(r.trim()==="")return{ok:!0,value:null};const t=V(r,this.opts),n=t===null?NaN:t,i=this.checkValue(n);return i!==!0?{ok:!1,message:i}:{ok:!0,value:n}}destroy(){for(const a of this.#e)a();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const l=g}),Le("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 n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=K("packages/core/src/internal/util.js"),W=X.isFunction,H=X.uid,V=K("packages/core/src/columns/types/radix.js"),z=V.compileRadixFormat,w=V.compileRadixParse,S=V.normaliseRadixOptions,g=V.radixRange,l=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),d=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),a=new Map;function r(f){const u=f||"";let o=a.get(u);if(o)return o;try{o=new Intl.NumberFormat(f||void 0,{maximumFractionDigits:0})}catch{o={format:m=>String(m)}}return a.set(u,o),o}function t(f,u){const o=u||{},m={};if(f){for(const h of d)f[h]!==void 0&&(m[h]=f[h]);const c=g(f.bitWidth??null,f.signed!==!1);typeof f.min=="number"&&f.min>c.min&&(m.min=f.min),typeof f.max=="number"&&f.max<c.max&&(m.max=f.max)}for(const c of d)o[c]!==void 0&&(m[c]=o[c]);return typeof o.min=="number"&&(m.min=o.min),typeof o.max=="number"&&(m.max=o.max),S(m)}class n extends x{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 o=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}});o.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(o.value=this.params.key),this.input=o;const m=I(this.doc,"span",{class:l.hint,attrs:{"aria-live":"polite"}});this.hint=m,this.#e.push(_(o,"input",()=>this.refresh())),this.#e.push(_(o,"keydown",h=>this.#n(h)));const c=I(this.doc,"div",{class:l.root,children:[o,m]});return this.refresh(),c}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 o=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;u.key==="ArrowUp"?(W(u.preventDefault)&&u.preventDefault(),this.nudge(o)):u.key==="ArrowDown"&&(W(u.preventDefault)&&u.preventDefault(),this.nudge(-o))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(u){const{min:o,max:m}=this.options;return u<o?o:u>m?m:u}evaluate(){const u=this.input?String(this.input.value):"";if(u.trim()==="")return{value:null,message:null};const o=this.parse(u);return o.ok?{value:this.mode()==="clamp"?this.clamp(o.value):o.value,message:null}:this.mode()==="clamp"&&typeof o.value=="number"&&(o.reason==="range"||o.reason==="negative")?{value:this.clamp(o.value),message:null}:{value:NaN,message:this.messageFor(o.reason)}}messageFor(u){const o=this.options;return u==="negative"?`This column holds an unsigned ${o.bitWidth}-bit pattern; enter ${this.format(0)} or more`:u==="range"?`Must be between ${this.format(o.min)} and ${this.format(o.max)}`:`Enter a ${o.name} value, e.g. ${this.format(o.radix===2?5:26)}`}refresh(){const{value:u,message:o}=this.evaluate();if(this.input&&this.input.classList&&(o?this.input.classList.add(B.invalid):this.input.classList.remove(B.invalid),this.input.setAttribute("aria-invalid",o?"true":"false"),o&&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(o){this.hint.textContent=o,this.hint.classList&&this.hint.classList.add(l.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(l.hintInvalid),this.hint.textContent=u===null?"":`= ${r(this.params.locale).format(u)}`}}nudge(u){if(!this.input)return;const o=this.parse(this.input.value);let m;typeof o.value=="number"?m=o.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 o=u==null?"":String(u);if(o.trim()==="")return{ok:!0,value:null};const m=this.parse(o);let c;if(m.ok)c=m.value;else if(this.mode()==="clamp"&&typeof m.value=="number"&&(m.reason==="range"||m.reason==="negative"))c=this.clamp(m.value);else return{ok:!1,message:this.messageFor(m.reason)};const h=this.checkValue(c);return h!==!0?{ok:!1,message:h}:{ok:!0,value:c}}destroy(){for(const u of this.#e)u();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const i=n}),Le("packages/dom/src/editors/segmented.js",function(e,K){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=Q.keyOf,W=Q.normaliseLookup,H=Q.documentFor,V=Q.lookupFor,w=K("packages/dom/src/editors/select.js").SelectEditor,g=K("packages/core/src/internal/util.js").isFunction,d=K("packages/dom/src/cell/icons.js").createIcon,a=6;class r extends x{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(f){const u=f||{},o=t(u),m=V(u,o,{colId:u.column&&(u.column.id||u.column.field)}),c=Number(o.max??a),h=m.options().length;if(Number.isFinite(c)&&h>c){const s=new w;s.init(u),this.#e=s,this.params=u,this.doc=H(u),this.props=o,this.lookup=m,this.popup=s.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 o=0;o<this.options.length;o++)u.appendChild(this.buildSegment(this.options[o],o));return this.props.allowClear===!0&&u.appendChild(this.buildClear()),this.#t.push(_(u,"keydown",o=>this.onKeyDown(o))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),u}buildSegment(f,u){const o=this.doc,m=I(o,"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(d(o,f.icon,{className:B.icon})),m.appendChild(I(o,"span",{class:`${B.editor}__segment-label`,text:f.label})),this.#t.push(_(m,"mousedown",c=>{c&&g(c.preventDefault)&&c.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 o=0;o<this.options.length;o++)if(X(this.options[o].id)===u)return o;return-1}paint(){for(let f=0;f<this.segments.length;f++){const u=f===this.indexOf(this.selected),o=this.segments[f];o.setAttribute("aria-checked",u?"true":"false"),o.setAttribute("tabindex",f===this.focused?"0":"-1"),o.classList.toggle(`${B.editor}__segment--active`,u),o.classList.toggle(`${B.editor}__segment--disabled`,this.options[f].disabled===!0)}}select(f,u){const o=this.options[f];!o||o.disabled===!0||(this.selected=o.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 o=this.focused;for(let m=0;m<u;m++)if(o=(o+f+u)%u,this.options[o].disabled!==!0){this.focusAt(o);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 o=0;o<u;o++){const m=f===1?o:u-1-o;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 o=0;o<this.options.length;o++)u.appendChild(this.buildSegment(this.options[o],o));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(i){return{...i.column&&i.column.edit&&i.column.edit.props||{},...i.props||{}}}const n=r}),Le("packages/dom/src/editors/rating.js",function(e,K){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),x=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"),V=H.ratingFills,z=H.fillState,w=H.ratingText,S=H.clampRating,g=H.DEFAULT_RATING_ICON,l=H.DEFAULT_RATING_MAX,a=K("packages/core/src/internal/util.js").isFunction;class r extends x{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 o=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));o.appendChild(m),this.slider=m;const c=I(f,"span",{class:`${B.editor}__rating-value`});return o.appendChild(c),this.readout=c,this.props.allowClear===!0&&o.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(),o}buildItem(f){const u=this.doc,o=String(this.props.icon??g),m=I(u,"span",{class:`${B.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[W(u,o,{className:B.icon})]}),c=I(u,"span",{class:`${B.editor}__rating-item`,attrs:{"data-index":f,"data-icon":o,"aria-hidden":"true"},children:[W(u,o,{className:B.icon}),m]});return this.fills.push(m),this.#e.push(_(c,"mousedown",h=>{h&&a(h.preventDefault)&&h.preventDefault(),this.setRating(this.ratingAt(f,h),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(_(c,"mousemove",h=>{const s=this.ratingAt(f,h);s!==this.preview&&(this.preview=s,this.paint())})),this.items.push(c),c}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&&a(u.preventDefault)&&u.preventDefault(),this.setRating(null)})),f}ratingAt(f,u){if(this.props.allowHalf!==!0)return f+1;const o=this.items[f],m=o&&Number(o.offsetWidth),c=u&&Number(u.offsetX);return!Number.isFinite(m)||m<=0||!Number.isFinite(c)?f+1:c*2<m?f+.5:f+1}focusTarget(){return this.slider}setRating(f,u){this.rating=f===null?null:S(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,o=this.preview===null?this.rating:this.preview,m=V(o===null?0:o,f,{allowHalf:u});for(let s=0;s<this.items.length;s++){const p=z(m[s]);this.items[s].setAttribute("data-fill",p),this.items[s].classList.toggle(`${B.editor}__rating-item--filled`,p!=="empty"),this.fills[s]&&this.fills[s].style.setProperty("--lat-rating-fill",`${(m[s]*100).toFixed(2)}%`)}const c=o===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:w(o),max:f}),h=this.slider;h&&(h.setAttribute("aria-valuenow",o===null?"0":String(o)),h.setAttribute("aria-valuetext",c),h.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=c)}onKeyDown(f){const u=()=>{a(f.preventDefault)&&f.preventDefault()},o=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(o);break;case"ArrowLeft":case"ArrowDown":u(),this.nudge(-o);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 o=Number(u);if(!Number.isFinite(o))return{ok:!1,message:`"${u}" is not a rating`};const m=this.checkValue(o);return m!==!0?{ok:!1,message:m}:{ok:!0,value:o}}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(i,f,u){if(i==null||i==="")return null;const o=Number(i);return Number.isFinite(o)?S(o,f,u,!1):null}const n=r}),Le("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 S}}),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 d}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),x=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,S=100;class g extends x{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const n=Number(this.props.min??w);return Number.isFinite(n)?n:w}max(){const n=Number(this.props.max??S);return Number.isFinite(n)?n:S}step(){const n=Number(this.props.step??1);return Number.isFinite(n)&&n>0?n:1}build(){const n=this.doc,i=this.min(),f=this.max(),u=this.step(),o=a(this.props.marks);this.marks=o,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const m=I(n,"div",{class:`${B.editor}__slider`});this.root=m;const c=I(n,"input",{class:`${B.editor}__slider-input`,attrs:{type:"range",min:String(i),max:String(f),step:String(u),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:o.length?`${this.id}-marks`:null}});if(this.range=c,m.appendChild(c),o.length){const s=I(n,"datalist",{attrs:{id:`${this.id}-marks`}}),p=I(n,"div",{class:`${B.editor}__slider-marks`});for(const y of o){s.appendChild(I(n,"option",{attrs:{value:String(y.value),label:y.label}}));const O=I(n,"span",{class:`${B.editor}__slider-mark`,text:y.label,attrs:{"data-value":String(y.value)}});O.style&&z(O.style.setProperty)&&O.style.setProperty("--lat-slider-mark",`${(l(y.value,i,f)*100).toFixed(2)}%`),p.appendChild(O)}m.appendChild(s),m.appendChild(p)}const h=I(n,"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 s=I(n,"span",{class:`${B.editor}__slider-value`});m.appendChild(s),this.readout=s}return this.#e.push(_(c,"input",()=>this.setAmount(Number(c.value),"range"))),this.#e.push(_(c,"change",()=>this.setAmount(Number(c.value),"range"))),this.#e.push(_(c,"keydown",s=>this.onKeyDown(s))),this.#e.push(_(h,"input",()=>this.onFieldInput())),this.#e.push(_(h,"change",()=>this.paint())),this.#e.push(_(h,"keydown",s=>this.onKeyDown(s))),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 n=this.field;n&&!this.params.key&&this.props.selectOnFocus!==!1&&z(n.select)&&n.select()}snap(n){if(!Number.isFinite(n))return this.min();const i=this.min(),f=this.max(),u=this.step(),o=Math.min(Math.max(n,i),f),m=i+Math.round((o-i)/u)*u,c=d(u),h=c>0?Number(m.toFixed(c)):Math.round(m);return Math.min(Math.max(h,i),f)}setAmount(n,i){this.amount=n===null?null:this.snap(n),this.paint(i)}onFieldInput(){const n=this.field?String(this.field.value):"";if(n.trim()===""){this.amount=null,this.paint("field");return}const i=W(n,this.params.locale);if(i===null||Number.isNaN(i)){this.paint("field");return}this.setAmount(i,"field")}paint(n){const i=this.min(),f=this.max(),u=this.amount,o=u===null?i:u;this.range&&n!=="range"&&(this.range.value=String(o)),this.field&&n!=="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(o,i,f)*100).toFixed(2)}%`),m&&m.setAttribute&&m.setAttribute("data-empty",u===null?"true":"false");const c=this.labelFor(u);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",c),this.readout&&(this.readout.textContent=c)}labelFor(n){if(n===null)return String(this.props.emptyLabel??"");const i=this.marks.find(u=>u.value===n),f=H(n,this.props);return i&&i.label!==f?`${f} (${i.label})`:f}onKeyDown(n){if(n.key==="Escape"){z(n.preventDefault)&&n.preventDefault(),this.cancel();return}if(n.key==="Enter"){z(n.preventDefault)&&n.preventDefault(),this.commit();return}n.key==="Tab"&&this.commit()}readValue(){const n=this.field?String(this.field.value):"";if(n.trim()==="")return null;const i=W(n,this.params.locale);return i===null||Number.isNaN(i)?NaN:this.snap(i)}checkValue(n){return n==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof n!="number"||Number.isNaN(n)?"Enter a number":n<this.min()?`Must be ${this.min()} or more`:n>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(n){const i=String(n??"").trim();if(i==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const f=W(i,this.params.locale);if(f===null||Number.isNaN(f))return{ok:!1,message:"Enter a number"};const u=this.snap(f),o=this.checkValue(u);return o!==!0?{ok:!1,message:o}:{ok:!0,value:u}}destroy(){for(const n of this.#e)n();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function l(t,n,i){const f=i-n;return!Number.isFinite(f)||f===0?0:Math.min(1,Math.max(0,(Number(t)-n)/f))}function d(t){if(!Number.isFinite(t))return 0;const n=String(t),i=n.indexOf("e");if(i>=0){const u=n.slice(0,i),o=u.indexOf("."),m=o<0?0:u.length-o-1;return Math.min(15,Math.max(0,m-Number(n.slice(i+1))))}const f=n.indexOf(".");return f<0?0:Math.min(15,n.length-f-1)}function a(t){if(!t)return[];const n=[];if(Array.isArray(t)){for(const i of t){if(i&&typeof i=="object"){const u=Number(i.value);Number.isFinite(u)&&n.push({value:u,label:String(i.label??u)});continue}const f=Number(i);Number.isFinite(f)&&n.push({value:f,label:String(f)})}return n}if(typeof t=="object")for(const[i,f]of Object.entries(t)){const u=Number(i);Number.isFinite(u)&&n.push({value:u,label:String(f)})}return n}const r=g}),Le("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 S}}),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 d}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),x=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"]),S=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function g(n){if(n==null)return null;if(typeof n=="object"){const u=n,o=g(u.token??u.value??u.colour??u.color);return o?{...o,label:u.label==null?o.label:String(u.label)}:null}const i=String(n).trim();if(i==="")return null;const f=W(i);return f?{token:null,hex:f,label:f}:Object.hasOwn(S,i)?{token:i,hex:S[i],label:i}:null}function l(n,i){const f=n&&n.ownerDocument,u=f&&f.defaultView;if(!u||!z(u.getComputedStyle))return null;try{const o=u.getComputedStyle(n);return!o||!z(o.getPropertyValue)?null:W(String(o.getPropertyValue(`--lattice-variant-${i}-solid`)).trim())}catch{return null}}class d extends x{static popup=!0;swatches=[];buttons=[];native=null;hex=null;preview=null;#e=[];alpha(){return this.props.alpha===!0}build(){const i=this.doc;this.swatches=a(this.props.swatches);const f=I(i,"div",{class:`${B.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=I(i,"span",{class:`${B.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),f.appendChild(this.preview),this.swatches.length){const o=I(i,"div",{class:`${B.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let m=0;m<this.swatches.length;m++)o.appendChild(this.buildSwatch(this.swatches[m],m));f.appendChild(o)}this.native=I(i,"input",{class:`${B.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),f.appendChild(this.native),this.hex=I(i,"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",o=>this.onKeyDown(o))),this.#e.push(_(f,"keydown",o=>this.onKeyDown(o)));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(i,f){const u=I(this.doc,"button",{class:`${B.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":i.label,"data-index":f,"data-variant":i.token}});return i.token||r(u,i.hex),this.#e.push(_(u,"mousedown",o=>{o&&z(o.preventDefault)&&o.preventDefault(),this.setColour(this.swatches[f].hex)})),this.buttons.push(u),u}buildClear(){const i=I(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(_(i,"mousedown",f=>{f&&z(f.preventDefault)&&f.preventDefault(),this.setColour(null)})),i}focusTarget(){return this.hex}attached(){super.attached();for(let i=0;i<this.swatches.length;i++){const f=this.swatches[i];if(!f.token)continue;const u=l(this.buttons[i]||this.element(),f.token);u&&(f.hex=u)}this.paint()}setColour(i){const f=i===null?null:W(i,{alpha:this.alpha()});this.hex&&(this.hex.value=f===null?"":f),this.paint()}current(){const i=this.hex?String(this.hex.value).trim():"";return i===""?null:W(i,{alpha:this.alpha()})}paint(){const i=this.current(),f=i===null?null:i.slice(0,7);r(this.preview,f),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",i===null?"true":"false"),this.native&&(this.native.value=f===null?"#000000":f);for(let u=0;u<this.buttons.length;u++){const o=i!==null&&this.swatches[u].hex.toLowerCase()===i.toLowerCase();this.buttons[u].setAttribute("aria-checked",o?"true":"false"),this.buttons[u].classList.toggle(`${B.editor}__colour-swatch--selected`,o),this.swatches[u].token||r(this.buttons[u],this.swatches[u].hex)}}onKeyDown(i){if(i.key==="Escape"){z(i.preventDefault)&&i.preventDefault(),this.cancel();return}if(i.key==="Enter"){z(i.preventDefault)&&i.preventDefault(),this.commit();return}i.key==="Tab"&&this.commit()}readValue(){const i=this.hex?String(this.hex.value).trim():"";if(i==="")return null;const f=W(i,{alpha:this.alpha()});return f===null?i:f}checkValue(i){if(i==null||i==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const f=H(i);return f?!this.alpha()&&f.a<1?"This column does not accept transparency":!0:`"${String(i)}" is not a colour`}toClipboard(){const i=this.current();return i===null?"":i}fromClipboard(i){const f=String(i??"").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 o=this.checkValue(u);return o!==!0?{ok:!1,message:o}:{ok:!0,value:u}}destroy(){for(const i of this.#e)i();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function a(n){const i=Array.isArray(n)&&n.length?n:n===!1?[]:w,f=[];for(const u of i){const o=g(u);o&&f.push(o)}return f}function r(n,i){const f=n&&n.style;if(f){if(i===null){z(f.removeProperty)&&f.removeProperty("--lat-swatch");return}z(f.setProperty)&&f.setProperty("--lat-swatch",i)}}const t=d}),Le("packages/dom/src/editors/treeselect.js",function(e,K){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const x=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,V=_.clear,z=_.keyOf,w=_.rawOptions,S=_.lookupKey,g=K("packages/core/src/internal/util.js"),l=g.isFunction,d=g.isObject,a="\0";class r extends x{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 i=super.build();return i.classList.add("lat-treeselect"),this.list&&this.list.element().setAttribute("role","tree"),i}initSelection(){this.rebuild(),this.selected=this.params.value??null;const i=this.nodeById(this.selected);if(i)for(let f=i.parent;f;f=f.parent)this.expanded.add(f.key)}rebuild(){const i=w(this.params,this.props),f=this.props.keys||{},u=f.value||S(this.params,"valueKey")||"id",o=f.label||S(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const m of i){if(!d(m)){this.addNode(null,String(m??""),m,null);continue}Array.isArray(m.path)&&m.path.length?this.addByPath(m,u,o):this.addByChildren(m,null,u,o)}if(this.props.defaultExpanded===!0)for(const m of this.nodes.keys())this.expanded.add(m)}addNode(i,f,u,o){const m=i?`${i.key}${a}${f}`:f;let c=this.nodes.get(m);return c?c.id===void 0&&u!==void 0&&(c.id=u):(c={id:u,label:f,key:m,parent:i,children:[],depth:i?i.depth+1:0,disabled:!1},this.nodes.set(m,c),(i?i.children:this.roots).push(c)),o&&(o.disabled===!0&&(c.disabled=!0),o.icon!==void 0&&(c.icon=o.icon),o.variant!==void 0&&(c.variant=o.variant)),c}addByPath(i,f,u){const o=i.path;let m=null;for(let c=0;c<o.length;c++){const h=c===o.length-1,s=String(o[c]),p=h&&i[u]!=null?String(i[u]):s,y=this.addNode(m,s,h?i[f]:void 0,h?i:null);h&&(y.label=p),m=y}}addByChildren(i,f,u,o){const m=i[u],c=i[o]!=null?String(i[o]):String(m??""),h=this.addNode(f,c,m,i),s=Array.isArray(i.children)?i.children:[];for(const p of s)d(p)?this.addByChildren(p,h,u,o):this.addNode(h,String(p??""),p,null)}nodeById(i){if(i==null)return;const f=z(i);for(const u of this.nodes.values())if(u.id!==void 0&&z(u.id)===f)return u}filterOptions(i){const f=String(i||"").trim().toLowerCase(),u=f!=="";this.matched=u?this.computeMatches(f):new Set;const o=[],m=c=>{for(const h of c)u&&!this.matched.has(h.key)||(o.push(h),h.children.length&&(u||this.expanded.has(h.key))&&m(h.children))};return m(this.roots),o}computeMatches(i){const f=new Set,u=o=>{let m=o.label.toLowerCase().includes(i);for(const c of o.children)u(c)&&(m=!0);return m&&f.add(o.key),m};for(const o of this.roots)u(o);return f}repaint(i){if(this.refreshOptions(),!i||!this.list)return;const f=this.visible.findIndex(u=>u.key===i);f>=0&&this.list.setActive(f)}isBranch(i){return!!i&&i.children.length>0}isSelectable(i){return!i||i.disabled||i.id===void 0||i.id===null?!1:!(this.leavesOnly&&this.isBranch(i))}setExpanded(i,f){this.isBranch(i)&&(f?this.expanded.add(i.key):this.expanded.delete(i.key),this.repaint(i.key))}choose(i){if(i){if(!this.isSelectable(i)){this.isBranch(i)&&this.setExpanded(i,!this.expanded.has(i.key));return}this.selected=i.id,this.input&&(this.input.value=""),this.query="",this.repaint(i.key),this.paintDisplay(),this.commit()}}isSelected(i){return this.selected!=null&&i&&i.id!==void 0&&z(i.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(i){if(i==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a value";if(!this.nodes.size)return!0;const f=this.nodeById(i);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(i)}" is not a valid option`}renderOption(i,f,u){V(f),f.setAttribute("role","treeitem"),f.setAttribute("aria-level",String(i.depth+1)),f.setAttribute("data-depth",String(i.depth));const o=W(this.doc,"span",{class:"lat-tree__indent"});for(let y=0;y<i.depth;y++)o.appendChild(W(this.doc,"span",{class:"lat-tree__guide"}));f.appendChild(o);const m=this.isBranch(i),c=m&&(this.expanded.has(i.key)||this.query.trim()!==""),h=m?c?"chevronDown":"chevronRight":"blank",s=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(s,"mousedown",y=>{l(y.preventDefault)&&y.preventDefault(),l(y.stopPropagation)&&y.stopPropagation(),this.setExpanded(i,!this.expanded.has(i.key))}),f.appendChild(s),i.icon&&f.appendChild(I(this.doc,i.icon,{className:X.icon})),f.appendChild(W(this.doc,"span",{class:`${X.option}__label`,text:i.label})),i.variant?f.setAttribute("data-variant",i.variant):f.removeAttribute("data-variant"),m?f.setAttribute("aria-expanded",c?"true":"false"):f.removeAttribute("aria-expanded");const p=this.isSelected(i);f.classList.toggle(X.optionSelected,p),f.classList.toggle(X.optionDisabled,!this.isSelectable(i)),f.classList.toggle("lat-tree__row--branch",m),f.setAttribute("aria-selected",p?"true":"false"),this.isSelectable(i)?f.removeAttribute("aria-disabled"):f.setAttribute("aria-disabled","true")}paintDisplay(){const i=this.display;if(!i)return;if(V(i),this.selected==null){i.removeAttribute("data-variant");return}const f=this.nodeById(this.selected);if(!f){i.appendChild(W(this.doc,"span",{text:String(this.selected)}));return}f.icon&&i.appendChild(I(this.doc,f.icon,{className:X.icon})),i.appendChild(W(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(f)})),f.variant?i.setAttribute("data-variant",f.variant):i.removeAttribute("data-variant")}pathLabel(i){const f=[];for(let u=i;u;u=u.parent)f.unshift(u.label);return f.join(String(this.props.pathSeparator??" / "))}onKeyDown(i){const f=this.list,u=f&&f.active>=0?this.visible[f.active]:null;switch(i.key){case"ArrowRight":{if(l(i.preventDefault)&&i.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(i.preventDefault)&&i.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(i.preventDefault)&&i.preventDefault(),f&&this.visible.length&&f.setActive(0);return;case"End":l(i.preventDefault)&&i.preventDefault(),f&&this.visible.length&&f.setActive(this.visible.length-1);return;default:super.onKeyDown(i)}}focusNode(i){if(!this.list)return;const f=this.visible.findIndex(u=>u.key===i);f>=0&&this.list.setActive(f)}acceptHighlight(i){const f=this.list,u=f&&f.active>=0?this.visible[f.active]:null;if(!u){i&&i.commit&&this.commit();return}if(this.isSelectable(u)){this.choose(u);return}this.isBranch(u)?this.setExpanded(u,!this.expanded.has(u.key)):i&&i.commit&&this.commit()}moveHighlight(i){const f=this.list;if(!f)return;let u=f.active;for(let o=0;o<this.visible.length;o++){if(u+=i,u<0||u>=this.visible.length)return;if(!this.visible[u].disabled){f.setActive(u);return}}}}const t=r}),Le("packages/dom/src/editors/objectpicker.js",function(e,K){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return i}}),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 x=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,V=B.debounce,z=B.rawOptions,w=B.optionSource,S=B.lookupSearch,g=B.lookupKey,l=K("packages/core/src/internal/util.js"),d=l.isFunction,a=l.isObject,r=l.getPath,n=K("packages/dom/src/cell/icons.js").createIcon;class i extends x{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const h=super.build();if(h.classList.add("lat-objectpicker"),d(this.props.search)&&!(this.lookup&&this.lookup.search)){const s=Number(this.props.searchDebounce)||200;this.#n=V(p=>this.runRemoteSearch(String(p)),s)}return h}onQuery(h){super.onQuery(h),this.#n&&this.#n(h)}initSelection(){const h=z(this.params,this.props).map(s=>this.toOption(s));(h.length||!this.all.length)&&(this.all=h),this.selected=this.params.value??null}toOption(h){if(!a(h)){const b=h==null?"":String(h);return{id:h,label:b,secondary:"",avatar:"",initials:u(b),disabled:!1,raw:{}}}const s=this.props.valueKey||g(this.params,"valueKey")||"id",p=this.props.labelKey||g(this.params,"labelKey")||"label",y=f(h,this.props.template??p,""),O=f(h,this.props.secondary,""),A=f(h,this.props.avatar,"");return{id:h[s],label:y||String(h[s]??""),secondary:O,avatar:A,initials:u(y||String(h[s]??"")),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);d(h)&&(this.#t=!0,Promise.resolve(h()).then(s=>{!this.element()||!Array.isArray(s)||(this.all=s.map(p=>this.toOption(p)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(h){const s=String(h||"").trim().toLowerCase();if(s==="")return this.all;const p=o(this.props.searchFields);return this.all.filter(y=>{if(!p)return y.label.toLowerCase().includes(s)||y.secondary.toLowerCase().includes(s);for(const O of p){const A=d(O)?O(y.raw):r(y.raw,O);if(A!=null&&String(A).toLowerCase().includes(s))return!0}return!1})}async runRemoteSearch(h){const s=S(this.params,this.props);if(!s)return;this.#e&&this.#e.abort();const p=new AbortController;this.#e=p;try{const y=await s(h,p.signal);if(p.signal.aborted||this.#e!==p)return;this.refreshOptions(Array.isArray(y)?y.map(O=>this.toOption(O)):[])}catch(y){if(!p.signal.aborted)throw y}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 s=H(h);return this.all.find(p=>H(p.id)===s)}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,s,p){W(s),s.appendChild(this.buildAvatar(h));const y=_(this.doc,"span",{class:"lat-object__text"});y.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:h.label})),h.secondary&&y.appendChild(_(this.doc,"span",{class:"lat-object__secondary",text:h.secondary})),s.appendChild(y),h.icon&&s.appendChild(n(this.doc,h.icon,{className:I.icon})),h.variant?s.setAttribute("data-variant",h.variant):s.removeAttribute("data-variant");const O=this.isSelected(h);s.classList.add("lat-object__row"),s.classList.toggle(I.optionSelected,O),s.classList.toggle(I.optionDisabled,h.disabled===!0),s.setAttribute("aria-selected",O?"true":"false"),h.disabled?s.setAttribute("aria-disabled","true"):s.removeAttribute("aria-disabled")}buildAvatar(h){const s=_(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!h.avatar)return s.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:h.initials})),s.setAttribute("data-fallback","initials"),s;const p=_(this.doc,"img",{class:"lat-avatar__image",attrs:{src:h.avatar,alt:"",loading:"lazy",decoding:"async"}});return X(p,"error",()=>{p.parentNode===s&&(s.removeChild(p),s.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:h.initials})),s.setAttribute("data-fallback","initials"))}),s.appendChild(p),s}paintDisplay(){const h=this.display;if(!h)return;if(W(h),this.selected==null){h.removeAttribute("data-variant");return}const s=this.optionById(this.selected);if(!s){h.appendChild(_(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}h.appendChild(this.buildAvatar(s)),h.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:s.label})),s.variant?h.setAttribute("data-variant",s.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(c,h,s){if(h==null)return s;const p=d(h)?h(c):r(c,String(h));return p==null?s:String(p)}function u(c){const h=String(c||"").trim().split(/\s+/).filter(y=>y!=="");if(!h.length)return"";const s=[...h[0]][0]||"";if(h.length===1)return s.toUpperCase();const p=[...h[h.length-1]][0]||"";return(s+p).toUpperCase()}function o(c){if(c==null)return null;const s=(Array.isArray(c)?c:[c]).filter(p=>typeof p=="string"||d(p));return s.length?s:null}const m=i}),Le("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 d}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,B=Q.CLS,I=Q.VirtualList,_=Q.el,X=Q.on,W=Q.clear,H=K("packages/dom/src/cell/icons.js"),V=H.createIcon,z=H.iconNames,S=K("packages/core/src/internal/util.js").isFunction;class g extends x{static popup=!0;input=null;display=null;list=null;names=[];matches=[];rows=[];columns=8;cursor=-1;selected=null;query="";off=[];build(){const r=this.props;this.columns=Math.max(1,Math.floor(Number(r.columns)||8)),this.names=l(r.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:r.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(r.rowHeight)||34,height:Number(r.listHeight)||204,renderItem:(n,i,f)=>this.renderRow(n,i,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),r.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",n=>this.onKeyDown(n))),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 r=_(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(r,"mousedown",t=>{S(t.preventDefault)&&t.preventDefault(),this.selected=null,this.paintDisplay(),this.commit()})),r}focusTarget(){return this.input}onQuery(r){this.query=r,this.refreshIcons()}refreshIcons(){const r=this.query.trim().toLowerCase();this.matches=r===""?this.names.slice():this.names.filter(n=>n.toLowerCase().includes(r)),this.rows=[];for(let n=0;n<this.matches.length;n+=this.columns)this.rows.push(this.matches.slice(n,n+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(r){return r<0?-1:Math.floor(r/this.columns)}moveCursor(r){if(!this.matches.length)return-1;const t=Math.max(0,Math.min(this.matches.length-1,this.cursor+r));return this.setCursor(t)}setCursor(r){return this.cursor=r,this.list&&this.list.setActive(this.rowOf(r)),this.cursor}cursorName(){return this.cursor>=0&&this.cursor<this.matches.length?this.matches[this.cursor]:null}renderRow(r,t,n){t.setAttribute("role","row"),t.classList.add("lat-iconpicker__row");let i=t.__latIconCells;if(!i){i=[],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",o=>{S(o.preventDefault)&&o.preventDefault();const m=u.getAttribute("data-icon");m&&this.choose(m)}),t.appendChild(u),i.push(u)}t.__latIconCells=i}for(let f=0;f<i.length;f++){const u=i[f],o=r[f];if(o===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=n*this.columns+f;u.removeAttribute("aria-hidden"),u.classList.remove("lat-iconpicker__cell--empty"),u.setAttribute("data-icon",o),u.setAttribute("title",o),u.setAttribute("aria-label",o),u.__latIconName!==o&&(W(u),u.appendChild(V(this.doc,o,{className:B.icon})),u.__latIconName=o);const c=this.selected===o;u.classList.toggle("lat-iconpicker__cell--active",m===this.cursor),u.classList.toggle("lat-iconpicker__cell--selected",c),u.setAttribute("aria-selected",c?"true":"false")}}paintDisplay(){const r=this.display;if(r){if(W(r),this.selected==null){r.appendChild(_(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}r.appendChild(V(this.doc,this.selected,{className:B.icon})),r.appendChild(_(this.doc,"span",{text:this.selected}))}}choose(r){this.selected=r;const t=this.matches.indexOf(r);t>=0&&(this.cursor=t),this.list&&this.list.paint(),this.paintDisplay(),this.commit()}readValue(){return this.selected??null}checkValue(r){return r==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose an icon":this.names.includes(String(r))?!0:`"${String(r)}" is not a known icon name`}onKeyDown(r){const t=()=>{S(r.preventDefault)&&r.preventDefault()};switch(r.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 n=this.cursorName();n&&this.choose(n);return}case"Escape":t(),this.cancel();return;case"Tab":{const n=this.cursorName();n&&(this.selected=n),this.commit();return}default:break}}destroy(){for(const r of this.off)r();this.off.length=0,this.list&&(this.list.destroy(),this.list=null),this.input=null,this.display=null,this.rows=[],super.destroy()}}function l(a){const r=z();if(Array.isArray(a)&&a.length){const t=new Set(r);return a.map(n=>String(n)).filter(n=>t.has(n))}return r.filter(t=>t!=="blank")}const d=g}),Le("packages/dom/src/editors/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return S}}),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"),x=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"),V=H.formatTemperature,z=H.parseTemperature,w=H.findScale;function S(d,a){return V(d,{...a,decimals:void 0,minDecimals:0,maxDecimals:20})}class g extends x{input=null;hint=null;opts=null;#e=[];buildOptions(){const a=this.params.column&&this.params.column.dataType||null,r=a&&a.temperatureConfig||{};return{scale:this.props.scale||r.scale||"C",locale:this.params.locale}}build(){const a=this.props;this.opts=this.buildOptions();const r=w(this.opts.scale),t=r?r.scale.symbol:"",n=`${this.id}-scale`,i=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:a.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?n:null}});i.value=S(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(i.value=this.params.key),this.input=i;const f=typeof a.step=="number"?a.step:0;return f>0&&this.#e.push(_(i,"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:n,"aria-hidden":"true"}}),I(this.doc,"div",{class:`${B.editor}__unit`,children:[i,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const a=this.input;a&&!this.params.key&&this.props.selectOnFocus!==!1&&W(a.select)&&a.select()}nudge(a){const r=z(this.input?this.input.value:"",this.opts);let t=(r??0)+a;const{min:n,max:i}=this.props;typeof n=="number"&&t<n&&(t=n),typeof i=="number"&&t>i&&(t=i),this.input&&(this.input.value=S(t,this.opts))}readValue(){const a=this.input?String(this.input.value).trim():"";if(a==="")return null;const r=z(a,this.opts);return r===null?Number.NaN:r}checkValue(a){if(a===null)return!0;if(typeof a!="number"||Number.isNaN(a))return"Enter a temperature";const{min:r,max:t}=this.props;return typeof r=="number"&&a<r?`Must be ${r} or more`:typeof t=="number"&&a>t?`Must be ${t} or less`:!0}destroy(){for(const a of this.#e)a();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const l=g}),Le("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 d}});const Q=K("packages/dom/src/editors/common.js"),x=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"),V=H.parseMoney,z=H.toMoney,w=H.normaliseCode,S=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function g(a){const r=z(a);return r?String(r.amount):""}class l extends x{input=null;picker=null;opts=null;#e=[];buildOptions(){const r=this.params.column&&this.params.column.dataType||null,t=r&&r.currencyConfig||{},n=z(this.params.value),i=w(this.props.code)||n&&n.code||w(t.code)||"USD";let f=this.props.codes||t.codes||S;return f=f.map(u=>w(u)).filter(Boolean),f.includes(i)||(f=[i,...f]),{code:i,codes:f,locale:this.params.locale}}build(){const r=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:r.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 n=I(this.doc,"select",{class:`${B.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const i of this.opts.codes){const f=I(this.doc,"option",{text:i,attrs:{value:i}});i===this.opts.code&&(f.selected=!0),n.appendChild(f)}return this.picker=n,I(this.doc,"div",{class:`${B.editor}__unit`,children:[t,n]})}focusTarget(){return this.input}attached(){super.attached();const r=this.input;r&&!this.params.key&&this.props.selectOnFocus!==!1&&W(r.select)&&r.select()}readValue(){const r=this.input?String(this.input.value).trim():"";if(r==="")return null;const t=this.picker?this.picker.value:this.opts.code,n=V(r,{...this.opts,code:t});return n===null?Number.NaN:n}checkValue(r){if(r===null)return!0;if(!r||typeof r!="object"||!Number.isFinite(r.amount))return"Enter an amount";const t=r.amount,{min:n,max:i}=this.props;return typeof n=="number"&&t<n?`Must be ${n} or more`:typeof i=="number"&&t>i?`Must be ${i} or less`:!0}destroy(){for(const r of this.#e)r();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const d=l}),Le("packages/dom/src/editors/index.js",function(e,K){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return x}}),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 S}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return i}}),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 O}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return k}}),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 de}});const x=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,S=K("packages/dom/src/editors/select.js").SelectEditor,l=K("packages/dom/src/editors/multiselect.js").MultiSelectEditor,a=K("packages/dom/src/editors/time.js").TimeEditor,t=K("packages/dom/src/editors/datetime.js").DateTimeEditor,i=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,O=K("packages/dom/src/editors/radix.js").RadixEditor,b=K("packages/dom/src/editors/segmented.js").SegmentedEditor,R=K("packages/dom/src/editors/rating.js").RatingEditor,F=K("packages/dom/src/editors/slider.js").SliderEditor,T=K("packages/dom/src/editors/colour.js").ColourEditor,E=K("packages/dom/src/editors/treeselect.js").TreeSelectEditor,$=K("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,k=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:x,textarea:I,number:X,date:H,checkbox:z,select:S,multiSelect:l,temperature:G,currency:Y,time:a,datetime:t,duration:i,ipaddress:u,password:m,code:h,unit:p,radix:O,slider:F,rating:R,segmented:b,treeSelect:E,objectPicker:$,iconPicker:k,colour:T}),se=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function ee(he,ge){const Ee=he&&he.edit&&he.edit.editor,ye=ge&&ge.editors||{},Ae=!!(he&&he.lookup&&he.lookup.multiple);if(te(Ee)||ne(Ee))return Ee;if(typeof Ee=="string"){if(Ae&&Ee==="select")return l;const be=ye[Ee]||ae[Ee];if(be)return be;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 Ae?l:S;const we=se[pe];return we&&(ye[we]||ae[we])||null}function ie(he,ge){const Ee=ee(he.column||{},ge);if(!Ee)return null;const ye=new Ee;return ye.init(he),ne(ye.cancelBeforeStart)&&ye.cancelBeforeStart()===!0?(ne(ye.destroy)&&ye.destroy(),null):ye}const de=ae}),Le("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 S}}),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 d}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,V=K("packages/core/src/internal/util.js").isFunction;function z(c){let h=0,s=0,p=0,y=null,O=null;for(const A of c||[]){if(A==null||A==="")continue;h++;const b=typeof A=="number"?A:Number(A);Number.isFinite(b)&&(s++,p+=b,(y===null||b<y)&&(y=b),(O===null||b>O)&&(O=b))}return{count:h,numericCount:s,sum:s?p:null,min:y,max:O,avg:s?p/s:null}}class w{root=null;valueNode=null;init(h){this.ctx=h,this.doc=h.document,this.root=I(this.doc,"div",{class:`${x.statusBar}__panel`,attrs:{"data-align":h.align||"end"}}),h.label&&this.root.appendChild(I(this.doc,"span",{class:`${x.statusBar}__label`,text:h.label})),this.valueNode=I(this.doc,"span",{class:`${x.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(h,s){const p=this.ctx&&this.ctx.messages;return(p&&V(p.t)?p:W).t(h,s)}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 S extends w{read(){const h=this.ctx.host||{},s=V(h.totalRowCount)?h.totalRowCount():0,p=V(h.loadError)?h.loadError():null;if(p)return p;if(s==null)return this.t("status.counting");const y=V(h.rowCount)?h.rowCount():s;if(y==null)return p||this.t("status.counting");const O=this.ctx.noun,A=b=>O===void 0?this.t("count.rows",{count:b}):`${f(b,this.ctx.locale)}${O?` ${O}`:""}`;return y===s?this.t("status.total",{rows:A(s)}):this.t("status.shownOfTotal",{shown:f(y,this.ctx.locale),total:A(s)})}}class g extends w{read(){const h=this.ctx.host||{},s=V(h.selectedAcrossSource)?h.selectedAcrossSource():null;if(s)return typeof s.count=="number"?this.t("status.selectedAcrossSource",{count:s.count}):this.t("status.selectedAcrossSourceCounting");const p=V(h.selectedCount)?h.selectedCount():0;return p?this.t("status.selected",{count:p}):""}}class l extends w{read(){const h=this.ctx.host||{},s=V(h.rangeValues)?h.rangeValues():[],p=z(s);if(!p.count)return"";const y=this.ctx.stats||["count","sum","min","max","avg"],O=[];for(const A of y){if(A==="count"){O.push(this.t("status.count",{count:p.count}));continue}const b=p[A];b!==null&&O.push(`${this.t(`status.stat.${A}`)} ${o(b,this.ctx.locale)}`)}return O.join(" ")}}class d extends w{read(){const h=this.ctx.host||{},s=V(h.progress)?h.progress():null;if(!s)return"";const{loaded:p,estimated:y,done:O}=s;if(O)return"";if(!y)return this.t("status.loading",{count:p||0});const A=Math.min(100,Math.round((p||0)/y*100));return this.t("status.loadingOf",{loaded:p||0,total:y,percent:A})}}class a extends w{read(){const h=this.ctx.host||{},s=V(h.updateStats)?h.updateStats():null;return s?s.paused?s.pending?this.t("status.pausedWaiting",{waiting:this.t("count.waiting",{count:s.pending})}):this.t("status.paused"):s.coalescedTotal?this.t("status.coalesced",{count:s.coalescedTotal}):"":""}}class r extends w{read(){const h=this.ctx.host||{},s=V(h.hiddenUnresolved)?h.hiddenUnresolved():0;return s?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:s})}):""}}const t=Object.freeze({rowCount:S,selectedCount:g,aggregation:l,progress:d,updates:a,comments:r});class n{panels=[];root=null;init(h){const s=h||{};this.doc=B(s),this.host=s.host||{},this.messages=s.messages||null,this.root=I(this.doc,"div",{class:x.statusBar,attrs:{role:"status","aria-live":"polite"}});const p=s.registry||{},y=Array.isArray(s.panels)&&s.panels.length?s.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const O of y){const A=typeof O=="string"?O:O.name,b=typeof O=="function"?O:p[A]||t[A];if(!b)continue;const v=new b;v.init({document:this.doc,host:this.host,locale:s.locale,messages:this.messages,...typeof O=="object"?O.props||{}:{}}),this.panels.push({name:String(A||"panel"),panel:v}),this.root.appendChild(v.element())}this.refresh()}element(){return this.root}addPanel(h,s,p){const y=new s;return y.init({document:this.doc,host:this.host,messages:this.messages,...p||{}}),this.panels.push({name:h,panel:y}),this.root&&this.root.appendChild(y.element()),y.refresh(),y}removePanel(h){const s=this.panels.findIndex(O=>O.name===h);if(s<0)return!1;const[p]=this.panels.splice(s,1),y=p.panel.element();return y&&y.parentNode&&y.parentNode.removeChild(y),V(p.panel.destroy)&&p.panel.destroy(),!0}refresh(){for(const h of this.panels)h.panel.refresh()}destroy(){for(const h of this.panels)V(h.panel.destroy)&&h.panel.destroy();this.panels=[],this.root&&_(this.root),this.root=null}}const i=new Map;function f(c,h){const s=h||"";let p=i.get(s);return p||(p=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:0}),i.set(s,p)),p.format(Number(c)||0)}const u=new Map;function o(c,h){const s=h||"";let p=u.get(s);return p||(p=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:3}),u.set(s,p)),p.format(Number(c)||0)}const m=n}),Le("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 r}});const Q=K("packages/dom/src/editors/common.js"),x=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,S=K("packages/dom/src/cell/icons.js").renderIconInto;function g(t,n){const i=[];for(const f of t||[]){const u=H(f)?f(n):f;if(u==null||u===!1)continue;if(u==="separator"){i.push({separator:!0});continue}if(typeof u=="string"){i.push({name:u});continue}const o=u,m=o.subMenu||o.children;m?i.push({...o,subMenu:g(m,n)}):i.push(o)}return i.filter((f,u,o)=>f.separator?u===0||u===o.length-1?!1:!o[u-1].separator:!0)}class l{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(n){const i=n||{};this.doc=B(i),this.host=i.host||this.doc.body,this.ctx=i.ctx||{},this.onClose=i.onClose||null,this.parent=i.parent||null}place(n){const i=this.host,f=H(i.getBoundingClientRect)?i.getBoundingClientRect():{left:0,top:0},u=H(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},o=this.doc.defaultView||{innerWidth:0,innerHeight:0},m=o.innerWidth||0,c=o.innerHeight||0;let h=n.x||0,s=n.y||0;const p=z(i);if(n.anchor&&H(n.anchor.getBoundingClientRect)){const A=n.anchor.getBoundingClientRect();n.placement==="below"?(h=p?A.right-u.width:A.left,s=A.bottom):(h=p?A.left-u.width:A.right,s=A.top)}else p&&(h-=u.width);const y={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(c||1/0,(f.top||0)+(f.height||1/0))};h+u.width>y.right&&(h-=u.width),h<y.left&&(h=y.left),s+u.height>y.bottom&&(s-=u.height),s<y.top&&(s=y.top);const O=y.bottom-s;u.height>O&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(O))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(h-f.left+(i.scrollLeft||0))}px`,this.root.style.top=`${Math.round(s-f.top+(i.scrollTop||0))}px`}show(n){return this.hide(),n.ctx&&(this.ctx={...this.ctx||{},...n.ctx}),this.items=g(n.items,this.ctx),this.returnFocus=n.returnFocus||null,this.anchor=n.anchor&&H(n.anchor.setAttribute)&&n.anchor.getAttribute&&n.anchor.getAttribute("aria-haspopup")?n.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=I(this.doc,"div",{class:x.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((i,f)=>{if(i.separator){this.root.appendChild(I(this.doc,"div",{class:x.menuSeparator,attrs:{role:"separator"}}));return}const u=I(this.doc,"div",{class:[x.menuItem,i.cssClass||""],attrs:{role:i.checked===void 0?"menuitem":"menuitemcheckbox",tabindex:"-1","aria-disabled":i.disabled?"true":null,"aria-checked":i.checked===void 0?null:String(i.checked===!0),"aria-haspopup":i.subMenu?"true":null,"aria-expanded":i.subMenu?"false":null,"data-index":f}});if(i.icon!=null&&i.icon!==""){const m=I(this.doc,"span",{class:x.icon});S(m,i.icon,`menu:${i.name||f}`),u.appendChild(m)}u.appendChild(I(this.doc,"span",{class:`${x.menuItem}__label`,text:i.name||""})),i.shortcut&&u.appendChild(I(this.doc,"span",{class:`${x.menuItem}__shortcut`,text:i.shortcut})),i.subMenu&&u.appendChild(I(this.doc,"span",{class:`${x.menuItem}__arrow`,text:"›"}));const o=this.itemNodes.length;this.off.push(_(u,"click",()=>this.invoke(o))),this.off.push(_(u,"mouseenter",()=>{this.focus(o),i.subMenu?this.openSubMenu(o):this.closeChild()})),this.itemNodes.push(u),this.root.appendChild(u)}),this.host.appendChild(this.root),this.place(n),this.open=!0,this.off.push(_(this.root,"keydown",i=>this.onKeyDown(i))),H(this.doc.addEventListener)&&this.off.push(_(this.doc,"mousedown",this.outside=i=>{this.root&&!a(this.root,i.target)&&!(this.child&&this.child.root&&a(this.child.root,i.target))&&this.hide()},!0)),H(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let n=0;n<this.itemNodes.length;n++)if(!this.itemAt(n).disabled)return n;return-1}itemAt(n){const i=this.itemNodes[n];return i?this.items[Number(i.getAttribute("data-index"))]||{}:{}}focus(n){if(n<0||n>=this.itemNodes.length)return;const i=this.itemNodes[this.focused];i&&i.classList.remove(`${x.menuItem}--focused`),this.focused=n;const f=this.itemNodes[n];f.classList.add(`${x.menuItem}--focused`),H(f.focus)&&f.focus(),H(f.scrollIntoView)&&f.scrollIntoView({block:"nearest",inline:"nearest"})}move(n){const i=this.itemNodes.length;if(!i)return;let f=this.focused;for(let u=0;u<i;u++)if(f=(f+n+i)%i,!this.itemAt(f).disabled){this.focus(f);return}}invoke(n){const i=this.itemAt(n);if(!(!i||i.disabled)){if(i.subMenu){this.openSubMenu(n);return}H(i.action)&&i.action({...this.ctx,item:i}),this.hideRoot()}}openSubMenu(n){const i=this.itemAt(n);i.subMenu&&(this.closeChild(),this.child=new l({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:i.subMenu,anchor:this.itemNodes[n]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(n){switch(n.key){case"ArrowDown":d(n),this.move(1);break;case"ArrowUp":d(n),this.move(-1);break;case"Home":d(n),this.focus(this.firstEnabled());break;case"End":d(n),this.focus(this.itemNodes.length-1);break;case"ArrowRight":d(n),this.openSubMenu(this.focused);break;case"ArrowLeft":d(n),this.parent&&(this.hide(),H(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":d(n),this.invoke(this.focused);break;case"Escape":d(n),this.hideRoot();break;default:n.key&&n.key.length===1&&this.jumpTo(n.key);break}}jumpTo(n){const i=n.toLowerCase(),f=this.itemNodes.length;for(let u=1;u<=f;u++){const o=(this.focused+u+f)%f,m=this.itemAt(o);if(!m.disabled&&(m.name||"").toLowerCase().startsWith(i)){this.focus(o);return}}}hideRoot(){let n=this;for(;n.parent;)n=n.parent;n.hide()}hide(){this.closeChild();for(const n of this.off)n();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 d(t){H(t.preventDefault)&&t.preventDefault(),H(t.stopPropagation)&&t.stopPropagation()}function a(t,n){let i=n;for(;i;){if(i===t)return!0;i=i.parentNode}return!1}const r=l}),Le("packages/dom/src/viewpicker.js",function(e,K){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return S}}),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 d}});const Q=K("packages/dom/src/editors/common.js"),x=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,V=K("packages/core/src/internal/util.js").isFunction,w=K("packages/dom/src/cell/icons.js").createIcon,S=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(r,t){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(r,t)}init(r){this.messages=r&&r.messages||r&&r.grid&&r.grid.messages||W;const t=r||{};this.doc=x(t),this.host=t.host||{},this.props=t.props||{},this.root=B(this.doc,"div",{class:S.root,attrs:{role:"group","aria-label":String(this.props.title||"Saved views")}}),this.refresh()}element(){return this.root}refresh(){const r=this.root;if(!r)return;for(const u of this.off)u();this.off.length=0,_(r),this.diffs=new Map;const t=this.views(),n=t.filter(u=>u.builtin),i=t.filter(u=>!u.builtin);n.length&&(r.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),n.length)),r.appendChild(this.buildList(n))),r.appendChild(this.buildHead(String(this.props.title||"Saved views"),i.length)),i.length?r.appendChild(this.buildList(i)):r.appendChild(B(this.doc,"p",{class:S.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const f=this.buildFoot();f&&r.appendChild(f)}buildList(r){const t=B(this.doc,"div",{class:S.list,attrs:{role:"list"}});for(const n of r)t.appendChild(this.buildItem(n));return t}views(){const r=V(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?r:r.slice().sort((t,n)=>String(t.name||"").localeCompare(String(n.name||"")))}activeId(){return V(this.host.activeId)?this.host.activeId():null}buildHead(r,t){return B(this.doc,"div",{class:S.head,children:[B(this.doc,"span",{class:S.title,text:String(r)}),B(this.doc,"span",{class:S.count,text:String(t)})]})}buildItem(r){const t=String(r.id),n=this.activeId()===t,i=V(this.host.canEdit)?this.host.canEdit(r)!==!1:!0,f=B(this.doc,"div",{class:[S.item,n?S.itemActive:"",this.editing===t?S.itemEditing:""],attrs:{role:"listitem","data-view":t,"data-shared":r.shared?"true":"false"}});if(this.editing===t)return f.appendChild(this.buildRenameRow(r)),f;const u=B(this.doc,"button",{class:S.apply,attrs:{type:"button","aria-current":n?"true":null,title:[n?`${r.name} is applied`:`Apply ${r.name}`,r.shared?"Shared with everyone":"Private to you"].join(": ")},children:[B(this.doc,"span",{class:S.name,text:String(r.name||"")}),r.isDefault?this.buildBadges(r):null].filter(Boolean)});V(this.host.apply)?this.off.push(I(u,"click",()=>this.applyView(t))):u.setAttribute("disabled",""),r.description&&u.appendChild(B(this.doc,"span",{class:S.description,text:String(r.description)}));const o=this.buildDiff(t,n);return o&&u.appendChild(o),f.appendChild(u),r.builtin||f.appendChild(this.confirming===t?this.buildConfirm(r):this.buildActions(r,i)),f}buildBadges(r){const t=B(this.doc,"span",{class:S.badges});return r.isDefault&&t.appendChild(B(this.doc,"span",{class:[S.badge,S.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),t}buildDiff(r,t){if(this.props.showDiff!==!0||!V(this.host.diff))return null;const n=this.diffOf(r);if(!n)return null;if(!n.changed)return B(this.doc,"span",{class:[S.diff,S.diffClean],text:this.t(t?"views.applied":"views.matchesGrid")});const i=l(n);return i.length?B(this.doc,"span",{class:S.diff,text:i.join(" · ")}):null}diffOf(r){if(!V(this.host.diff))return null;if(this.diffs.has(r))return this.diffs.get(r);let t=null;try{t=this.host.diff(r)}catch{t=null}return this.diffs.set(r,t),t}buildActions(r,t){const n=String(r.id),i=B(this.doc,"span",{class:S.actions});if(t&&V(this.host.rename)&&i.appendChild(this.buildAction("Rename",`Rename ${r.name}`,()=>{this.editing=n,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),r.isDefault&&V(this.host.clearDefault)?i.appendChild(this.buildAction("Unset default",`Stop applying ${r.name} at load`,()=>{this.host.clearDefault(n),this.refresh()},"pin")):!r.isDefault&&V(this.host.setDefault)&&i.appendChild(this.buildAction("Make default",`Apply ${r.name} when the grid loads`,()=>{this.host.setDefault(n),this.refresh()},"pin")),V(this.host.export)&&i.appendChild(this.buildAction("Share",`Export ${r.name}`,()=>this.host.export(n),"share")),t&&V(this.host.remove)){const f=this.buildAction("Delete",`Delete ${r.name}`,()=>{this.confirming=n,this.refresh()},"trash");f.classList.add(S.actionDanger),i.appendChild(f)}return i}buildConfirm(r){const t=String(r.id),n=B(this.doc,"span",{class:S.confirm});n.appendChild(B(this.doc,"span",{text:this.t("views.confirmDelete",{name:r.name})}));const i=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:r.name}),()=>{this.confirming=null,this.host.remove(t),this.refresh()});return i.classList.add(S.actionDanger),n.appendChild(i),n.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),n}buildRenameRow(r){const t=String(r.id),n=B(this.doc,"span",{class:S.confirm}),i=B(this.doc,"input",{class:S.input,attrs:{type:"text","aria-label":`New name for ${r.name}`}});i.value=String(r.name||""),this.input=i;const f=()=>{const o=String(i.value||"").trim();this.editing=null,o&&o!==r.name&&this.host.rename(t,o),this.refresh()},u=()=>{this.editing=null,this.refresh()};return this.off.push(I(i,"keydown",o=>{o.key==="Enter"?f():o.key==="Escape"&&u()})),n.appendChild(i),n.appendChild(this.buildAction("Save","Save the new name",f)),n.appendChild(this.buildAction("Cancel","Leave the name alone",u)),n}buildFoot(){if(this.props.allowSave===!1||!V(this.host.saveAs))return null;const r=B(this.doc,"div",{class:S.foot}),t=B(this.doc,"input",{class:S.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 n=()=>{const f=String(t.value||"").trim();if(!f){V(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"&&n()}));const i=B(this.doc,"button",{class:S.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(I(i,"click",n)),r.appendChild(t),r.appendChild(i),r}buildAction(r,t,n,i){const f=B(this.doc,"button",{class:S.action,text:i?null:r,attrs:{type:"button",title:t,"aria-label":t,"data-action":r}});return i&&f.appendChild(w(this.doc,i,{className:S.actionIcon})),this.off.push(I(f,"click",n)),f}applyView(r){this.confirming=null,this.host.apply(r),this.refresh()}focusInput(){const r=this.input;r&&V(r.focus)&&r.focus(),r&&V(r.select)&&r.select()}destroy(){for(const r of this.off)r();this.off.length=0,this.root=null,this.input=null,this.diffs=new Map}}function l(a,r=3){if(!a||!a.changed)return[];const t=a.counts||{},n=[],i=(f,u,o)=>{f&&n.push((f===1?u:o).replace("%",String(f)))};if(i(t.columnsHidden,"hides % column","hides % columns"),i(t.columnsShown,"shows % column","shows % columns"),i(t.columnsMoved,"moves % column","moves % columns"),i(t.columnsPinned,"repins % column","repins % columns"),i(t.columnsResized,"resizes % column","resizes % columns"),a.filters&&a.filters.changed){const f=t.filterColumns||0;n.push(f?`changes ${f} filter${f===1?"":"s"}`:"changes the filter")}return a.quick&&a.quick.changed&&n.push("changes the search"),a.sort&&a.sort.changed&&n.push("changes the sort"),a.group&&a.group.changed&&n.push("changes the grouping"),a.pivot&&a.pivot.changed&&n.push("changes the pivot"),i(t.columnsTotalled,"changes % total","changes % totals"),a.pagination&&a.pagination.changed&&n.push("changes the page size"),n.length<=r?n:[...n.slice(0,r),`and ${n.length-r} more`]}const d=g}),Le("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"),x=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:`${x.panel}__body`}),this.refresh()}t(H,V){const z=this.host||{};if(typeof z.t=="function")return z.t(H,V);const w=this.ctx||{};if(w.messages&&typeof w.messages.t=="function")return w.messages.t(H,V);const S=w.grid;return(S&&S.messages?S.messages:_).t(H,V)}element(){return this.root}refresh(){}destroy(){for(const H of this.off)H();this.off.length=0,this.root=null}}}),Le("packages/dom/src/formattingpanel.js",function(e,K){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const Q=K("packages/dom/src/editors/common.js"),x=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"),S=w.compileRules,g=w.summariseColumn,l=w.needsDistribution,d=w.DISTRIBUTION_LABELS,a="*",r=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}]),n=Object.freeze([{op:"topPercent",label:d.topPercent,values:1},{op:"bottomPercent",label:d.bottomPercent,values:1},{op:"topN",label:d.topN,values:1},{op:"bottomN",label:d.bottomN,values:1},{op:"aboveMean",label:d.aboveMean,values:0},{op:"belowMean",label:d.belowMean,values:0},{op:"aboveMedian",label:d.aboveMedian,values:0},{op:"belowMedian",label:d.belowMedian,values:0},{op:"zAbove",label:d.zAbove,values:1},{op:"zBelow",label:d.zBelow,values:1},{op:"outlier",label:d.outlier,values:0}]),i=Object.freeze([...t,...n]),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"]}]),o=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(y){const O=i.find(A=>A.op===y);return O?O.values:1}function c(y){if(!y)return"";if(y.scale){const{min:v,max:R,from:j}=y.scale;if(Number.isFinite(v)&&Number.isFinite(R))return`Colour scale, ${v} to ${R}`;const F=o.find(C=>C.from===j);return F?`Colour scale ${F.label}`:"Colour scale"}const O=y.when||{},A=i.find(v=>v.op===O.op),b=A?A.label:O.op;return!A||A.values===0?`Value ${b}`:A.values===2?`Value ${b} ${O.value} and ${O.value2}`:`Value ${b} ${O.value}`}class h extends z{scope=a;mode="condition";refresh(){const O=this.root;if(O){for(const A of this.off)A();this.off.length=0,X(O),O.appendChild(this.#o()),O.appendChild(this.#i()),O.appendChild(this.#l())}}#e(){const O=H(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:a,title:"All columns"},...O]}#t(){return H(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(O){if(!H(this.host.columnSamples))return[];const A=this.host.columnSamples(O);return Array.isArray(A)?A:[...A||[]]}#r(O,A,b){const v=l(O)?g(A):null;return S(O,v)({value:b})}#o(){const O=I(this.doc,"div",{class:`${x.panel}__row`});O.appendChild(I(this.doc,"label",{class:`${x.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const A=I(this.doc,"select",{class:`${x.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const b of this.#e()){const v=I(this.doc,"option",{text:b.title,attrs:{value:b.id}});b.id===this.scope&&v.setAttribute("selected","selected"),A.appendChild(v)}return A.value=this.scope,this.off.push(_(A,"change",()=>{this.scope=A.value||a,this.refresh()})),O.appendChild(A),O}#i(){const O=I(this.doc,"ul",{class:`${x.panel}__list`}),A=this.#t();if(!A.length)return O.appendChild(I(this.doc,"li",{class:`${x.panel}__empty`,text:this.t("formatting.noRules")})),O;A.forEach((R,j)=>{const F=I(this.doc,"li",{class:`${x.panel}__item`,attrs:{"data-rule":R.id}}),C=I(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${c(R)}`}});C.checked=R.enabled!==!1,this.off.push(_(C,"change",()=>{this.#c("updateRule",this.scope,R.id,{enabled:C.checked})})),F.appendChild(C);const T=I(this.doc,"span",{class:`${x.panel}__swatch`}),L=R.style||{};if(L.background&&T.style&&T.style.setProperty)T.style.setProperty("background",String(L.background));else if(R.scale&&R.scale.colours&&T.style&&T.style.setProperty){const P=R.scale.colours;T.style.setProperty("background",`linear-gradient(90deg, ${P[0]}, ${P[P.length-1]})`)}F.appendChild(T),F.appendChild(I(this.doc,"span",{class:`${x.panel}__text`,text:c(R)}));const E=I(this.doc,"button",{class:`${x.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...j===0?{disabled:"disabled"}:{}}});this.off.push(_(E,"click",()=>this.#c("moveRule",this.scope,R.id,j-1))),F.appendChild(E);const D=I(this.doc,"button",{class:`${x.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...j===A.length-1?{disabled:"disabled"}:{}}});this.off.push(_(D,"click",()=>this.#c("moveRule",this.scope,R.id,j+1))),F.appendChild(D);const $=I(this.doc,"button",{class:`${x.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${c(R)}`}});this.off.push(_($,"click",()=>this.#c("removeRule",this.scope,R.id))),F.appendChild($),O.appendChild(F)});const b=this.#s(A);b&&O.appendChild(b);const v=I(this.doc,"button",{class:`${x.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(_(v,"click",()=>this.#c("clearRules",this.scope))),O.appendChild(v),O}#s(O){const A=this.#n(this.scope);if(!A.length)return null;const b=O.filter(R=>R.enabled!==!1);if(!b.length)return null;const v=I(this.doc,"div",{class:`${x.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const R of A.slice(0,r)){const j=this.#r(b,A,R),F=I(this.doc,"span",{class:`${x.panel}__previewcell`,text:String(R)});j&&F.style&&F.style.setProperty&&(j.background&&F.style.setProperty("background",String(j.background)),j.color&&F.style.setProperty("color",String(j.color))),v.appendChild(F)}return v}#l(){const O=I(this.doc,"div",{class:`${x.panel}__form`}),A=I(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return A.appendChild(I(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),A.appendChild(I(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),A.value=this.mode,this.off.push(_(A,"change",()=>{this.mode=A.value==="scale"?"scale":"condition",this.refresh()})),O.appendChild(A),this.mode==="scale"?O.appendChild(this.#u()):O.appendChild(this.#a()),O}#a(){const O=I(this.doc,"div",{class:`${x.panel}__form`}),A=I(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),b=I(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const $ of t)b.appendChild(I(this.doc,"option",{text:$.label,attrs:{value:$.op}}));A.appendChild(b);const v=I(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const $ of n)v.appendChild(I(this.doc,"option",{text:$.label,attrs:{value:$.op}}));A.appendChild(v),A.value="gt",O.appendChild(A);const R=I(this.doc,"input",{class:`${x.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),j=I(this.doc,"input",{class:`${x.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});O.appendChild(R),O.appendChild(j);const F=()=>{const $=m(A.value);R.style.setProperty("display",$>=1?"":"none"),j.style.setProperty("display",$>=2?"":"none"),E()};this.off.push(_(A,"change",F));const C=I(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const $ of f)C.appendChild(I(this.doc,"option",{text:$.name,attrs:{value:$.name}}));C.value=f[0].name,O.appendChild(C);const T=I(this.doc,"div",{class:`${x.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});O.appendChild(T);const L=()=>{const $=f.find(N=>N.name===C.value)||f[0],P=m(A.value),k={op:A.value};return P>=1&&(k.value=R.value),P>=2&&(k.value2=j.value),{when:k,style:{background:$.background,color:$.color}}},E=()=>{X(T);const $=this.#n(this.scope);if($.length)for(const P of $.slice(0,r)){const k=this.#r([L()],$,P),N=I(this.doc,"span",{class:`${x.panel}__previewcell`,text:String(P)});k&&N.style&&N.style.setProperty&&(k.background&&N.style.setProperty("background",String(k.background)),k.color&&N.style.setProperty("color",String(k.color))),T.appendChild(N)}};this.off.push(_(R,"input",E)),this.off.push(_(j,"input",E)),this.off.push(_(C,"change",E)),F();const D=I(this.doc,"button",{class:`${x.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(D,"click",()=>{this.#c("addRule",this.scope,L()),R.value="",j.value=""})),O.appendChild(D),O}#u(){const O=I(this.doc,"div",{class:`${x.panel}__form`}),A=I(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const C of u)A.appendChild(I(this.doc,"option",{text:C.name,attrs:{value:C.name}}));A.value=u[0].name,O.appendChild(A);const b=I(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const C of o)b.appendChild(I(this.doc,"option",{text:C.label,attrs:{value:C.from}}));b.value=o[0].from,O.appendChild(b);const v=I(this.doc,"div",{class:`${x.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});O.appendChild(v);const R=()=>{const C=u.find(T=>T.name===A.value)||u[0];return{scale:{from:b.value,colours:[...C.colours]}}},j=()=>{X(v);const C=this.#n(this.scope);if(C.length)for(const T of C.slice(0,r)){const L=this.#r([R()],C,T),E=I(this.doc,"span",{class:`${x.panel}__previewcell`,text:String(T)});L&&L.background&&E.style&&E.style.setProperty&&E.style.setProperty("background",String(L.background)),v.appendChild(E)}};this.off.push(_(A,"change",j)),this.off.push(_(b,"change",j)),j();const F=I(this.doc,"button",{class:`${x.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(F,"click",()=>{this.#c("addRule",this.scope,R())})),O.appendChild(F),O}#c(O,...A){H(this.host[O])&&this.host[O](...A),this.refresh()}}function s(y={}){const O=new h;return O.init({document:B(y),host:y.host||{}}),O}const p=h}),Le("packages/dom/src/statisticspanel.js",function(e,K){"use strict";Object.defineProperty(e,"shouldThinLabels",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,V=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=70,w=40;function S(t,n){return!t||!n?!1:t<n*2+w}const g=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"}]),l=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),d=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 a(t){if(t==null||!Number.isFinite(t))return"—";if(Number.isInteger(t))return String(t);const n=Math.abs(t);return n!==0&&(n<.001||n>=1e7)?t.toExponential(2):String(Number(t.toPrecision(4)))}class r extends V{column=null;#e=0;#t(){return W(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const n=this.root;if(!n)return;for(const u of this.off)u();this.off.length=0,_(n);const i=this.#t();if(!i.length){n.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("stats.noColumns")}));return}i.some(u=>u.id===this.column)||(this.column=i[0].id),n.appendChild(this.#o(i));const f=W(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!f&&W(this.host.columnProfileAsync)){const u=B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("facets.computing")});n.appendChild(u);const o=++this.#e,m=this.column;Promise.resolve(this.host.columnProfileAsync(m)).then(c=>{if(o!==this.#e||this.root!==n||this.column!==m)return;const h=B(this.doc,"div",{});this.#n(h,c);for(const s of[...h.children])n.insertBefore(s,u);n.removeChild(u)},()=>{o!==this.#e||this.root!==n||(u.textContent=this.t("stats.noValues"))});return}this.#e++,this.#n(n,f)}#n(n,i){if(!i||!i.present){n.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("stats.noValues")}));const u=this.#r(i);u&&n.appendChild(u);return}if(n.appendChild(B(this.doc,"p",{class:`${x.panel}__count`,text:this.t("stats.filtered",{count:i.rows})})),Array.isArray(i.topValues)){n.appendChild(this.#l(i,l)),n.appendChild(this.#a(i.topValues));const u=this.#r(i);u&&n.appendChild(u);return}if(n.appendChild(this.#l(i)),i.computed!=="source"){for(const o of d){const m=this.#i(o);m&&n.appendChild(m)}const u=this.#s();u&&n.appendChild(u)}i.histogram&&i.histogram.length>1&&n.appendChild(this.#u(i.histogram));const f=this.#r(i);f&&n.appendChild(f)}#r(n){const i=n&&Array.isArray(n.unavailable)?n.unavailable:[];if(!i.length)return null;const f=this.doc.createElement("div");f.setAttribute("data-unavailable",""),f.appendChild(B(this.doc,"p",{class:`${x.panel}__count`,text:this.t("stats.unavailable",{stats:i.map(o=>o.stat).join(", ")})}));const u=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const o of i)u.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:o.stat})),u.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,text:o.reasonKey?this.t(o.reasonKey,o.reasonParams):o.reason}));return f.appendChild(u),f}#o(n){const i=B(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const f of n){const u=B(this.doc,"option",{text:f.title,attrs:{value:f.id,selected:f.id===this.column?!0:null}});i.appendChild(u)}return i.value=this.column,this.off.push(I(i,"change",()=>{this.column=i.value,this.refresh()})),B(this.doc,"label",{class:`${x.panel}__field`,children:[B(this.doc,"span",{class:`${x.panel}__label`,text:this.t("stats.column")}),i]})}#i(n){const i=this.host.reduceColumn;if(!W(i)||!this.column)return null;const f=[];for(const m of n.kernels){const c=i(this.column,m);c==null||Number.isNaN(c)||f.push([m,c])}if(!f.length)return null;const u=this.doc.createElement("div");u.appendChild(B(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t(n.label)}));const o=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const[m,c]of f)o.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(`total.${m}`)})),o.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,text:typeof c=="number"?a(c):String(c)}));return u.appendChild(o),u}#s(){const n=this.host.columnCapability;if(!W(n)||!this.column)return null;const i=n(this.column);if(!i)return null;const f=this.doc.createElement("div");f.appendChild(B(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t("stats.section.capability")}));const u=B(this.doc,"dl",{class:`${x.panel}__stats`}),o=[["stats.cp",i.cp,null],["stats.cpk",i.cpk,i.interval],["stats.pp",i.pp,null],["stats.ppk",i.ppk,i.intervalPp],["stats.outOfSpec",i.outOfSpec,null]];for(const[m,c,h]of o){if(c==null)continue;u.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(m)}));const s=[B(this.doc,"span",{text:a(c)})];h&&Number.isFinite(h.lower)&&s.push(B(this.doc,"span",{class:`${x.panel}__stat-interval`,text:`${a(h.lower)} – ${a(h.upper)}`,attrs:{title:`${Math.round(h.confidence*100)}%`}})),u.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,children:s}))}return f.appendChild(u),f}#l(n,i=g){const f=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const u of i){const o=n[u.key];f.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(u.label)})),f.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,text:u.kind==="count"?String(o??0):a(o)}))}return f}#a(n){const i=this.doc.createElement("div");i.appendChild(B(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t("stats.topValues")}));const f=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const u of n)f.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:String(u.value)})),f.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,children:[B(this.doc,"span",{text:String(u.count)}),B(this.doc,"span",{class:`${x.panel}__stat-interval`,text:`${Math.round(u.share*100)}%`})]}));return i.appendChild(f),i}#u(n){const i=n.reduce((m,c)=>Math.max(m,c.count),0)||1,f=B(this.doc,"div",{class:`${x.panel}__histogram`});f.appendChild(B(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t("stats.distribution.detail")}));const u=B(this.doc,"ul",{class:`${x.panel}__histogram-list`,attrs:{role:"list","aria-label":this.t("stats.distribution.detail")}}),o=[];for(const m of n){const c=m.count||0,h=c?Math.max(2,c/i*100):0,s=String(c),p=h>=z,y=B(this.doc,"div",{class:`${x.panel}__bar`,style:{width:`${h}%`},children:p?[B(this.doc,"span",{class:`${x.panel}__bin-count ${x.panel}__bin-count--inside`,text:s})]:[]}),O=B(this.doc,"div",{class:`${x.panel}__bin-track`,children:p?[y]:[y,B(this.doc,"span",{class:`${x.panel}__bin-count ${x.panel}__bin-count--outside`,text:s})]}),A=B(this.doc,"span",{class:`${x.panel}__bin-range`,text:`${a(m.from)}–${a(m.to)}`});o.push(A);const b=this.t("stats.bin",{count:c,from:a(m.from),to:a(m.to)});u.appendChild(B(this.doc,"li",{class:`${x.panel}__bin`,attrs:{title:b,"aria-label":b},children:[A,O]}))}return f.appendChild(u),this.#c(f,u,o),f}#c(n,i,f){const u=globalThis.ResizeObserver;if(!W(u))return;const o=()=>{const c=n.clientWidth||(W(n.getBoundingClientRect)?n.getBoundingClientRect().width:0);if(!c)return;let h=0;for(const s of f){const p=s.scrollWidth||(W(s.getBoundingClientRect)?s.getBoundingClientRect().width:0);p>h&&(h=p)}i.classList.toggle(`${x.panel}__histogram-list--thin`,S(c,h))},m=new u(o);m.observe(n),this.off.push(()=>m.disconnect()),o()}}}),Le("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"),x=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 V(S,g=4){const l=Number(S);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,d=l&&X(l.get)?l.get("regression"):null;return d&&Array.isArray(d.predictors)&&d.response?d:null}refresh(){const g=this.root;if(!g)return;I(g);const l=this.#e();if(!l){g.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("regression.noModel")}));return}const d=X(this.host.regressionModel)?this.host.regressionModel(l):null;if(!d){g.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("regression.cannotFit")}));return}g.appendChild(B(this.doc,"p",{class:`${x.panel}__count`,text:this.t("regression.observations",{count:d.n})})),g.appendChild(this.#t(d)),g.appendChild(this.#n(d));const a=this.#r(d,l);a&&g.appendChild(a),g.appendChild(this.#o(d))}#t(g){const l=B(this.doc,"dl",{class:`${x.panel}__stats`}),d=(a,r)=>{l.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-label`,text:a})),l.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,text:r}))};return d(this.t("regression.r2"),V(g.r2,4)),d(this.t("regression.adjR2"),V(g.adjR2,4)),l}#n(g){const l=B(this.doc,"div",{class:`${x.panel}__section`});l.appendChild(B(this.doc,"h4",{class:`${x.panel}__heading`,text:this.t("regression.coefficients")}));const d=B(this.doc,"table",{class:`${x.panel}__coef-table`}),a=B(this.doc,"tr");for(const r of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])a.appendChild(B(this.doc,"th",{text:this.t(r)}));d.appendChild(a);for(const r of g.coefficients){const t=B(this.doc,"tr");t.appendChild(B(this.doc,"td",{text:r.name})),t.appendChild(B(this.doc,"td",{text:`${V(r.estimate)} ± ${V(r.stdError)}`})),t.appendChild(B(this.doc,"td",{text:V(r.stdError)})),t.appendChild(B(this.doc,"td",{text:V(r.t,3)})),t.appendChild(B(this.doc,"td",{text:V(r.p,4)})),d.appendChild(t)}return l.appendChild(d),l}#r(g,l){if(!Array.isArray(g.vif)||g.vif.length<2)return null;const d=B(this.doc,"div",{class:`${x.panel}__section`});d.appendChild(B(this.doc,"h4",{class:`${x.panel}__heading`,text:this.t("regression.vif")}));const a=B(this.doc,"dl",{class:`${x.panel}__stats`});return g.vif.forEach((r,t)=>{a.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-label`,text:l.predictors[t]})),a.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,text:V(r,3)}))}),d.appendChild(a),d}#o(g){const l=g.heteroscedasticity,d=B(this.doc,"div",{class:`${x.panel}__section`});return d.appendChild(B(this.doc,"h4",{class:`${x.panel}__heading`,text:this.t("regression.heteroscedasticity")})),l?(d.appendChild(B(this.doc,"p",{class:`${x.panel}__flag`,attrs:{"data-heteroscedastic":l.heteroscedastic?"true":"false"},text:this.t(l.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:V(l.statistic,3),p:V(l.p,4)})})),d):(d.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("regression.cannotFit")})),d)}}const w=z}),Le("packages/dom/src/comparepanel.js",function(e,K){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return S}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,V=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 S extends V{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 d=this.#e();if(d.length<2){l.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("compare.needTwo")}));return}d.some(t=>t.id===this.first)||(this.first=d[0].id),(!d.some(t=>t.id===this.second)||this.second===this.first)&&(this.second=(d.find(t=>t.id!==this.first)||d[0]).id),l.appendChild(this.#t("compare.first",d,this.first,t=>{this.first=t,this.second===t&&(this.second=(d.find(n=>n.id!==t)||d[0]).id),this.refresh()})),l.appendChild(this.#t("compare.second",d,this.second,t=>{this.second=t,this.first===t&&(this.first=(d.find(n=>n.id!==t)||d[0]).id),this.refresh()}));const a=W(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!a||!a.n){l.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("compare.noPairs")}));return}l.appendChild(B(this.doc,"p",{class:`${x.panel}__count`,text:this.t("compare.pairs",{count:a.n})}));const r=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const t of z){const n=a[t.key];n!=null&&(r.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(t.label)})),r.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,text:w(n)})))}l.appendChild(r)}#t(l,d,a,r){const t=B(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t(l)}});for(const n of d)t.appendChild(B(this.doc,"option",{text:n.title,attrs:{value:n.id,selected:n.id===a?!0:null}}));return t.value=a,this.off.push(I(t,"change",()=>r(t.value))),B(this.doc,"label",{class:`${x.panel}__field`,children:[B(this.doc,"span",{class:`${x.panel}__label`,text:this.t(l)}),t]})}}}),Le("packages/dom/src/insightspanel.js",function(e,K){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return S}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,V=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 S extends V{column=null;by=null;#e(){return W(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const l=this.root;if(!l)return;for(const i of this.off)i();this.off.length=0,_(l);const d=this.#e();if(!d.length){l.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("insights.empty")}));return}const a=this.#t();a&&l.appendChild(a);const r=this.#n();r&&l.appendChild(r),l.appendChild(this.#o(d));const t=this.#s();t&&l.appendChild(t);const n=this.#u();n&&l.appendChild(n)}#t(){if(!W(this.host.subsetVsPopulation))return null;const l=this.host.subsetVsPopulation();if(!l)return null;const d=this.#c("insights.subset");return l.filtered?(d.appendChild(B(this.doc,"p",{class:`${x.panel}__count`,text:this.t("stats.filtered",{count:l.subsetN})})),d.appendChild(this.#r(l.ranked)),d):(d.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("insights.noFilter")})),d)}#n(){const l=this.props&&this.props.other;if(!l||!W(this.host.datasetVsDataset))return null;let d;try{d=this.host.datasetVsDataset(l)}catch{return null}if(!d||!d.ranked)return null;const a=this.#c("insights.dataset");return a.appendChild(this.#r(d.ranked)),a}#r(l){const d=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const a of l||[]){const r=B(this.doc,"dt",{class:`${x.panel}__stat-name`});r.appendChild(B(this.doc,"span",{text:String(a.name??a.column)})),r.appendChild(B(this.doc,"span",{class:`${x.panel}__stat-interval`,text:String(a.measure||"")}));const t=B(this.doc,"dd",{class:`${x.panel}__stat-value`});t.appendChild(B(this.doc,"span",{text:w(a.magnitude)})),a.reliable===!1&&t.appendChild(B(this.doc,"span",{class:`${x.panel}__stat-interval`,text:this.t("insights.smallSample")})),d.appendChild(r),d.appendChild(t)}return d}#o(l){const d=this.#c("insights.groups");l.some(r=>r.id===this.column)||(this.column=l[0].id),(!l.some(r=>r.id===this.by)||this.by===this.column)&&(this.by=(l.find(r=>r.id!==this.column)||l[0]).id),d.appendChild(this.#d("stats.column",l,this.column,r=>{this.column=r,this.by===r&&(this.by=(l.find(t=>t.id!==r)||l[0]).id),this.refresh()})),d.appendChild(this.#d("insights.by",l,this.by,r=>{this.by=r,this.column===r&&(this.column=(l.find(t=>t.id!==r)||l[0]).id),this.refresh()}));const a=W(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return a?(d.appendChild(this.#i(a)),d):(d.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("insights.needGroups")})),d)}#i(l){const d=B(this.doc,"dl",{class:`${x.panel}__stats`});Array.isArray(l.groups)&&l.groups.length===2&&this.#a(d,"insights.groups",`${l.groups[0]} · ${l.groups[1]}`),this.#a(d,"insights.test",String(l.method||l.test||""));const a=l.effectSize||{};this.#a(d,"insights.effect",`${a.name||""} ${w(a.value)}`.trim());const r=l.interval;let t="—";if(r&&Number.isFinite(r.lower)&&Number.isFinite(r.upper)){const i=Number.isFinite(r.confidence)?` (${Math.round(r.confidence*100)}%)`:"";t=`${w(r.lower)} – ${w(r.upper)}${i}`}const n=this.#a(d,"insights.interval",t);return r&&r.method&&n.appendChild(B(this.doc,"span",{class:`${x.panel}__stat-interval`,text:String(r.method)})),Number.isFinite(l.pValue)&&this.#a(d,"insights.pValue",w(l.pValue)),d}#s(){if(!W(this.host.anomalies))return null;let l;try{l=this.host.anomalies()}catch{return null}if(!l)return null;const d=this.#c("insights.anomalies");d.appendChild(B(this.doc,"p",{class:`${x.panel}__count`,text:this.t("insights.anomalyCount",{count:l.flagged||0,n:l.n||0})}));const a=B(this.doc,"dl",{class:`${x.panel}__stats`});this.#a(a,"insights.anomalyMethod",String(l.method||""));const r=this.#l(l);r!==null&&this.#a(a,"insights.anomalyThreshold",w(r)),d.appendChild(a);const t=(l.rows||[]).map(n=>({name:n.rowKey!=null?String(n.rowKey):`#${n.index}`,measure:(n.why||[]).map(i=>i.name||i.column).join(", "),magnitude:n.score}));return d.appendChild(this.#r(t)),d}#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 d=Array.isArray(l.columns)?l.columns[0]:null;return d&&Number.isFinite(d.threshold)?d.threshold:null}#a(l,d,a){l.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(d)}));const r=B(this.doc,"dd",{class:`${x.panel}__stat-value`});return r.appendChild(B(this.doc,"span",{text:a})),l.appendChild(r),r}#u(){if(!W(this.host.columnCapability)||!this.column)return null;const l=this.host.columnCapability(this.column);if(!l)return null;const d=this.#c("stats.section.capability"),a=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const r of z){const t=l[r.field];if(t==null)continue;a.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(r.key)}));const n=[B(this.doc,"span",{text:w(t)})],i=r.interval?l[r.interval]:null;i&&Number.isFinite(i.lower)&&n.push(B(this.doc,"span",{class:`${x.panel}__stat-interval`,text:`${w(i.lower)} – ${w(i.upper)}`,attrs:{title:`${Math.round(i.confidence*100)}%`}})),a.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,children:n}))}return d.appendChild(a),d}#c(l){const d=this.doc.createElement("div");return d.appendChild(B(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t(l)})),d}#d(l,d,a,r){const t=B(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t(l)}});for(const n of d)t.appendChild(B(this.doc,"option",{text:n.title,attrs:{value:n.id,selected:n.id===a?!0:null}}));return t.value=a,this.off.push(I(t,"change",()=>r(t.value))),B(this.doc,"label",{class:`${x.panel}__field`,children:[B(this.doc,"span",{class:`${x.panel}__label`,text:this.t(l)}),t]})}}}),Le("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 j}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return E}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.cssEscape,I=Q.documentFor,_=Q.el,X=Q.on,W=Q.clear,V=K("packages/core/src/i18n/index.js").defaultMessages,z=K("packages/core/src/internal/util.js"),w=z.isFunction,S=z.nextFrame,g=K("packages/dom/src/cell/icons.js"),l=g.createIcon,d=g.updateIcon,a=g.icon,t=K("packages/dom/src/viewpicker.js").ViewPicker,i=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,O=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,b=K("packages/core/src/compute/total.js").TOTAL_LABELS;class v extends O{dragging=null;collapsed=new Set;refresh(){const P=this.root;if(!P)return;for(const Y of this.off)Y();this.off.length=0,W(P);const k=_(this.doc,"input",{class:`${x.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.query&&(k.value=this.query),this.off.push(X(k,"input",()=>{this.query=k.value,this.paintList()})),P.appendChild(k),P.appendChild(this.buildZone("group","Row groups")),P.appendChild(this.buildZone("values","Grouped row calculation")),P.appendChild(this.buildZone("pivot","Pivot"));const N=_(this.doc,"div",{class:`${x.panel}__heading`});N.appendChild(_(this.doc,"span",{text:this.t("panel.columns")}));const G=_(this.doc,"button",{class:`${x.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),q=_(this.doc,"button",{class:`${x.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()})),N.appendChild(G),N.appendChild(q),P.appendChild(N),this.list=_(this.doc,"div",{class:`${x.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),P.appendChild(this.list),this.paintList()}columns(){const P=this.host;return w(P.columns)?P.columns()||[]:P.columns&&w(P.columns.all)?P.columns.all():[]}paintList(){const P=this.list;if(!P)return;W(P);const k=String(this.query||"").trim().toLowerCase();this.paintNodes(P,this.bandTree(),k)}paintNodes(P,k,N,G=!1){let q=0;for(const Y of k){if(Y.column){const ae=String(Y.column.title||Y.column.id||"");if(N&&!G&&!ae.toLowerCase().includes(N))continue;P.appendChild(this.buildColumnRow(Y.column)),q++;continue}const J=!!N&&this.bandTitle(Y.band).toLowerCase().includes(N),te=_(this.doc,"div",{class:`${x.panel}__bandBody`}),ne=this.paintNodes(te,Y.children,N,G||J);if(N&&!ne&&!J)continue;const oe=_(this.doc,"div",{class:`${x.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||N)&&oe.appendChild(te),P.appendChild(oe),q++}return q}bandTree(){const P=this.columns(),k=new Map,N=this.host;if(w(N.columnGroups)){const Y=J=>{for(const te of J||[])Array.isArray(te.columns)&&(k.set(te.id,te.title),Y(te.columns))};Y(N.columnGroups())}const G=[],q=new Map;for(const Y of P){let J=G,te="";for(const ne of Y.groupPath||[]){te+=`/${ne}`;let oe=q.get(te);oe||(oe={band:{id:ne,title:k.has(ne)?k.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(P){return String(P.title||"")||this.t("columngroup.untitled")}buildColumnRow(P){const k=String(P.title||P.id||""),N=_(this.doc,"div",{class:`${x.panel}__column`,attrs:{"data-col":P.id,draggable:"true",title:this.t("panel.columnDragHint",{column:k})}});N.appendChild(_(this.doc,"span",{class:`${x.panel}__grip`,attrs:{"aria-hidden":"true"}}));const G=_(this.doc,"input",{attrs:{type:"checkbox","aria-label":k}});return G.checked=!(P.layout&&P.layout.hidden),P.layout&&P.layout.lockVisible&&G.setAttribute("disabled",""),this.off.push(X(G,"change",()=>this.setVisible(P.id,G.checked))),N.appendChild(G),N.appendChild(_(this.doc,"span",{text:k})),N.setAttribute("tabindex","0"),N.setAttribute("role","listitem"),this.off.push(X(N,"keydown",q=>this.onRowKey(q,P))),this.off.push(X(N,"dragstart",()=>{this.dragging=P.id})),this.off.push(X(N,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(X(N,"dragover",q=>{if(!this.dragging||this.dragging===P.id)return;if(w(q.preventDefault)&&q.preventDefault(),this.bandDrop(this.dragging,P)){N.setAttribute("data-drop","into");return}const J=D(q,N);N.setAttribute("data-drop",J?"before":"after")})),this.off.push(X(N,"dragleave",()=>N.removeAttribute("data-drop"))),this.off.push(X(N,"drop",q=>{w(q.preventDefault)&&q.preventDefault();const Y=this.dragging;if(this.dragging=null,this.clearDropMark(),!Y||Y===P.id)return;const J=this.bandDrop(Y,P);if(J==="leave"){this.leaveBand(Y);return}if(J){this.joinBand(Y,J);return}this.moveColumn(Y,P.id,D(q,N))})),N}bandOf(P){const k=typeof P=="string"?this.columns().find(G=>G.id===P):P,N=k&&k.groupPath||[];return N.length?N[N.length-1]:null}bandDrop(P,k){const N=this.host;if(!w(N.groupColumns))return null;const G=this.bandOf(P),q=this.bandOf(k);return q&&q!==G?q:G&&!q?"leave":null}joinBand(P,k){const N=this.columns().find(q=>q.id===P),G=this.titleOf(P);if(N&&N.layout&&N.layout.lockPosition){this.announce(this.t("a11y.column.cannotGroup",{column:G}),{repeat:!0});return}this.host.groupColumns([P],{groupId:k}),this.announce(this.t("a11y.column.addedToGroup",{column:G,group:this.bandName(k)}),{repeat:!0}),this.refresh()}leaveBand(P){w(this.host.ungroupColumn)&&(this.host.ungroupColumn(P),this.announce(this.t("a11y.column.removedFromGroup",{column:this.titleOf(P)}),{repeat:!0}),this.refresh())}bandName(P){const k=G=>{for(const q of G){if(!q.band)continue;if(q.band.id===P)return q.band;const Y=k(q.children);if(Y)return Y}return null},N=k(this.bandTree());return N?this.bandTitle(N):P}buildBandRow(P,k){const{band:N,ids:G}=P,q=this.bandTitle(N),Y=_(this.doc,"div",{class:`${x.panel}__bandRow`,attrs:{"data-band-row":N.id,tabindex:"0",role:"listitem","aria-label":q}}),J=_(this.doc,"button",{class:`${x.panel}__bandToggle`,attrs:{type:"button","aria-expanded":k?"true":"false","aria-label":this.t(k?"panel.bandCollapse":"panel.bandExpand",{band:q})},text:k?"▾":"▸"});this.off.push(X(J,"click",()=>this.toggleBand(N.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:`${x.panel}__bandTitle`,text:q});if(Y.appendChild(ae),w(this.host.renameGroup)){const se=_(this.doc,"button",{class:`${x.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,N))),Y.appendChild(se)}if(w(this.host.dissolveGroup)){const se=_(this.doc,"button",{class:`${x.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(N.id))),Y.appendChild(se)}return this.off.push(X(Y,"keydown",se=>this.onBandKey(se,N,Y))),this.off.push(X(Y,"dragover",se=>{!this.dragging||!w(this.host.groupColumns)||this.bandOf(this.dragging)===N.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)===N.id)&&this.joinBand(ee,N.id)})),Y}toggleBand(P){this.collapsed.has(P)?this.collapsed.delete(P):this.collapsed.add(P),this.paintList(),this.focusBand(P)}focusBand(P){const k=this.list&&this.list.querySelector?this.list.querySelector(`[data-band-row="${B(P)}"]`):null;k&&w(k.focus)&&k.focus()}dissolveBand(P){if(!w(this.host.dissolveGroup))return;const k=this.bandName(P);this.collapsed.delete(P),this.host.dissolveGroup(P),this.announce(this.t("a11y.group.dissolved",{group:k}),{repeat:!0}),this.refresh()}startBandRename(P,k,N){const G=_(this.doc,"input",{class:`${x.panel}__bandRename`,attrs:{type:"text","aria-label":this.t("columngroup.rename")}});G.value=N.title||"";let q=!1;const Y=J=>{q||(q=!0,J?(this.host.renameGroup(N.id,G.value),this.announce(this.t("a11y.group.renamed",{group:G.value}),{repeat:!0}),this.refresh()):this.paintList(),this.focusBand(N.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))),k.parentNode&&k.parentNode.replaceChild(G,k),w(G.focus)&&G.focus(),w(G.select)&&G.select()}onBandKey(P,k,N){if(P.target&&P.target!==N)return;const G=P.key;G==="Enter"?(w(P.preventDefault)&&P.preventDefault(),this.toggleBand(k.id)):G==="Delete"?(w(P.preventDefault)&&P.preventDefault(),this.dissolveBand(k.id)):(G==="ArrowUp"||G==="ArrowDown")&&(w(P.preventDefault)&&P.preventDefault(),this.walk(N,G==="ArrowUp"))}walk(P,k){const N=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col], [data-band-row]")]:[],G=N.indexOf(P),q=N[G+(k?-1:1)];q&&w(q.focus)&&q.focus()}onRowKey(P,k){const N=P&&P.key,G=v.zoneKeys[String(N).toLowerCase()];if(G&&!P.ctrlKey&&!P.metaKey&&!P.altKey){w(P.preventDefault)&&P.preventDefault(),this.toggleZone(G,k);return}if(N!=="ArrowUp"&&N!=="ArrowDown")return;const q=N==="ArrowUp",Y=this.columns().map(ae=>ae.id),J=Y.indexOf(k.id);if(J<0)return;if(w(P.preventDefault)&&P.preventDefault(),!P.shiftKey){const ae=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col], [data-band-row]")]:[],se=ae.findIndex(ie=>ie.getAttribute("data-col")===k.id),ee=ae[se+(q?-1:1)];ee&&w(ee.focus)&&ee.focus();return}const te=k.layout&&(k.layout.movable===!1||k.layout.lockPosition),ne=String(k.title||k.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(k.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(k.id)}"]`):null;le&&w(le.focus)&&le.focus()}toggleZone(P,k){const N=this.titleOf(k.id),G=this.t(v.zoneLabel[P]||"panel.zone.group");if(this.zoneColumns(P).includes(k.id)){this.dropFromZone(P,k.id),this.announce(this.t("a11y.panel.removedFrom",{column:N,list:G}),{repeat:!0}),this.restoreFocus(k.id);return}if(this.addToZone(P,k.id)){this.announce(this.t("a11y.panel.addedTo",{column:N,list:G}),{repeat:!0}),this.restoreFocus(k.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:N,list:G}),{repeat:!0})}restoreFocus(P){const k=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(P)}"]`):null;k&&w(k.focus)&&k.focus()}announce(P,k){const N=this.host||{};w(N.announce)&&N.announce(P,k)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const P of this.list.querySelectorAll("[data-drop]"))P.removeAttribute("data-drop")}moveColumn(P,k,N){const G=this.host||{};w(G.moveColumn)&&(G.moveColumn(P,k,N),this.refresh())}buildZone(P,k){const N=_(this.doc,"div",{class:`${x.panel}__zone`,attrs:{"data-zone":P,role:"group","aria-label":k}});N.appendChild(_(this.doc,"div",{class:`${x.panel}__zoneTitle`,text:k}));const G=this.zoneColumns(P);let q=v.zoneAbout[P]||"";P==="values"&&G.length&&!this.zoneColumns("group").length&&(q+=" Add a row group to see them."),q&&N.appendChild(_(this.doc,"div",{class:`${x.panel}__zoneAbout`,text:q}));const Y=_(this.doc,"div",{class:`${x.panel}__zoneBody`});G.length||Y.appendChild(_(this.doc,"span",{class:`${x.panel}__zoneHint`,text:this.t(v.zoneHint[P]||"panel.zoneHint.any")})),P==="values"&&Y.classList.add(`${x.panel}__zoneBody--rows`);for(const J of G){const te=_(this.doc,"span",{class:[x.chip,P==="values"?`${x.chip}--row`:""]});if(te.appendChild(_(this.doc,"span",{class:`${x.chip}__label`,text:this.titleOf(J)})),P==="values"&&w(this.host.setValueAggregation)){const oe=w(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",le=_(this.doc,"select",{class:`${x.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:x.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(X(ne,"click",()=>this.dropFromZone(P,J))),te.appendChild(ne),Y.appendChild(te)}return this.off.push(X(N,"dragover",J=>{w(J.preventDefault)&&J.preventDefault(),N.setAttribute("data-over","true")})),this.off.push(X(N,"dragleave",()=>N.removeAttribute("data-over"))),this.off.push(X(N,"drop",J=>{w(J.preventDefault)&&J.preventDefault(),N.removeAttribute("data-over"),this.dragging&&this.addToZone(P,this.dragging)})),N.appendChild(Y),N}static aggregations=Object.freeze(Object.keys(b).map(P=>({name:P})));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(P){const k=v.zoneApi[P],N=this.host;return k&&w(N[k.read])?N[k.read]()||[]:[]}titleOf(P){const k=this.columns().find(N=>N.id===P);return String(k&&(k.title||k.id)||P)}addToZone(P,k){const N=v.zoneApi[P],G=this.columns().find(Y=>Y.id===k);if(!N||!G||G[N.permission]===!1||!w(this.host[N.write]))return!1;const q=this.zoneColumns(P);return q.includes(k)?!1:(this.host[N.write]([...q,k]),this.refresh(),!0)}dropFromZone(P,k){const N=v.zoneApi[P];return!N||!w(this.host[N.write])?!1:(this.host[N.write](this.zoneColumns(P).filter(G=>G!==k)),this.refresh(),!0)}setVisible(P,k){const N=this.host;k&&w(N.showColumns)?N.showColumns([P]):!k&&w(N.hideColumns)&&N.hideColumns([P])}}class R extends O{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 P=this.root;if(!P)return;for(const te of this.off)te();this.off.length=0,W(P);const k=this.host,N=(w(k.columns)?k.columns():[]).filter(te=>!(te.filter&&te.filter.enabled===!1));if(!w(k.filterFor))return;const G=N.filter(te=>this.isFiltered(te.id));P.appendChild(this.buildSearch()),P.appendChild(this.buildSummary(G.length,N.length));const q=this.query.trim().toLowerCase(),Y=q?N.filter(te=>String(te.title||te.id).toLowerCase().includes(q)):N;if(!Y.length){P.appendChild(_(this.doc,"p",{class:`${x.panel}__empty`,text:q?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=_(this.doc,"div",{class:`${x.panel}__filters`});for(const te of Y)J.appendChild(this.buildSection(te));P.appendChild(J)}isFiltered(P){const k=this.host;return w(k.isFiltered)?k.isFiltered(P)===!0:!1}buildSearch(){const P=_(this.doc,"input",{class:`${x.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return P.value=this.query,this.off.push(X(P,"input",()=>{this.query=P.value||"",this.refresh();const k=this.root&&this.root.querySelector?this.root.querySelector(`.${x.panel}__search`):null;k&&w(k.focus)&&k.focus()})),P}buildSummary(P,k){const N=_(this.doc,"div",{class:`${x.panel}__filterSummary`});if(N.appendChild(_(this.doc,"span",{class:`${x.panel}__filterCount`,text:P?this.t("panel.filterSummaryActive",{active:P,total:k}):this.t("panel.filterSummaryNone",{total:k}),attrs:{"data-active":P?"true":"false"}})),!P)return N;const G=_(this.doc,"button",{class:`${x.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()})),N.appendChild(G),N}buildSection(P){const k=P.id,N=String(P.title||k),G=this.isFiltered(k),q=this.open.has(k),Y=_(this.doc,"section",{class:`${x.panel}__filter`,attrs:{"data-col":k,"data-filtered":G?"true":null}}),J=_(this.doc,"button",{class:`${x.panel}__filterTitle`,attrs:{type:"button","aria-expanded":q?"true":"false",title:this.t(G?"panel.filteredBy":"panel.filterBy",{column:N})},children:[l(this.doc,q?"chevronDown":"chevronRight",{className:`${x.panel}__twisty`}),_(this.doc,"span",{class:`${x.panel}__filterName`,text:N})]});G&&J.appendChild(_(this.doc,"span",{class:`${x.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const te=_(this.doc,"div",{class:`${x.panel}__filterBody`,style:{display:q?"":"none"}}),ne=()=>{if(te.firstChild)return;const oe=this.host.filterFor(k);oe&&w(oe.element)&&te.appendChild(oe.element())};if(this.off.push(X(J,"click",()=>{const oe=this.open.has(k);oe?this.open.delete(k):this.open.add(k),J.setAttribute("aria-expanded",oe?"false":"true"),te.style.display=oe?"none":"";const le=J.firstElementChild;le&&d(le,oe?"chevronRight":"chevronDown"),oe||ne()})),Y.appendChild(J),G){const oe=_(this.doc,"button",{class:`${x.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:N}),title:this.t("panel.clearFilter")},children:[l(this.doc,"close",{className:x.icon})]});this.off.push(X(oe,"click",le=>{w(le.stopPropagation)&&le.stopPropagation(),w(this.host.clearFilter)&&this.host.clearFilter(k),this.refresh()})),Y.appendChild(oe)}return Y.appendChild(te),q&&ne(),Y}}class j extends O{refresh(){const P=this.root;if(!P)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(P);const k=w(this.host.quickFilter)?this.host.quickFilter():"",N=_(this.doc,"input",{class:`${x.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});N.value=k||"",this.off.push(X(N,"input",()=>{w(this.host.setQuickFilter)&&this.host.setQuickFilter(N.value),this.paintCount()})),P.appendChild(N),this.box=N;const G=_(this.doc,"button",{class:`${x.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(X(G,"click",()=>{N.value="",w(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),w(N.focus)&&N.focus()})),P.appendChild(G),this.count=_(this.doc,"p",{class:`${x.panel}__count`}),P.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){S(()=>{this.box&&w(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const P=w(this.host.rowCount)?this.host.rowCount():null,k=w(this.host.totalRowCount)?this.host.totalRowCount():null;if(P===null||k===null||P===void 0){this.count.textContent="";return}this.count.textContent=P===k?this.t("count.rows",{count:k}):this.t("panel.rowsOf",{shown:P,total:k})}}const F=Object.freeze({columns:v,filters:R,views:t,quick:j,formatting:i,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"}),T=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class L{panels=[];actions=[];root=null;openPanel=null;off=[];t(P,k){return(this.messages&&typeof this.messages.t=="function"?this.messages:V).t(P,k)}init(P){const k=P||{};this.doc=I(k),this.host=k.host||{},this.grid=k.grid||null,this.messages=k.messages||k.grid&&k.grid.messages||V,this.icons=k.icons===void 0?k.side==="left":!!k.icons,this.side=k.side==="left"?"left":"right",this.root=_(this.doc,"div",{class:[x.panel,`${x.panel}--${this.side}`,this.icons?`${x.panel}--icons`:null]}),this.tabs=_(this.doc,"div",{class:`${x.panel}__tabs`,attrs:{role:"tablist"}}),this.body=_(this.doc,"div",{class:`${x.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:`${x.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const q of Array.isArray(k.actions)?k.actions:[])this.registerAction(q);const N=k.registry||{},G=Array.isArray(k.panels)&&k.panels.length?k.panels:["columns","filters"];for(const q of G){const Y=q!==null&&typeof q=="object",J=Y?q.name:q,te=w(J),ne=te?J.name||"panel":String(J),oe=Y&&w(q.Ctor)?q.Ctor:te?J:N[ne]||F[ne];oe&&this.registerPanel(ne,oe,Y?q:{})}k.openPanel&&this.show(k.openPanel)}registerPanel(P,k,N){const G=new k;G.init({document:this.doc,host:this.host,grid:this.grid,props:N&&N.props||{}});const q=N&&N.title||P,Y=N&&N.icon||P,J=_(this.doc,"button",{class:`${x.panel}__tab`,text:this.icons?null:q,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":P,title:this.icons?q:null,"aria-label":this.icons?q:null}});return this.icons&&J.appendChild(l(this.doc,Y,{className:`${x.panel}__icon`})),this.off.push(X(J,"click",()=>this.toggle(P))),this.tabs.appendChild(J),this.panels.push({name:P,title:q,panel:G}),G}registerAction(P){if(!P||!P.name)return null;if(P.separator)return this.actionGroup.appendChild(_(this.doc,"div",{class:`${x.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const k=_(this.doc,"button",{class:`${x.panel}__action`,text:this.icons?null:w(P.title)?String(P.title()):P.title,attrs:{type:"button","data-action":P.name,title:w(P.title)?null:P.title,"aria-label":w(P.title)?null:P.title}});if(this.icons){const q=(w(P.icon)?P.icon():P.icon)||(a(P.name)?P.name:"blank");k.appendChild(l(this.doc,q,{className:`${x.panel}__icon`})),k.setAttribute("data-icon",q)}const N=X(k,"click",()=>{w(P.enabled)&&!P.enabled()||(w(P.run)&&P.run(),this.paintActions())});return this.off.push(N),this.actionGroup.appendChild(k),this.actions.push({...P,button:k,offClick:N}),this.paintActions(),k}removeAction(P){const k=this.actions.findIndex(G=>G.name===P);if(k<0)return!1;const N=this.actions[k];return w(N.offClick)&&N.offClick(),N.button&&N.button.parentNode&&N.button.parentNode.removeChild(N.button),this.actions.splice(k,1),!0}paintActions(){for(const P of this.actions){if(!P.button)continue;const k=w(P.enabled)?!!P.enabled():!0;if(P.button.disabled=!k,P.button.setAttribute("aria-disabled",k?"false":"true"),w(P.active)&&P.button.setAttribute("aria-pressed",P.active()?"true":"false"),w(P.title)){const N=String(P.title());P.button.setAttribute("title",N),P.button.setAttribute("aria-label",N),!this.icons&&P.button.textContent!==N&&(P.button.textContent=N)}if(this.icons&&w(P.icon)){const N=String(P.icon());P.button.getAttribute("data-icon")!==N&&(W(P.button),P.button.appendChild(l(this.doc,N,{className:`${x.panel}__icon`})),P.button.setAttribute("data-icon",N))}}}show(P){const k=this.panels.find(N=>N.name===P);return k?(W(this.body),w(k.panel.refresh)&&k.panel.refresh(),this.body.appendChild(k.panel.element()),this.openPanel=P,this.paintTabs(),w(k.panel.focus)&&k.panel.focus(),!0):!1}hide(){W(this.body),this.openPanel=null,this.paintTabs()}toggle(P){this.openPanel===P?this.hide():this.show(P)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let P=0;P<this.tabs.childNodes.length;P++){const k=this.tabs.childNodes[P];k&&k.setAttribute&&k.setAttribute("aria-selected",k.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const P=this.panels.find(k=>k.name===this.openPanel);P&&w(P.panel.refresh)&&!this.#e(P.panel)&&P.panel.refresh(),this.paintActions()}#e(P){const k=this.doc&&this.doc.activeElement;if(!k||k===this.doc.body)return!1;const N=w(P.element)?P.element():null;return!!(N&&w(N.contains)&&N.contains(k))}destroy(){for(const P of this.off)P();this.off.length=0;for(const P of this.panels)w(P.panel.destroy)&&P.panel.destroy();this.panels=[],this.root=null}}const E=L;function D($,P){if(!P.getBoundingClientRect||typeof $.clientY!="number")return!0;const k=P.getBoundingClientRect();return $.clientY<k.top+k.height/2}}),Le("packages/dom/src/ui/groupbyzone.js",function(e,K){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return S}});const x=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 S extends x{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 d=this.columns().find(a=>a.id===l);return String(d&&(d.title||d.id)||l)}canGroup(l){const d=this.columns().find(a=>a.id===l);return!!d&&d.allowGroup!==!1&&!d.generated}announce(l,d){z(this.host.announce)&&this.host.announce(l,d)}refresh(){const l=this.root;if(!l)return;for(const r of this.off)r();this.off.length=0,W(l),l.appendChild(_(this.doc,"span",{class:I.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const d=this.groups(),a=_(this.doc,"div",{class:I.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});d.length||a.appendChild(_(this.doc,"span",{class:I.groupZoneHint,text:this.t("groupZone.hint")})),d.forEach((r,t)=>a.appendChild(this.#t(r,t,d.length))),l.appendChild(a),this.chips=a,l.appendChild(this.#i(d)),this.off.push(X(l,"dragover",r=>{this.dragging==null&&!this.#l(r)||(z(r.preventDefault)&&r.preventDefault(),l.setAttribute("data-over","true"))})),this.off.push(X(l,"dragleave",()=>l.removeAttribute("data-over"))),this.off.push(X(l,"drop",r=>{z(r.preventDefault)&&r.preventDefault(),l.removeAttribute("data-over");const t=this.#l(r)||this.dragging;t!=null&&this.#o(t,this.groups().length)})),this.#s()}#t(l,d,a){const r=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:r,at:d+1,of:a})}});t.appendChild(_(this.doc,"span",{class:I.groupZoneChipText,text:r}));const n=_(this.doc,"button",{class:I.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:r})}});return this.off.push(X(n,"click",()=>this.#r(l))),t.appendChild(n),this.off.push(X(t,"dragstart",i=>{this.dragging=l,i.dataTransfer&&z(i.dataTransfer.setData)&&i.dataTransfer.setData(w,l)})),this.off.push(X(t,"dragend",()=>{this.dragging=null})),this.off.push(X(t,"dragover",i=>{const f=this.#l(i)||this.dragging;f==null||f===l||z(i.preventDefault)&&i.preventDefault()})),this.off.push(X(t,"drop",i=>{const f=this.#l(i)||this.dragging;f!=null&&(z(i.preventDefault)&&i.preventDefault(),z(i.stopPropagation)&&i.stopPropagation(),this.#o(f,d))})),this.off.push(X(t,"keydown",i=>this.#n(i,l,d))),t}#n(l,d,a){const r=l&&l.key,t=this.groups();if(r==="Delete"||r==="Backspace"){z(l.preventDefault)&&l.preventDefault(),this.#r(d,t,a);return}const n=r==="ArrowLeft"||r==="ArrowUp",i=r==="ArrowRight"||r==="ArrowDown",f=r==="Home",u=r==="End";if(!n&&!i&&!f&&!u)return;if(z(l.preventDefault)&&l.preventDefault(),l.shiftKey&&(n||i)){const c=a+(n?-1:1);if(c<0||c>=t.length){this.announce(this.t(n?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(d)}),{repeat:!0});return}const h=t.slice();h.splice(a,1),h.splice(c,0,d),this.setGroups(h),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(d),at:c+1,of:h.length}),{repeat:!0}),this.#a(d);return}let o=a+(n?-1:i?1:0);f&&(o=0),u&&(o=t.length-1);const m=t[o];m&&this.#a(m)}#r(l,d=this.groups(),a=d.indexOf(l)){const r=this.titleOf(l);this.setGroups(d.filter(n=>n!==l)),this.announce(this.t("a11y.panel.removedFrom",{column:r,list:this.t("panel.zone.group")}),{repeat:!0});const t=this.groups();t.length?this.#a(t[Math.min(a,t.length-1)]):this.#u()}#o(l,d){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 a=this.groups(),r=a.indexOf(l),t=a.slice();r>=0&&(t.splice(r,1),r<d&&(d-=1)),t.splice(Math.max(0,Math.min(d,t.length)),0,l),this.setGroups(t);const n=t.indexOf(l);this.announce(this.t(r>=0?"a11y.panel.moved":"a11y.panel.addedTo",r>=0?{column:this.titleOf(l),at:n+1,of:t.length}:{column:this.titleOf(l),list:this.t("panel.zone.group")}),{repeat:!0}),this.#a(l)}#i(l){const d=new Set(l),a=_(this.doc,"label",{class:I.groupZoneAdd}),r=_(this.doc,"select",{class:I.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});r.appendChild(_(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const t of this.columns())d.has(t.id)||!this.canGroup(t.id)||r.appendChild(_(this.doc,"option",{text:this.titleOf(t.id),attrs:{value:t.id}}));return this.off.push(X(r,"change",()=>{const t=r.value;t&&this.#o(t,this.groups().length)})),this.adderSelect=r,a.appendChild(r),a}#s(){for(const d of this.#e)d();this.#e.length=0;const l=this.props&&this.props.header;if(!(!l||!z(l.querySelectorAll)))for(const d of l.querySelectorAll("[data-col]")){const a=z(d.getAttribute)?d.getAttribute("data-col"):null;!a||!this.canGroup(a)||(z(d.setAttribute)&&d.setAttribute("draggable","true"),this.#e.push(X(d,"dragstart",r=>{this.dragging=a,r.dataTransfer&&z(r.dataTransfer.setData)&&r.dataTransfer.setData(w,a)})),this.#e.push(X(d,"dragend",()=>{this.dragging=null})))}}#l(l){const d=l&&l.dataTransfer;if(d&&z(d.getData)){const a=d.getData(w);if(a)return a}return null}#a(l){const d=this.chips&&z(this.chips.querySelector)?this.chips.querySelector(`[data-col="${H(l)}"]`):null;d&&z(d.focus)&&d.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()}}}),Le("packages/dom/src/ui/tooltip.js",function(e,K){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return V}}),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"),x=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,H=K("packages/core/src/internal/util.js").isFunction;class V{root=null;init(g){this.doc=g.document,this.root=I(this.doc,"div",{class:`${x.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:V,...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",d=typeof l=="function"?l:this.components[l]||V;return this.root||(this.root=I(this.doc,"div",{class:x.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==d?(this.component&&H(this.component.destroy)&&this.component.destroy(),X(this.root),this.component=new d,this.componentCtor=d,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,d){const a=()=>this.show({target:g,content:l(),...d||{}}),r=()=>this.hide(),t=[_(g,"mouseenter",a),_(g,"mouseleave",r),_(g,"focus",a),_(g,"blur",r)],n=()=>{for(const i of t)i()};return this.off.push(n),n}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}),Le("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 S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const Q=K("packages/dom/src/editors/common.js"),x=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 d=Math.max(1,Number(l.pageSize)||100),a=l.total==null?null:Math.max(0,Number(l.total)),r=a==null?null:Math.max(1,Math.ceil(a/d)),t=Math.max(0,r==null?Number(l.page)||0:Math.min(Number(l.page)||0,r-1)),n=a===0?0:t*d+1,i=a==null?(t+1)*d:Math.min(a,(t+1)*d);return{page:t,pageSize:d,pageCount:r,from:n,to:i,first:t===0,last:r==null?l.hasMore!==!0:t>=r-1,total:a}}class S{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(d){const a=d||{};this.doc=B(a),this.host=a.host||{},this.pageSize=Number(a.pageSize)||100;const r=Array.isArray(a.pageSizes)&&a.pageSizes.length?[...a.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!r.includes(this.pageSize)&&r.push(this.pageSize),this.pageSizes=r.sort((t,n)=>t-n),this.page=Number(a.page)||0,this.total=a.total===void 0?null:a.total,this.locale=a.locale,this.messages=a.messages||null,this.onChange=a.onChange||null,this.root=I(this.doc,"nav",{class:x.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(d,a){const r=this.messages;return(r&&typeof r.t=="function"?r:H).t(d,a)}element(){return this.root}model(){return w({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(d){d.total!==void 0&&(this.total=d.total),d.counting!==void 0&&(this.counting=d.counting===!0),d.hasMore!==void 0&&(this.hasMore=d.hasMore===!0),d.page!==void 0&&(this.page=Number(d.page)||0),this.paint()}goTo(d){const a=this.page;this.page=d;const r=this.model();return this.page=r.page,this.paint(),this.page!==a&&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 d=this.model();return d.pageCount==null?this.page:this.goTo(d.pageCount-1)}setPageSize(d){const a=this.page*this.pageSize;this.pageSize=Math.max(1,Number(d)||1),this.page=Math.floor(a/this.pageSize),this.paint(),z(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const d=this.root;if(!d)return;for(const o of this.off)o();this.off.length=0,X(d);const a=this.model(),r=I(this.doc,"select",{class:`${x.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const o of this.pageSizes)r.appendChild(I(this.doc,"option",{text:String(o),attrs:{value:o}}));r.value=String(this.pageSize),this.off.push(_(r,"change",()=>this.setPageSize(Number(r.value)))),d.appendChild(r);const t=a.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:a.from,to:a.to}):this.t("pagination.summary",{from:a.from,to:a.to,total:a.total});d.appendChild(I(this.doc,"span",{class:`${x.pagination}__summary`,text:t}));const n=(o,m,c,h)=>{const s=I(this.doc,"button",{class:`${x.pagination}__button`,text:o,attrs:{type:"button","aria-label":h,disabled:c?"":null}});return c||this.off.push(_(s,"click",m)),s};d.appendChild(n("«",()=>this.goTo(0),a.first,this.t("pagination.first"))),d.appendChild(n("‹",()=>this.previous(),a.first,this.t("pagination.previous")));const i=I(this.doc,"span",{class:`${x.pagination}__page`});i.appendChild(I(this.doc,"span",{text:`${this.t("pagination.page")} `}));const f=I(this.doc,"input",{class:`${x.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":a.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:a.pageCount}),size:String(Math.max(2,String(a.pageCount??a.page+1).length))}});f.value=String(a.page+1);const u=()=>{const o=parseInt(String(f.value).trim(),10);if(!Number.isFinite(o)){f.value=String(this.model().page+1);return}this.goTo(o-1)};this.off.push(_(f,"keydown",o=>{o.key==="Enter"?(u(),o.preventDefault?.()):o.key==="Escape"?(f.value=String(this.model().page+1),f.blur?.()):o.stopPropagation?.()})),this.off.push(_(f,"blur",()=>u())),this.off.push(_(f,"focus",()=>f.select?.())),i.appendChild(f),a.pageCount!=null&&i.appendChild(I(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:a.pageCount})}`})),d.appendChild(i),d.appendChild(n("›",()=>this.next(),a.last,this.t("pagination.next"))),d.appendChild(n("»",()=>this.last(),a.last||a.pageCount==null,this.t("pagination.last")))}destroy(){for(const d of this.off)d();this.off.length=0,this.root=null}}const g=S}),Le("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 S}}),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 d}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,V=K("packages/core/src/i18n/index.js").defaultMessages;function z(a,r){const t=a&&a.grid&&a.grid.messages;return(t&&W(t.t)?t:V).t(r)}class w{root=null;init(r){this.doc=r.document,this.root=I(this.doc,"div",{class:`${x.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[I(this.doc,"span",{class:`${x.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),I(this.doc,"span",{class:`${x.overlay}__message`,text:r.message||z(r,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class S{root=null;init(r){this.doc=r.document,this.root=I(this.doc,"div",{class:`${x.overlay}__empty`,attrs:{role:"status"},children:[I(this.doc,"span",{class:`${x.overlay}__message`,text:r.message||z(r,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const g=Object.freeze({loading:w,empty:S});class l{root=null;slot=null;component=null;current=null;init(r){const t=r||{};this.doc=B(t),this.components={...g,...t.components||{}},this.root=I(this.doc,"div",{class:x.overlay,attrs:{"data-open":"false"}}),this.slot=I(this.doc,"div",{class:`${x.overlay}__slot`}),this.root.appendChild(this.slot),t.host&&t.host.appendChild(this.root)}element(){return this.root}show(r,t){const n=typeof r=="function"?r:this.components[r];return n?(this.hide(),this.component=new n,this.component.init({document:this.doc,message:t&&t.message,...t&&t.props||{}}),this.slot.appendChild(this.component.element()),this.current=typeof r=="string"?r:"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(r,t){this.components[r]=t}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const d=l}),Le("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 x=K("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return x.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return x.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}})}),Le("packages/dom/src/ui/celltooltip.js",function(e,K){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Q=K("packages/dom/src/editors/common.js"),x=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,S=K("packages/dom/src/detailhost.js").insideDetail,l=K("packages/dom/src/renderer/renderer.js").displayIndexOf,d=K("packages/dom/src/renderer/viewport.js"),a=d.CLASS,r=d.NAMESPACE,n=K("packages/dom/src/themeof.js").carryTheme,i={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,o=6;let m=0;class c{#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 y=p||{};this.#e=y.grid,this.#t=y.host,this.#n=y.viewport,this.#r=x(y),m+=1,this.#s=`lat-cell-tooltip-${m}`}mount(){const p=this.#n&&this.#n.root;if(!p||!W(p.addEventListener))return;const y=this.#e.on("cell:mouseover",b=>this.#b(b));W(y)&&this.#h.push(y);const O=this.#e.on("cell:mouseout",()=>this.#v());W(O)&&this.#h.push(O),this.#h.push(I(p,"focusin",b=>this.#j(b))),this.#h.push(I(p,"focusout",()=>this.#v())),this.#h.push(I(this.#r,"keydown",b=>this.#w(b),!0));const A=this.#r.defaultView;A&&W(A.addEventListener)&&this.#h.push(I(A,"scroll",()=>this.hide(),!0))}#m(){const p=W(this.#e.get)?this.#e.get("tooltip"):null,y=p&&typeof p=="object"?p:{},O=Number.isFinite(y.delay)&&y.delay>=0?Number(y.delay):f,A=y.maxWidth;return{delay:O,hideDelay:u,maxWidth:typeof A=="number"&&Number.isFinite(A)?`${A}px`:typeof A=="string"&&A?A:null}}#g(p){const y=p&&p.cell?p.cell.tooltip:null;return!y||typeof y!="object"||Array.isArray(y)||!W(y.render)&&!W(y.mount)?null:y}#y(p){if(!p||!W(p.closest))return null;const y=p.closest(`.${a.row}`);if(!y)return null;const O=l(y);if(O<0)return null;const A=this.#t.rowAt(O);if(!A)return null;const b=p.getAttribute("data-col");if(!b)return null;const v=this.#t.columns.get(b);return v?{row:A,key:A.key,index:O,colId:b,column:v,value:this.#t.cellValue?this.#t.cellValue(A,v):void 0,data:A.data,text:this.#t.cellText?this.#t.cellText(A,v):"",cell:p,grid:this.#e}:null}#b(p){const y=p&&p.target;if(!this.#g(p&&p.column)){this.#v();return}this.#S(y)}#j(p){const y=p&&p.target;if(!y||!W(y.closest)||S(y,this.#n.root))return;const O=y.closest(`.${a.cell}`);if(!O||O!==y){this.#v();return}const A=O.getAttribute("data-col"),b=A?this.#t.columns.get(A):null;if(!this.#g(b)){this.#v();return}this.#S(O)}#w(p){!p||p.key!=="Escape"||p.defaultPrevented||this.#l&&(W(p.preventDefault)&&p.preventDefault(),this.hide())}#S(p){if(this.#p||!p||(this.#L(),this.#l&&this.#a===p))return;this.#N();const{delay:y}=this.#m();if(!y){this.#M(p);return}this.#d=setTimeout(()=>{this.#d=null,this.#M(p)},y)}#v(){if(this.#N(),!this.#l||this.#f!==null)return;const{hideDelay:p}=this.#m();this.#f=setTimeout(()=>{this.#f=null,this.hide()},p)}#C(){if(this.#o)return this.#o;const p=this.#r,y=B(p,"div",{class:[r,i.tooltip],attrs:{id:this.#s,role:"tooltip","data-open":"false"}});this.#i=B(p,"div",{class:i.body}),y.appendChild(this.#i),this.#h.push(I(y,"mouseenter",()=>this.#L())),this.#h.push(I(y,"mouseleave",()=>this.#v()));const O=p.body;return O&&W(O.appendChild)&&O.appendChild(y),this.#o=y,y}#O(p,y){const O=this.#i;if(_(O),p==null||p==="")return!1;if(typeof p=="string")return O.textContent=p,!0;if(typeof p=="object"){if(typeof p.nodeType=="number")return O.appendChild(p),!0;const A=p;if(typeof A.html=="string")return O.innerHTML=z(A.html),!0;if(A.title!==void 0||A.rows!==void 0||A.note!==void 0)return this.#P(A),!0}return H(`tooltip-content:${y}`,`Column '${y}' 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}#P(p){const y=this.#r,O=this.#i,A=v=>v==null?"":String(v);p.title!==void 0&&p.title!==null&&p.title!==""&&O.appendChild(B(y,"div",{class:i.title,text:A(p.title)}));const b=Array.isArray(p.rows)?p.rows:[];if(b.length){const v=B(y,"div",{class:i.rows});for(const R of b){if(!R||typeof R!="object")continue;const j=B(y,"div",{class:i.row});j.appendChild(B(y,"span",{class:i.label,text:A(R.label)})),j.appendChild(B(y,"span",{class:i.value,text:A(R.value)})),v.appendChild(j)}O.appendChild(v)}p.note!==void 0&&p.note!==null&&p.note!==""&&O.appendChild(B(y,"div",{class:i.note,text:A(p.note)}))}#M(p){if(this.#p)return;const y=this.#y(p);if(!y){this.hide();return}const O=this.#g(y.column);if(!O){this.hide();return}this.hide();const A=this.#C();n(A,this.#n&&this.#n.root);let b;if(W(O.render))try{b=O.render(y)}catch(j){H(`tooltip-render:${y.colId}`,`Column '${y.colId}' cell.tooltip render threw; no tooltip was shown.`,j);return}const v=this.#O(b,y.colId);if(W(O.mount))try{O.mount(this.#i,y),this.#u=O}catch(j){H(`tooltip-mount:${y.colId}`,`Column '${y.colId}' cell.tooltip mount threw; the tooltip was closed.`,j),this.hide();return}else if(!v)return;const{maxWidth:R}=this.#m();R&&(A.style.maxWidth=R),this.#a=p,this.#l=!0,A.setAttribute("data-open","true"),this.#E(p),this.#T(p)}#E(p){if(!W(p.setAttribute))return;const y=W(p.getAttribute)?p.getAttribute("aria-describedby"):null;this.#c={cell:p,previous:y},p.setAttribute("aria-describedby",y?`${y} ${this.#s}`:this.#s)}#T(p){const y=this.#o;if(!y||!W(p.getBoundingClientRect))return;const O=this.#r.defaultView;if(!O)return;const A=p.getBoundingClientRect(),b=W(y.getBoundingClientRect)?y.getBoundingClientRect():{width:0,height:0},v=O.innerWidth||0,R=O.innerHeight||0,j=b.width||0,F=b.height||0;let C=A.bottom+o;const T=A.top-o-F;C+F>R-o&&T>=o&&(C=T),R&&(C=Math.max(o,Math.min(C,Math.max(o,R-F-o))));let L=A.left;v&&(L=Math.min(L,Math.max(o,v-j-o))),L=Math.max(o,L),y.style.left=`${Math.round(L)}px`,y.style.top=`${Math.round(C)}px`}hide(){if(this.#N(),this.#L(),!this.#l)return;if(this.#l=!1,this.#u&&W(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(y){H("tooltip-unmount","A cell.tooltip unmount threw while the tooltip was closing.",y)}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}#N(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#L(){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=c}),Le("packages/dom/src/platform.js",function(e,K){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return Q}});function Q(){const x=globalThis.navigator,B=String(x&&(x.userAgentData?.platform||x.platform)||"");return/mac|iphone|ipad/i.test(B)}}),Le("packages/dom/src/columnmenu.js",function(e,K){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return n}}),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 c}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"applyMenuLayer",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"resolveMenuChain",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return y}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/platform.js").macLike,W=K("packages/core/src/i18n/index.js").defaultMessages,V=K("packages/dom/src/ui/contextmenu.js").ContextMenu,z=K("packages/core/src/compute/total.js"),w=z.aggregatesFor,S=z.totalLabel,g=10,l=150;function d(O,A){const b=(te,ne)=>(O&&O.messages?O.messages:W).t(te,ne),v=O.columns.get(A);if(!v)return[];const R=O.sort.get(),j=R.find(te=>te.col===A),F=v.layout&&v.layout.pin,C=O.state.get().group||[],T=C.includes(A);if(v.generated&&Array.isArray(v.groupedIds))return n(O,v,C);const L=!v.sort||v.sort.enabled!==!1,E=!v.filter||v.filter.enabled!==!1,D=[];L&&D.push({name:b("menu.sortAscending"),icon:"↑",disabled:j&&j.dir==="asc",action:()=>O.sort.set([{col:A,dir:"asc"}])},{name:b("menu.sortDescending"),icon:"↓",disabled:j&&j.dir==="desc",action:()=>O.sort.set([{col:A,dir:"desc"}])},{name:b("menu.clearSort"),disabled:!j,action:()=>O.sort.set(R.filter(te=>te.col!==A))},{separator:!0}),E&&D.push({name:b("menu.filterEllipsis"),action:()=>O.emit("column:filter:open",{colId:A})},{separator:!0}),D.push({name:b("menu.columnStatistics"),action:()=>O.emit("column:profile:open",{colId:A})},{separator:!0}),D.push({name:b("menu.pinColumn"),children:[{name:b("menu.pinStart"),disabled:F==="start",action:()=>O.columns.pin(A,"start")},{name:b("menu.pinEnd"),disabled:F==="end",action:()=>O.columns.pin(A,"end")},{name:b("menu.unpin"),disabled:!F,action:()=>O.columns.pin(A,null)}]});const $=!(v.layout&&(v.layout.movable===!1||v.layout.lockPosition)),P=!(v.layout&&v.layout.resizable===!1),k=te=>{const ne=O.columns.get(te);return Number(ne&&ne.layout&&ne.layout.width)||l},N=O.columns.visible().filter(te=>!te.generated).map(te=>te.id),G=N.indexOf(A);if(D.push({name:b("menu.sizeToFit"),action:()=>O.columns.autoSize(A)},{name:b("menu.sizeAllToFit"),action:()=>O.columns.fit()},{name:b("menu.width"),disabled:!P,children:[{name:b("menu.narrower"),disabled:!P,action:()=>O.columns.resize(A,Math.max(1,k(A)-g))},{name:b("menu.wider"),disabled:!P,action:()=>O.columns.resize(A,k(A)+g)},{name:b("menu.autosize"),disabled:!P,action:()=>O.columns.autoSize(A)}]},{separator:!0},{name:b("menu.moveColumn"),disabled:!$,children:[{name:b("menu.moveLeft"),disabled:!$||G<=0,action:()=>O.columns.move(A,Math.max(0,G-1))},{name:b("menu.moveRight"),disabled:!$||G<0||G>=N.length-1,action:()=>O.columns.move(A,Math.min(N.length-1,G+1))},{name:b("menu.moveToStart"),disabled:!$||G<=0,action:()=>O.columns.move(A,0)},{name:b("menu.moveToEnd"),disabled:!$||G<0||G>=N.length-1,action:()=>O.columns.move(A,N.length-1)}]},{separator:!0}),v.allowGroup!==!1&&D.push({name:b(T?"menu.ungroup":"menu.groupBy"),action:()=>O.columns.group(T?C.filter(te=>te!==A):[...C,A])}),C.length&&D.push({name:b("menu.expandAll"),action:()=>O.rows.expandAll()},{name:b("menu.collapseAll"),action:()=>O.rows.collapseAll()}),x(O.columns.groupColumns)){const te=v.groupPath||[],ne=te.length?te[te.length-1]:null,oe=[{name:b("columngroup.group"),disabled:N.length<2||G<0,action:()=>{const le=N[G+1]??N[G-1];if(!le)return;const ae=(O.columns.get(le)||{}).groupPath||[],se=ae.length?ae[ae.length-1]:null;se?O.columns.groupColumns([A],{groupId:se}):O.columns.groupColumns([A,le],{title:b("columngroup.newGroup")})}}];ne&&oe.push({name:b("columngroup.dissolve"),action:()=>O.columns.dissolveGroup(ne)}),D.push({separator:!0},...oe)}const q=O.state&&x(O.state.get)?O.state.get().pivot:null,Y=q&&q.columns||[],J=Y.includes(A);if(v.allowPivot!==!1&&D.push({name:b(J?"menu.unpivot":"menu.pivotBy"),action:()=>O.columns.pivot(J?Y.filter(te=>te!==A):[...Y,A])}),v.allowTotal!==!1)if(x(O.get)&&O.get("aggregateChooser")===!0)D.push(a(O,v,b));else{const ne=!!v.total;D.push({name:b(ne?"menu.stopTotalling":"menu.totalColumn"),action:()=>O.columns.setTotal(A,ne?null:"sum")})}return D.push({name:b("menu.hideColumn"),disabled:v.layout&&v.layout.lockVisible===!0,action:()=>O.columns.hide(A)}),D}function a(O,A,b){const v=A.id,R=typeof A.total=="string"?A.total:null,j=[{name:b("menu.aggregateNone"),checked:!A.total,action:()=>O.columns.setTotal(v,null)},{separator:!0},...w(A).map(F=>({name:S(F),checked:R===F,action:()=>O.columns.setTotal(v,F)})),{separator:!0},r(O,A,b,"group",b("menu.aggregateGroup")),r(O,A,b,"grand",b("menu.aggregateGrand"))];return{name:b("menu.aggregate"),children:j}}function r(O,A,b,v,R){const j=A.id,F=v==="grand"?A.grandTotal:A.groupTotal,C=typeof F=="string"?F:null,T=[{name:b("menu.aggregateSame"),checked:F==null,action:()=>O.columns.setTotal(j,null,{scope:v})},{separator:!0},...w(A).map(L=>({name:S(L),checked:C===L,action:()=>O.columns.setTotal(j,L,{scope:v})}))];return{name:R,children:T}}function t(O,A){const b=(C,T)=>(O&&O.messages?O.messages:W).t(C,T),v=O.columns.get(A);if(!v)return[];const R=O.redaction,j=!!(R&&R.has(A)),F=[];return R&&(F.push({name:b(j?"menu.stopRedacting":"menu.redactColumn"),action:()=>R.toggle(A)}),(R.list().length>1||R.active&&!j)&&F.push({name:b("menu.stopRedactingAll"),action:()=>R.clear()}),F.push({separator:!0})),F.push({name:b("menu.hideColumn"),disabled:v.layout&&v.layout.lockVisible===!0,action:()=>O.columns.hide(A)}),F}function n(O,A,b){const v=(T,L)=>(O&&O.messages?O.messages:W).t(T,L),R=b[0],j=O.sort.get(),F=R?j.find(T=>T.col===R):null,C=[];R&&C.push({name:v("menu.sortGroupsAscending"),icon:"↑",disabled:F&&F.dir==="asc",action:()=>O.sort.set([{col:R,dir:"asc"}])},{name:v("menu.sortGroupsDescending"),icon:"↓",disabled:F&&F.dir==="desc",action:()=>O.sort.set([{col:R,dir:"desc"}])},{separator:!0},{name:v("menu.filterGroups"),action:()=>O.emit("column:filter:open",{colId:A.id})},{separator:!0}),C.push({name:v("menu.expandAll"),action:()=>O.rows.expandAll()},{name:v("menu.collapseAll"),action:()=>O.rows.collapseAll()},{separator:!0});for(const T of b){const L=O.columns.get(T);C.push({name:`Remove "${L&&L.title||T}" from grouping`,action:()=>O.columns.group(b.filter(E=>E!==T))})}return C.push({name:v("menu.clearGrouping"),disabled:!b.length,action:()=>O.columns.group([])}),C}function i(){const O=globalThis.navigator&&globalThis.navigator.clipboard;return!!(O&&typeof O.readText=="function")}function f(O){return x(O.get)&&O.get("edit")===!1?!1:(O.columns&&x(O.columns.visible)?O.columns.visible():[]).some(b=>{const v=b&&b.edit;return v?v.enabled===void 0||x(v.enabled)?!0:v.enabled!==!1:!1})}function u(O,A){if(x(O.get)&&O.get("edit")===!1)return!1;const b=A&&A.edit;return b?b.enabled===void 0||x(b.enabled)?!0:b.enabled!==!1:!1}const o=new Set(["number","currency","percent","integer"]);function m(O){const A=x(O.get)?O.get("rangeChart"):void 0;return A?x(A)?{enabled:!0,handler:A}:A&&typeof A=="object"&&x(A.onChart)?{enabled:!0,handler:A.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function c(O){const A=O.selection&&x(O.selection.ranges)?O.selection.ranges():[];if(!Array.isArray(A)||!A.length)return null;const b=A[A.length-1],v=x(O.columns.visible)?O.columns.visible():[],R=new Set(v.filter(j=>j&&o.has(j.type)).map(j=>j.id));return(b.columns||[]).some(j=>R.has(j))?b:null}function h(O,A){const b=(Y,J)=>(O&&O.messages?O.messages:W).t(Y,J),{colId:v,row:R}=A,j=O.selection.keys().length,F=O.selection.cells().length,C=(O.state&&x(O.state.get)?O.state.get().group:null)||[],T=O.ranges||null,L=_()?"Cmd":"Ctrl",E=()=>F||j||0,D=Y=>O.columns&&x(O.columns.get)?O.columns.get(Y):null,$=x(O.selection.cells)?O.selection.cells():[],P=[...new Set($.map(Y=>Y&&Y.colId).filter(Boolean))];!P.length&&v&&P.push(v);const k=P.length?P.some(Y=>u(O,D(Y))):f(O),N=v?u(O,D(v)):!1,G=m(O),q=G.enabled?c(O):null;return[{name:F>1?`Copy ${F} cells`:b("menu.copy"),shortcut:`${L}+C`,disabled:!E(),action:()=>T&&F?T.copy():O.export.clipboard({rows:j?"selected":"range"})},{name:b("menu.copyWithHeaders"),disabled:!E(),action:()=>O.export.clipboard({headers:!0,rows:j?"selected":"range"})},...v==null?[]:[{name:b("menu.paste"),shortcut:`${L}+V`,disabled:!T||!k||!i(),action:()=>T&&T.paste()},{separator:!0},{name:b("menu.clearCells",{count:F||1}),shortcut:"Delete",disabled:!T||!k||!F,action:()=>T&&T.clear()},{name:b("menu.fillDown"),shortcut:`${L}+D`,disabled:!T||!k||F<2,action:()=>T&&T.fillDown()}],...q&&G.handler?[{name:"Chart selection",action:()=>G.handler(O,q)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>O.export.csv({rows:"visible",download:!0})},{name:`Export ${j} selected row${j===1?"":"s"} to CSV`,disabled:!j,action:()=>O.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>O.export.excel({rows:"visible",download:!0})},{name:`Export ${j} selected row${j===1?"":"s"} to Excel`,disabled:!j,action:()=>O.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>O.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>O.export.print()},...O.importer&&x(O.importer.openFile)?[{name:b("menu.importCsv"),action:()=>O.importer.openFile()}]:[],{separator:!0},...C.length?[{name:b("menu.expandAll"),action:()=>O.rows.expandAll()},{name:b("menu.collapseAll"),action:()=>O.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!j,action:()=>O.selection.clear()},...x(O.get)&&O.get("rowDelete")===!0?[{name:b("menu.deleteRow",{count:j||1}),disabled:!j&&!R,action:()=>O.edit.deleteRows(j?void 0:R?R.key:void 0)}]:[],...v==null?[]:[{name:"Edit cell",disabled:!R||!v||!N,action:()=>R&&v&&O.edit.start(R.key,v)}]]}function s(O,A,b,v){if(O==null)return{items:A,spoke:!1,suppress:!1};if(O===!1)return{items:A,spoke:!0,suppress:!0};if(O===!0)return{items:A,spoke:!0,suppress:!1};if(Array.isArray(O))return{items:[...A,...O],spoke:!0,suppress:!1};if(x(O)){const R=O(b,A);return{items:Array.isArray(R)?R:A,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 O}. Ignoring it.`),{items:A,spoke:!1,suppress:!1}}function p(O,A,b){let v=Array.isArray(O)?O:[],R=!1;for(const j of A){if(!j)continue;const F=s(j.layer,v,b,j.where);v=F.items,F.spoke&&(R=F.suppress)}return R?null:v}class y{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#s=null;constructor(A){this.#n=A.grid,this.#e=A.cellMenu!==!1,this.#t=A.headerMenu!==!1,this.#i=x(A.items)?A.items:null,this.#s=x(A.headerItems)?A.headerItems:null,this.#r=new V({document:A.document,host:A.host,ctx:{grid:A.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",A=>{const b=String(A.colId),v=this.#c(b,d(this.#n,b));v.length&&this.#r.show({items:v,ctx:this.#u(b),anchor:A.element,placement:"below",returnFocus:A.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",A=>{const b=String(A.colId),v=this.#c(b,t(this.#n,b));v.length&&this.#r.show({items:v,ctx:this.#u(b),x:A.x,y:A.y,returnFocus:A.element})})),this.#o.push(this.#n.on("cell:contextmenu",A=>{const b=A.event;this.#e&&b&&x(b.preventDefault)&&b.preventDefault();const v=this.#l(A),R=h(this.#n,v),j=p(R,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#a(v.column),where:`column '${v.colId}' contextMenu`}],v);!j||!j.length||(!this.#e&&b&&x(b.preventDefault)&&b.preventDefault(),this.#r.show({items:j,ctx:v,x:b?b.clientX:void 0,y:b?b.clientY:void 0}))}))}#l(A){const b=this.#n.columns,v=A.column||(A.colId!=null&&b&&x(b.get)?b.get(A.colId):void 0),R=A.row,j=this.#n.rows,F=A.key!==void 0?A.key:R?R.key:void 0;return{key:F,colId:A.colId,value:A.value!==void 0||F===void 0||A.colId==null?A.value:j&&x(j.value)?j.value(F,A.colId):void 0,row:R,data:R?R.data:void 0,column:v,index:A.index!==void 0?A.index:A.rowIndex,grid:this.#n}}#a(A){if(!(!A||A.contextMenu===void 0||A.contextMenu===null))return A.contextMenu}#u(A){return{colId:A,column:this.#n.columns.get(A),grid:this.#n}}#c(A,b){return this.#s?p(b,[{layer:this.#s,where:"columnMenu"}],this.#u(A))||[]:b}destroy(){for(const A of this.#o)A();this.#o=[],this.#r.destroy()}}}),Le("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 S}});const x=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,V=K("packages/dom/src/platform.js").macLike,z="lat-shortcuts",w='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class S{#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,d){const a=this.#e;return(a&&a.messages?a.messages:I).t(l,d)}#s(l){const d=W[l.combo];if(!d)return l.meaning;const a=`shortcut.${d}`,r=this.#i(a);return r===a?l.meaning:r}mount(){const l=this.#t.viewport?.root;if(!l||!x(l.addEventListener))return;const d=a=>{if(this.open||a.key!=="?")return;const r=a.target,t=r&&r.tagName;t==="INPUT"||t==="TEXTAREA"||r&&r.isContentEditable||(a.preventDefault(),a.stopPropagation(),this.show())};l.addEventListener("keydown",d,!0),this.#o.push(()=>l.removeEventListener("keydown",d,!0))}show(){const l=this.#l();if(!l)return;const d=l.ownerDocument;this.#r=d&&d.activeElement,l.style.display="",x(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&&x(l.focus)&&l.focus(),this.#e.emit?.("shortcuts:closed",{})}#l(){if(this.#n)return this.#n;const l=this.#t.viewport?.overlays,d=l?.ownerDocument;if(!l||!d?.createElement)return null;const a=d.createElement("div");a.className=z,a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.setAttribute("tabindex","-1");const r=`${z}-title`;a.setAttribute("aria-labelledby",r);const t=d.createElement("div");t.className=`${z}__head`;const n=d.createElement("h2");n.className=`${z}__title`,n.id=r,n.textContent=this.#i("shortcuts.title");const i=d.createElement("button");i.className=`${z}__close`,i.type="button",i.setAttribute("aria-label",this.#i("shortcuts.close")),i.textContent="×",t.appendChild(n),t.appendChild(i),a.appendChild(t);const f=d.createElement("div");f.className=`${z}__body`;for(const o of X())o.items.length&&f.appendChild(this.#a(d,o));a.appendChild(f);const u=d.createElement("p");return u.className=`${z}__hint`,u.textContent=this.#i("shortcuts.hint"),a.appendChild(u),l.appendChild(a),this.#n=a,this.#u(a,i),a}#a(l,d){const a=l.createElement("section");a.className=`${z}__group`;const r=l.createElement("h3");r.className=`${z}__group-title`,r.textContent=this.#i(d.messageKey),a.appendChild(r);const t=l.createElement("dl");t.className=`${z}__list`;const n=V();for(const i of d.items){const f=l.createElement("dt");f.className=`${z}__keys`,i.alternatives.forEach((o,m)=>{if(m>0){const c=l.createElement("span");c.className=`${z}__or`,c.textContent=this.#i("shortcuts.or"),f.appendChild(c)}o.forEach((c,h)=>{h>0&&f.appendChild(l.createTextNode("+"));const s=l.createElement("kbd");s.textContent=n&&c==="Ctrl"?this.#i("shortcuts.key.cmd"):c,f.appendChild(s)})});const u=l.createElement("dd");u.className=`${z}__meaning`,u.textContent=this.#s(i),t.appendChild(f),t.appendChild(u)}return a.appendChild(t),a}#u(l,d){const a=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.hide();return}if(t.key!=="Tab")return;const n=[...l.querySelectorAll(w)];if(!n.length){t.preventDefault();return}const i=n[0],f=n[n.length-1],u=l.ownerDocument.activeElement;t.shiftKey&&(u===i||u===l)?(t.preventDefault(),f.focus()):!t.shiftKey&&u===f&&(t.preventDefault(),i.focus())},r=t=>{t.preventDefault?.(),this.hide()};l.addEventListener("keydown",a),d.addEventListener("click",r),this.#o.push(()=>{l.removeEventListener("keydown",a),d.removeEventListener("click",r)})}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}}}),Le("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 V}}),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 d}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return a}});const x=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",V="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"}),S=4,g=new Set;function l(r){if(!r)return null;const t=r===!0?{}:typeof r=="object"?r: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 d(r){return r===!0?{column:null,manualOrder:!1,betweenGroups:!1}:!r||typeof r!="object"?null:{column:typeof r.column=="string"?r.column:null,manualOrder:r.manualOrder===!0,betweenGroups:r.betweenGroups===!0}}class a{#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=d(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 n=t&&t.transfer;return!n||!n.send?!1:n.group===this.#o.group}get transfer(){return this.#o}#u(t,n){const i=this.#e;return(i&&i.messages?i.messages:I).t(t,n)}#c(t,n){const i=this.#t&&this.#t.announce;x(i)&&i.call(this.#t,t,n)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const t=this.#e.columns.visible().filter(n=>!n.generated);return t.length?t[0].id:null}paint(){if(!this.draggable)return;const t=this.#d(),n=this.#t.viewport?.root;if(!t||!n)return;const i=n.querySelectorAll(`.lat-cell[data-col="${t}"]`);for(const f of i){if(f.querySelector(`.${W}`))continue;const u=f.parentNode;if(u&&x(u.getAttribute)&&u.getAttribute("data-pinned"))continue;const o=this.#n.createElement("span");o.className=W,o.setAttribute("data-role","row-drag"),o.setAttribute("aria-hidden","true"),o.setAttribute("title",this.#u("a11y.reorder.grab")),o.textContent="⠿",f.insertBefore(o,f.firstChild||null)}this.#h(n,t)}#f(){const t=this.#e.rowOrder;return!!(t&&x(t.manual)&&t.manual())}#h(t,n){const i=this.#f();if(x(t.setAttribute)&&(i?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="${n}"]`);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",i?"true":"false");const o=this.#u(i?"rowOrder.exit":"rowOrder.enter");u.setAttribute("title",o),u.setAttribute("aria-label",o)}toggleManual(){const t=this.#e.rowOrder;if(!t)return;const n=this.#f()?t.exit():t.enter({origin:"user"}),i=f=>{f&&f.reason&&this.#c(this.#u(w[f.reason]||"a11y.reorder.refused"),{repeat:!0}),this.paint()};n&&x(n.then)?n.then(i):i(n)}mount(){if(!this.active)return;g.add(this);const t=this.#t.viewport?.root;if(!t||!x(t.addEventListener))return;const n=m=>this.#p(m),i=m=>this.#m(m),f=()=>this.#g(),u=m=>this.#P(m);if(t.addEventListener("pointerdown",n),t.addEventListener("keydown",u),x(this.#e.on)){let m=this.#f();this.#a.push(this.#e.on("state:changed",c=>{!c||!Array.isArray(c.sections)||!c.sections.includes("rowOrder")||this.#f()!==m&&(m=this.#f(),this.#c(this.#u(m?"a11y.rowOrder.entered":"a11y.rowOrder.exited"),{repeat:!0}))}))}const o=this.#n.defaultView||this.#n;o.addEventListener?.("pointermove",i),o.addEventListener?.("pointerup",f),this.#a.push(()=>{t.removeEventListener("pointerdown",n),t.removeEventListener("keydown",u),o.removeEventListener?.("pointermove",i),o.removeEventListener?.("pointerup",f)})}#p(t){const n=t.target;if(!n||!x(n.closest)||!n.closest('[data-role="row-drag"]'))return;const i=n.closest(".lat-row"),f=i?X(i):-1;if(f<0)return;const u=this.#e.rows.get(f);if(!u||u.group)return;const o=this.#N();if(o&&!(this.#o&&this.#o.send)){this.#c(this.#u(o),{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 n=this.#i;if(!n)return;if(!n.armed){if(Math.abs(t.clientX-n.x)+Math.abs(t.clientY-n.y)<S)return;n.armed=!0,this.#B(n),n.over=this,this.#e.emit("rowDrag:started",this.#y(n,this,n.from,n.key),"user")}this.#l&&this.#_(t.clientX,t.clientY);const i=this.#O(t.clientX,t.clientY);if(n.target=i,i!==this){this.#q(),i&&i.accepts(this)?(i.showDropTarget(t.clientX,t.clientY),n.hit=i.hitAt(t.clientX,t.clientY)):n.hit=null,this.#j(n,i),this.#w(n,i,n.hit?n.hit.at:null,n.hit?n.hit.overKey:null);return}const f=this.#L(t.clientX,t.clientY);if(this.#j(n,i),f<0){this.#w(n,this,null,null);return}n.at=f,this.#$(f);const u=this.#e.rows.get(f);this.#w(n,this,f,u?u.key:null)}#g(){const t=this.#i;this.#i=null,this.#q(),this.#z();for(const f of g)f.hideDropTarget();if(!t||(this.#S(t),!t.armed))return;const n=t.target;if(this.#e.emit("rowDrag:ended",this.#b(t),"user"),n&&n!==this){this.#C(t,n);return}if(t.at===t.from)return;const i=this.#N();if(i){this.#c(this.#u(i),{repeat:!0});return}this.#E(t.key,t.at)}#y(t,n,i,f){const u=this.#e.rows.byKey(t.key);return{key:t.key,data:u?u.data:null,over:n?n.grid:null,at:i,overKey:f}}#b(t){const n=t.target||null;if(n&&n!==this){if(!n.accepts(this))return{...this.#y(t,n,null,null),dropped:!1};const i=t.hit||{at:n.grid.rows.count(),overKey:null};return{...this.#y(t,n,i.at,i.overKey),dropped:!0}}if(n===this){const i=this.#e.rows.get(t.at);return{...this.#y(t,this,t.at,i?i.key:null),dropped:t.at!==t.from&&this.#N()===null}}return{...this.#y(t,null,null,null),dropped:!1}}#j(t,n){if(t.over===n)return;const i=t.over;t.over=n,i&&(this.#S(t),this.#e.emit("rowDrag:left",this.#y(t,i,null,null),"user"))}#w(t,n,i,f){t.pending={over:n,at:i,overKey:f},t.frame===null&&(t.frame=this.#v(()=>{t.frame=null;const u=t.pending;t.pending=null,!(!u||this.#i!==t)&&this.#e.emit("rowDrag:moved",this.#y(t,u.over,u.at,u.overKey),"user")}))}#S(t){t.pending=null,t.frame!==null&&(t.frame(),t.frame=null)}#v(t){const n=this.#n.defaultView||globalThis;if(x(n.requestAnimationFrame)){const f=n.requestAnimationFrame(t);return()=>{x(n.cancelAnimationFrame)&&n.cancelAnimationFrame(f)}}const i=setTimeout(t,16);return()=>clearTimeout(i)}#C(t,n){if(!n.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const i=this.#e.rows.byKey(t.key);if(!i)return;const f=this.#o.mode,u=t.key,o=t.hit||{at:n.grid.rows.count(),overKey:null};let m=null;const c=n.receive(i.data,o.at,{overKey:o.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(u),onCancel:s=>{m=s}}),h=s=>{if(s!==!0){const p=s===!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:i.data,mode:f})):this.#e.emit("row:copied",{key:u,data:i.data,mode:f}),this.#c(this.#u(f==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};c&&x(c.then)?c.then(h):h(c)}receive(t,n,i={}){const f=this.#e,u=t&&typeof t=="object"?{...t}:t,o=i.overKey??null,m=i.source||null,c=x(i.onCancel)?i.onCancel:null,h=()=>{const A=f.rows.totalCount(),b=f.rows.apply({add:[u],at:Math.max(0,n||0)}),v=f.rows.totalCount()>A;return v&&f.emit("row:received",{data:u,at:n,overKey:o,rejected:b?.rejected||[]}),v},s=()=>{if(o!==null){const A=f.rows.get(n);if(!A||A.key!==o)return!1}else n=f.rows.count();return!x(i.revalidate)||i.revalidate()},p=x(f.rendererHost)?f.rendererHost():null;if(!p||!x(p.gateBefore))return h();const y=c?f.on("rowReceive:cancelled",A=>c(A.reason)):null,O=p.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:u,at:n,overKey:o,source:m,origin:"user"},h,s);return y&&(O&&x(O.then)?O.then(y,y):y()),O}hitAt(t,n){const i=this.#L(t,n);if(i<0)return{at:this.#e.rows.count(),overKey:null};const f=this.#e.rows.get(i);return{at:i,overKey:f?f.key:null}}showDropTarget(t,n){const i=this.root;i&&x(i.setAttribute)&&i.setAttribute("data-drop-target","")}hideDropTarget(){const t=this.root;t&&x(t.removeAttribute)&&t.removeAttribute("data-drop-target")}#O(t,n){const i=this.#n.elementFromPoint?this.#n.elementFromPoint(t,n):null,f=i&&x(i.closest)?i.closest(".lattice"):null;if(!f)return null;for(const u of g)if(u.root===f)return u;return null}#P(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 n=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0;if(!n)return;const i=this.#n.activeElement,f=i&&x(i.closest)?i.closest(".lat-row"):null,u=f?X(f):-1;if(u<0)return;t.preventDefault?.(),t.stopPropagation?.();const o=this.#N();if(o){this.#c(this.#u(o),{repeat:!0});return}const m=this.#e.rows.get(u);!m||m.group||this.#E(m.key,this.#M(u,n))}#M(t,n){const i=this.#e;if(n>0||!x(i.rows.groupHeadings))return t+n;const f=new Set(i.rows.groupHeadings(t).map(o=>o.key));let u=t+n;for(;u>=0;){const o=i.rows.get(u);if(!o||!f.has(o.key))break;u+=n}return u<0?t:u}#E(t,n){const i=this.#e.rows.count(),f=Math.max(0,Math.min(i-1,n)),u=this.#e.rows.move(t,f,{origin:"user"});u&&x(u.then)?u.then(o=>this.#T(o,i)):this.#T(u,i)}#T(t,n){if(!t){this.#c(this.#u("a11y.reorder.vetoed"),{repeat:!0});return}if(!t.moved){if(!t.reason||t.reason==="unchanged")return;const i=t.reason==="vetoed"&&t.detail&&t.detail!=="prevented"?t.detail:null,f=i?this.#u("a11y.reorder.vetoedBecause",{reason:i}):this.#u(w[t.reason]||"a11y.reorder.refused");this.#c(f,{repeat:!0});return}if(Array.isArray(t.regrouped)&&t.regrouped.length){const i=t.regrouped.map(f=>String(f.to??"")).join(" / ");this.#c(this.#u("a11y.reorder.regrouped",{group:i}),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:t.to+1,total:n}),{repeat:!0})}#N(){const t=this.#e,n=this.#r||{manualOrder:!1,betweenGroups:!1};if(t.sort.get().length)return n.manualOrder?"a11y.reorder.sortedManual":"a11y.reorder.sorted";if((t.state.get().group||[]).length&&!this.#f()&&!n.betweenGroups)return"a11y.reorder.grouped";const i=t.filters.get();return i&&Object.keys(i).length?"a11y.reorder.filtered":null}#L(t,n){const i=this.#n.elementFromPoint?this.#n.elementFromPoint(t,n):null,f=i&&x(i.closest)?i.closest(".lat-row"):null;return!f||x(f.getAttribute)&&f.getAttribute("data-pinned")?-1:X(f)}#B(t){const n=this.root,i=n&&x(n.querySelector)?n.querySelector(`.lat-row[data-index="${t.from}"]`):null;i&&x(i.classList?.add)&&i.classList.add(V);const f=this.#n.body;if(!f||!x(f.appendChild))return;const u=this.#d(),o=u&&x(this.#e.rows?.text)&&this.#e.rows.text(t.key,u)||this.#u("a11y.reorder.grab"),m=n&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(n):null,c=(s,p)=>m&&m.getPropertyValue(s).trim()||p,h=this.#n.createElement("div");h.textContent=String(o),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:${c("--lattice-space","4px")} calc(${c("--lattice-space","4px")} * 2)`,`border-radius:${c("--lattice-radius-sm",c("--lattice-radius","4px"))}`,`border:${c("--lattice-border-width","1px")} solid ${c("--lattice-border-strong","#0003")}`,`background:${c("--lattice-background","#fff")}`,`color:${c("--lattice-foreground","#000")}`,`box-shadow:${c("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${c("--lattice-font-size","13px")} ${c("--lattice-font-family","system-ui, sans-serif")}`].join(";"),f.appendChild(h),this.#l=h}#_(t,n){this.#l&&(this.#l.style.transform=`translate(${Math.round(t)+14}px, ${Math.round(n)+16}px)`)}#z(){this.#l&&(this.#l.parentNode&&this.#l.parentNode.removeChild(this.#l),this.#l=null);const t=this.root,n=t&&x(t.querySelectorAll)?t.querySelectorAll(`.${V}`):[];for(const i of n)i.classList.remove(V)}#$(t){const n=this.#t.viewport?.overlays;if(!n)return;this.#s||(this.#s=this.#n.createElement("div"),this.#s.className=H,n.appendChild(this.#s));const i=this.#t.viewport.root,f=i.querySelector(`.lat-row[data-index="${t}"]`)||i.querySelectorAll(".lat-row")[0];if(!f||!x(f.getBoundingClientRect))return;const u=f.getBoundingClientRect(),o=i.getBoundingClientRect(),m=this.#i&&t>this.#i.from;this.#s.style.display="",this.#s.style.top=`${Math.round((m?u.bottom:u.top)-o.top)}px`}#q(){this.#s&&(this.#s.style.display="none")}destroy(){g.delete(this);for(const t of this.#a)t();this.#a=[],this.#i&&this.#S(this.#i),this.#i=null,this.#z(),this.#s&&this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null}}}),Le("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 x=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 V=[];for(const w of B)V.push(H.on(w,()=>this.#r(H)));V.push(H.on("scroll",w=>this.#i(H,w))),V.push(H.on("destroy",()=>this.remove(H))),this.#t.set(H,V);const[z]=this.#e;z!==H&&this.#o(H,I(z.columns.state()))}remove(H){const V=this.#t.get(H);if(V)for(const z of V)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 V=I(H.columns.state());this.#n=!0;try{for(const z of this.#e)z!==H&&this.#o(z,V)}finally{this.#n=!1}}#o(H,V){if(!H.columns||!x(H.columns.apply))return;const z=new Map((H.columns.state()||[]).map(S=>[S.id,S])),w=[];for(const S of V){const g=z.get(S.id);g&&(w.push({...g,...S}),z.delete(S.id))}for(const S of z.values())w.push(S);H.columns.apply(w)}#i(H,V){if(this.#n)return;const z=V&&typeof V.left=="number"?V.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 V of W||[])H.add(V);return H}}),Le("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 x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-tagbar";function X(V){if(!V)return null;const z=V===!0?{}:typeof V=="object"?V: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 S=this.#e;return(S&&S.messages?S.messages:I).t(z,w)}mount(){if(!this.active)return;const z=this.#t.viewport,w=z?.root;if(!w||!x(w.insertBefore))return;const S=this.#n.createElement("div");S.className=_,S.setAttribute("role","toolbar"),S.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 d=`${_}-select-${Math.abs(H(String(w.className)))}`;l.id=d,g.setAttribute("for",d),S.appendChild(g),S.appendChild(l),w.insertBefore(S,z.header||w.firstChild),this.#o=S,this.#i=l;const a=()=>{const t=this.#r.multiple?[...l.selectedOptions||[]].map(n=>n.value).filter(Boolean):l.value?[l.value]:[];this.#e.columns.showTagged(t),this.#u(t)};l.addEventListener("change",a),this.#l.push(()=>l.removeEventListener("change",a));const r=this.#e.on("model:changed",()=>this.refresh());this.#l.push(r),this.refresh()}#u(z){const w=this.#t&&this.#t.announce;if(!x(w))return;const S=z.length?z.join(", "):this.#a("tags.all");w.call(this.#t,this.#a("tags.showing",{tag:S}))}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 S=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,S.includes(g)&&(l.selected=!0),this.#i.appendChild(l)}this.#r.multiple||(this.#i.value=S.length?S[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(V){let z=0;for(let w=0;w<V.length;w++)z=z*31+V.charCodeAt(w)|0;return z}}),Le("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 V}});const x=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(S=>H(S,w)):z.col===w&&z.op==="eq"&&z.value===!0:!1}class V{#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,S){const g=this.#e;return(g&&g.messages?g.messages:I).t(w,S)}#h(){const w=this.#r&&this.#r.column;let S=null;for(const g of this.#e.columns.all()){const l=W(g.shadow);if(!l||l.kind!=="anomalyFlag")continue;const d=l.of||g.field||g.id;if(w){if(g.id===w||d===w)return this.#d=g.id,g}else S||(S=g,this.#d=g.id)}return w?null:S}#p(){if(!this.#d||!x(this.#e.rows&&this.#e.rows.forEach))return 0;let w=0;try{this.#e.rows.forEach(S=>{!S||S.group||S.key==null||this.#e.rows.value(S.key,this.#d)===!0&&w++})}catch{return 0}return w}mount(){if(!this.active)return;const w=this.#t.viewport,S=w&&w.root;if(!S||!x(S.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),S.insertBefore(g,w.header||S.firstChild),this.#o=g,this.#i=l;const d=()=>this.toggle();l.addEventListener("click",d),this.#s.push(()=>l.removeEventListener("click",d));for(const a of["filter:changed","rows:changed","model:changed"])this.#s.push(this.#e.on(a,()=>{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},S=this.#u?{op:"and",conditions:[this.#u,w]}:w;this.#l=!0,this.#a=!0;try{this.#e.filters.set(S)}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.#y(this.#c,!0);return}const S=this.#p();if(this.#c=S,!S){this.#o.style.display="none";return}this.#y(S,!1)}#y(w,S){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",S?"true":"false"),this.#i.setAttribute("aria-pressed",S?"true":"false");const g=this.#r&&this.#r.label,l=S?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}}}),Le("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 a}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return i}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,W=K("packages/core/src/model/rowkey.js").createRowKey,V=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",d='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function a(f){if(!f)return null;const u=f===!0?{}:typeof f=="object"?f:null;if(!u)return null;const o=x(u.load)?u.load:null,m=Array.isArray(u.fields)&&u.fields.length?u.fields:null;return{timeout:n(u.timeout),container:u.container??null,mode:u.container?"inline":u.mode==="dialog"?"dialog":"drawer",load:o,create:x(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 r(f,u){const o=x(f)?f():f;return o?typeof o=="string"?u&&x(u.querySelector)?u.querySelector(o):null:o&&x(o.appendChild)?o:null:null}const t=2e3;function n(f){return f===!1||f===0?0:typeof f!="number"||!Number.isFinite(f)||f<=0?t:f}class i{#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=a(u.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#y(u,o){const m=this.#e;return(m&&m.messages?m.messages:_).t(u,o)}mount(){if(!this.active)return;const u=this.#t.viewport?.root;if(!u||!x(u.addEventListener)||this.#o.trigger==="none")return;const o=m=>{const c=m.target;if(!c||!x(c.closest)||c.closest(".lat-editor-host, .lat-editor--popup"))return;const h=c.closest(".lat-row"),s=h?w(h):-1;if(s<0)return;const p=this.#e.rows.get(s);!p||p.group||p.detail||(m.preventDefault?.(),m.stopPropagation?.(),this.openRow(p.key))};u.addEventListener("dblclick",o,!0),this.#g.push(()=>u.removeEventListener("dblclick",o,!0))}openRow(u){const o=this.#e.rows.byKey(u);if(!o)return!1;const m=this.#C();if(!m)return!1;this.#a=o,this.#u=!1,this.#v(),this.#f=this.#n.activeElement,m.style.display="",this.#$(m),this.#P(o);const c=this.#o.load;if(!c)this.#_(o.data);else{this.#N();const h=++this.#h;this.#M(h,s=>{this.#L(new Error(`Loading the record timed out after ${s}ms`),u,"form.loadTimeout")}),Promise.resolve().then(()=>c({row:o,data:o.data,key:u,grid:this.#e})).then(s=>{h!==this.#h||!this.open||(this.#T(),this.#_(s||o.data))}).catch(s=>{h!==this.#h||!this.open||(this.#T(),this.#L(s,u))})}return x(m.focus)&&m.focus(),this.#e.emit("form:opened",{key:u,row:o}),!0}openNew(u){const o=this.#C();if(!o)return!1;this.#h+=1,this.#T(),this.#a=null,this.#u=!0,this.#v(),this.open||(this.#f=this.#n.activeElement),o.style.display="",this.#$(o);const m=o.querySelector(`.${l}__title`);return m&&(m.textContent=this.#y("form.newTitle")),this.#_(u&&typeof u=="object"?{...u}:{}),x(o.focus)&&o.focus(),this.#e.emit("form:opened",{key:null,row:null,created:!0}),!0}close(){if(!this.#i)return;this.#h+=1,this.#T(),this.#ye(),this.#i.style.display="none";const u=this.#a?this.#a.key:null;this.#a=null,this.#u=!1,this.#v();const o=this.#f;this.#f=null,o&&x(o.focus)&&o.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,o={},m={},c=[],h=[];for(const s of this.#d){const p=x(s.editor.commit)?s.editor.commit():{ok:!0,value:void 0};if(!p.ok)return this.#W(s,p.message),!1;if(o[s.field]=p.value,s.readOnly){h.push(s.field);continue}const y=s.initial;Object.is(y,p.value)||(m[s.field]=p.value,s.colId?c.push({key:u,colId:s.colId,value:p.value}):h.push(s.field))}return this.#u?this.#b(o):(c.length&&this.#e.edit.setCells(c,"cell",{origin:"form"}),this.#e.emit("form:saved",{key:u,values:o,changed:m,unmapped:h}),this.close(),!0)}#b(u){const o=this.#d.filter(h=>!h.colId).map(h=>h.field),m=this.#o.create;if(!m)return this.#j(u)?(this.#w(u,u,o),!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.#v(),this.#E(!1);const c=++this.#h;return this.#M(c,h=>{this.#S(new Error(`Adding the record timed out after ${h}ms`),u,!0)}),Promise.resolve().then(()=>m(u)).then(h=>{if(!(c!==this.#h||!this.open)){if(this.#T(),!this.#j(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.#S(new Error("rowForm.create answered with a row that carries no row key"),u,!1);return}this.#w(h,u,o)}}).catch(h=>{c!==this.#h||!this.open||(this.#T(),this.#S(h,u,!1))}),!0}#j(u){if(!u||typeof u!="object")return!1;const o=W(this.#e.get("rowKey"),{warn:!1});return!o||o.stable===!1?!1:x(o.keyEmpty)?!o.keyEmpty(u):!0}#w(u,o,m){const c=this.#e,h=c.rows.apply({add:[u]}),s=h&&Array.isArray(h.added)?h.added[0]:null;if(!s){this.#S(new Error("The new row could not be added"),o,!1);return}const p=s.key;c.emit("form:saved",{key:p,values:o,changed:o,unmapped:m,created:!0}),this.close();const y=c.get("selection");(typeof y=="string"?y!=="none":y&&typeof y=="object"&&y.mode!=="none")&&c.selection&&x(c.selection.set)&&c.selection.set([p]),c.scroll&&x(c.scroll.toRow)&&c.scroll.toRow(p)}#S(u,o,m){this.#E(!0),this.#v();const c=this.#n.createElement("div");c.className=`${l}__failure`;const h=this.#n.createElement("p");h.className=`${l}__note ${l}__note--error`,h.setAttribute("role","alert"),h.textContent=this.#y("form.createFailed");const s=this.#n.createElement("button");s.className=`${l}__retry`,s.type="button",s.textContent=this.#y("form.retry"),s.addEventListener("click",()=>this.save()),c.appendChild(h),c.appendChild(s),x(this.#s.insertBefore)?this.#s.insertBefore(c,this.#s.firstChild):this.#s.appendChild(c),this.#c=c,this.#e.emit("form:error",{key:null,error:u,timedOut:m,created:!0})}#v(){const u=this.#c;this.#c=null,u&&u.parentNode&&u.parentNode.removeChild(u)}#C(){if(this.#i)return this.#i;const u=this.#t.viewport?.overlays,o=this.#n||u?.ownerDocument;if(!o?.createElement)return null;const m=r(this.#o.container,o),c=m||u;if(!c)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=o.createElement("div"),s=this.#m?"lattice ":"";h.className=`${s}${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 y=o.createElement("div");y.className=`${l}__head`;const O=o.createElement("h2");O.className=`${l}__title`,O.id=p,y.appendChild(O);const A=o.createElement("div");A.className=`${l}__body`;const b=o.createElement("div");b.className=`${l}__foot`;const v=o.createElement("button");v.className=`${l}__cancel`,v.type="button",v.textContent=this.#y("form.cancel");const R=o.createElement("button");return R.className=`${l}__save`,R.type="button",R.textContent=this.#y("form.save"),b.appendChild(v),b.appendChild(R),h.appendChild(y),h.appendChild(A),h.appendChild(b),c.appendChild(h),this.#i=h,this.#s=A,this.#l=R,this.#O(h,R,v),h}#O(u,o,m){const c=p=>{if(p.stopPropagation(),p.key==="Escape"){p.preventDefault(),this.close();return}if(p.key!=="Tab"||this.#m)return;const y=[...u.querySelectorAll(d)];if(!y.length){p.preventDefault();return}const O=y[0],A=y[y.length-1],b=u.ownerDocument.activeElement;p.shiftKey&&(b===O||b===u)?(p.preventDefault(),A.focus()):!p.shiftKey&&b===A&&(p.preventDefault(),O.focus())},h=p=>{p.preventDefault?.(),this.save()},s=p=>{p.preventDefault?.(),this.close()};u.addEventListener("keydown",c),o.addEventListener("click",h),m.addEventListener("click",s),this.#g.push(()=>{u.removeEventListener("keydown",c),o.removeEventListener("click",h),m.removeEventListener("click",s)})}#P(u){const o=this.#i.querySelector(`.${l}__title`);if(!o)return;const m=this.#o.title;x(m)?o.textContent=String(m({row:u,data:u.data})??""):typeof m=="string"?o.textContent=m:o.textContent=this.#y("form.title")}#M(u,o){this.#T();const m=this.#o.timeout;if(!m)return;const c=this.#n.defaultView||globalThis;x(c.setTimeout)&&(this.#p=c.setTimeout(()=>{this.#p=null,!(u!==this.#h||!this.open)&&(this.#h+=1,o(m))},m))}#E(u){this.#l&&(this.#l.disabled=!u,u?this.#l.removeAttribute("aria-disabled"):this.#l.setAttribute("aria-disabled","true"))}#T(){if(this.#p===null)return;const u=this.#n.defaultView||globalThis;x(u.clearTimeout)&&u.clearTimeout(this.#p),this.#p=null}#N(){this.#ye(),this.#E(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const u=this.#n.createElement("p");u.className=`${l}__note`,u.setAttribute("role","status"),u.textContent=this.#y("form.loading"),this.#s.appendChild(u)}#L(u,o,m="form.loadFailed"){this.#ye(),this.#E(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const c=this.#n.createElement("p");c.className=`${l}__note ${l}__note--error`,c.setAttribute("role","alert"),c.textContent=this.#y(m);const h=this.#n.createElement("button");h.className=`${l}__retry`,h.type="button",h.textContent=this.#y("form.retry"),h.addEventListener("click",()=>this.openRow(o)),this.#s.appendChild(c),this.#s.appendChild(h),this.#e.emit("form:error",{key:o,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}))}#_(u){this.#ye(),this.#E(!0),this.#s.replaceChildren&&this.#s.replaceChildren();const o=u&&typeof u=="object"?u:{};for(const m of this.#B()){const c=m.field;if(!c)continue;const h=m.colId?this.#e.columns.get(m.colId):this.#ie(c),s=Object.hasOwn(o,c)?o[c]:null,p=this.#n.createElement("div");p.className=`${l}__field`;const y=this.#n.createElement("label");y.className=`${l}__label`,y.textContent=String(m.label??(h&&h.title)??c);const O=this.#n.createElement("div");O.className=`${l}__control`,p.appendChild(y),p.appendChild(O),this.#s.appendChild(p);const A={field:c,colId:h?h.id:null,editor:null,initial:s,opener:null,wrap:p,readOnly:!1},v=!!(h&&(h.computed||h.generated))?null:V({grid:this.#e,column:this.#he(m,h,c),colId:h?h.id:c,row:this.#a,data:o,value:s,text:s==null?"":String(s),locale:this.#e.get("locale"),props:m.props||h&&h.edit&&h.edit.props,lookup:m.lookup||h&&h.lookup,document:this.#n,cell:O,overlay:this.#q(),stop:()=>this.#H(A)},this.#r);if(!v){A.readOnly=!0,A.colId=null,A.editor={commit:()=>({ok:!0,value:A.initial})},this.#z(O,h,s),this.#d.push(A);continue}A.editor=v;try{x(v.value)&&(A.initial=v.value())}catch{}if(this.#d.push(A),v.popup===!0)this.#I(O,A);else{const R=x(v.element)?v.element():null;R&&O.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.")}#z(u,o,m){const c=this.#n.createElement("div");c.className=`${l}__static`,c.setAttribute("aria-readonly","true");let h="";try{const s=o&&o.dataType&&o.dataType.format;x(s)&&(h=s({value:m,column:o,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)),c.textContent=h,u.appendChild(c)}#$(u){if(!this.#m)return;const o=this.#t.viewport?.root;if(!(!o||!x(o.getAttribute)))for(const m of["data-theme","data-density","dir"]){const c=m==="data-theme"?g(o):o.getAttribute(m);c?u.setAttribute(m,c):x(u.removeAttribute)&&u.removeAttribute(m)}}#q(){return this.#m?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#I(u,o){const m=this.#n.createElement("button");m.className=`${l}__opener`,m.type="button",o.opener=m,this.#U(o);const c=()=>{x(o.editor.attached)&&o.editor.attached()};m.addEventListener("click",c),this.#g.push(()=>m.removeEventListener("click",c)),u.appendChild(m)}#W(u,o){const m=u.wrap;m&&x(m.scrollIntoView)&&m.scrollIntoView({block:"nearest"});const c=u.opener||(x(u.editor.focusTarget)?u.editor.focusTarget():null);c&&x(c.focus)&&c.focus();const h=this.#t&&this.#t.announce;x(h)&&o&&h.call(this.#t,String(o))}#H(u){if(!u.opener||!u.editor)return;const o=x(u.editor.popupHandle)?u.editor.popupHandle():null;o&&x(o.hide)&&o.hide(),this.#U(u),x(u.opener.focus)&&u.opener.focus()}#U(u){if(!u.opener)return;let o="";try{const c=u.colId?this.#e.columns.get(u.colId):null,h=c&&c.dataType&&c.dataType.format;x(h)&&(o=h({value:x(u.editor.value)?u.editor.value():null,column:c,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")})),(o===""||o==null)&&x(u.editor.toClipboard)&&(o=u.editor.toClipboard())}catch{o=""}const m=o===""||o==null;u.opener.textContent=m?this.#y("form.choose"):String(o),u.opener.classList.toggle(`${l}__opener--empty`,m)}#he(u,o,m){const c=u.editor||u.type||u.lookup||u.props,h={...o&&o.edit?o.edit:{},enabled:!0};return u.editor&&(h.editor=u.editor),u.props&&(h.props=u.props),o&&!c?{...o,edit:h}:{...o||{id:m,field:m},type:u.type||o&&o.type||"text",lookup:u.lookup||o&&o.lookup||void 0,edit:h}}#ie(u){for(const o of this.#e.columns.all())if(!o.generated&&o.field===u)return o;return null}#ye(){for(const u of this.#d)x(u.editor.destroy)&&u.editor.destroy();this.#d=[]}destroy(){this.#h+=1,this.#T(),this.#ye();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}}}),Le("packages/dom/src/toolpanelmount.js",function(e,K){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,I=K("packages/dom/src/ui/toolpanel.js"),_=I.ToolPanel,X=I.toolPanels,W=I.toolPanelTitles,H=I.toolPanelIcons,V=K("packages/dom/src/filters/index.js"),z=V.createFilter,w=V.filterFor,g=K("packages/dom/src/filters/text.js").TextFilter,l=K("packages/dom/src/filters/engineset.js"),d=l.EngineSetFilter,a=l.VALUE_LIMIT,r=K("packages/dom/src/editors/common.js"),t=r.CLS,n=r.documentFor,i=r.scannableRows,f=r.el,u=K("packages/dom/src/filtermenu.js"),o=u.mergeColumnFilter,m=u.branchFor,c=u.valueSource,h=u.isSetFilter,s=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(L,E,D){const $=f(L,"div",{class:`${t.panel}__filterRefusal`});return $.appendChild(f(L,"div",{class:`${t.filter}__note`,text:D,attrs:{role:"note","data-warning":"filter:values-unsupported"}})),$.appendChild(E.element()),{get:()=>E.get(),set:P=>E.set(P),active:()=>E.active(),...x(E.clear)?{clear:()=>E.clear()}:{},destroy:()=>E.destroy(),element:()=>$}}function y(L){const{grid:E,container:D}=L||{};if(!E)throw new Error("[lattice] mountPanel needs a grid");if(!D||!D.appendChild)throw new Error("[lattice] mountPanel needs a container element");const $=x(L.panel)?L.panel:X[String(L.panel)];if(!$)throw new Error(`[lattice] unknown panel "${L.panel}"; known panels are ${Object.keys(X).join(", ")}`);const P=D.ownerDocument||n(D),k=C(E,P,L.announce),N=new $;N.init({document:P,host:k,grid:E,props:L.props||{}});const G=N.element();D.appendChild(G);const q=[];for(const Y of s)x(E.on)&&q.push(E.on(Y,()=>N.refresh()));return x(E.on)&&q.push(E.on("config:changed",Y=>{Y&&(Y.key==="regression"||Array.isArray(Y.keys)&&Y.keys.includes("regression"))&&N.refresh()})),{element:G,refresh(){N.refresh()},destroy(){for(const Y of q)Y();q.length=0,x(N.destroy)&&N.destroy(),G&&G.parentNode&&G.parentNode.removeChild(G)}}}const O=260,A=30,b=`${t.panel}-dock`;function v(L,E,D){if(!L||!x(L.set))return;const $=m(D.filters.get(),E)||null,P=x(L.get)&&(!x(L.active)||L.active())&&L.get()||null;JSON.stringify(P)!==JSON.stringify($)&&($?L.set($):x(L.clear)?L.clear():L.set(null))}function R(L,E){if(L==="insights"){const P=E&&x(E.get)?E.get("insights"):null;return{other:(P&&typeof P=="object"?P:{}).compareWith||null}}if(L!=="views")return{};const D=E&&x(E.get)?E.get("views"):null,$=D&&typeof D=="object"?D:{};return{allowSave:$.allowSave!==!1,showDiff:$.showDiff===!0,builtinTitle:$.builtinTitle,savedTitle:$.savedTitle}}function j(L,E){const D=L!==null&&typeof L=="object",$=D?L.name:L,P=x($),k=P?$.name||"panel":String($),N=P?$:X[k];if(!N)return B(`toolpanel:${k}`,`unknown tool panel "${k}"`),null;const G=D&&L.props||{};return{name:k,title:D&&L.title||(W[k]?E.messages.t(W[k]):k),icon:D&&L.icon||H[k]||k,Ctor:N,props:{...P?{}:R(k,E),...G}}}function F(L){const E=L.pagination&&x(L.pagination.get)?L.pagination.get():null;return E&&Number.isFinite(E.total)?E.total:L.rows.count()}function C(L,E,D){const $=new Map;return{announce(P,k){x(D)&&D(P,k)},t(P,k){return L.messages.t(P,k)},grid:L,document:E,columns:()=>L.columns.all(),columnGroups:()=>L.state.get().columnGroups||[],groupColumns:(P,k)=>L.columns.groupColumns(P,k),ungroupColumn:P=>L.columns.ungroupColumn(P),renameGroup:(P,k)=>L.columns.renameGroup(P,k),dissolveGroup:P=>L.columns.dissolveGroup(P),showColumns:P=>L.columns.show(P),hideColumns:P=>L.columns.hide(P),groupBy:()=>L.state.get().group||[],setGroupBy:P=>L.columns.group(P),pivotBy:()=>(L.state.get().pivot||{}).columns||[],setPivotBy:P=>L.columns.pivot(P),valueColumns:()=>L.columns.all().filter(P=>P.total).map(P=>P.id),setValueColumns:P=>L.columns.totals(P),valueAggregation(P){const k=L.columns.get(P);return!k||!k.total?"sum":typeof k.total=="string"?k.total:"custom"},setValueAggregation(P,k){L.columns.setTotal(P,k)},quickFilter:()=>L.state.get().quick||"",setQuickFilter:P=>L.filters.quick(P),rowCount:()=>F(L),totalRowCount:()=>x(L.rows.totalCount)?L.rows.totalCount():L.rows.count(),formattableColumns:()=>L.columns.visible().filter(P=>!P.generated).map(P=>({id:P.id,title:String(P.title??P.id)})),formattingRules:P=>L.formatting.list(P),columnSamples:P=>{let k=P;if(!k||k==="*"){const q=L.columns.visible().find(Y=>!Y.generated);k=q?q.id:null}if(!k)return[];const N=[],G=new Set;for(const q of i(L)){const Y=L.rows.value(q.key,k);if(Y==null||Y==="")continue;const J=typeof Y=="object"?N.length:Y;if(!G.has(J)&&(G.add(J),N.push(Y),N.length>=24))break}return N},profilableColumns:()=>L.columns.visible().filter(P=>!P.generated).map(P=>({id:P.id,title:String(P.title??P.id)})),columnProfile:P=>{const k=L.config().source;return((L.state.get().pivot||{}).columns||[]).length&&k&&typeof k=="object"&&x(k.aggregate)?null:L.statistics.profile(P)},columnProfileAsync:P=>L.statistics.profileAsync(P),reduceColumn:(P,k)=>L.statistics.reduce(P,k),columnCapability:P=>L.statistics.capability(P),regressionModel:P=>x(L.statistics.regressionModel)?L.statistics.regressionModel(P):null,insightsColumns:()=>L.columns.visible().filter(P=>!P.generated).map(P=>({id:P.id,title:String(P.title??P.id),type:P.type})),subsetVsPopulation:()=>L.statistics.subsetVsPopulation(),datasetVsDataset:P=>L.statistics.datasetVsDataset(P),compareGroups:(P,k)=>L.statistics.compareGroups(P,k),anomalies:P=>L.statistics.anomalies(P||{}),compareColumns:(P,k)=>{if(!P||!k||P===k)return null;const N=L.statistics.regression(P,k);return{n:N?N.n:0,pearson:L.statistics.correlation(P,k),spearman:L.statistics.spearman(P,k),kendall:L.statistics.kendall(P,k),covariance:L.statistics.covariance(P,k),slope:N?N.slope:null,intercept:N?N.intercept:null,r2:N?N.r2:null,stdError:N?N.stdError:null,weighted:L.statistics.weightedAverage(P,k)}},addRule:(P,k)=>L.formatting.add(P,k),removeRule:(P,k)=>L.formatting.remove(P,k),updateRule:(P,k,N)=>L.formatting.update(P,k,N),moveRule:(P,k,N)=>L.formatting.move(P,k,N),clearRules:P=>L.formatting.clear(P),views:()=>L.views.list(),activeId:()=>L.views.activeId,apply:P=>{L.views.apply(P)},saveAs:P=>L.views.save(P),rename:(P,k)=>L.views.rename(P,k),setDefault:P=>L.views.setDefault(P),clearDefault:()=>L.views.setDefault(null),remove:P=>L.views.remove(P),export:P=>L.views.export(P),diff:P=>L.views.diff(P),moveColumn(P,k,N){const G=L.columns.all().map(te=>te.id),q=G.indexOf(P),Y=G.indexOf(k);if(q<0||Y<0)return;let J=N?Y:Y+1;q<J&&(J-=1),J!==q&&L.columns.move(P,J)},isFiltered(P){return m(L.filters.get(),P)!==null},clearFilter(P){L.filters.set(o(L.filters.get(),P,null));const k=$.get(P);k&&x(k.clear)?k.clear():k&&x(k.set)&&k.set(null)},clearAllFilters(){L.filters.set(null);for(const P of $.values())x(P.clear)?P.clear():x(P.set)&&P.set(null)},filterFor(P){if($.has(P))return v($.get(P),P,L),$.get(P);const k=L.columns.get(P);if(!k)return null;const N=k.filter&&k.filter.props&&k.filter.props.values,G=c(L),q=G?L.config().context??null:null,Y=G?oe=>G.columnValues(P,{...oe||{},context:q}):null,J={grid:L,column:k,colId:P,type:k.type,locale:L.get("locale"),props:{...k.filter&&k.filter.props,values:N||(k.lookup?void 0:G?()=>Y({limit:a}).then(oe=>oe&&oe.supported?oe.values.map(le=>le.value):[]):()=>L.columns.distinct(P)),...G?{valueList:!1}:{}},lookup:k.lookup,document:E,value:oe=>L.rows.value(oe.row&&oe.row.key,P),rows:G?()=>[]:k.lookup?void 0:()=>i(L),changed:()=>{const le=(x(te.active)?te.active():!0)&&x(te.get)?te.get():null;L.filters.set(o(L.filters.get(),P,le||null))},fetchValues:Y};let te=null;const ne=G&&!N&&!k.lookup?w(k):null;if(ne&&h(ne)){const oe=G.columnValuesRefusal(P);if(oe){const le=new g;le.init({...J,props:{...J.props,valueList:!1}}),te=p(E,le,L.messages.t("filter.valuesUnsupported",{column:k.title||P})),B(`filter:values-unsupported:${P}`,`the filter on column "${P}" cannot list its values: ${oe}. It offers the text condition editor instead.`)}else te=new d,te.init(J)}else te=z(J);return te&&(v(te,P,L),$.set(P,te)),te},destroyFilters(){for(const P of $.values())x(P.destroy)&&P.destroy();$.clear()}}}class T{#e;#t;#n;#r;#o;#i=null;#s=[];#l="right";#a=null;#u=!1;#c=!1;constructor(E){this.#e=E.grid,this.#t=E.document,this.#n=E.root,this.#o=C(E.grid,E.document,E.announce);const $=(E.panels||["columns","filters"]).map(P=>j(P,E.grid)).filter(Boolean);this.#l=E.side==="left"?"left":"right",this.#r=new _,this.#r.init({document:E.document,host:this.#o,grid:E.grid,panels:$,actions:E.actions,icons:E.icons,side:this.#l,openPanel:E.openPanel})}mount(){const E=this.#t.createElement("div");E.className=`${b} ${b}--${this.#l}`,E.appendChild(this.#r.element()),this.#n.appendChild(E),this.#i=E;const D=this.#r.show.bind(this.#r),$=this.#r.hide.bind(this.#r);this.#r.show=P=>{const k=D(P);return this.#h(),k},this.#r.hide=()=>{$(),this.#h()};for(const P of[...s,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#s.push(this.#e.on(P,()=>this.#r.refresh()));this.#s.push(this.#e.on("config:changed",P=>{P&&(P.key==="regression"||Array.isArray(P.keys)&&P.keys.includes("regression"))&&this.#r.refresh()})),this.#s.push(this.#e.on("presentation:started",P=>{this.#u=!0;const k=P&&P.options&&Array.isArray(P.options.chrome)?P.options.chrome:[];this.#c=k.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",P=>{const k=P&&P.colId,N=this.#r.panels.find(G=>G.name==="statistics");N&&k!=null&&(N.panel.column=String(k)),this.open("statistics")})),this.#h()}open(E){this.#r.show(E),this.#h()}close(){this.#r.hide(),this.#h()}toggle(E){this.#r.toggle(E),this.#h()}addAction(E){if(!(!E||!E.name)&&!this.#r.actions.some(D=>D.name===E.name)){if(this.#r.registerAction(E),this.#a&&!E.annotation){const D=this.#r.actions.find($=>$.name===E.name);D&&this.#f(D.button)}else!this.#a&&E.annotation&&this.#u&&!this.#c&&this.#d();this.#h()}}removeAction(E){this.#r.removeAction(E)&&this.#h()}presentOnly(){return this.#a?!0:this.#r.actions.some(E=>E.annotation&&E.button)?(this.#d(),!0):!1}#d(){const E=this.#r;this.#a={hidden:[],reopen:E.openPanel||null},this.#a.reopen&&E.hide(),this.#f(E.body);for(const D of[...E.tabs?.children||[]])D!==E.actionGroup&&this.#f(D);for(const D of[...E.actionGroup?.children||[]]){const $=E.actions.find(P=>P.button===D);(!$||!$.annotation)&&this.#f(D)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#h()}presentRestore(){const E=this.#a;if(!E)return!1;this.#a=null;for(const D of E.hidden)D.el&&D.el.style&&(D.el.style.display=D.display);return E.reopen&&this.#r.show(E.reopen),this.#h(),!0}#f(E){if(!E||!E.style||!this.#a)return;const D=E.style.display||"";D!=="none"&&(E.style.display="none",this.#a.hidden.push({el:E,display:D}))}#h(){if(!this.#i)return;const E=!!this.#r.openPanel;this.#i.setAttribute("data-open",E?"true":"false"),this.#i.style.width=E?`${O}px`:"";const D=`${E?O:this.#p()}px`;this.#n.style.paddingLeft=this.#l==="left"?D:"",this.#n.style.paddingRight=this.#l==="left"?"":D,this.#n.style.setProperty("--lattice-dock-left",this.#l==="left"?D:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#l==="left"?"0px":D)}#p(){const E=this.#r&&x(this.#r.element)?this.#r.element().querySelector?.(`.${t.panel}__tabs`):null,D=E&&(E.offsetWidth||E.getBoundingClientRect?.().width)||0;return D>0?Math.ceil(D):A}destroy(){for(const E of this.#s)E();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=""}}}),Le("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"),x=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,V=X.isEditable,w=K("packages/dom/src/detailhost.js").insideDetail,S=`${W.editor}-host`;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=-1;#u=[];#c=null;#d=!1;#f=null;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=>{const c=m.key||m.row&&m.row.key;this.#f=c&&m.colId?{key:c,colId:m.colId}:null,this.open(m)})),this.#u.push(this.#e.on("cell:edit:end",()=>{this.#f=null,this.close(!0)}));const t=this.#n.viewport.root,n=this.#e.get("edit"),i=n&&typeof n=="object"&&n.start||"double",f=m=>{if(w(m.target,t))return;const c=l(m.target,O=>O.getAttribute&&O.getAttribute("data-col"));if(!c)return;const h=l(c,O=>O.getAttribute&&O.getAttribute("data-key"));if(!h)return;const s=this.#e.rows.byKey(h.getAttribute("data-key"));if(!s||s.group)return;const p=c.getAttribute("data-col"),y=this.#e.columns.get(p);!y||!y.edit||!y.edit.enabled||this.#e.edit.start(s.key,p)},u=i==="key"?null:i==="single"?"click":"dblclick";u&&(t.addEventListener(u,f),this.#u.push(()=>t.removeEventListener(u,f)));const o=m=>{!this.#i||!this.#l||this.#g(m.target)||this.commit()};this.#t.addEventListener("mousedown",o,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",o,!0))}get target(){return this.#l}open(t){const n=t.key||t.row&&t.row.key,i=t.colId;if(!n||!i)return;if(this.#i&&this.#l&&this.#l.key===n&&this.#l.colId===i){this.#m();return}this.close();const f=this.#e.columns.get(i),u=this.#e.rows.byKey(n);if(!f||!u||!V({column:f,edit:f.edit,row:u,value:this.#e.rows.value(n,i),grid:this.#e}))return;const o=this.#w(n,i);if(this.#c=o,!o){B("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const m=this.#e.permissions,c=!!(m&&x(m.isSecret)&&m.isSecret(i)),h=_({grid:this.#e,column:f,colId:i,row:u,data:u.data,value:c?null:this.#e.rows.value(n,i),text:c?"":this.#e.rows.text(n,i),locale:this.#e.get("locale"),props:f.edit&&f.edit.props,lookup:f.lookup,document:this.#t,cell:o,overlay:this.#n.viewport.overlays,onCommit:y=>this.#p({value:y,key:n,colId:i}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:y=>{this.#d||this.#e.edit.stop(y)}},this.#r);if(!h){B(`celledit.noeditor:${i}`,`column "${i}" has no editor.`);return}this.#i=h,this.#s=o,this.#l={key:n,colId:i},this.#d=!1,this.#a=this.#j(o);const s=h.element();h.popup?(this.#n.viewport.overlays.appendChild(s),d(s,o,this.#n.viewport.root)):o.replaceChildren(s),o.classList.add(S),x(h.attached)&&h.attached(),a(s);const p=y=>this.#h(y);s.addEventListener("keydown",p),this.#u.push(()=>s.removeEventListener("keydown",p))}#h(t){const n=t.key;if(n!=="Enter"&&n!=="Tab"&&n!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),n==="Escape"){this.#e.edit.stop(!0);return}const i=n==="Enter"?this.#y(t.shiftKey?-1:1):this.#b(t.shiftKey?-1:1);this.commit()&&i&&this.#e.edit.start(i.key,i.colId)}#p(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(x(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:n}=this.#l;if(x(this.#i.value)){const i=this.#i.value();if(x(this.#i.validate)){const f=this.#i.validate(i);if(f!==!0){if(H(this.#c,f),x(this.#i.focusTarget)){const u=this.#i.focusTarget();u&&x(u.focus)&&u.focus()}return!1}H(this.#c,null)}this.#p({value:i,key:t,colId:n})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#m(){const t=x(this.#i.element)?this.#i.element():null;if(!t)return;const n=t.querySelector&&t.querySelector("input, select, textarea, [tabindex]")||t;x(n.focus)&&n.focus()}#g(t){if(!t)return!1;const n=x(this.#i.element)?this.#i.element():null;if(n&&x(n.contains)&&n.contains(t))return!0;const i=this.#c;return!!(i&&x(i.contains)&&i.contains(t))}#y(t){if(!this.#l||this.#a<0)return null;for(let n=this.#a+t;n>=0&&n<this.#e.rows.count();n+=t){const i=this.#e.rows.get(n);if(i&&!i.group)return{key:i.key,colId:this.#l.colId}}return null}#b(t){if(!this.#l)return null;const n=this.#e.columns.visible(),i=n.findIndex(f=>f.id===this.#l.colId);for(let f=i+t;f>=0&&f<n.length;f+=t){const u=n[f];if(u.edit&&u.edit.enabled)return{key:this.#l.key,colId:u.id}}return null}#j(t){const n=l(t,f=>f.getAttribute&&f.getAttribute("data-index"));if(!n)return-1;const i=Number(n.getAttribute("data-index"));return Number.isFinite(i)?i:-1}#w(t,n){const i=this.#n.viewport.root;if(!i||!i.querySelectorAll)return null;for(const f of i.querySelectorAll(`[data-col="${n}"]`)){const u=l(f,o=>o.getAttribute&&o.getAttribute("data-key"));if(u&&u.getAttribute("data-key")===t)return f}return null}close(t=!1){const n=this.#l,i=this.#d;this.#c&&H(this.#c,null);const f=this.#S();if(this.#i&&x(this.#i.destroy)&&this.#i.destroy(),this.#s){if(this.#s.classList.remove(S),this.#o&&x(this.#o.releaseCell)){const u=this.#l?this.#e.columns.get(this.#l.colId):null;this.#o.releaseCell(this.#s,u)}this.#s.replaceChildren&&this.#s.replaceChildren(),f&&this.#v(this.#s),this.#n.refresh({force:!0})}if(this.#i=null,this.#c=null,this.#s=null,this.#l=null,this.#a=-1,this.#d=!1,!t&&n&&!i){const u=this.#f;u&&u.key===n.key&&u.colId===n.colId&&this.#e.edit.stop(!1)}}#S(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const n=this.#i&&x(this.#i.element)?this.#i.element():null,i=f=>!!f&&x(f.contains)&&f.contains(t);return i(n)||i(this.#s)}#v(t){const i=x(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;i&&x(i.focus)&&i.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function l(r,t){let n=r;for(;n;){if(t(n))return n;n=n.parentNode}return null}function d(r,t,n){if(!x(t.getBoundingClientRect))return;const i=t.getBoundingClientRect(),f=n.getBoundingClientRect();r.style.position="absolute",r.style.top=`${Math.round(i.top-f.top)}px`,r.style.minWidth=`${Math.round(i.width)}px`,r.style.left=`${Math.round(i.left-f.left)}px`;const u=r.offsetWidth||Math.round(i.width),o=Math.round(i.left-f.left)+u-Math.round(f.width);o>0&&(r.style.left=`${Math.max(0,Math.round(i.left-f.left)-o)}px`)}function a(r){const t=r.querySelector&&r.querySelector("input, select, textarea, [tabindex]")||r;x(t.focus)&&t.focus(),x(t.select)&&t.select()}}),Le("packages/dom/src/editbar.js",function(e,K){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return V}});const Q=K("packages/core/src/internal/util.js"),x=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 V{#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,S=w.createElement("div");S.className=H;const g=w.createElement("span");g.className=`${H}__ref`,g.textContent="";const l=w.createElement("div");l.className=`${H}__slot`;const d=w.createElement("span");d.className=`${H}__readonly`,S.appendChild(g),S.appendChild(l),this.#n.insertBefore(S,this.#n.firstChild),this.#r=S,this.#o=g,this.#i=l,this.#l=d;for(const a of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(a,r=>this.#h(r)))}bind(w,S){const g=this.#e.columns.get(S),l=w?this.#e.rows.byKey(w):null;this.#a=l&&g&&!l.group?{key:w,colId:S}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#f(),!this.#a){this.#o.textContent="";return}const{key:w,colId:S}=this.#a,g=this.#e.columns.get(S);if(!g)return;if(this.#o.textContent=g.title||S,!!!(g.edit&&g.edit.enabled)){this.#l.textContent=this.#e.rows.text(w,S),this.#i.appendChild(this.#l);return}const d=this.#e.rows.byKey(w);if(!d)return;const a=_({grid:this.#e,column:g,colId:S,row:d,data:d.data,value:this.#e.rows.value(w,S),text:this.#e.rows.text(w,S),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(!a){B(`editbar.noeditor:${S}`,`column "${S}" has no editor.`),this.#l.textContent=this.#e.rows.text(w,S),this.#i.appendChild(this.#l);return}this.#s=a;const r=a.element();a.popup?(this.#l.textContent=this.#e.rows.text(w,S),this.#i.appendChild(this.#l)):this.#i.appendChild(r),x(a.attached)&&a.attached();const t=f=>this.#p(f),n=()=>{this.#u=!0},i=[r,this.#i];for(const f of i)f.addEventListener("keydown",t),f.addEventListener("input",n),f.addEventListener("change",n);this.#c=()=>{for(const f of i)f.removeEventListener("keydown",t),f.removeEventListener("input",n),f.removeEventListener("change",n)}}#f(){this.#c&&(this.#c(),this.#c=null),this.#s&&x(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:S,colId:g}=this.#a;if(!this.#s||!x(this.#s.value))return!1;const l=this.#s.value();return this.#u=!1,this.#e.edit.start(S,g),this.#e.edit.stop(!1,{value:l,key:S,colId:g}),this.refresh(),!0}destroy(){this.#f();for(const w of this.#d)w();this.#d=[],this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#a=null}}}),Le("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 x=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",V='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(S){this.#e=S.grid,this.#t=S.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(S,g){const l=this.#e;return(l&&l.messages?l.messages:I).t(S,g)}#d(S){const g=`paste.preview.reason.${S}`,l=this.#c(g);return l===g?S:l}#f(S){return S==null||S===""?"":String(S)}#h(S,g){const l=this.#e.columns&&x(this.#e.columns.get)?this.#e.columns.get(g):null;return`${l&&(l.title||l.headerName)||g} · ${S}`}show(S,g){const l=this.#b();if(!l)return!1;this.#l=g&&g.onConfirm,this.#a=g&&g.onCancel||null;const d=S&&S.changes||[],a=S&&S.rejected||[],r=d.filter(n=>n.changed);this.#p(r,a);const t=l.ownerDocument;return this.#s=t&&t.activeElement,l.style.display="",x(l.focus)&&l.focus(),this.#w(this.#c("a11y.paste.previewOpened",{count:r.length,changes:r.length,rejected:a.length}),{repeat:!0}),!0}#p(S,g){const l=this.#r.ownerDocument;W(this.#r);const d=X(l,"p",{class:`${H}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:S.length,changes:S.length,rejected:g.length})});if(this.#r.appendChild(d),!S.length&&!g.length){this.#r.appendChild(X(l,"p",{class:`${H}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!S.length;return}this.#o.disabled=!S.length,S.length&&(this.#r.appendChild(X(l,"h3",{class:`${H}__heading`,text:this.#c("paste.preview.changesHeading",{count:S.length})})),this.#r.appendChild(this.#m(l,S))),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(S,g){const l=X(S,"tr",{children:[X(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),X(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),d=g.map(a=>X(S,"tr",{children:[X(S,"th",{attrs:{scope:"row"},text:this.#h(a.key,a.colId)}),X(S,"td",{class:`${H}__old`,text:this.#f(a.oldValue)}),X(S,"td",{class:`${H}__new`,text:this.#f(a.newValue)})]}));return X(S,"table",{class:`${H}__table`,children:[X(S,"thead",{children:[l]}),X(S,"tbody",{children:d})]})}#g(S,g){const l=X(S,"tr",{children:[X(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),d=g.map(a=>X(S,"tr",{children:[X(S,"th",{attrs:{scope:"row"},text:this.#h(a.key,a.colId)}),X(S,"td",{class:`${H}__reason`,text:this.#d(a.reason)})]}));return X(S,"table",{class:`${H}__table ${H}__table--rejected`,children:[X(S,"thead",{children:[l]}),X(S,"tbody",{children:d})]})}confirm(){const S=this.#l;this.#y(),x(S)&&S()}cancel(){const S=this.#a;this.#y(),this.#w(this.#c("a11y.paste.cancelled"),{repeat:!0}),x(S)&&S()}#y(){if(!this.#n)return;this.#n.style.display="none",this.#l=null,this.#a=null;const S=this.#s;this.#s=null,S&&x(S.focus)&&S.focus()}#b(){if(this.#n)return this.#n;const S=this.#t.viewport&&this.#t.viewport.overlays,g=S&&S.ownerDocument;if(!S||!g||!x(g.createElement))return null;const l=`${H}-title`,d=X(g,"h2",{class:`${H}__title`,attrs:{id:l},text:this.#c("paste.preview.title")}),a=X(g,"div",{class:`${H}__body`}),r=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")}),n=X(g,"div",{class:`${H}__foot`,children:[t,r]}),i=X(g,"div",{class:H,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":l},children:[X(g,"div",{class:`${H}__head`,children:[d]}),a,n]});return S.appendChild(i),this.#n=i,this.#r=a,this.#o=r,this.#i=t,this.#j(i,r,t),i}#j(S,g,l){const d=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.cancel();return}if(t.key!=="Tab")return;const n=[...S.querySelectorAll(V)].filter(o=>!o.disabled);if(!n.length){t.preventDefault();return}const i=n[0],f=n[n.length-1],u=S.ownerDocument.activeElement;t.shiftKey&&(u===i||u===S)?(t.preventDefault(),f.focus()):!t.shiftKey&&u===f&&(t.preventDefault(),i.focus())},a=t=>{t&&x(t.preventDefault)&&t.preventDefault(),this.confirm()},r=t=>{t&&x(t.preventDefault)&&t.preventDefault(),this.cancel()};S.addEventListener("keydown",d),g.addEventListener("click",a),l.addEventListener("click",r),this.#u.push(()=>{S.removeEventListener("keydown",d),g.removeEventListener("click",a),l.removeEventListener("click",r)})}#w(S,g){const l=this.#t&&this.#t.announce;x(l)&&l.call(this.#t,S,g)}destroy(){for(const S of this.#u)S();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}}}),Le("packages/dom/src/rangeselect.js",function(e,K){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const x=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"),V=H.isTextEntry,z=H.isFindBarControl,S=K("packages/dom/src/pastepreview.js").PastePreview,g=K("packages/dom/src/columnmenu.js"),l=g.chartableRange,d=g.rangeChartConfig,a="lat-cell--range",r="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"}),n=3;class i{#e;#t;#n;#r=!1;#o=[];#i=null;#s=null;#l=null;#a=null;#u=null;constructor(o){this.#e=o.grid,this.#t=o.renderer,this.#n=o.document,this.#a=o.preview||null}mount(){const o=this.#t.viewport.root,m=p=>this.#c(p),c=p=>this.#d(p),h=()=>this.#f(),s=p=>this.#h(p);o.addEventListener("pointerdown",m),this.#n.addEventListener("pointermove",c),this.#n.addEventListener("pointerup",h),o.addEventListener("keydown",s),this.#o.push(()=>{o.removeEventListener("pointerdown",m),this.#n.removeEventListener("pointermove",c),this.#n.removeEventListener("pointerup",h),o.removeEventListener("keydown",s)});for(const p of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(p,()=>this.paint()));this.paint()}#c(o){if(o.button!==0)return;const m=o.target;if(!m||!x(m.closest))return;if(this.#r=!1,m.closest('[data-role="fill-handle"]')){if(this.#T())return;this.#i={mode:"fill",fromX:o.clientX,fromY:o.clientY,armed:!0};return}if(m.closest('[data-role="row-drag"]'))return;const c=this.#q(m);if(!c)return;if(o.shiftKey&&this.#e.selection.corner()){const s=this.#E(c);this.#e.selection.extendRange(s.rowIndex,s.colId),this.#i={mode:"select",fromX:o.clientX,fromY:o.clientY,armed:!0};return}const h=this.#M(c);this.#u=h,this.#e.selection.startRange(h.rowIndex,h.colId,{additive:o.ctrlKey||o.metaKey}),this.#i={mode:"select",fromX:o.clientX,fromY:o.clientY,armed:!1}}#d(o){const m=this.#i;if(!m)return;if(!m.armed){if(Math.abs(o.clientX-m.fromX)+Math.abs(o.clientY-m.fromY)<n)return;m.armed=!0}const c=this.#I(o.clientX,o.clientY);if(!c)return;if(m.mode==="fill"){this.#l=c,this.paint();return}const h=this.#E(c);this.#e.selection.extendRange(h.rowIndex,h.colId)}#f(){const o=this.#i;if(this.#i=null,!!o){if(o.mode==="fill"&&this.#l){const m=this.#l;this.#l=null,this.fillTo(m.rowIndex)}this.#l=null,this.paint()}}#h(o){if(this.#B()||z(o.target)||V(o.target))return;const m=o.ctrlKey||o.metaKey,c=o.key;if(m&&(c==="c"||c==="C")){this.copy(),o.preventDefault();return}if(m&&(c==="v"||c==="V")){this.paste(),o.preventDefault();return}if(m&&(c==="d"||c==="D")){this.fillDown(),o.preventDefault();return}if(m&&!o.altKey&&(c==="z"||c==="Z"||c==="y"||c==="Y")){const j=this.#e.edit;if(!j||j.undoShortcuts===!1)return;const F=c==="y"||c==="Y"||o.shiftKey;this.#w(F)&&o.preventDefault();return}if(c==="Delete"||c==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),o.preventDefault();return}if(this.#e.edit&&this.#e.edit.clearOnDelete===!1)return;this.clear(),o.preventDefault();return}if(o.altKey&&c==="F1"){this.chartSelection()&&o.preventDefault();return}if(!o.shiftKey)return;const h={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[c];if(!h)return;if(m){const j=this.#$();if(!j)return;if(!this.#r){const E=this.#M(j);this.#u=E,this.#e.selection.startRange(E.rowIndex,E.colId,{additive:!0}),this.#r=!0}const F=this.#e.columns.visible().map(E=>E.id),C=F.indexOf(j.colId),T=this.#e.selection.corner()||{row:j.rowIndex,colId:j.colId},L=this.#E({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,T.row+h[0])),colId:F[Math.min(F.length-1,Math.max(0,(C<0?0:C)+h[1]))]});this.#e.selection.extendRange(L.rowIndex,L.colId),o.preventDefault();return}this.#r=!1;const s=this.#e.selection.corner(),p=this.#$(),y=s||p;if(!y)return;if(!s&&p){const j=this.#M(p);this.#u=j,this.#e.selection.startRange(j.rowIndex,j.colId)}const O=this.#e.columns.visible().map(j=>j.id),A=O.indexOf(y.colId??y.colId),b=O[Math.min(O.length-1,Math.max(0,A+h[1]))],v=Math.min(this.#e.rows.count()-1,Math.max(0,(s?s.row:p.rowIndex)+h[0])),R=this.#E({rowIndex:v,colId:b});this.#e.selection.extendRange(R.rowIndex,R.colId),o.preventDefault()}async copy(){const o=this.#e.export.rangeText();if(!o)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||!x(m.writeText))return!1;try{return await m.writeText(o),this.#e.emit("clipboard:copy",{text:o,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:o,ok:!1,rows:"range"},"user"),!1}}async paste(){const o=globalThis.navigator&&globalThis.navigator.clipboard;if(!o||!x(o.readText))return 0;let m="";try{m=await o.readText()}catch{return 0}return this.pasteText(m)}pasteText(o){if(!o)return 0;const m=this.#e.selection.cells(),c=m.length?m[0]:this.#j();if(!c)return 0;const h=m.length>1?{rows:new Set(m.map(s=>s.key)).size,columns:new Set(m.map(s=>s.colId)).size}:void 0;if(this.#p()){const s=this.#e.edit.previewPaste(c,o,h);if(s.changes.length+s.rejected.length>1)return this.#m().show(s,{onConfirm:()=>this.#g(c,o,h)}),0}return this.#g(c,o,h)}#p(){const o=this.#e.edit;return!!(o&&o.pastePreview&&x(o.previewPaste))}#m(){return this.#a||(this.#a=new S({grid:this.#e,renderer:this.#t})),this.#a}#g(o,m,c){const h=this.#e.edit.pasteInto(o,m,c,{origin:"user"}),s=p=>this.#b(p?this.#y("a11y.range.written",{count:p}):this.#y("a11y.range.refused"),{repeat:!0});return h&&x(h.then)?h.then(s):s(h),h}#y(o,m){const c=this.#e;return(c&&c.messages?c.messages:I).t(o,m)}#b(o,m){const c=this.#t&&this.#t.announce;x(c)&&c.call(this.#t,o,m)}#j(){const o=this.#$();if(!o)return null;const m=this.#e.rows.get(o.rowIndex);return m?{key:m.key,colId:o.colId}:null}#w(o){const m=this.#e.history;return!(!m||!(o?m.canRedo():m.canUndo())||!(o?m.redo():m.undo()))}clear(){let o=this.#e.selection.cells();const m=this.#j(),c=this.#n&&this.#n.activeElement;if(!!(m&&c&&x(c.matches)&&c.matches('[data-col][tabindex="0"]'))&&!o.some(y=>y.key===m.key&&y.colId===m.colId)?o=[m]:o.length||(o=m?[m]:[]),!o.length)return 0;const s=this.#e.edit.setCells(o.map(y=>({key:y.key,colId:y.colId,value:null})),"cell",{origin:"user"}),p=y=>{y&&this.#b(this.#y("a11y.range.cleared",{count:y}),{repeat:!0})};return s&&x(s.then)?s.then(p):p(s),s}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const o=this.#e.selection.cells();if(o.length<2)return 0;const m=[...new Set(o.map(s=>s.key))];if(m.length<2)return 0;const c=m[0],h=[];for(const{key:s,colId:p}of o)s!==c&&h.push({key:s,colId:p,value:this.#e.rows.value(c,p)});return this.#e.edit.setCells(h,"cell",{origin:"user"})}chartSelection(){const o=d(this.#e);if(!o.handler)return!1;const m=l(this.#e);return m?(o.handler(this.#e,m),!0):!1}fillTo(o){if(this.#e.selection.ranges().length>1)return 0;const m=this.#e.selection.cells();if(!m.length)return 0;const c=[...new Set(m.map(b=>b.key))],h=[...new Set(m.map(b=>b.colId))],s=this.#z(c[c.length-1]);if(s<0||o<=s)return 0;const p=[];for(let b=s+1;b<=o;b++){const v=this.#e.rows.get(b);if(!v)break;p.push(v)}if(!p.length)return 0;const y=[];for(const b of h){const v=c.map(j=>this.#e.rows.value(j,b)),R=this.#S(v,p,b);for(let j=0;j<p.length;j++)y.push({key:p[j].key,colId:b,value:R[j]})}const O=this.#e.edit.setCells(y,"cell",{origin:"user"}),A=this.#e.selection.corner();return A&&this.#e.selection.extendRange(o,A.colId),O}#S(o,m,c){const h=this.#e.get("selection"),s=h&&typeof h=="object"?h.fill:void 0;if(x(s)){const p=this.#e.columns.get(c),y=m.map(A=>({row:A,column:p})),O=s({source:o,target:y,direction:"down"});if(Array.isArray(O)&&O.length===m.length)return O}return X(o,m.length)}paint(){const o=this.#t.viewport.root;if(!o||!o.querySelectorAll)return;const m=this.#e.selection,c=m.ranges().length>0,h=this.#l;for(const s of o.querySelectorAll("[data-col]")){const p=s.getAttribute("data-col"),y=s.parentNode,O=s.getAttribute?s.getAttribute("data-index"):null,A=O!==null&&O!==""?O:y&&y.getAttribute?y.getAttribute("data-index"):null;if(A===null||A==="")continue;const b=Number(A);if(!Number.isFinite(b)||b<0)continue;const v=c&&m.inRange(b,p),R=!!h&&this.#v(b,p,h);s.classList.toggle(a,v||R);const j=v||R?this.#C(b,p,m):null;s.classList.toggle(r,!!j&&j.any);for(const[F,C]of Object.entries(t))s.classList.toggle(C,!!j&&j[F])}this.#O()}#v(o,m,c){const h=this.#e.selection.cells();if(!h.length||!new Set(h.map(y=>y.colId)).has(m))return!1;const p=this.#z([...new Set(h.map(y=>y.key))].pop());return o>p&&o<=c.rowIndex}#C(o,m,c){const h=this.#e.columns.visible().map(A=>A.id),s=h.indexOf(m),p=s>0?h[s-1]:null,y=s>=0&&s<h.length-1?h[s+1]:null,O={top:!c.inRange(o-1,m),bottom:!c.inRange(o+1,m),left:!p||!c.inRange(o,p),right:!y||!c.inRange(o,y)};return O.any=O.top||O.bottom||O.left||O.right,O}#O(){const o=this.#e.selection.corner(),m=this.#t.viewport.overlays;if(!m)return;if(!o||this.#L()===!1||this.#e.selection.ranges().length>1||this.#T()){this.#s&&(this.#s.style.display="none");return}const c=this.#W(o.row,o.colId);if(!c||!x(c.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.#y("a11y.fillHandle")),m.appendChild(this.#s));const h=c.getBoundingClientRect(),s=this.#t.viewport.root.getBoundingClientRect();this.#s.style.display="";const y=this.#t.viewport.rtl===!0?h.left:h.right;this.#s.style.left=`${Math.round(y-s.left)-4}px`,this.#s.style.top=`${Math.round(h.bottom-s.top)-4}px`}#P(o){const m=this.#t;return!o||typeof m.spanAt!="function"?null:m.spanAt(o.rowIndex,o.colId)}#M(o){const m=this.#P(o);return m?{rowIndex:m.row,colId:m.columnId}:o}#E(o){const m=this.#P(o);if(!m)return o;const c=this.#u,h=!!c&&c.rowIndex>=m.row+m.rows,s=this.#N(),p=c?s.indexOf(c.colId):-1,y=p>=0&&p>=m.col+m.cols;return{rowIndex:h?m.row:m.row+m.rows-1,colId:y?m.columnId:m.endColumnId}}#T(){const o=this.#e.selection.corner();if(!o)return!1;const m=this.#P({rowIndex:o.row,colId:o.colId});return!!m&&(m.rows>1||m.cols>1)}#N(){const o=this.#e.columns;return o&&x(o.visible)?o.visible().map(m=>m.id):[]}#L(){return W(this.#e.get("selection")).fillHandle}#B(){const o=this.#t.viewport.root;return!!(o&&o.querySelector&&o.querySelector(".lat-editor-host, .lat-editor--popup"))}#_(){const o=this.#e.selection.cells();return o.length?o[0]:null}#z(o){for(let m=0;m<this.#e.rows.count();m++){const c=this.#e.rows.get(m);if(c&&c.key===o)return m}return-1}#$(){const o=this.#t.viewport.root,m=o&&o.querySelector?o.querySelector('[data-col][tabindex="0"]'):null;return m?this.#q(m):null}#q(o){if(!o||!x(o.closest))return null;const m=o.closest("[data-col]");if(!m||!m.classList.contains("lat-cell"))return null;const c=m.closest("[data-index]");if(!c)return null;const h=Number(c.getAttribute("data-index"));return!Number.isFinite(h)||h<0?null:{rowIndex:h,colId:m.getAttribute("data-col")}}#I(o,m){const c=this.#n.elementFromPoint?this.#n.elementFromPoint(o,m):null;return c?this.#q(c):null}#W(o,m){const c=this.#t.viewport.root;if(!c||!c.querySelectorAll)return null;for(const h of c.querySelectorAll(`[data-col="${m}"]`)){const s=h.closest?h.closest("[data-index]"):null;if(s&&Number(s.getAttribute("data-index"))===o)return h}return null}destroy(){for(const o of this.#o)o();this.#o=[],this.#s&&x(this.#s.remove)&&this.#s.remove(),this.#s=null,this.#i=null,this.#l=null,this.#a&&x(this.#a.destroy)&&this.#a.destroy(),this.#a=null}}const f=i}),Le("packages/dom/src/importer.js",function(e,K){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return i}});const x=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,V=_.readXlsx,z=_.looksLikeXlsx,w=K("packages/dom/src/editors/common.js"),S=w.el,g=w.clear,l=w.on,a=K("packages/dom/src/renderer/textentry.js").isTextEntry,r="lat-import",t='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',n=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class i{#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 o=u.settings&&typeof u.settings=="object"?u.settings:{};this.#r={file:o.file!==!1,drop:o.drop!==!1,paste:o.paste!==!1,mode:o.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",o=>{o.dataTransfer&&[...o.dataTransfer.types||[]].includes("Files")&&(o.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",o=>{u.classList.remove("lat-import--dropzone");const m=o.dataTransfer&&o.dataTransfer.files&&o.dataTransfer.files[0];m&&(o.preventDefault(),this.#c(m))}))),this.#r.paste&&this.#o.push(l(u,"paste",o=>{if(a(o.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const m=o.clipboardData&&o.clipboardData.getData("text/plain");!m||!m.includes(`
57
57
  `)||(o.preventDefault(),this.fromText(m))})))}openFile(){const u=S(this.#n,"input",{attrs:{type:"file",accept:n}});u.style.display="none",this.#o.push(l(u,"change",()=>{const o=u.files&&u.files[0];o&&this.#c(o),u.parentNode&&u.parentNode.removeChild(u)})),this.#n.body.appendChild(u),u.click()}#c(u){if(x(u.arrayBuffer)){u.arrayBuffer().then(m=>{const c=new Uint8Array(m);if(z(c)){this.fromXlsx(c,u.name);return}this.fromText(new TextDecoder().decode(c),u.name)});return}if(x(u.text)){u.text().then(m=>this.fromText(m,u.name));return}const o=new this.#n.defaultView.FileReader;o.onload=()=>this.fromText(String(o.result||""),u.name),o.readAsText(u)}async fromXlsx(u,o){const{header:m,rows:c}=await V(u);if(!m.length)return;const h=W(m,c,{columns:this.#e.columns.all()}),s=c.filter(p=>p.length!==m.length).length;this.#l={rows:c,columns:h,delimiter:null,name:o,warnings:s?[`${s} row(s) do not have ${m.length} columns`]:[]},this.#d()}fromText(u,o){const{header:m,rows:c,delimiter:h}=X(u);if(!m.length)return;const s=W(m,c,{columns:this.#e.columns.all()}),p=c.filter(y=>y.length!==m.length).length;this.#l={rows:c,columns:s,delimiter:h,name:o,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&&x(u.focus)&&u.focus(),this.#f(this.#h("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#f(u,o){const m=this.#t&&this.#t.announce;x(m)&&m.call(this.#t,u,o)}#h(u,o){return(this.#e&&this.#e.messages?this.#e.messages:I).t(u,o)}#p(){const u=this.#n,o=S(u,"div",{class:r,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#h("import.title"),hidden:!0}}),m=S(u,"div",{class:`${r}__panel`});m.appendChild(S(u,"h2",{class:`${r}__title`,text:this.#h("import.title")})),this.#s=S(u,"div",{class:`${r}__body`}),m.appendChild(this.#s);const c=S(u,"div",{class:`${r}__footer`}),h=S(u,"button",{class:`${r}__cancel`,text:this.#h("import.cancel"),attrs:{type:"button"}}),s=S(u,"button",{class:`${r}__confirm`,text:this.#h("import.confirm"),attrs:{type:"button"}});this.#o.push(l(h,"click",()=>this.close())),this.#o.push(l(s,"click",()=>this.#g())),c.appendChild(h),c.appendChild(s),m.appendChild(c),o.appendChild(m),this.#o.push(l(o,"keydown",y=>{if(y.key==="Escape"){y.preventDefault(),this.close();return}if(y.key!=="Tab")return;const O=[...o.querySelectorAll(t)].filter(v=>!v.hidden);if(!O.length)return;const A=O[0],b=O[O.length-1];y.shiftKey&&this.#n.activeElement===A?(y.preventDefault(),b.focus()):!y.shiftKey&&this.#n.activeElement===b&&(y.preventDefault(),A.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(o),this.#i=o}#m(){const u=this.#n,o=g(this.#s),{rows:m,columns:c,name:h,warnings:s}=this.#l;o.appendChild(S(u,"p",{class:`${r}__summary`,text:this.#h("import.summary",{count:m.length,name:h||this.#h("import.clipboard")})}));for(const v of s)o.appendChild(S(u,"p",{class:`${r}__warning`,text:v}));const p=this.#e.columns.all().map(v=>v.field||v.id).filter(Boolean),y=S(u,"table",{class:`${r}__map`}),O=S(u,"tr",{});for(const v of["import.colSource","import.colField","import.colType"])O.appendChild(S(u,"th",{text:this.#h(v)}));y.appendChild(O),c.forEach((v,R)=>{const j=S(u,"tr",{});j.appendChild(S(u,"td",{text:v.source}));const F=S(u,"select",{attrs:{"data-col":String(R),"aria-label":this.#h("import.mapLabel",{source:v.source})}});F.appendChild(S(u,"option",{text:this.#h("import.skip"),attrs:{value:""}}));for(const T of p)F.appendChild(S(u,"option",{text:T,attrs:{value:T,selected:T===v.field?!0:null}}));v.field&&!p.includes(v.field)&&F.appendChild(S(u,"option",{text:v.field,attrs:{value:v.field,selected:!0}}));const C=S(u,"td",{});C.appendChild(F),j.appendChild(C),j.appendChild(S(u,"td",{class:`${r}__type`,text:v.type})),y.appendChild(j)}),o.appendChild(y);const A=S(u,"div",{class:`${r}__mode`}),b=S(u,"select",{attrs:{"aria-label":this.#h("import.modeLabel"),"data-mode":"mode"}});b.appendChild(S(u,"option",{text:this.#h("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),b.appendChild(S(u,"option",{text:this.#h("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),A.appendChild(S(u,"label",{text:this.#h("import.modeLabel")})),A.appendChild(b),o.appendChild(A)}#g(){const{rows:u,columns:o}=this.#l;for(const p of this.#i.querySelectorAll("select[data-col]")){const y=Number(p.getAttribute("data-col"));o[y]&&p.value!==void 0&&p.value!==null&&(o[y].field=p.value)}const m=this.#i.querySelector("select[data-mode]"),c=m?m.value:void 0,h=c==="replace"||c==="append"?c:this.#r.mode,s=H(u,o);this.#e.import.apply(s,{mode:h}),this.close(),this.#f(this.#h("import.done",{count:s.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&x(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}}}),Le("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 S}});const x=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,V=_.documentFor,z="lat-history";class w{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(l,d){return(this.messages&&typeof this.messages.t=="function"?this.messages:I).t(l,d)}init(l){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||I;const d=l||{};if(this.doc=V(d),this.host=d.host||{},this.props=d.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 a=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(a,"click",()=>this.toggle())),this.root.appendChild(a),this.toggleButton=a,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,d,a){const r=X(this.doc,"button",{class:`${z}__${l}`,attrs:{type:"button"},children:[X(this.doc,"span",{class:`${z}__glyph`,text:a,attrs:{"aria-hidden":"true"}}),X(this.doc,"span",{class:`${z}__label`,text:d})]});return this.off.push(W(r,"click",()=>{const t=this.host[l];x(t)&&t(),this.refresh()})),r}element(){return this.root}refresh(){if(!this.root)return;const l=this.host,d=x(l.canUndo)?l.canUndo():!1,a=x(l.canRedo)?l.canRedo():!1,r=x(l.peek)?l.peek("undo"):null,t=x(l.peek)?l.peek("redo"):null;this.#t(this.undoButton,"undo",d,r),this.#t(this.redoButton,"redo",a,t),this.open&&this.#n()}#t(l,d,a,r){if(!l)return;l.disabled=!a;const t=d==="undo",n=this.t(t?"history.undo":"history.redo"),i=l.querySelector(`.${z}__label`);i&&(i.textContent=n);const f=r&&r.label?this.t("history.described",{action:n,label:r.label}):n;l.setAttribute("title",a?f:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),l.setAttribute("aria-label",a?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 d=x(this.host.list)?this.host.list():[];if(!d.length){l.appendChild(X(this.doc,"p",{class:`${z}__empty`,text:this.t("history.empty")}));return}d.forEach((a,r)=>{const t=X(this.doc,"button",{class:`${z}__item`,attrs:{type:"button",role:"menuitem","data-type":a.type,"data-undone":a.undone?"true":null},children:[X(this.doc,"span",{class:`${z}__kind`,text:a.type}),X(this.doc,"span",{class:`${z}__text`,text:a.label||a.type})]});this.off.push(W(t,"click",()=>{const n=r+1;for(let i=0;i<n;i++)x(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&&x(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const S=w}),Le("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return V}}),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"),x=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 V{#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,d=l&&l.enabled;for(const a of g.querySelectorAll("[data-key]")){const r=a.getAttribute("data-key"),t=d?l.statusOf(r):"unchanged";for(const i of Object.values(X))a.classList.remove(i);d&&X[t]&&a.classList.add(X[t]),a.setAttribute("data-diff",d?t:"");const n=d&&t==="changed";for(const i of a.querySelectorAll("[data-col]")){const f=i.getAttribute("data-col");if(i.classList.remove(W,H),i.removeAttribute("data-before"),!n)continue;const u=l.cellStatus(r,f);if(u==="changed"){i.classList.add(W);const o=this.#r(l,r,f);o===null?i.removeAttribute("title"):(i.setAttribute("data-before",o),i.setAttribute("title",this.#o("diff.before",{value:o})))}else u==="added-column"&&i.classList.add(H)}}}#r(g,l,d){const a=this.#e,r=a&&a.columns,t=r&&x(r.get)?r.get(d):null,n=a&&a.permissions;if(t&&n&&x(n.isSecret)&&n.isSecret(t))return null;const i=g.before(l,d);if(i==null)return this.#o("diff.empty");if(!t||!x(t.formatValue))return String(i);const f=x(g.beforeRow)?g.beforeRow(l):void 0,o={...(a.rows&&x(a.rows.byKey)?a.rows.byKey(l):null)||{},data:f===void 0?{}:f};try{const m=t.formatValue(i,o,o.data);return m==null?"":String(m)}catch(m){return B(`diff-before-format:${d}`,`the formatter for column "${d}" threw while formatting a previous value, so the diff hover shows the raw one.`,m),String(i)}}#o(g,l){const d=this.#e;return(d&&d.messages?d.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 d of Object.values(X))l.classList.remove(d);l.removeAttribute("data-diff")}for(const l of g.querySelectorAll("[data-col]"))l.classList.remove(W,H),l.removeAttribute("data-before")}}}function z(S){return!!(S&&S.diff&&(x(S.diff)||typeof S.diff=="object"))}const w=V}),Le("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 x=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()};x(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):x(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const V=this.#l();if(V){V.sweep();for(const z of H.querySelectorAll("[data-key]")){const w=z.getAttribute("data-key");for(const S of z.querySelectorAll("[data-col]")){const g=V.active?V.colourFor(w,S.getAttribute("data-col")):null;g?(S.classList.add(B),S.style.setProperty(I,g)):S.classList.contains(B)&&(S.classList.remove(B),S.style.removeProperty(I))}}this.#s(V)}}#s(H){this.#r!==null&&x(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const V=H.nextExpiry;if(!Number.isFinite(V)||!x(this.#i.setTimeout))return;const z=Math.max(0,V-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},z)}#l(){const H=this.#e.highlight;return H&&x(H.model)?H.model():null}destroy(){this.#r!==null&&x(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const V of this.#n)V();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const V of H.querySelectorAll(`.${B}`))V.classList.remove(B),V.style.removeProperty(I)}}const X=_}),Le("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 x=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()};x(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):x(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const V=this.#e.find;if(!V||!x(V.stateFor))return;const z=x(V.model)?V.model():null,w=!!z&&z.active;if(!w&&!this.#o)return;let S=!1;for(const g of H.querySelectorAll("[data-key]")){const l=g.getAttribute("data-key");for(const d of g.querySelectorAll("[data-col]")){const a=w?V.stateFor(l,d.getAttribute("data-col")):null;a?(S=!0,d.classList.add(B),d.classList.toggle(I,a==="current")):d.classList.contains(B)&&d.classList.remove(B,I)}}this.#o=S}destroy(){for(const V of this.#n)V();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll)){for(const V of H.querySelectorAll(`.${B}`))V.classList.remove(B,I);this.#o=!1}}}const X=_}),Le("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"),x=Q.el,B=Q.on,_=K("packages/dom/src/renderer/textentry.js").isTextEntry,W=K("packages/core/src/i18n/index.js").defaultMessages,V=K("packages/core/src/internal/util.js").isFunction,z="lat-find",w=12,S=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=[];#y=null;#b=null;#j=!1;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#n=a.document||a.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=a.settings&&typeof a.settings=="object"?a.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(a,r){const t=this.#e;return(t&&t.messages&&V(t.messages.t)?t.messages:W).t(a,r)}mount(){const a=this.#S();if(!a)return;a.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),a.attachDriver({run:()=>this.#E()});const r=this.#t.viewport?.root;if(r&&V(r.addEventListener)&&this.#o.shortcut!==!1){const t=n=>{if(!(n.ctrlKey||n.metaKey)||n.altKey||n.shiftKey||n.key!=="f"&&n.key!=="F")return;const i=n.target;if(this.#s&&i===this.#s){n.preventDefault(),n.stopPropagation(),V(this.#s.select)&&this.#s.select();return}_(i)||(n.preventDefault(),n.stopPropagation(),this.show())};r.addEventListener("keydown",t,!0),this.#g.push(()=>r.removeEventListener("keydown",t,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#N())),this.#g.push(this.#e.on("columns:changed",()=>this.#C())),this.#g.push(this.#e.on("column:visible",()=>this.#C()))}show(a){const r=this.#v();if(!r)return;const t=r.style.display!=="none";r.style.display="",t||this.#w(),this.#S().setOpen(!0),a!=null&&(this.#s.value=String(a),this.#P()),this.#s.focus(),V(this.#s.select)&&this.#s.select(),this.#N()}hide(){this.#_();const a=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#w()),a&&(a.clear(),a.setOpen(!1));const r=this.#t.viewport?.root;if(!r||!(this.#i&&this.#n&&this.#n.activeElement&&V(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const i=(V(r.querySelector)?r.querySelector('[tabindex="0"]'):null)||r;V(i.focus)&&i.focus()}search(){this.#P()}destroy(){this.#j=!0,this.#_();for(const r of this.#g)r();this.#g=[];const a=this.#S();a&&(a.attachUi(null),a.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#w(){const a=this.#t;a&&V(a.invalidate)&&a.invalidate("size")}#S(){const a=this.#e&&this.#e.find;return a&&V(a.model)?a.model():null}#v(){if(this.#i)return this.#i;const a=this.#t.viewport,r=a?.root,t=this.#n;if(!r||!t||!V(r.insertBefore))return null;const n=x(t,"div",{class:z,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=x(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=x(t,"span",{class:`${z}__count`,attrs:{"aria-hidden":"true"}}),this.#a=x(t,"span",{class:`${z}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=x(t,"span",{class:`${z}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const i=x(t,"button",{class:`${z}__nav ${z}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),f=x(t,"button",{class:`${z}__nav ${z}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=x(t,"button",{class:`${z}__toggle ${z}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=x(t,"button",{class:`${z}__toggle ${z}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#f=x(t,"select",{class:`${z}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const u=x(t,"button",{class:`${z}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),o=x(t,"div",{class:`${z}__options`,children:[this.#c,this.#d,this.#f]});for(const c of[this.#s,this.#l,this.#a,this.#u,i,f,u,o])n.appendChild(c);this.#g.push(B(this.#s,"input",()=>this.#O())),this.#g.push(B(i,"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.#P()})),this.#g.push(B(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#P()})),this.#g.push(B(this.#f,"change",()=>{const c=this.#f.value;this.#m=c?String(c):null,this.#P()})),this.#g.push(B(u,"click",()=>this.hide()));const m=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),this.hide();return}c.key==="Enter"&&c.target===this.#s&&(c.preventDefault(),c.stopPropagation(),this.#y!==null&&(this.#L(),this.#P()),c.shiftKey?this.#e.find.prev():this.#e.find.next())};return n.addEventListener("keydown",m),this.#g.push(()=>n.removeEventListener("keydown",m)),n.style.display="none",r.insertBefore(n,a.header||r.firstChild),this.#i=n,this.#C(),n}#C(){const a=this.#f;if(!a)return;const r=this.#n;for(;a.firstChild;)a.removeChild(a.firstChild);a.appendChild(x(r,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,n=t&&V(t.visible)?t.visible():[];let i=!1;for(const f of n){if(!f||f.id===void 0)continue;const u=String(f.id);a.appendChild(x(r,"option",{text:f.title||u,attrs:{value:u}})),u===this.#m&&(i=!0)}i||(this.#m=null),a.value=this.#m||""}#O(){const a=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):S;if(this.#L(),a===0||!V(this.#r.setTimeout)){this.#P();return}this.#y=this.#r.setTimeout(()=>{this.#y=null,this.#P()},a)}#P(){const a=this.#S();if(!a||this.#j)return;const r=this.#s?this.#s.value:"";if(!r){this.#B(),a.clear();return}a.begin(r,{caseSensitive:this.#h,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#M()}),this.#E()}#M(){const a=this.#t&&this.#t.window,r=a&&Number.isFinite(a.first)?a.first:0;return Math.max(0,r)}#E(){if(this.#b!==null||this.#j)return;const a=()=>{this.#b=null,this.#T()};V(this.#r.requestAnimationFrame)?this.#b=this.#r.requestAnimationFrame(a):V(this.#r.setTimeout)?this.#b=this.#r.setTimeout(a,0):a()}#T(){const a=this.#S();!a||this.#j||!a.active||(a.stale&&a.rescan({from:this.#M()}),!a.complete&&(a.step(w)||this.#E()))}#N(){if(!this.#i||this.#j)return;const a=this.#e.find.count(),r=this.#S().active;let t="",n="idle";r&&(a.total===0?(t=a.complete?this.t("find.none"):this.t("find.searching"),n=a.complete?"none":"searching"):(t=this.t(a.complete?"find.count":"find.countPartial",{current:a.current,total:a.total}),n=a.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",n);const i=r&&a.windowed;this.#a.textContent=i?this.t("find.loadedRows"):"",this.#a.style.display=i?"":"none",r?a.complete&&(this.#u.textContent=a.total===0?this.t(i?"a11y.find.noneLoaded":"a11y.find.none"):this.t(i?"a11y.find.countLoaded":"a11y.find.count",{current:a.current,count:a.total})):this.#u.textContent=""}#L(){this.#y!==null&&V(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#y),this.#y=null}#B(){this.#b!==null&&(V(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#b):V(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null)}#_(){this.#L(),this.#B()}}const l=g}),Le("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",x="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 V of X.querySelectorAll(`.${x}[data-col]`))H&&W.has(V.getAttribute("data-col"))?V.classList.add(Q):V.classList.contains(Q)&&V.classList.remove(Q)}destroy(){for(const X of this.#n)X();this.#n=[]}}const I=B}),Le("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 x=K("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function I(W,H){let V=W;for(;V;){if(H(V))return V;V=V.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 V=I(H,z=>z.getAttribute&&z.getAttribute("data-key")!==null);return V?V.getAttribute("data-key"):null}paint(){const H=this.#e.validation;if(!H||!H.active)return;const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll))for(const z of V.querySelectorAll(`.${B}[data-col]`)){const w=z.getAttribute("data-col"),S=this.#r(z),g=S?H.errorFor(S,w):null;x(z,g?g.message:null)}}destroy(){for(const H of this.#n)H();this.#n=[]}}const X=_}),Le("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 S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const x=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",V="lat-presenting__progress",z="lat-cell--dimmed",w=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class S{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(d){this.#e=d.grid,this.#t=d.renderer,this.#n=d.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",a=>this.#a(a))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&x(this.#n.watch)&&this.#r.push(this.#n.watch(a=>{a||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const d=this.#t.viewport?.root;if(d&&x(d.addEventListener)){const a=r=>this.#l(r);d.addEventListener("keydown",a),this.#r.push(()=>d.removeEventListener("keydown",a))}}#l(d){const a=this.#e.presentation;if(!a?.active)return;const r=d.ctrlKey||d.metaKey,t=d.key;if(t==="Escape"&&!this.#n){d.defaultPrevented||(a.stop(),d.preventDefault?.());return}if(r){t==="="||t==="+"?(a.nudge(1),d.preventDefault?.()):t==="-"||t==="_"?(a.nudge(-1),d.preventDefault?.()):t==="0"&&(a.setScale(1.5),d.preventDefault?.());return}if(!a.views.length||I(d.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(a.step(1),d.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(a.step(-1),d.preventDefault?.()):t==="Home"?(a.goTo(0),d.preventDefault?.()):t==="End"?(a.goTo(a.views.length-1),d.preventDefault?.()):(t==="r"||t==="R")&&(a.reset(),d.preventDefault?.())}#a(d){!d||!d.viewId||(this.#u(),this.#e.views?.apply?.(d.viewId),this.#c(d))}#u(){const d=this.#t.viewport?.root;d?.classList&&(d.classList.remove(H),d.offsetWidth,d.classList.add(H))}#c(d){const a=this.#t.viewport?.overlays;if(!a||!this.#e.presentation.views.length)return;const r=a.ownerDocument;if(!r?.createElement)return;if(!this.#i){const i=r.createElement("div");i.className=V,i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),a.appendChild(i),this.#i=i}const t=this.#e.views?.get?.(d.viewId),n=t&&t.name?t.name:"";this.#i.textContent=n?`${n} · ${(d.index||0)+1} / ${d.count||0}`:`${(d.index||0)+1} / ${d.count||0}`}#d(){if(this.#o){this.#h();return}const d=!!(this.#n&&this.#n.active());this.#n&&!d&&this.#n.enter();const a=new Set(this.#e.presentation?.options?.chrome||[]),r=[];for(const n of w){if(a.has(n)||n==="toolPanel"&&this.#j())continue;const i=this.#w(n);i&&i.style&&i.style.display!=="none"&&(i.style.display="none",r.push(i))}const t=this.#y();t&&t.style&&t.style.display!=="none"&&this.#b(t)&&(t.style.display="none",r.push(t)),this.#o={maximised:d,hidden:r},this.#t.viewport?.root?.classList?.add(W),this.#h(),this.#m()}#f(){const d=this.#o;this.#o=null;const a=this.#t.viewport?.root;if(a?.classList?.remove(W),a?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),a?.classList?.remove(H),this.#p(),d){const r=this.#e.toolPanel;r&&x(r.presentRestore)&&r.presentRestore();for(const t of d.hidden)t.style.display="";this.#n&&!d.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#h(){const d=this.#t.viewport?.root;!d||!d.style||(d.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const d=this.#t.viewport?.root;if(!d?.querySelectorAll)return;const a=this.#e.presentation?.active?this.#e.presentation.spotlight:null,r=a&&a.keys.length?new Set(a.keys):null,t=a&&a.colIds.length?new Set(a.colIds):null;for(const n of d.querySelectorAll("[data-key]")){const i=!r||r.has(n.getAttribute("data-key"));for(const f of n.querySelectorAll("[data-col]"))!a||i&&(!t||t.has(f.getAttribute("data-col")))?f.classList.remove(z):f.classList.add(z)}}#m(){this.#g();const d=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(d)||d<=0||!this.#e.presentation.views.length)return;const a=this.#t.viewport?.root?.ownerDocument?.defaultView;a?.setInterval&&(this.#s=a.setInterval(()=>{const r=this.#e.presentation;r.active&&r.goTo(r.index>=r.views.length-1?0:r.index+1)},Math.max(1e3,d)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#y(){const d=this.#e.element;return!d||!x(d.querySelector)?null:d.querySelector(`.${X.statusBar}`)}#b(d){const a=d.children||[];for(const r of a)if(!r.style||r.style.display!=="none")return!1;return!0}#j(){const d=this.#e.toolPanel;return!!(d&&x(d.presentOnly)&&d.presentOnly())}#w(d){const a=this.#e.element;if(!a||!x(a.querySelector))return null;const r={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[d];return r?a.querySelector(r):null}destroy(){this.#o&&this.#f();for(const d of this.#r)d();this.#r=[]}}const g=S}),Le("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 x=K("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function I(V,z,w){const S=w.getComputedStyle(V),g=z.style;if(g)for(let l=0;l<S.length;l++){const d=S[l];B.has(d)||g.setProperty(d,S.getPropertyValue(d),S.getPropertyPriority(d))}}function _(V,z,w){if(I(V,z,w),V.tagName==="CANVAS"&&x(V.toDataURL))try{const l=V.toDataURL("image/png"),d=z.style;d&&(d.setProperty("background-image",`url(${l})`),d.setProperty("background-size","100% 100%"),d.setProperty("background-repeat","no-repeat"))}catch{}const S=V.children||[],g=z.children||[];for(let l=0;l<S.length&&l<g.length;l++)_(S[l],g[l],w)}function X(V,z){if(!V||V.startsWith("data:")||V.startsWith("blob:"))return!0;try{return new URL(V,z).origin===z}catch{return!0}}async function W(V,z={}){const w=V.ownerDocument,S=w?.defaultView;if(!S||typeof S.getComputedStyle!="function")throw new Error("capture needs a browser document");const g=V.getBoundingClientRect(),l=Math.max(1,Math.ceil(g.width)),d=Math.max(1,Math.ceil(g.height)),a=Math.max(.1,Number(z.scale)||2),r=S.location?.origin||"";for(const m of V.querySelectorAll("img")){const c=m.getAttribute("src")||"";if(!X(c,r))throw new Error(`capture refused: the image at ${c} 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=V.cloneNode(!0);_(V,t,S),t.style.width=`${l}px`,t.style.height=`${d}px`,t.style.margin="0";const n=new S.XMLSerializer().serializeToString(t),i=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${d}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${n}</div></foreignObject></svg>`,f=new S.Image;await new Promise((m,c)=>{f.onload=()=>m(void 0),f.onerror=()=>c(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(i)}`});const u=w.createElement("canvas");u.width=Math.round(l*a),u.height=Math.round(d*a);const o=u.getContext("2d");if(!o)throw new Error("capture could not get a 2d context");return o.fillStyle=z.background||S.getComputedStyle(V).backgroundColor||"#ffffff",o.fillRect(0,0,u.width,u.height),o.drawImage(f,0,0,u.width,u.height),new Promise((m,c)=>{u.toBlob(h=>h?m({blob:h,width:u.width,height:u.height}):c(new Error("capture produced no image")),z.type||"image/png",z.quality)})}const H=W}),Le("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 c}});const Q=K("packages/core/src/internal/util.js"),x=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"]),V=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,S="system-ui, -apple-system, sans-serif";function g(h,s){if(!h||typeof h!="object")return null;const p=V[h.type];if(!p)return null;const y=typeof h.id=="string"&&h.id?h.id:B("mark"),O=Array.isArray(h.points)?h.points:[],A=[];for(const v of O){const R=Number(v&&v.x),j=Number(v&&v.y);Number.isFinite(R)&&Number.isFinite(j)&&A.push({x:R,y:j})}const b=typeof h.colour=="string"&&h.colour?h.colour:s;if(p==="text"){const v=typeof h.text=="string"?h.text:"";if(!A.length||!v)return null;const R={id:y,tool:p,colour:b,points:[A[0]],text:v,region:l(h.region)},j=Number(h.fontSize);return Number.isFinite(j)&&j>0&&(R.fontSize=j),typeof h.background=="string"&&h.background&&(R.background=h.background),R}return A.length<2?null:{id:y,tool:p,colour:b,points:A,region:l(h.region)}}function l(h){return h==="start"||h==="end"?h:"centre"}function d(h){const s={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")&&(s.region=h.region),h.tool==="text"&&(s.text=h.text,h.fontSize!==void 0&&(s.fontSize=h.fontSize),h.background!==void 0&&(s.background=h.background)),s}const a="lat-annotate",r=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(h){return h==="arrow"||h==="rect"}function n(h,s){return{id:h,count:s,valueOf(){return this.count}}}const i=10;function f(h,s,p){const y=p.x-s.x,O=p.y-s.y,A=y*y+O*O;let b=A?((h.x-s.x)*y+(h.y-s.y)*O)/A:0;b=Math.max(0,Math.min(1,b));const v=s.x+b*y,R=s.y+b*O;return Math.hypot(h.x-v,h.y-R)}function u(h){const s=h.points;if(!s.length)return null;if(h.tool==="text"){const b=h.fontSize||w,v=(h.text||"").length*b*.6;return{x1:s[0].x,y1:s[0].y,x2:s[0].x+v,y2:s[0].y+b*1.2}}let p=1/0,y=1/0,O=-1/0,A=-1/0;for(const b of s)p=Math.min(p,b.x),y=Math.min(y,b.y),O=Math.max(O,b.x),A=Math.max(A,b.y);return{x1:p,y1:y,x2:O,y2:A}}function o(h,s){const p=u(h);if(!p)return 1/0;if(h.tool==="text"||h.tool==="rect"){if(s.x>=p.x1&&s.x<=p.x2&&s.y>=p.y1&&s.y<=p.y2)return 0;if(h.tool==="text")return 1/0}const y=h.points;if(h.tool==="rect"){const A=[{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 b=1/0;for(let v=0;v<4;v++)b=Math.min(b,f(s,A[v],A[(v+1)%4]));return b}if(y.length===1)return Math.hypot(s.x-y[0].x,s.y-y[0].y);let O=1/0;for(let A=0;A<y.length-1;A++)O=Math.min(O,f(s,y[A],y[A+1]));return O}class m{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;#c=null;constructor(s){this.#e=s.grid,this.#t=s.renderer,this.#u=Array.isArray(s.seed)?s.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(s){const p=g(s,this.#i);return p?(p.durable=!0,this.#s.push(p),this.#P(),this.redraw(),this.#T(),n(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.`),n(null,this.#s.length))}list(){return this.#s.map(d)}remove(s){const p=this.#s.findIndex(y=>y.id===s);return p<0?(I("annotate.remove.unknown",`annotate.remove ignored an unknown id: "${s}".`),!1):(this.#s.splice(p,1),this.#c===s&&(this.#c=null),this.redraw(),this.#T(),!0)}replaceAll(s){const p=Array.isArray(s)?s:[];this.#s=p.map(y=>g(y,this.#i)).filter(Boolean);for(const y of this.#s)y.durable=!0;this.#s.length&&this.#P(),this.redraw(),this.#T()}#d(){const s=this.#t.viewport?.root;if(!s||!x(s.addEventListener))return;const p=y=>{if(!(!this.#o||!y)){if(y.key==="Escape"){this.use(null),y.preventDefault?.();return}if(this.#o==="erase"){if(y.key==="Tab"){this.#f(y);return}(y.key==="Delete"||y.key==="Backspace")&&this.#h(y)}}};s.addEventListener("keydown",p,!0),this.#a.push(()=>s.removeEventListener("keydown",p,!0))}#f(s){if(!this.#s.length){this.#L("a11y.annotate.noMarks");return}s.preventDefault?.();const p=this.#c?this.#s.findIndex(A=>A.id===this.#c):-1,y=s.shiftKey?-1:1,O=p<0?y>0?0:this.#s.length-1:(p+y+this.#s.length)%this.#s.length;this.#c=this.#s[O].id,this.redraw(),this.#L("a11y.annotate.focusedMark",{at:O+1,of:this.#s.length})}#h(s){if(!this.#c)return;s.preventDefault?.();const p=this.#c;this.remove(p),this.#L("a11y.annotate.erased")}#p(){const s=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!s||!x(s.matchMedia))return;let p=null;const y=()=>{const O=s.devicePixelRatio||1;let A;try{A=s.matchMedia(`(resolution: ${O}dppx)`)}catch{return}p=A;const b=()=>{this.redraw(),y()};x(A.addEventListener)?A.addEventListener("change",b,{once:!0}):x(A.addListener)&&A.addListener(b)};y(),this.#a.push(()=>{p=null})}use(s,p={}){const y=!!p.colour&&s===this.#o;p.colour&&(this.#i=String(p.colour));const O=s&&W.includes(s)?s:null;this.#o=O&&O===this.#o&&!y?null:O,this.#o!=="erase"&&(this.#c=null);const A=this.#o?this.#P():this.#n;return A&&(A.style.pointerEvents=this.#o?"auto":"none",A.style.cursor=this.#o?"crosshair":""),this.#T(),this.#o}undo(){const s=this.#s.pop();return s&&this.#c===s.id&&(this.#c=null),this.redraw(),this.#T(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#T())}#m(){const s=this.#s.filter(p=>p.durable);s.length!==this.#s.length&&(this.#s=s,this.redraw(),this.#T())}redraw(){!this.#n&&this.#s.length&&this.#P();const s=this.#n,p=this.#r;if(!s||!p)return;this.#M();const{left:y,top:O}=this.#O();p.clearRect(0,0,s.width,s.height);const A=this.#l?[...this.#s,this.#l]:this.#s;for(const b of["centre","start","end"]){const v=A.filter(R=>l(R.region)===b);if(v.length){p.save(),this.#g(p,b),p.translate((b==="centre"?-y:0)||0,-O||0);for(const R of v)this.#w(p,R),R.id===this.#c&&this.#v(p,R);p.restore()}}}#g(s,p="centre"){const y=this.#n,O=this.#t.viewport?.bodyViewport;if(!x(y?.getBoundingClientRect)||!x(O?.getBoundingClientRect))return;const A=y.getBoundingClientRect(),b=O.getBoundingClientRect();if(!b.width||!b.height)return;const v=this.#y(p,b);v&&(s.beginPath(),s.rect(v.left-A.left,b.top-A.top,v.width,b.height),s.clip())}#y(s,p){const y=j=>{if(!x(j?.getBoundingClientRect))return null;const F=j.getBoundingClientRect();return F&&F.width>0?{left:F.left,width:F.width}:null},O=y(this.#t.viewport?.bodyStart),A=y(this.#t.viewport?.bodyEnd);if(s==="start")return O;if(s==="end")return A;let b=p.left,v=p.left+p.width;const R=p.left+p.width/2;for(const j of[O,A]){if(!j)continue;const F=j.left+j.width;j.left+j.width/2<R?b=Math.max(b,F):v=Math.min(v,j.left)}return v>b?{left:b,width:v-b}:null}#b(s){for(const[p,y]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!x(y?.getBoundingClientRect))continue;const O=y.getBoundingClientRect();if(O&&O.width>0&&s>=O.left&&s<O.left+O.width)return p}return"centre"}#j(s){const p=this.#t.viewport?.bodyViewport;if(!x(p?.getBoundingClientRect))return!0;const y=p.getBoundingClientRect();return!y.width||!y.height?!0:s.clientX>=y.left&&s.clientX<=y.right&&s.clientY>=y.top&&s.clientY<=y.bottom}#w(s,p){const y=p.points;if(!y.length)return;const O=this.#e.presentation?.scale||1;s.lineWidth=(r[p.tool]||3)*O,s.strokeStyle=p.colour,s.fillStyle=p.colour,s.lineCap="round",s.lineJoin="round",s.globalAlpha=p.tool==="highlight"?.32:1;const A=y[0],b=y[y.length-1];if(p.tool==="text"){const v=(p.fontSize||w)*O;s.font=`${v}px ${S}`,s.textBaseline="top";const R=p.text||"";if(p.background){let j=R.length*v*.6;if(typeof s.measureText=="function"){const F=s.measureText(R);F&&Number.isFinite(F.width)&&(j=F.width)}s.fillStyle=p.background,s.fillRect(A.x-v*.15,A.y-v*.1,j+v*.3,v*1.2)}s.fillStyle=p.colour,s.fillText(R,A.x,A.y),s.globalAlpha=1;return}if(p.tool==="rect")s.strokeRect(A.x,A.y,b.x-A.x,b.y-A.y);else if(p.tool==="arrow")s.beginPath(),s.moveTo(A.x,A.y),s.lineTo(b.x,b.y),s.stroke(),this.#S(s,A,b,s.lineWidth);else{s.beginPath(),s.moveTo(A.x,A.y);for(let v=1;v<y.length;v++)s.lineTo(y[v].x,y[v].y);s.stroke()}s.globalAlpha=1}#S(s,p,y,O){const A=Math.atan2(y.y-p.y,y.x-p.x),b=Math.max(8,O*3);s.beginPath(),s.moveTo(y.x,y.y),s.lineTo(y.x-b*Math.cos(A-Math.PI/7),y.y-b*Math.sin(A-Math.PI/7)),s.lineTo(y.x-b*Math.cos(A+Math.PI/7),y.y-b*Math.sin(A+Math.PI/7)),s.closePath(),s.fill()}#v(s,p){const y=u(p);if(!y||!x(s.strokeRect))return;const O=6;s.save(),s.setLineDash?.([4,3]),s.strokeStyle="#1a73e8",s.lineWidth=2,s.globalAlpha=1,s.strokeRect(y.x1-O,y.y1-O,y.x2-y.x1+O*2,y.y2-y.y1+O*2),s.restore()}#C(s,p){const y=this.#e.presentation?.scale||1,O=i*y;for(let A=this.#s.length-1;A>=0;A--){const b=this.#s[A];if(l(b.region)===p&&o(b,s)<=O)return b}return null}#O(){const s=x(this.#t.scrollPosition)?this.#t.scrollPosition():null,p=this.#t.viewport?.rtl===!0;return{left:X(s?.left||0,p),top:s?.top||0}}#P(){if(this.#n)return this.#n;const s=this.#t.viewport?.overlays,p=s?.ownerDocument;if(!s||!p?.createElement)return null;const y=p.createElement("canvas");return y.className=a,y.style.position="absolute",y.style.inset="0",y.style.pointerEvents="none",s.appendChild(y),this.#n=y,this.#r=y.getContext?y.getContext("2d"):null,this.#M(),this.#E(y),y}#M(){const s=this.#n,p=this.#t.viewport?.root;if(!s||!p?.getBoundingClientRect)return;const y=p.getBoundingClientRect(),A=s.ownerDocument?.defaultView?.devicePixelRatio||1,b=Math.max(1,Math.round(y.width*A)),v=Math.max(1,Math.round(y.height*A));s.width===b&&s.height===v||(s.width=b,s.height=v,s.style&&(s.style.width=`${Math.max(1,y.width)}px`,s.style.height=`${Math.max(1,y.height)}px`),this.#r?.setTransform(A,0,0,A,0,0))}#E(s){const p=(v,R="centre")=>{const j=s.getBoundingClientRect(),{left:F,top:C}=this.#O();return{x:v.clientX-j.left+(R==="centre"?F:0),y:v.clientY-j.top+C}},y=v=>{if(!this.#o||!this.#j(v))return;const R=this.#b(v.clientX);if(this.#o==="erase"){const j=this.#C(p(v,R),R);j&&(this.remove(j.id),this.#L("a11y.annotate.erased")),v.preventDefault?.();return}this.#l={id:B("mark"),tool:this.#o,colour:this.#i,points:[p(v,R)],region:R},s.setPointerCapture?.(v.pointerId),v.preventDefault?.()},O=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()},A=v=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,s.releasePointerCapture?.(v.pointerId),this.redraw(),this.#T())},b=v=>{if(!this.#o)return;const R=this.#t.viewport?.bodyViewport;if(!R)return;let j=!1;v.deltaY&&typeof R.scrollTop=="number"&&(R.scrollTop+=v.deltaY,j=!0),v.deltaX&&typeof R.scrollLeft=="number"&&(R.scrollLeft+=v.deltaX,j=!0),j&&v.preventDefault?.()};s.addEventListener("pointerdown",y),s.addEventListener("pointermove",O),s.addEventListener("pointerup",A),s.addEventListener("pointercancel",A),s.addEventListener("wheel",b,{passive:!1}),this.#a.push(()=>{s.removeEventListener("pointerdown",y),s.removeEventListener("pointermove",O),s.removeEventListener("pointerup",A),s.removeEventListener("pointercancel",A),s.removeEventListener("wheel",b)})}#T(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#N(s,p){const y=this.#e.messages;return y&&x(y.t)?y.t(s,p):s}#L(s,p){this.#t.announce?.(this.#N(s,p),{repeat:!0})}destroy(){for(const s of this.#a)s();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const c=m}),Le("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 V}});const x=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 S=Math.round(w/60);return S<60?`${S}m ago`:`${Math.round(S/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,S=w.depth,g=w.position;this.#r.max=String(Math.max(1,S)),this.#r.value=String(Math.max(0,S-g)),this.#r.disabled=S===0;const l=w.at(),d=w.live;this.#o&&(this.#o.textContent=d?this.#l("timeline.live"):X(Date.now()-(l||Date.now())),this.#o.setAttribute("data-live",d?"true":"false")),this.#i&&(this.#i.textContent=S===0?this.#l("timeline.recording"):W(l,this.#e.get("locale"))),this.#n.setAttribute("data-live",d?"true":"false")}#l(w,S){const g=this.#e;return(g&&g.messages?g.messages:I).t(w,S)}#a(){if(this.#n)return;const w=this.#t.viewport?.overlays,S=w?.ownerDocument;if(!w||!S?.createElement)return;const g=S.createElement("div");g.className=_;const l=S.createElement("span");l.className=`${_}__ago`,l.setAttribute("role","status"),l.setAttribute("aria-live","polite");const d=S.createElement("input");d.className=`${_}__range`,d.type="range",d.min="0",d.step="1",d.setAttribute("aria-label",this.#l("timeline.scrub"));const a=S.createElement("span");a.className=`${_}__clock`;const r=S.createElement("button");r.className=`${_}__live`,r.type="button",r.textContent=this.#l("timeline.goLive"),r.setAttribute("aria-label",this.#l("timeline.returnToPresent")),g.appendChild(l),g.appendChild(d),g.appendChild(a),g.appendChild(r),w.appendChild(g),this.#n=g,this.#r=d,this.#o=l,this.#i=a;const t=()=>{const f=this.#e.timeline.depth;this.#e.timeline.seek(f-Number(d.value))};d.addEventListener("input",t);const n=()=>this.#e.timeline.toLive();r.addEventListener("click",n);const i=f=>f.stopPropagation();d.addEventListener("keydown",i),this.#s.push(()=>{d.removeEventListener("input",t),r.removeEventListener("click",n),d.removeEventListener("keydown",i)})}#u(){this.#n&&(x(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 V=H}),Le("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 x=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",V="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 d=[];for(const a of l.querySelectorAll("[data-key]")){const r=a.getAttribute("data-key");if(r){d.push(r);for(const t of a.querySelectorAll("[data-col]")){const n=t.getAttribute("data-col"),i=g.at(r,n),f=!!(i&&i.count);t.classList.toggle(H,f),t.classList.toggle(V,f&&i.unresolved>0),this.#i(t,i,n)}}}(d.length!==this.#r.length||d.some((a,r)=>a!==this.#r[r]))&&(this.#r=d,g.request(d))}#o(g,l){const d=this.#e;return(d&&d.messages?d.messages:I).t(g,l)}#i(g,l,d){if(!l||!l.count){g.hasAttribute("aria-description")&&g.removeAttribute("aria-description");return}const a=l.count,r=l.unresolved,t=this.#o("count.comments",{count:a});g.setAttribute("aria-description",r>0?this.#o("comments.someUnresolved",{comments:t,unresolved:r}):this.#o("comments.allResolved",{comments:t}))}#s(){const g=this.#t.viewport?.root;if(!g||!x(g.addEventListener))return;const l=a=>{const r=this.#e.comments;if(!r||!r.enabled)return;const t=a.target&&x(a.target.closest)?a.target.closest("[data-col]"):null;if(!t||!t.classList.contains(H)||!this.#l(t,a))return;const n=t.closest("[data-key]"),i=n&&n.getAttribute("data-key");i&&(a.stopPropagation(),a.preventDefault(),r.open(i,t.getAttribute("data-col")))},d=a=>{const r=this.#e.comments;if(!r||!r.enabled||!a.altKey||a.key!=="m"&&a.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&x(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const n=t.closest("[data-key]"),i=n&&n.getAttribute("data-key");i&&(a.preventDefault(),a.stopPropagation(),r.open(i,t.getAttribute("data-col")))};g.addEventListener("click",l,!0),g.addEventListener("keydown",d,!0),this.#n.push(()=>{g.removeEventListener("click",l,!0),g.removeEventListener("keydown",d,!0)})}#l(g,l){if(!x(g.getBoundingClientRect))return!1;const d=g.getBoundingClientRect(),a=Math.max(14,Math.min(24,d.height*.6));return(X(g)?l.clientX<=d.left+a:l.clientX>=d.right-a)&&l.clientY<=d.top+a}destroy(){for(const g of this.#n)g();this.#n=[]}}const w=z}),Le("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 x=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,V="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,d=>this.#l(l,d)));this.#a(),this.paint()}}#l(g,l){if(this.#f(),g==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const a=l&&l.peer;a&&(this.#r.textContent=this.#h(g==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:a.name}))}#a(){const g=this.#t.viewport?.overlays,l=g?.ownerDocument;if(!g||!l?.createElement)return;const d=this.#e.get("presence")||{},a=l.createElement("span");if(a.className=`${V}__live`,a.setAttribute("role","status"),a.setAttribute("aria-live","polite"),g.appendChild(a),this.#r=a,d.roster===!1)return;const r=l.createElement("div");r.className=V,d.roster&&d.roster.side==="start"&&r.setAttribute("data-side","start"),r.style.pointerEvents="auto",g.appendChild(r),this.#n=r}paint(){const g=this.#e.presence,l=this.#t.viewport?.root;if(!g||!g.enabled||!l?.querySelectorAll)return;this.#d(l);const d=g.peers(),a=[...d].sort((r,t)=>r.at-t.at);for(const r of a)for(const t of r.ranges||[])for(const n of t.rowIds||[])for(const i of t.columns||[])this.#c(l,n,i,r,"range");for(const r of a)r.cursor&&this.#c(l,r.cursor.rowId,r.cursor.colId,r,"cursor");for(const r of a)r.editing&&this.#c(l,r.editing.rowId,r.editing.colId,r,"edit");this.#f(),this.#u(d)}#u(g){if(this.#s!==null)return;const l=g.filter(r=>r.cursorFresh);if(!l.length)return;const a=Math.max(...l.map(r=>r.cursorAt||0))+H-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,a))}#c(g,l,d,a,r){const t=g.querySelector(`[data-key="${X(l)}"]`),n=t&&t.querySelector(`[data-col="${X(d)}"]`);n&&(n.setAttribute("data-presence",r),n.style.setProperty("--lat-peer",a.colour),n.setAttribute("data-peer-name",a.name),n.setAttribute("data-peer-initial",a.initials||(a.name||"?").slice(0,1).toUpperCase()),a.idle?n.setAttribute("data-peer-idle","true"):n.removeAttribute("data-peer-idle"),r==="cursor"&&a.cursorFresh&&n.setAttribute("data-peer-fresh","true"),this.#o.add(`${l}${d}`))}#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 a of l){const r=g.createElement("button");r.className=`${V}__peer`,r.type="button",r.style.setProperty("--lat-peer",a.colour),r.toggleAttribute("data-idle",!!a.idle),r.toggleAttribute("data-hidden",!!a.hidden);let t="presence.peer";a.hidden?t="presence.peerHidden":a.idle&&(t="presence.peerIdle"),r.setAttribute("aria-label",this.#h(t,{name:a.name}));const n=g.createElement("span");n.className=`${V}__dot`,n.setAttribute("aria-hidden","true"),n.textContent=a.initials||(a.name||"?").slice(0,1).toUpperCase(),r.appendChild(n);const i=g.createElement("span");i.className=`${V}__name`,i.textContent=a.name,r.appendChild(i),r.addEventListener("click",()=>this.#e.presence.jumpTo(a.id)),this.#n.appendChild(r)}const d=l.filter(a=>a.hidden).length;if(d){const a=g.createElement("span");a.className=`${V}__hidden`,a.textContent=this.#h("presence.hidden",{count:d}),this.#n.appendChild(a)}}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 d=this.#e;return(d&&d.messages?d.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&&x(this.#n.remove)&&this.#n.remove(),this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const w=z}),Le("packages/dom/src/commentpanel.js",function(e,K){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return S}}),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 d}});const x=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,V="lat-comments",z=/^(https?:|mailto:)/i,w='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function S(a,r){if(!Number.isFinite(a))return"";const t=Math.max(0,Math.round((r-a)/1e3));if(t<60)return"just now";const n=Math.round(t/60);if(n<60)return`${n}m ago`;const i=Math.round(n/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function g(a,r,t,n){r.textContent="";const i=String(t??"");if(!n){r.textContent=i;return}const f=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let u=0,o=f.exec(i);for(;o;){o.index>u&&r.appendChild(a.createTextNode(i.slice(u,o.index)));const m=o[0];if(m.startsWith("*")){const c=a.createElement("em");c.textContent=m.slice(1,-1),r.appendChild(c)}else if(m.startsWith("`")){const c=a.createElement("code");c.textContent=m.slice(1,-1),r.appendChild(c)}else{const c=m.indexOf("]("),h=m.slice(1,c),s=m.slice(c+2,-1);if(z.test(s)){const p=a.createElement("a");p.href=s,p.textContent=h,p.rel="noopener noreferrer",p.target="_blank",r.appendChild(p)}else r.appendChild(a.createTextNode(h))}u=o.index+m.length,o=f.exec(i)}u<i.length&&r.appendChild(a.createTextNode(i.slice(u)))}class l{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(r){this.#e=r.grid,this.#t=r.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",r=>this.#a(r))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#b(),this.#w()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(r){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#f(r.rowId,r.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#b(),this.#w(),this.#o&&x(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const r=this.#s;this.#s=null,r&&x(r.focus)&&r.focus()}#c(){const r=this.#e.comments.openKey;if(!r)return;const{rowId:t}=H(r);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(r){if(!this.#r)return;const n=this.#r.ownerDocument.createElement("p");n.className=`${V}__note`,n.setAttribute("role","status"),n.textContent=r,this.#r.appendChild(n)}#f(r,t){const n=this.#t.viewport?.root;if(!n||!n.querySelector)return null;const i=n.querySelector(`[data-key="${X(r)}"]`);return i?i.querySelector(`[data-col="${t}"]`):null}#h(r,t){const n=this.#e;return(n&&n.messages?n.messages:I).t(r,t)}#p(r){const t=r.createElement("div");t.className=V,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#h("comments.panel"));const n=r.createElement("header");n.className=`${V}__head`;const i=r.createElement("div");i.className=`${V}__title`,n.appendChild(i);const f=r.createElement("button");f.className=`${V}__resolve`,f.type="button",n.appendChild(f);const u=r.createElement("button");u.className=`${V}__close`,u.type="button",u.setAttribute("aria-label",this.#h("comments.close")),u.textContent="×",n.appendChild(u);const o=r.createElement("div");o.className=`${V}__list`,o.setAttribute("role","log"),o.setAttribute("aria-live","polite");const m=r.createElement("form");m.className=`${V}__composer`;const c=r.createElement("textarea");c.className=`${V}__input`,c.rows=2,c.setAttribute("aria-label",this.#h("comments.write"));const h=r.createElement("button");h.className=`${V}__send`,h.type="submit",h.textContent=this.#h("comments.post"),m.appendChild(c),m.appendChild(h),t.appendChild(n),t.appendChild(o),t.appendChild(m),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=o,this.#o=c,this.#m=i,this.#g=f;const s=A=>{A.preventDefault();const b=String(c.value||"").trim();b&&(c.value="",this.#e.comments.add(b))},p=()=>this.#e.comments.close(),y=()=>{this.#y()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},O=A=>{if(A.stopPropagation(),A.key==="Escape"){A.preventDefault(),this.#e.comments.close();return}if(A.key!=="Tab")return;const b=[...t.querySelectorAll(w)].filter(F=>F.offsetParent!==null||F===c);if(!b.length)return;const v=b[0],R=b[b.length-1],j=t.ownerDocument.activeElement;A.shiftKey&&j===v?(A.preventDefault(),R.focus()):!A.shiftKey&&j===R&&(A.preventDefault(),v.focus())};m.addEventListener("submit",s),u.addEventListener("click",p),f.addEventListener("click",y),t.addEventListener("keydown",O),this.#l.push(()=>{m.removeEventListener("submit",s),u.removeEventListener("click",p),f.removeEventListener("click",y),t.removeEventListener("keydown",O)})}#m=null;#g=null;#y(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#b(){const r=this.#e.comments;if(!this.#n||!r.openKey)return;const t=this.#n.ownerDocument,n=this.#e.get("comments")||{},i=Date.now(),f=r.openKey,{rowId:u,field:o}=H(f),m=this.#e.columns.get(o),c=this.#e.rows.byKey(u),h=x(n.rowLabel)&&c?n.rowLabel(c):u;if(this.#m.textContent=this.#h("comments.cellTitle",{column:m&&(m.title??m.id)||o,row:h}),this.#g.textContent=this.#y()>0?this.#h("comments.resolve"):this.#h("comments.reopen"),this.#r.textContent="",r.loading){this.#d(this.#h("comments.loading"));return}const s=r.thread||[];if(!s.length){this.#d(this.#h("comments.empty"));return}const p=c&&m?m.getValue(c.data,c):void 0;for(const y of s)this.#r.appendChild(this.#j(t,y,i,p,n))}#j(r,t,n,i,f){const u=r.createElement("article");u.className=`${V}__item`,t.pending&&u.setAttribute("data-pending","true"),t.resolved&&u.setAttribute("data-resolved","true");const o=r.createElement("div");o.className=`${V}__meta`;const m=r.createElement("span");m.className=`${V}__author`,m.textContent=t.author&&(t.author.name||t.author.initials)||this.#h("comments.unknownAuthor"),o.appendChild(m);const c=r.createElement("time");c.className=`${V}__time`;const h=S(t.at,n);c.textContent=t.edited?this.#h("comments.edited",{time:h}):h,o.appendChild(c),u.appendChild(o);const s=r.createElement("div");if(s.className=`${V}__body`,g(r,s,t.body,!!f.markdown),u.appendChild(s),t.value!==void 0&&!Object.is(t.value,i)){const O=r.createElement("p");O.className=`${V}__moved`,O.textContent=this.#h("comments.valueMoved",{was:String(t.value),now:String(i)}),u.appendChild(O)}const p=t.can||{},y=O=>p[O]!==!1;if(y("edit")||y("delete")){const O=r.createElement("div");if(O.className=`${V}__actions`,y("delete")){const A=r.createElement("button");A.type="button",A.className=`${V}__action`,A.textContent=this.#h("comments.delete"),A.addEventListener("click",()=>this.#e.comments.remove(t.id)),O.appendChild(A)}u.appendChild(O)}return u}#w(){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:n,field:i}=H(t),f=this.#f(n,i)||this.#i,u=this.#t.viewport?.root;if(!f||!u||!x(f.getBoundingClientRect))return;const o=f.getBoundingClientRect(),m=u.getBoundingClientRect(),c=this.#n.getBoundingClientRect();let h=o.bottom-m.top+4;h+c.height>m.height&&o.top-m.top>c.height&&(h=o.top-m.top-c.height-4);let s=o.left-m.left;s+c.width>m.width&&(s=Math.max(0,m.width-c.width-4)),this.#n.style.top=`${Math.max(0,h)}px`,this.#n.style.left=`${Math.max(0,s)}px`;const p=o.bottom<m.top||o.top>m.bottom;this.#n.toggleAttribute("data-offscreen",p)}destroy(){for(const r of this.#l)r();this.#l=[],this.#n&&x(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const d=l}),Le("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 S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const x=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",V="https://www.latticegrid.dev",z=["br","bl","tl","tr"],w=4e3;class S{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(d){this.#e=d.grid,this.#t=d.document,this.#n=d.element,this.#i=d.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),x(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const d=this.#e.licence&&this.#e.licence.ready;d&&x(d.then)&&d.then(()=>this.refresh(),()=>this.refresh())}refresh(){const d=this.#d();d&&!this.#r?(this.#f(),this.#u()):!d&&this.#r&&(this.#h(),this.#c())}#a(){const d=this.#i;if(!d||!x(d.matchMedia))return!1;try{return!!d.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),x(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&&x(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const d=this.#e.licence;return!!(d&&x(d.watermark)&&d.watermark())}#f(){const d=this.grid&&this.grid.messages?this.grid.messages:I,a=X(this.#t,"a",{class:`${H}__link`,text:d.t("licence.watermark"),attrs:{href:V,target:"_blank",rel:"noopener noreferrer"}}),r=X(this.#t,"span",{class:`${H}__free`,text:d.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:[a,r]}),this.#o.push(W(this.#r,"pointerdown",t=>{x(t.stopPropagation)&&t.stopPropagation()})),this.#n&&x(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#h(){this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const d of this.#o)d();this.#o=[],this.#h()}}const g=S}),Le("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_MAXIMISE_Z",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"MAXIMISE_Z_PROP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/internal/util.js"),x=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,V="lat-maximised",z={top:"0px",left:"0px",right:"0px",bottom:"0px",width:"auto",height:"auto",minWidth:"0px",minHeight:"0px",maxWidth:"none",maxHeight:"none",margin:"0px"},w="1000",S="--lattice-maximise-z",g="lat-maximised-host",l="lat-maximise-placeholder";class d{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=w;#c=null;#d=!1;#f=null;constructor(t){this.#e=t.element,this.#t=t.document,this.#n=B(t.onChange)?t.onChange:null,this.#r=B(t.captureScroll)?t.captureScroll:null,this.#o=B(t.restoreScroll)?t.restoreScroll:null,t.zIndex!==void 0&&t.zIndex!==null&&(this.#u=String(t.zIndex)),t.container&&B(t.container.appendChild)&&(this.#c=t.container)}active(){return this.#i!==null}enter(){if(this.active())return!0;const t=this.#e.parentNode,n=this.#c||this.#t.body;if(!t||!n||!this.#t.body)return x("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=_(this.#t,"div",{class:l}),this.#i.style.visibility="hidden";const i=this.#e.offsetWidth,f=this.#e.offsetHeight;i&&(this.#i.style.width=`${i}px`),f&&(this.#i.style.height=`${f}px`);const u=this.#r?this.#r():null,o=B(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?H(this.#c||t):null;o&&(this.#e.setAttribute("data-theme",o),this.#d=!0),t.insertBefore(this.#i,this.#e),this.#p(()=>n.appendChild(this.#e)),this.#a={};for(const[m,c]of Object.entries(this.#h()))this.#a[m]=this.#e.style[m]||"",this.#e.style[m]=c;return this.#f=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#t.body.style&&B(this.#t.body.style.setProperty)&&this.#t.body.style.setProperty(S,this.#u),this.#e.classList.add(V),this.#t.body.classList&&this.#t.body.classList.add(g),u&&this.#o&&this.#o(u),this.#s=X(this.#t,"keydown",m=>this.#m(m)),this.#g(),!0}#h(){return{...z,position:this.#c?"absolute":"fixed",zIndex:this.#u}}exit(){if(!this.active())return!1;const t=this.#r?this.#r():null,n=this.#i,i=n.parentNode;if(i&&B(i.insertBefore)&&this.#p(()=>i.insertBefore(this.#e,n)),B(n.remove)&&n.remove(),this.#i=null,this.#d&&(this.#e.removeAttribute("data-theme"),this.#d=!1),this.#a){for(const[f,u]of Object.entries(this.#a))this.#e.style[f]=u;this.#a=null}return this.#f!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#f),this.#f=null,this.#t.body&&this.#t.body.style&&B(this.#t.body.style.removeProperty)&&this.#t.body.style.removeProperty(S),this.#e.classList.remove(V),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(g),t&&this.#o&&this.#o(t),this.#s&&this.#s(),this.#s=null,this.#g(),!0}toggle(){return this.active()?!this.exit():this.enter()}#p(t){const n=this.#t.activeElement,i=n&&n!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(n)?n:null;t(),i&&B(i.focus)&&i.focus()}#m(t){!t||t.key!=="Escape"||t.defaultPrevented||this.exit()}#g(){this.#n&&this.#n();for(const t of this.#l)t(this.active())}watch(t){return B(t)?(this.#l.add(t),()=>this.#l.delete(t)):()=>{}}destroy(){this.exit()}}const a=d}),Le("packages/dom/src/promptbar.js",function(e,K){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),x=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,V=K("packages/core/src/internal/util.js").isFunction,z=K("packages/core/src/ai/schema.js"),w=z.describeGrid,S=z.promptText,g=K("packages/core/src/ai/intent.js"),l=g.applyPlan,d=g.buildPrompt,a=g.planIntent,r="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;#y="idle";#b=0;#j=!1;#w=[];t(u,o){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(u,o)}init(u={}){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||W,this.#e=x(u),this.#t=u.grid||null,this.#n=V(u.ask)?u.ask:null,this.#r=u.schemaOptions||{},this.#o=u.context,this.#i={onPlan:V(u.onPlan)?u.onPlan:null,onApply:V(u.onApply)?u.onApply:null,onError:V(u.onError)?u.onError:null},this.#s=B(this.#e,"div",{class:r,attrs:{"data-state":"idle",role:"search"}}),this.#S(u)}element(){return this.#s}refresh(){this.#j||!this.#s||this.#y!=="busy"&&this.#P()}destroy(){this.#j=!0,this.#b++;for(const u of this.#w)u();this.#w.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.#j||this.#y==="busy")return null;const o=String(u??(this.#l&&this.#l.value)??"").trim();if(!o)return null;if(!this.#n)return this.#E("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const m=++this.#b;this.#v("busy"),this.#M("Thinking…");let c;try{const h=w(this.#t,this.#r),s=S(h);if(c=await this.#n({prompt:o,schema:h,schemaText:s,message:d(o,s),context:this.#o}),this.#j||m!==this.#b)return null;const p=a(c,h);return this.#C(p),p}catch(h){return this.#j||m!==this.#b||(this.#i.onError&&this.#i.onError(h),this.#E(h instanceof Error?h.message:String(h))),null}}apply(){const u=this.#g;if(this.#j||!u||!u.ok)return null;const o=this.#t?.ai,m=V(o?.apply)?o.apply(u):l(u,this.#t);return this.#i.onApply&&this.#i.onApply(m,u),this.#P(),this.#l&&(this.#l.value=""),m.failed.length?this.#E(`Applied ${m.applied.length}; ${m.failed.map(c=>`${c.type} failed: ${c.reason}`).join("; ")}`):this.#M(`Applied: ${u.describe()}`),m}discard(){this.#j||(this.#P(),this.#M("Discarded."))}#S(u){const o=this.#e,m=B(o,"div",{class:`${r}__row`});this.#l=B(o,"input",{class:`${r}__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.#w.push(I(this.#l,"keydown",h=>{const s=h&&h.key;s==="Enter"?(V(h.preventDefault)&&h.preventDefault(),this.ask()):s==="Escape"&&this.#g&&(V(h.preventDefault)&&h.preventDefault(),this.discard())})),m.appendChild(this.#l),this.#a=B(o,"button",{class:`${r}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#w.push(I(this.#a,"click",()=>{this.ask()})),m.appendChild(this.#a),this.#s.appendChild(m),this.#u=B(o,"div",{class:`${r}__preview`,attrs:{hidden:!0}}),this.#c=B(o,"p",{class:`${r}__summary`}),this.#d=B(o,"ul",{class:`${r}__notes`});const c=B(o,"div",{class:`${r}__buttons`});this.#f=B(o,"button",{class:`${r}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#h=B(o,"button",{class:`${r}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#w.push(I(this.#f,"click",()=>{this.apply()})),this.#w.push(I(this.#h,"click",()=>{this.discard()})),c.appendChild(this.#f),c.appendChild(this.#h),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(c),this.#s.appendChild(this.#u),this.#p=B(o,"p",{class:`${r}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(o,"p",{class:`${r}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#v(u){if(this.#y=u,!this.#s)return;this.#s.setAttribute("data-state",u);const o=u==="busy";n(this.#l,o),n(this.#a,o),this.#a&&(this.#a.textContent=this.t(o?"prompt.asking":"prompt.ask")),i(this.#u,u!=="preview"),i(this.#m,u!=="error")}#C(u){const o=u;if(this.#i.onPlan&&this.#i.onPlan(u),!o.ok){this.#g=null;const m=o.rejected.length?o.rejected.map(c=>c.reason).join("; "):"nothing to do";this.#E(`I could not turn that into a change: ${m}`);return}this.#g=u,this.#M(""),this.#c&&(this.#c.textContent=o.describe()),this.#O(o.rejected),this.#v("preview")}#O(u){const o=this.#d;if(o){_(o),i(o,!u.length);for(const m of u.slice(0,6))o.appendChild(B(this.#e,"li",{class:`${r}__note`,text:m.reason}));u.length>6&&o.appendChild(B(this.#e,"li",{class:`${r}__note`,text:this.t("prompt.moreNotes",{count:u.length-6})}))}}#P(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&_(this.#d),this.#v("idle")}#M(u){this.#p&&(this.#p.textContent=u)}#E(u){this.#g=null,this.#M(""),this.#m&&(this.#m.textContent=u),this.#v("error")}}function n(f,u){f&&(f.disabled=u,u?f.setAttribute("disabled",""):f.removeAttribute("disabled"))}function i(f,u){f&&(f.hidden=u,u?f.setAttribute("hidden",""):f.removeAttribute("hidden"))}}),Le("packages/dom/src/stat.js",function(e,K){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/internal/util.js"),x=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,S=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",d=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),a=Object.freeze({direction:"flat",change:null,percent:null});function r(s,p){if(!Number.isFinite(s)||!Number.isFinite(p))return a;const y=s-p,O=y>0?"up":y<0?"down":"flat",A=p===0?null:y/Math.abs(p)*100;return{direction:O,change:y,percent:A}}function t(s,p){return s==="flat"||p==="neither"?"flat":s===p?"good":"bad"}function n(s,p,y=null){if(x(p)){const j=p(s,y);return j==="good"||j==="warn"||j==="bad"?j:null}if(!B(p))return null;const O=typeof s=="number"&&Number.isFinite(s)?s:null;if(O===null)return null;const A=Number.isFinite(Number(p.good))?Number(p.good):null,b=Number.isFinite(Number(p.warn))?Number(p.warn):null,v=String(p.direction||"up")==="down",R=j=>v?O<=j:O>=j;return A!==null&&R(A)?"good":b!==null&&R(b)?"warn":A===null&&b===null?null:"bad"}function i(s){return!(x(s.value)||s.value!==void 0&&!B(s.value))}function f(s){return!s||!s.rows||!x(s.rows.totalCount)?!0:s.rows.totalCount()>0}function u(s){const p=B(s)?s:{},y=p.grid||null,O=c(p.container,y);if(!O)return I("stat.container","createStat needs a `container`: an element or a selector."),h();const A=O.ownerDocument||(typeof document>"u"?null:document);if(!A)return I("stat.document","createStat needs a document; it draws DOM."),h();const b=A.createElement("div");b.className=["lattice",g.root,p.class].filter(Boolean).join(" "),b.setAttribute("role","group");const v=A.createElement("div");v.className=g.title;const R=A.createElement("div");R.className=g.value;const j=A.createElement("div");j.className=g.interval;const F=A.createElement("div");F.className=g.delta;const C=A.createElement("div");C.className=g.footer;const T=A.createElement("div");if(T.className=g.note,T.hidden=!0,p.icon!=null&&p.icon!==""){const te=A.createElement("span");te.className=g.icon,te.setAttribute("aria-hidden","true"),S(te,p.icon,`stat:${p.title||"stat"}`),b.appendChild(te);const ne=A.createElement("div");ne.className=g.body,ne.appendChild(v),ne.appendChild(R),ne.appendChild(T),ne.appendChild(j),ne.appendChild(F),ne.appendChild(C),b.appendChild(ne)}else b.appendChild(v),b.appendChild(R),b.appendChild(T),b.appendChild(j),b.appendChild(F),b.appendChild(C);O.appendChild(b);let E=null;const D=[];let $=!1;function P(){if(x(p.value))return p.value(y);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 y?oe==="count"?N().length:ne?le?G(String(ne),String(oe),String(le)):k()==="filtered"&&y.statistics&&x(y.statistics.reduce)?y.statistics.reduce(String(ne),String(oe)):X(N().map(ae=>m(ae,String(ne))),String(oe)):null:null}function k(){return String(p.scope||"filtered")}function N(){if(!y||!y.rows)return[];const te=k();if(te==="all"){const oe=[];return x(y.rows.forEachAll)&&y.rows.forEachAll(le=>{le.group||oe.push(o(le))}),oe}if(te==="selected")return(y.selection&&x(y.selection.rows)?y.selection.rows():[]).filter(Boolean).map(o);const ne=[];return x(y.rows.forEach)&&y.rows.forEach(oe=>{oe.group||ne.push(o(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 N()){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(x(p.format))return String(p.format(te,y));if(te==null)return p.empty??"—";const ne=B(p.value)?p.value:p,oe=ne.show||ne.of;if((ne.show?!0:d.has(String(ne.fn||"sum")))&&y&&oe&&x(y.columns?.get)){const ae=y.columns.get(String(oe));if(ae&&x(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?(y&&y.messages||z).t(`stat.tone.${te}`):""}function J(){if($)return;const te=P(),ne=i(p)&&!!y&&!f(y),oe=ne?null:te,le=x(p.baseline)?p.baseline(y):p.baseline;E=oe,v.textContent=p.title??"",v.hidden=!p.title,R.textContent=q(oe),T.hidden=!ne,ne&&(T.textContent=y.messages.t("stat.noData"));const ae=ne||le===void 0||le===null?a:r(typeof oe=="number"?oe:null,Number(le)),se=t(ae.direction,p.goodWhen||"up");if(F.hidden=ae.change===null,ae.change!==null){const he=ae.direction==="up"?"↑":ae.direction==="down"?"↓":"→",ge=ae.percent===null?q(Math.abs(ae.change)):`${Math.abs(ae.percent).toFixed(1)}%`;F.textContent=`${he} ${ge}`,F.setAttribute("data-tone",se),F.setAttribute("data-direction",ae.direction)}const ee=x(p.interval)?p.interval(oe,y):null,ie=!!ee&&Number.isFinite(ee.lower)&&Number.isFinite(ee.upper);j.hidden=!ie,ie&&(j.textContent=`${q(ee.lower)} – ${q(ee.upper)}`,Number.isFinite(ee.confidence)&&j.setAttribute("title",`${Math.round(ee.confidence*100)}%`));const de=ne?l:p.bands?n(oe,p.bands,y):null;de?b.setAttribute("data-tone",de):b.removeAttribute("data-tone"),C.textContent=x(p.footer)?String(p.footer(oe,y)):p.footer??"",C.hidden=!C.textContent,b.setAttribute("aria-label",[p.title,R.textContent,ne?T.textContent:"",ie?j.textContent:"",ae.change===null?"":F.textContent,ae.change===null?"":Y(se),C.textContent].filter(Boolean).join(", "))}if(y&&x(y.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()};y.on(te,ne),D.push(()=>x(y.off)&&y.off(te,ne))}return J(),{element:()=>b,value:()=>E,refresh:J,destroy(){$=!0;for(const te of D)try{te()}catch{}D.length=0,b.remove()}}}function o(s){return B(s)&&"data"in s?s.data:s}function m(s,p){if(!B(s))return;if(!p.includes("."))return s[p];let y=s;for(const O of p.split(".")){if(!B(y))return;y=y[O]}return y}function c(s,p){if(s&&typeof s=="object")return s;if(typeof s!="string")return null;const y=p&&p.element&&p.element.ownerDocument||(typeof document>"u"?null:document);return y?y.querySelector(s):null}function h(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),Le("packages/dom/src/kpistrip.js",function(e,K){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return X}});const x=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:V,kpis:z}){this.#e=H,this.#t=V,this.#n=Array.isArray(z)?z.filter(x):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const V=this.#t.createElement("div");V.className=`lattice ${_.band}`,V.setAttribute("role","group"),V.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=V;for(const z of this.#n){const w=I({...z,grid:this.#e,container:V});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)}}}),Le("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 Ft}});const x=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,V=W.isFunction,z=W.warnOnce,S=K("packages/dom/src/localviews.js").createLocalViewStorage,l=K("packages/dom/src/renderer/index.js").DomRenderer,a=K("packages/dom/src/cell/index.js").createCellLayer,r=K("packages/dom/src/cell/icons.js"),t=r.icon,n=r.iconNames,f=K("packages/dom/src/editors/index.js").editors,o=K("packages/dom/src/filters/index.js").filters,m=K("packages/dom/src/ui/index.js"),c=m.StatusBar,h=m.TooltipManager,s=m.Pagination,p=m.GroupByZone,O=K("packages/dom/src/ui/celltooltip.js").CellTooltips,b=K("packages/dom/src/filtermenu.js").FilterMenu,R=K("packages/dom/src/columnmenu.js").ColumnMenu,F=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,T=K("packages/dom/src/rowreorder.js").RowReorder,E=K("packages/dom/src/alignedgrids.js").AlignedGrids,$=K("packages/dom/src/columntagbar.js").ColumnTagBar,k=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,Ae=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,je=K("packages/dom/src/findbar.js").FindBar,Ze=K("packages/dom/src/redactpaint.js").RedactionPainter,st=K("packages/dom/src/validationpaint.js").ValidationPainter,yt=K("packages/dom/src/presentation.js").PresentationController,Ct=K("packages/dom/src/capture.js").captureElement,Et=K("packages/dom/src/annotate.js").AnnotationLayer,Dt=K("packages/dom/src/timelinebar.js").TimelineBar,nt=K("packages/dom/src/commentpaint.js").CommentPainter,ke=K("packages/dom/src/presencepaint.js").PresencePainter,We=K("packages/dom/src/commentpanel.js").CommentPanel,qe=K("packages/dom/src/watermark.js").Watermark,ve=K("packages/dom/src/maximise.js"),Se=ve.Maximiser,me=ve.DEFAULT_MAXIMISE_Z,Me=K("packages/dom/src/promptbar.js").PromptBar,_e=K("packages/dom/src/kpistrip.js").KpiStrip;function De(Ge,ft,ot){const lt=ft==="redo"?"toolbar.redo":"toolbar.undo";return!ot||!ot.label?Ge(lt):Ge(ft==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:ot.label})}const Oe=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],xe=2e3;function Ue(Ge,ft,ot,lt){const Ot=ft.annotate===!0?Je(Ge,lt):[];if(ft.actions===!1)return[];if(ft.actions===void 0&&ft.side!=="left")return Ot;const Nt=Array.isArray(ft.actions)?ft.actions:Oe,gt=(Ut,tn)=>Ge.messages.t(Ut,tn),Rt={undo:{name:"undo",title:()=>De(gt,"undo",Ge.history.peek("undo")),icon:"undo",run:()=>Ge.history.undo(),enabled:()=>Ge.history.canUndo()},redo:{name:"redo",title:()=>De(gt,"redo",Ge.history.peek("redo")),icon:"redo",run:()=>Ge.history.redo(),enabled:()=>Ge.history.canRedo()},export:{name:"export",title:()=>gt("toolbar.exportCsv"),icon:"download",run:()=>Ge.export.csv({download:!0,fileName:ft.exportName})},excel:{name:"excel",title:()=>gt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ge.export.excel({download:!0,fileName:ft.exportName})},clipboard:{name:"clipboard",title:()=>gt("toolbar.clipboard"),icon:"copy",run:()=>Ge.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>gt("toolbar.print"),icon:"print",run:()=>Ge.export.print()},pause:{name:"pause",title:()=>{if(!Ge.updates.paused)return gt("toolbar.pause");const Ut=Ge.updates.stats().pending;return Ut?gt("toolbar.applyHeld",{count:Ut}):gt("toolbar.resume")},icon:()=>Ge.updates.paused?"play":"pause",run:()=>Ge.updates.paused?Ge.updates.resume():Ge.updates.pause()},restore:{name:"restore",title:()=>gt("toolbar.restoreView"),icon:"restore",run:()=>Ge.state.reset(),enabled:()=>Ge.state.modified()},maximise:{name:"maximise",title:()=>gt(ot&&ot.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>ot&&ot.active()?"minimise":"maximise",run:()=>ot.toggle()}};return ot||delete Rt.maximise,Nt.map(Ut=>Ut==="-"?{name:"-",separator:!0}:typeof Ut=="string"?Rt[Ut]:!Ut||typeof Ut!="object"||!Ut.name?null:{...Ut,run:V(Ut.run)?()=>Ut.run({grid:Ge,keys:Ge.selection&&V(Ge.selection.keys)?Ge.selection.keys():[],cells:Ge.selection&&V(Ge.selection.cells)?Ge.selection.cells():[]}):void 0}).filter(Boolean).concat(Ot)}function Je(Ge,ft){const ot={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},lt=(Nt,gt)=>Ge.messages.t(Nt,gt),Ot=["pen","arrow","rect","highlight","erase"].map(Nt=>({name:Nt,title:()=>lt(`toolbar.annotate.${Nt}`),icon:ot[Nt],run:()=>Ge.annotate?.use(Nt),active:()=>Ge.annotate?.tool===Nt,annotation:!0}));return Ot.push(Qe(Ge,lt,ft)),Ot}function Qe(Ge,ft,ot){return{name:"clearAll",title:()=>ft("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(Ge.annotate?.count||0)>0,annotation:!0,run:()=>at(Ge,ft,ot)}}function at(Ge,ft,ot){const lt=Ge.toolPanel;if(!lt)return;const Ot=gt=>ot?.announce?.(ft(gt),{repeat:!0});lt.removeAction("clearAll");const Nt=()=>{lt.removeAction("clearAllConfirm"),lt.removeAction("clearAllKeep"),lt.addAction(Qe(Ge,ft,ot))};lt.addAction({name:"clearAllConfirm",title:()=>ft("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{Ge.annotate?.clear(),Nt(),Ot("a11y.annotate.cleared")}}),lt.addAction({name:"clearAllKeep",title:()=>ft("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>Nt()}),Ot("a11y.annotate.confirmClear")}const it=["pen","arrow","rect","highlight","erase","clearAll"];function mt(Ge){let ft=null,ot=null;return Ge.on("source:error",lt=>{const Ot=lt&&lt.error;ot=String(Ot&&Ot.message||"").replace(/^\[lattice\]\s*/,"")||(Ge.messages?Ge.messages.t("overlay.error"):"Something went wrong")}),Ge.on("rows:changed",()=>{ot=null}),{loadError:()=>ot,rowCount:()=>{if(V(Ge.rows.matchCount))return Ge.rows.matchCount();const lt=Ge.pagination&&V(Ge.pagination.get)?Ge.pagination.get():null;return lt&&Number.isFinite(lt.total)?lt.total:Ge.rows.count()},totalRowCount:()=>V(Ge.rows.totalCount)?Ge.rows.totalCount():Ge.rows.count(),selectedAcrossSource:()=>{ft||(ft=V(Ge.rendererHost)?Ge.rendererHost():{});const lt=V(ft.selectionSummary)?ft.selectionSummary():null;return lt&&lt.predicate?{count:lt.count}:null},selectedCount:()=>{const lt=Ge.selection&&Ge.selection.keys?Ge.selection.keys():null;return lt?lt.length:0},rangeValues:()=>{const lt=Ge.selection;return!lt||!V(lt.cells)?[]:lt.cells().map(({key:Ot,colId:Nt})=>Ge.rows.value(Ot,Nt))},hiddenUnresolved:()=>V(Ge.comments&&Ge.comments.hiddenUnresolved)?Ge.comments.hiddenUnresolved():0,progress:()=>V(Ge.source&&Ge.source.progress)?Ge.source.progress():null,updateStats:()=>Ge.updates?Ge.updates.stats():null}}function wt(Ge,ft){for(const[ot,lt]of Object.entries(f||{}))Ge.register("editor",ot,lt);for(const[ot,lt]of Object.entries(o||{}))Ge.register("filter",ot,lt);for(const[ot,lt]of Object.entries(ft.components||{}))Ge.register("component",ot,lt);for(const[ot,lt]of Object.entries(ft.pipes||{}))Ge.register("pipe",ot,lt);for(const[ot,lt]of Object.entries(ft.totalFns||{}))Ge.register("totalFn",ot,lt)}function dt(Ge,ft,ot,lt,Ot,Nt){const gt=[],Rt=ft.viewport;let Ut=null;if(ot.maximise!==!1){const ut=ot.maximise&&typeof ot.maximise=="object"?ot.maximise:{};let vt=ut.zIndex;if(vt==null){const Mt=Rt.root,Vt=lt.defaultView;vt=Vt&&typeof Vt.getComputedStyle=="function"?Vt.getComputedStyle(Mt).getPropertyValue("--lattice-maximise-z").trim():"",vt||(vt=me)}Ut=new Se({element:Nt,document:lt,onChange:()=>ft.invalidate("all"),captureScroll:()=>ft.scrollState(),restoreScroll:Mt=>ft.restoreScroll(Mt),zIndex:vt,container:ut.container}),Ge.maximise=Ut,gt.push(()=>Ut.destroy())}if(ot.statusBar){const ut=typeof ot.statusBar=="object"?ot.statusBar:{},vt=new c;vt.init({document:lt,host:mt(Ge),panels:ut.panels,registry:ut.registry,locale:Ge.get("locale"),messages:Ge.messages}),Rt.statusBar.appendChild(vt.element());const Mt=()=>{const nn=Rt.statusBar.offsetHeight||Rt.statusBar.getBoundingClientRect?.().height||0;Rt.root.style.setProperty("--lattice-status-height",`${Math.ceil(nn)}px`)},Vt=()=>{vt.refresh(),Mt()},_t=["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(nn=>Ge.on(nn,Vt));Vt(),Mt(),gt.push(()=>{for(const nn of _t)nn();Rt.root.style.removeProperty("--lattice-status-height"),vt.destroy?.()})}const tn=ie(ot.selection);if(tn.ranges){const ut=new se({grid:Ge,renderer:ft,document:lt});ut.mount(),Ge.ranges=ut,gt.push(()=>ut.destroy())}if(ot.import){const ut=new he({grid:Ge,renderer:ft,document:lt,settings:typeof ot.import=="object"?ot.import:{}});Ge.importer=ut,gt.push(()=>ut.destroy())}if(ot.historyBar){const ut=typeof ot.historyBar=="object"?ot.historyBar.element:null,vt=new Ee;vt.init({document:lt,host:{undo:()=>Ge.history.undo(),redo:()=>Ge.history.redo(),canUndo:()=>Ge.history.canUndo(),canRedo:()=>Ge.history.canRedo(),peek:Vt=>Ge.history.peek(Vt),list:()=>Ge.history.list()},props:typeof ot.historyBar=="object"?ot.historyBar:{}}),(ut||Rt.root).appendChild(vt.element());const Mt=[Ge.on("history:changed",()=>vt.refresh())];Ge.historyBar=vt,gt.push(()=>{for(const Vt of Mt)Vt();vt.destroy()})}if(ot.diff){const ut=new Ae({grid:Ge,renderer:ft});ut.mount(),Ge.diffPainter=ut,gt.push(()=>ut.destroy())}if(ot.ai&&V(ot.ai.ask)){const ut=new Me;ut.init({document:lt,grid:Ge,ask:ot.ai.ask,schemaOptions:ot.ai.schemaOptions,context:ot.ai.context,placeholder:ot.ai.placeholder});const vt=ot.ai.element||Rt.root;vt===Rt.root?vt.insertBefore(ut.element(),vt.firstChild):vt.appendChild(ut.element()),Ge.promptBar=ut,gt.push(()=>ut.destroy())}if(ot.groupPanel){const ut=typeof ot.groupPanel=="object"?ot.groupPanel:{},vt=new p;vt.init({document:lt,grid:Ge,host:J(Ge,lt,(Mt,Vt)=>ft.announce?.(Mt,Vt)),props:{header:Rt.header,hint:ut.hint}}),Rt.root.insertBefore(vt.element(),Rt.header),Ge.groupPanel=vt;for(const Mt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])V(Ge.on)&&gt.push(Ge.on(Mt,()=>vt.refresh()));gt.push(()=>vt.destroy())}if(ot.kpis){const ut=new _e({grid:Ge,document:lt,kpis:ot.kpis});ut.active&&(ut.mount(),Rt.root.insertBefore(ut.element(),Rt.header),Ge.kpiStrip=ut,gt.push(()=>ut.destroy()))}if(ot.toolPanel){const ut=typeof ot.toolPanel=="object"?ot.toolPanel:{},vt=new Y({grid:Ge,document:lt,root:Rt.root,panels:ut.panels,openPanel:ut.openPanel,side:ut.side,icons:ut.icons,actions:Ue(Ge,ut,Ut,ft),announce:(Mt,Vt)=>ft.announce?.(Mt,Vt)});vt.mount(),Ge.toolPanel=vt,gt.push(()=>vt.destroy()),ut.annotate===void 0&&(gt.push(Ge.on("presentation:started",()=>{for(const Mt of Je(Ge,ft))vt.addAction(Mt)})),gt.push(Ge.on("presentation:ended",()=>{for(const Mt of it)vt.removeAction(Mt)})))}if(!!ot.pagination&&(()=>{const ut=typeof ot.pagination=="object"?ot.pagination:{};return Ge.pagination.set({pageSize:Number(ut.pageSize)||100}),Ge.pagination.get().pageSize>0})()){const ut=typeof ot.pagination=="object"?ot.pagination:{},vt=new s;vt.init({document:lt,pageSize:ut.pageSize,pageSizes:ut.pageSizes,page:ut.page,total:ut.total,locale:Ge.get("locale"),messages:Ge.messages,onChange:({page:_t,pageSize:nn})=>Ge.pagination.set({page:_t,pageSize:nn})});const Mt=()=>{const _t=Ge.pagination.get();vt.total=_t.total,vt.counting=_t.counting===!0,vt.hasMore=_t.total==null&&_t.pageCount>_t.page+1,vt.page=_t.page,vt.paint()};Ge.pagination.set({pageSize:vt.pageSize}),Mt();const Vt=["rows:changed","filter:changed","model:changed"].map(_t=>Ge.on(_t,Mt));Rt.statusBar.appendChild(vt.element()),gt.push(()=>{for(const _t of Vt)_t();vt.destroy?.()})}if(ot.edit!==!1)if(ot.editBar){const ut=new le({grid:Ge,document:lt,root:Rt.root});ut.mount(),Ge.editBar=ut,gt.push(()=>ut.destroy())}else{const ut=new ne({grid:Ge,document:lt,renderer:ft,registry:Ot,cellLayer:ft.cellLayer});ut.mount(),gt.push(()=>ut.destroy())}const ln=new b({grid:Ge,document:lt,layer:Rt.overlays,registry:Ot});ln.mount(),gt.push(()=>ln.destroy());const Zt=new R({grid:Ge,document:lt,host:Rt.root,cellMenu:ot.contextMenu!==!1,headerMenu:ot.columnMenu!==!1,items:V(ot.contextMenu)?ot.contextMenu:void 0,headerItems:V(ot.columnMenu)?ot.columnMenu:void 0});if(Zt.mount(),gt.push(()=>Zt.destroy()),Array.isArray(ot.alignedGrids)&&ot.alignedGrids.length){const ut=new E;ut.add(Ge);for(const vt of ot.alignedGrids)vt&&vt!==Ge&&ut.add(vt);gt.push(()=>ut.destroy())}const jt=new G({grid:Ge,renderer:ft,document:lt,registry:Ot});jt.active&&(jt.mount(),gt.push(()=>jt.destroy())),Object.defineProperty(Ge,"form",{configurable:!0,value:Object.freeze({open(ut){return jt.active?jt.openRow(ut):!1},openNew(ut){return jt.active?jt.openNew(ut):(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(){jt.active&&jt.close()},save(){return jt.active?jt.save():!1},isOpen(){return jt.active?jt.open:!1}})}),gt.push(()=>{delete Ge.form}),Object.defineProperty(Ge,"icons",{configurable:!0,value:Object.freeze({get(ut){const vt=t(ut);return vt?{viewBox:vt.viewBox,paths:vt.paths.slice(),paint:vt.paint==="stroke"?"stroke":"fill"}:null},names(){return n()}})}),gt.push(()=>{delete Ge.icons});const It=new $({grid:Ge,renderer:ft,document:lt});It.active&&(It.mount(),gt.push(()=>It.destroy()));const Ht=new k({grid:Ge,renderer:ft,document:lt});Ht.active&&(Ht.mount(),gt.push(()=>Ht.destroy()));const Wt=new T({grid:Ge,renderer:ft,document:lt});if(Wt.active){Wt.mount(),Wt.paint();const ut=Ge.on("render:done",()=>Wt.paint());gt.push(()=>{ut(),Wt.destroy()})}if(ot.shortcuts!==!1){const ut=new F({grid:Ge,renderer:ft});ut.mount(),gt.push(()=>ut.destroy())}const Qt=new Ne({grid:Ge,renderer:ft,window:lt.defaultView||void 0});Qt.mount(),gt.push(()=>Qt.destroy());const Yt=new Ve({grid:Ge,renderer:ft,window:lt.defaultView||void 0});if(Yt.mount(),gt.push(()=>Yt.destroy()),ot.find!==!1){const ut=new je({grid:Ge,renderer:ft,document:lt,settings:ot.find});ut.mount(),gt.push(()=>ut.destroy())}const Jt=new Ze({grid:Ge,renderer:ft});Jt.mount(),gt.push(()=>Jt.destroy());const on=new st({grid:Ge,renderer:ft});on.mount(),gt.push(()=>on.destroy());const en=new yt({grid:Ge,renderer:ft,maximiser:Ut});en.mount(),gt.push(()=>en.destroy());const fn=new Dt({grid:Ge,renderer:ft});fn.mount(),gt.push(()=>fn.destroy()),ot.environment||Ge.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 mn=null;for(const[ut,vt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])gt.push(Ge.on(ut,()=>{mn=vt}));gt.push(Ge.on("render:done",ut=>{Ge.diagnostics.render(mn||ut.cause,ut.phases),mn=null}));const cn=lt.defaultView;if(cn&&V(cn.requestAnimationFrame)){let ut=cn.requestAnimationFrame(function vt(Mt){Ge.diagnostics.frame(Mt),ut=cn.requestAnimationFrame(vt)});gt.push(()=>{V(cn.cancelAnimationFrame)&&cn.cancelAnimationFrame(ut)})}const gn=new ke({grid:Ge,renderer:ft});if(gn.mount(),gt.push(()=>gn.destroy()),gt.push(Ge.on("presence:lockRefused",ut=>gn.announceRefusal(ut.peer))),Ge.presence&&Ge.presence.enabled){for(const Mt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])gt.push(Ge.on(Mt,()=>Ge.presence.publish()));let ut="";gt.push(Ge.on("render:done",()=>{const Mt=ft.focusState&&ft.focusState(),Vt=Mt?`${Mt.rowKey}${Mt.colId}`:"";Vt!==ut&&(ut=Vt,Ge.presence.publish())}));const vt=Nt.ownerDocument;if(vt&&V(vt.addEventListener)){const Mt=()=>Ge.presence.setPaused(vt.visibilityState==="hidden");vt.addEventListener("visibilitychange",Mt),Mt(),gt.push(()=>vt.removeEventListener("visibilitychange",Mt))}}const wn=new nt({grid:Ge,renderer:ft});wn.mount(),gt.push(()=>wn.destroy());const En=new We({grid:Ge,renderer:ft});En.mount(),gt.push(()=>En.destroy()),gt.push(Ge.on("facet:computed",()=>ft.refreshHeader?.())),tn&&tn.headerCheckbox===!0&&gt.push(Ge.on("selection:changed",()=>ft.refreshHeader?.())),gt.push(Ge.on("facet:expanded",()=>ft.invalidate("columns"))),gt.push(Ge.on("model:changed",()=>ft.invalidate("rows")));const qt=(ut,vt)=>ft.announce?.(ut,vt),hn=Ge.messages,Kt=(ut,vt)=>hn.t(ut,vt),yn=ut=>Kt("count.rows",{count:ut});gt.push(Ge.on("sort:changed",()=>{const ut=Ge.sort.get();if(!ut.length){qt(Kt("a11y.sort.cleared"));return}const vt=ut.map(Mt=>{const Vt=Ge.columns.get(Mt.col);return Kt("a11y.sort.column",{column:Vt&&Vt.title||Mt.col,direction:Kt(Mt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});qt(Kt("a11y.sort.by",{columns:hn.list(vt)}))})),gt.push(Ge.on("filter:changed",()=>{const ut=Ge.rows.matchCount?Ge.rows.matchCount():Ge.rows.count();if(ut===null)return;const vt=Ge.rows.totalCount?Ge.rows.totalCount():ut;qt(ut===vt?Kt("a11y.filter.cleared",{rows:yn(vt)}):Kt("a11y.filter.applied",{shown:yn(ut),total:yn(vt)}))})),gt.push(Ge.on("selection:changed",()=>{const ut=Ge.selection.keys().length;qt(ut===0?Kt("a11y.selection.cleared"):Kt("a11y.selection.count",{count:ut}))})),gt.push(Ge.on("group:toggled",ut=>{const vt=Ge.rows.byKey?Ge.rows.byKey(ut.key):null,Mt=(vt&&(vt.groupLabel??vt.groupValue))??ut.key;qt(Kt(ut.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Mt,rows:yn(Ge.rows.count())}))})),gt.push(Ge.on("column:grouped",ut=>{const vt=Array.isArray(ut.columns)?ut.columns:[];if(!vt.length){qt(Kt("a11y.group.cleared"));return}const Mt=vt.map(Vt=>{const _t=Ge.columns.get(Vt);return _t&&_t.title||Vt});qt(Kt("a11y.group.by",{columns:hn.list(Mt)}))})),gt.push(Ge.on("page:changed",ut=>{const vt=Number(ut.size)||0,Mt=Number(ut.total)||0,Vt=vt>0?Math.max(1,Math.ceil(Mt/vt)):1;qt(Kt("a11y.page.position",{page:(Number(ut.page)||0)+1,pages:Vt}))}));let Xt={added:0,removed:0},sn=null;const Ln=()=>{sn=null;const ut=[];Xt.added&&ut.push(Kt("count.rowsAdded",{count:Xt.added})),Xt.removed&&ut.push(Kt("count.rowsRemoved",{count:Xt.removed})),Xt={added:0,removed:0},ut.length&&qt(hn.list(ut))};gt.push(Ge.on("rows:changed",ut=>{if(!ut||typeof ut.added!="number")return;const vt=Number(ut.added)||0,Mt=Number(ut.removed)||0;!vt&&!Mt||(Xt.added+=vt,Xt.removed+=Mt,sn||(sn=setTimeout(Ln,xe)))})),gt.push(()=>{sn&&clearTimeout(sn)}),gt.push(Ge.on("rows:paused",()=>{sn&&(clearTimeout(sn),sn=null),Xt={added:0,removed:0},qt(Kt("a11y.updates.paused"),{repeat:!0})})),gt.push(Ge.on("rows:resumed",()=>qt(Kt("a11y.updates.resumed"),{repeat:!0})));let pn={count:0,first:null},dn=null;const Fn=()=>{dn=null;const{count:ut,first:vt}=pn;if(pn={count:0,first:null},!ut||!vt)return;const Mt=Ge.columns.get(vt.colId),Vt=Mt&&Mt.title||vt.colId,_t=vt.reason?Kt("a11y.edit.reason",{reason:vt.reason}):"";if(ut===1){const nn=vt.restored===void 0||vt.restored===null||vt.restored===""?Kt("value.empty"):String(vt.restored);qt(Kt("a11y.edit.refusedOne",{column:Vt,value:nn,reason:_t}),{repeat:!0});return}qt(Kt("a11y.edit.refusedMany",{count:ut,reason:_t}),{repeat:!0})};gt.push(Ge.on("cell:reverted",ut=>{!ut||!ut.applied||(pn.count+=1,pn.first||(pn.first=ut),dn||(dn=setTimeout(Fn,150)))})),gt.push(()=>{dn&&clearTimeout(dn)}),gt.push(Ge.on("history:applied",ut=>{const vt=!!(ut&&ut.direction==="redo"),Mt=ut&&ut.step&&ut.step.label;qt(Mt?Kt(vt?"a11y.history.redo":"a11y.history.undo",{label:Mt}):Kt(vt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const vn=new Et({grid:Ge,renderer:ft,seed:ot.state&&Array.isArray(ot.state.annotations)?ot.state.annotations:null});vn.mount(),gt.push(()=>vn.destroy()),Ge.annotate=vn,Ge.capture=async(ut={})=>{const{blob:vt,width:Mt,height:Vt}=await Ct(ft.viewport.root,ut);return(ut.download===!0||ut.download!==!1&&ut.fileName)&&X(vt,ut.fileName||`${Ge.get("exportName")||"grid"}.png`),Ge.emit("presentation:captured",{width:Mt,height:Vt,bytes:vt.size,mimeType:vt.type,fileName:ut.fileName||null},"api"),vt};const xn=new qe({grid:Ge,document:lt,element:Rt.overlays,window:lt.defaultView||void 0});xn.mount(),gt.push(()=>xn.destroy());const Tn=new h({grid:Ge,document:lt,element:Rt.overlays});Tn.mount?.(),gt.push(()=>Tn.destroy?.());const kn=new O({grid:Ge,host:Ge.rendererHost(),viewport:Rt,document:lt});return kn.mount(),gt.push(()=>kn.destroy()),gt}function Pt(Ge){const ft=[],ot=lt=>{if(lt&&(lt.__lattice&&ft.push(lt),lt.children))for(const Ot of lt.children)ot(Ot)};return ot(Ge),ft}function Ft(Ge,ft={}){(!Ge||typeof Ge!="object"||!("appendChild"in Ge))&&H("createGrid needs a host element as its first argument."),ft=I(ft);const ot=Ge.ownerDocument||(typeof document<"u"?document:null);ot||H("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const lt=ot.documentElement&&ot.documentElement.lang,Ot=!ft.licence&&V(ot.querySelector)?ot.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Nt={...ft};if(!ft.locale&&lt&&(Nt.locale=lt),Ot&&(Nt.licence=Ot),ft.views&&ft.views.local)if(ft.views.storage)z("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const Zt=ft.views.local===!0?{}:ft.views.local;Nt.views={...ft.views,storage:S(Zt)}}const gt=x(Nt),Rt=gt.rendererHost();Rt.document=ot,wt(Rt.registry,ft),Rt.cellLayer=a(Rt),Rt.detailHost=new we({grid:gt,document:Ge.ownerDocument||globalThis.document,createGrid:(Zt,jt)=>Ft(Zt,jt)});const Ut=new l(Ge,Rt),tn=gt.on("detail:toggled",()=>{Rt.detailHost.syncTarget(),Rt.detailHost.prune()}),an=gt.on("config:changed",Zt=>{Zt&&Zt.key==="detail"&&Rt.detailHost.reconfigure()});gt.on("destroy",()=>{tn(),an(),Rt.detailHost.destroy()}),Rt.detailHost.syncTarget(),gt.attachRenderer(Ut),Ut.mount();const bn=dt(gt,Ut,ft,ot,Rt.registry,Ge),ln=gt.destroy.bind(gt);return gt.destroy=()=>{for(const Zt of bn)try{Zt()}catch{}Ge.__lattice===gt&&(Ge.__lattice=null),ln()},Ge.__lattice=gt,gt}}),Le("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return i}}),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 c}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return h}});const Q=K("packages/core/src/internal/util.js"),x=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"),S=w.toIsoDate,g=w.toIsoDateTime,d=K("packages/dom/src/createGrid.js").createGrid,a=new Set([...Object.keys(_),...Object.keys(H)]);function r(s,p){for(const y of s.children)if(y.tagName===p.toUpperCase())return y;return null}function t(s,p){const y=[];for(const O of s.children)O.tagName===p.toUpperCase()&&y.push(O);return y}function n(s,p){const y=x(s.getAttribute)?s.getAttribute("data-field"):null;return y||String(s.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${p}`}function i(s){const p=s.trim();if(p==="")return null;if(p==="true"||p==="false")return p==="true";const y=Number(p);return Number.isFinite(y)&&p!==""?y:p}function f(s,p){return p==="text"?s===""?null:s:p==="boolean"?z(s):p==="number"?X(s):p==="date"||p==="dateString"?S(s):p==="datetime"?g(s):i(s)}function u(s){const p=r(s,"thead"),y=r(p||s,"tr"),A=(y?t(y,"th").length?t(y,"th"):t(y,"td"):[]).map((j,F)=>{const C=n(j,F),T={id:C,field:C,title:String(j.textContent||"").trim()||C},L=x(j.getAttribute)?j.getAttribute("data-type"):null;L&&(a.has(L)?T.type=L:B(`hydrate.unknownType:${L}`,`data-type "${L}" on column "${C}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const E=x(j.getAttribute)?j.getAttribute("data-format"):null;return E&&(T.format=E),T}),b=r(s,"tbody"),R=(b?t(b,"tr"):t(s,"tr").filter(j=>j!==y)).map((j,F)=>{const C=t(j,"td"),L={__row:(x(j.getAttribute)?j.getAttribute("data-id"):null)||`row${F}`};return A.forEach((E,D)=>{L[E.field]=C[D]?E.type?f(String(C[D].textContent||""),E.type):i(String(C[D].textContent||"")):null}),L});return{columns:A,rows:R}}function o(s,p){if(p===void 0)return s;if(p!==null&&typeof p=="object"&&!Array.isArray(p)&&Array.isArray(p.only))return p.only;if(!Array.isArray(p))return p;const y=new Map;for(const A of p)if(A&&typeof A=="object"){const b=A.id??A.field;b!=null&&y.set(b,A)}const O=s.map(A=>{const b=y.get(A.id)??y.get(A.field);return b===void 0?A:{...A,...b}});for(const[A,b]of y)s.some(v=>v.id===A||v.field===A)||O.push({...b});return O}const m="data-lattice-hydrate-config";function c(s,p,y={}){const{columns:O,rows:A}=u(p);return d(s,{rowKey:"__row",...y,columns:o(O,y.columns),rows:y.rows!==void 0?y.rows:A})}function h(s,p={}){const y=s.ownerDocument.createElement("div");y.setAttribute("data-lattice-hydrated",""),s.removeAttribute("data-lattice-grid"),y.__latticeTable=s;try{y.setAttribute(m,JSON.stringify(p))}catch{y.setAttribute(m,"{}")}return s.parentNode.insertBefore(y,s),s.parentNode.removeChild(s),c(y,s,p)}}),Le("packages/dom/src/autoinit.js",function(e,K){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return z}});const x=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,S){const g=[];return x(w.hasAttribute)&&w.hasAttribute(S)&&g.push(w),x(w.querySelectorAll)&&g.push(...w.querySelectorAll(`[${S}]`)),g}function H(w){const S=w.parentNode;if(!S||!S.children)return null;const g=[...S.children],l=g.indexOf(w),d=[g[l+1],g[l-1]];for(const a of d)if(a&&a.tagName==="SCRIPT"&&x(a.getAttribute)&&a.hasAttribute("data-lattice-config"))return a;return null}function V(w){const S=H(w);if(!S)return{};try{return JSON.parse(S.textContent||"{}")}catch(g){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",g),{}}}function z(w){const S=w||(typeof document<"u"?document:null);if(!S)return[];const g=[];for(const l of W(S,"data-lattice-grid")){if(l.__lattice)continue;const d=V(l);g.push(l.tagName==="TABLE"?X(l,d):I(l,d))}return g}}),Le("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Q=K("packages/dom/src/createGrid.js"),x=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,V=K("packages/core/src/index.js"),z=V.createHeadlessGrid,w=V.registerModules,S=V.setLicence,g=V.version,l=V.getVersion,d=V.serialiseState,a=V.restoreState,r=V.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 V.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return V.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return V.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return V.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return V.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return V.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return V.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return V.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return V.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return V.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return V.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return V.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return V.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return V.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return V.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return V.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return V.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return V.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return V.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return V.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return V.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return V.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return V.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return V.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return V.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return V.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return V.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return V.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return V.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return V.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return V.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return V.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return V.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return V.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return V.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return V.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return V.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return V.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return V.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return V.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return V.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return V.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return V.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return V.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return V.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return V.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return V.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return V.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return V.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return V.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return V.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return V.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return V.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return V.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return V.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return V.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return V.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return V.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return V.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return V.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return V.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return V.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return V.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return V.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return V.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return V.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return V.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return V.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return V.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return V.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return V.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return V.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return V.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return V.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return V.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return V.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return V.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return V.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return V.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return V.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return V.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return V.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return V.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return V.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return V.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return V.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return V.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return V.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return V.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return V.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return V.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return V.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return V.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return V.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return V.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return V.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return V.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return V.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return V.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return V.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return V.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return V.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return V.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return V.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return V.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return V.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return V.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return V.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return V.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return V.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return V.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return V.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return V.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return V.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return V.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return V.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return V.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return V.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return V.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return V.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return V.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return V.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return V.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return V.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return V.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return V.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return V.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return V.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return V.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return V.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return V.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return V.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return V.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return V.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return V.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return V.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return V.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return V.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return V.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return V.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return V.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return V.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return V.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return V.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return V.VERSION}});const n=K("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return n.DomRenderer}});const i=K("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return i.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return i.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return i.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 o=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return o.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return o.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return o.mountPanel}});const m=K("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return m.CellEditController}});const c=K("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return c.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 s=K("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return s.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 y=K("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return y.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return y.PROMPT_CLASS}});const O=K("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return O.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return O.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return O.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return O.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return O.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return O.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return O.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return O.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return O.sanitiseHtml}});const A=K("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return A.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return A.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return A.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return A.BaseEditor}});const b=K("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return b.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return b.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return b.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return b.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return b.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 j=Object.freeze({createGrid:x,createHeadlessGrid:z,defaults:r,registerModules:w,setLicence:S,version:g,autoInit:X,hydrateTable:I,serialiseState:d,restoreState:a,createLocalViewStorage:H}),F=j}),Le("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 V}}),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"]),x=Object.freeze({sort:(w,S)=>w.sort.set(S||[]),filters:(w,S)=>w.filters.set(S||null),quickFilter:(w,S)=>{if(S&&typeof S=="object"){w.filters.quick(S.text||"",{mode:S.mode});return}w.filters.quick(typeof S=="string"?S:"")},selectedKeys:(w,S)=>w.selection.set(Array.isArray(S)?S:[])});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 V(w){const S={},g={},l={};for(const[d,a]of Object.entries(w||{})){if(H(d)){l[d]=a;continue}if(Object.hasOwn(x,d)){g[d]=a;continue}S[d]=a}return{config:S,imperative:g,handlers:l}}function z(w){const S=w.createGrid;if(typeof S!="function")throw new TypeError("createGridController needs createGrid; pass it in from the grid package.");const g=V(w.props||{}),l=S(w.element,{...g.config});let d=g.handlers,a=g.config,r={};const t=f=>{if(!f||typeof f.type!="string")return;const u=d[B(f.type)];typeof u=="function"&&u(f)},n=l.on("*",t);for(const[f,u]of Object.entries(g.imperative))u!==void 0&&(x[f](l,u),r[f]=u);let i=!1;return{grid:l,update(f){if(i)return;const u=V(f||{});d=u.handlers;const o={};for(const[m,c]of Object.entries(u.config))Object.is(a[m],c)||(o[m]=c);for(const m of Object.keys(a))Object.hasOwn(u.config,m)||(o[m]=void 0);Object.keys(o).length&&l.setAll(o),a=u.config;for(const[m,c]of Object.entries(x)){const h=u.imperative[m];Object.is(r[m],h)||h===void 0&&!Object.hasOwn(r,m)||(c(l,h),r[m]=h)}},destroy(){i||(i=!0,n(),l.destroy())}}}}),Le("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 V}});const x=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","history","columnResize","workload:click","task:filtered","draw","dependencies","cell:click","zoomChange","visibleRangeChange","taskExpand","taskCollapse","resourceExpand","resourceCollapse","selectionChange","rowMove","taskAdd","taskRemove","taskUpdate","dependencyAdd","dependencyRemove","dependencyUpdate","assignmentChange","datesChanged","change","schedulingConflict","taskDragStart","taskDrag","taskResizeStart","taskPartialResize","taskResizeEnd","percentBarDragStart","percentBarDrag","percentBarDrop","taskClick","taskDblClick","taskMouseOver","taskMouseOut","dirtyChange"]),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,S)=>z.move(w,S)}),chart:Object.freeze({}),layout:Object.freeze({})}),_=Object.freeze({chart:"update"});function X(z){return`on${String(z).split(":").map(S=>S.charAt(0).toUpperCase()+S.slice(1)).join("")}`}const W=Object.freeze(Object.fromEntries(Object.entries(B).map(([z,w])=>[z,Object.freeze(Object.fromEntries(w.map(S=>[X(S),S])))])));function H(z,w){const S=W[z]||{},g=I[z]||{},l={},d={},a={};for(const[r,t]of Object.entries(w||{})){if(Object.hasOwn(S,r)){a[r]=t;continue}if(Object.hasOwn(g,r)){d[r]=t,l[r]=t;continue}l[r]=t}return{config:l,live:d,handlers:a}}function V(z){const w=String(z.viewer),S=z.mount,g=z.name||w;if(typeof S!="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||{}),d=S(z.element,{...l.config});if(!d||typeof d!="object")throw new TypeError(`the ${g} factory returned no instance; nothing can be driven.`);let a=l.handlers,r=l.config;const t={...l.live},n=[];if(typeof d.on=="function")for(const o of B[w]||[]){const m=X(o),c=d.on(o,h=>{const s=a[m];typeof s=="function"&&s(h)});typeof c=="function"&&n.push(c)}const i=_[w],f=I[w]||{};let u=!1;return{instance:d,update(o){if(u)return;const m=H(w,o||{});a=m.handlers;const c={};for(const[s,p]of Object.entries(m.config))Object.is(r[s],p)||(c[s]=p);if(r=m.config,!Object.keys(c).length)return;const h=[];for(const s of Object.keys(c)){const p=f[s];if(p){p(d,c[s]),t[s]=c[s];continue}i&&typeof d[i]=="function"||h.push(s)}if(i&&typeof d[i]=="function"){const s={};for(const p of Object.keys(c))f[p]||(s[p]=c[p]);Object.keys(s).length&&d[i](s)}h.length&&x(`react.viewer.${w}.mountOnly.${h.join(".")}`,`${g}: ${h.map(s=>`\`${s}\``).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 o of n)try{o()}catch{}n.length=0,typeof d.destroy=="function"&&d.destroy()}}}}}),Le("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 V}}),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 S}}),Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return a}});const x=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 V(){return Object.keys(_)}function z(r){return B+String(r).replace(/:/g,"-")}function w(r,t){if(W.has(r))return t!==null&&t!=="false";if(t!==null){if(X.has(r)){const n=Number(t);return Number.isFinite(n)?n:void 0}if(H.has(r))try{return JSON.parse(t)}catch{return}return t}}function S(r){if(!r||!r.createElement||r.getElementById&&r.getElementById(I))return;const t=r.createElement("style");t.setAttribute("id",I),t.appendChild(r.createTextNode(`lattice-grid{display:block}
58
58
  `));const n=r.head||r.documentElement||null;n&&n.appendChild(t)}const g=new Set(["quickFilter","quickFilterText","sort","filters","selectedKeys"]);function l(r,t,n){let i;if(t==="quickFilter"||t==="quickFilterText"){if(!r.filters||typeof r.filters.quick!="function")return d(t);i=()=>r.filters.quick(n==null?"":String(n))}else if(t==="sort"){if(!r.sort||typeof r.sort.set!="function")return d(t);i=()=>r.sort.set(Array.isArray(n)?n:[])}else if(t==="filters"){if(!r.filters||typeof r.filters.set!="function")return d(t);i=()=>r.filters.set(n??{})}else{if(!r.selection||typeof r.selection.set!="function")return d(t);i=()=>r.selection.set(Array.isArray(n)?n:[])}i()}function d(r){x(`webcomponent.write:${r}`,`<lattice-grid>: \`${r}\` could not be written to the grid (it has no API for it), so it had no effect.`)}class a{#e;#t;#n=null;#r={};#o=null;#i=!1;#s=!1;constructor(t,n){this.#e=t,this.#t=n.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[n,i]of Object.entries(t))this.#l(n,i)}attributeChanged(t,n){const i=_[t];if(!i)return;const f=w(i,n);f===void 0&&!W.has(i)||this.#l(i,f)}connect(){this.#i=!1,this.#s=!0,!this.#n&&queueMicrotask(()=>this.settleCreate())}settleCreate(){if(!this.#s||this.#n)return;S(this.#e.ownerDocument||null);const t={},n=[];for(const[f,u]of Object.entries(this.#r))g.has(f)&&f!=="quickFilterText"?n.push([f,u]):t[f]=u;const i=this.#t(this.#e,t);this.#n=i;for(const[f,u]of n)l(i,f,u);this.#a(i)}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,n){if(this.#r[t]=n,!!this.#n){if(g.has(t)){l(this.#n,t,n);return}typeof this.#n.set=="function"&&this.#n.set(t,n)}}#a(t){!t||typeof t.on!="function"||(this.#o=t.on("*",n=>{const i=this.#e;if(!i||typeof i.dispatchEvent!="function")return;const f={...n};delete f.grid,i.dispatchEvent(this.#u(z(n.type),f))}))}#u(t,n){const i=globalThis.CustomEvent;return typeof i=="function"?new i(t,{detail:n,bubbles:!0,composed:!0}):{type:t,detail:n,bubbles:!0,composed:!0}}}}),Le("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 S}}),Object.defineProperty(e,"adoptIntoHostRoot",{enumerable:!0,get:function(){return g}});const Q=Symbol.for("lattice.webcomponent.styleMirror"),x=/--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 d=String(l.tagName||"").toLowerCase();if(d!=="style"&&d!=="link"||d==="link"&&!String(l.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("stylesheet"))return!1;const a=String(l.getAttribute("id")||"");if(a.startsWith("lattice")||a.startsWith("lat-")||l.hasAttribute&&l.hasAttribute("data-lattice"))return!0;if(d==="link"){const r=String(l.getAttribute("href")||"");return/lattice/i.test(r)?!0:x.test(W(l))}return x.test(String(l.textContent||""))}function W(l){if(String(l&&l.tagName||"").toLowerCase()==="style")return String(l.textContent||"");try{const a=l&&l.sheet;if(!a||!a.cssRules)return"";let r="";for(const t of a.cssRules)r+=`${t.cssText}
59
- `;return r}catch{return""}}function H(l,d){const a=B.get(l);if(a)return a.sheet;const r=W(l);if(!r)return null;const t=d.CSSStyleSheet,n=new t;try{n.replaceSync(r)}catch{return null}n[Q]=!0;let i=null;const f=d.MutationObserver;return typeof f=="function"&&String(l.tagName).toLowerCase()==="style"&&(i=new f(()=>{try{n.replaceSync(String(l.textContent||""))}catch{}}),i.observe(l,{childList:!0,characterData:!0,subtree:!0})),B.set(l,{sheet:n,stop:()=>i&&i.disconnect()}),n}function V(l){return l?l.nodeType===9?l:l.ownerDocument||globalThis.document||null:globalThis.document||null}function z(l){const d=l||globalThis.document;return!d||typeof d.querySelectorAll!="function"?[]:[...d.querySelectorAll("style,link[rel]")].filter(X)}function w(l={}){if(!_())return[];const d=l.document||globalThis.document,a=d&&d.defaultView||globalThis,r=[];for(const t of z(d)){const n=H(t,a);n&&!r.includes(n)&&r.push(n)}return r}function S(l,d={}){const a=()=>{};if(!l||typeof l!="object")return a;const r=d.document||V(l);if(!r)return a;const t=r.defaultView||globalThis;let n=I.get(l);n||(n=new Map,I.set(l,n));const i=[],f=_(),u=s=>{if(n.has(s))return;const p=f?H(s,t):null;if(p){n.set(s,p);const O=l.adoptedStyleSheets||[];O.includes(p)||(l.adoptedStyleSheets=[...O,p]);return}if(String(s.tagName).toLowerCase()!=="link"||typeof l.appendChild!="function")return;const y=r.createElement("link");y.setAttribute("rel","stylesheet"),y.setAttribute("href",s.getAttribute("href")||""),y.setAttribute("data-lattice","adopted"),l.appendChild(y),i.push(y),n.set(s,y)};for(const s of z(r))u(s);let o=null;const m=t.MutationObserver,c=r.head||r.documentElement;typeof m=="function"&&c&&(o=new m(s=>{for(const p of s)for(const y of p.addedNodes||[])X(y)&&u(y)}),o.observe(c,{childList:!0}));let h=!1;return()=>{if(h)return;h=!0,o&&o.disconnect();const s=l.adoptedStyleSheets||[],p=new Set([...n.values()]);l.adoptedStyleSheets=s.filter(y=>!p.has(y));for(const y of i)y.parentNode&&y.parentNode.removeChild(y);n.clear()}}function g(l){if(!l||typeof l.getRootNode!="function"||typeof l.getAttribute=="function"&&String(l.getAttribute("lattice-styles")||"")==="off")return null;const d=l.getRootNode();return!d||d.nodeType!==11||!d.host?null:S(d)}}),Le("packages/modules/webcomponent/elements.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_GRID_NAME",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_TAG_PREFIX",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VIEWER_ALIASES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"VIEWER_BINDING",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"coerceElementAttribute",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"attributeConfig",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createElementScope",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"scopeFor",{enumerable:!0,get:function(){return b}}),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 T}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return N}}),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 x=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,V=K("packages/modules/webcomponent/controller.js"),z=V.GridElementController,w=V.observedAttributeNames,S=V.domEventName,g=V.ATTRIBUTE_CONFIG,d=K("packages/modules/webcomponent/styles.js").adoptIntoHostRoot,a="default",r="lattice-",t=Object.freeze({grid:"grid",kpi:"kpi",chart:"chart",kanban:"kanban",calendar:"calendar",gantt:"gantt",layout:"layout",tabs:"tabs",router:"router"}),n=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}}),i=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"]),o=Symbol.for("lattice.webcomponent.routerScope"),m=new WeakMap;function c(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 de of ie){if(f.has(de)||u.has(de)||se&&se.has(de)||de.startsWith("data-")||de.startsWith("aria-"))continue;const he=c(ae.getAttribute(de));he!==void 0&&(ee[s(de)]=he)}return ee}function s(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 y(ae){const se=[];for(const ee of p(ae))f.has(ee)||u.has(ee)||ee.startsWith("data-")||ee.startsWith("aria-")||se.push(s(ee));return se}function O(){const ae=new Map,se=new Set;return{publish(ee,ie){const de=ee||a;ie?ae.set(de,ie):ae.delete(de);for(const he of[...se])he()},get(ee){return ae.get(ee||a)||null},names(){return[...ae.keys()]},subscribe(ee){return se.add(ee),()=>{se.delete(ee)}}}}function A(ae={}){const se=typeof ae.createDataRouter=="function"?ae.createDataRouter:null;let ee=null,ie=!1;return{grids:O(),get router(){return ee},attach(he,ge,Ee){ie||!se||(ee||(ee=se(ae.config||{})),ee.attach(he,ge,Ee||{}))},detach(he){if(!(ie||!ee))try{ee.detach(he)}catch{}},destroy(){ie=!0;const he=ee;ee=null,he&&he.destroy()}}}function b(ae){let se=ae&&ae.parentNode||null;for(;se;){if(se[o])return se[o];se=se.parentNode||se.host||null}const ie=(ae&&typeof ae.getRootNode=="function"?ae.getRootNode():ae&&ae.ownerDocument||null)||globalThis.document||globalThis;let de=m.get(ie);return de||(de=A(),m.set(ie,de)),de}function v(ae,se,ee){const ie=se&&typeof se=="object"?se:{},de=ee&&typeof ee=="object"?ee:{};for(const[he,ge]of Object.entries(ie))Object.is(de[he],ge)||ae.filters.where(he,typeof ge=="function"?ge:null);for(const he of Object.keys(de))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 j=new Set(["instance","config","grid","gridName","router"]);function F(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||j.has(se)||se.startsWith("__"))return;const ee=Object.getOwnPropertyDescriptor(ae,se);if(ee&&typeof ee.get=="function")return;if(F(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(de){this.__write(se,de)},configurable:!0,enumerable:!0}),ee&&(ae[se]=ie)}function T(ae){let se=!1;for(const ee of Object.getOwnPropertyNames(ae)){if(ee.startsWith("__")||j.has(ee))continue;const ie=Object.getOwnPropertyDescriptor(ae,ee);!ie||typeof ie.get=="function"||!ie.enumerable||(C(ae,ee),se=!0)}return se}function L(ae,se,ee){if(!ae||typeof ae.dispatchEvent!="function")return;const ie=globalThis.CustomEvent,de={detail:ee,bubbles:!0,composed:!0};ae.dispatchEvent(typeof ie=="function"?new ie(se,de):{type:se,...de})}function E(ae){const se=ae.viewer,ee=i[se],ie=ae.label||ee.label,de=ae.mount,he=X[se]||[];class ge 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 ye of["config","grid","gridName",...ee.properties,...ee.scalars])R(this,ye);T(this)}get instance(){return this.__controller?this.__controller.instance:null}move(ye,Ae){const pe=this.instance;return pe&&typeof pe.move=="function"?pe.move(ye,Ae):Promise.resolve(!1)}get grid(){return this.__props.grid}set grid(ye){this.__write("grid",ye)}get gridName(){const ye=this.__props.gridName;if(typeof ye=="string")return ye;const Ae=typeof this.getAttribute=="function"?this.getAttribute("grid-name"):null;return Ae===null?void 0:Ae}set gridName(ye){this.__write("gridName",ye)}get config(){return{...this.__props}}set config(ye){if(!(!ye||typeof ye!="object")){for(const[Ae,pe]of Object.entries(ye))this.__props[Ae]=pe;this.__schedule()}}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__wired){this.__wired=!0;const ye=d(this);ye&&this.__release.push(ye);const Ae=b(this);this.__scope=Ae,ee.fromContext&&this.__release.push(Ae.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())}}T(this);for(const ye of y(this))C(this,ye);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 ye of this.__release.splice(0))try{ye()}catch{}this.__tearDown()}}__write(ye,Ae){this.__props[ye]=Ae,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 ye=this.__scope;return ye?ye.grids.get(this.gridName):null}__resolve(){const ye={...h(this,this.__ownAttributes),...this.__props};if(delete ye.gridName,ee.fromContext){const pe=this.__boundGrid();pe?ye[ee.fromContext]=pe:delete ye[ee.fromContext]}const Ae=n[se];Ae&&Ae(ye);for(const pe of he)ye[W(pe)]=we=>L(this,S(pe),we);return ye}__settle(){if(!this.__connected)return;T(this);const ye=this.__resolve(),Ae=ee.fromContext&&ye[ee.fromContext]||null;if(this.__controller&&!Object.is(this.__builtAgainst,Ae)&&this.__tearDown(),!this.__controller){for(const we of ee.requires)if(ye[we]===void 0||ye[we]===null)return;if(ee.fromContext&&!Ae&&ye.rows===void 0)return;const pe=new Set(p(this));this.__controller=H({viewer:se,mount:de,element:this,props:ye,name:ie});for(const we of p(this))pe.has(we)||this.__ownAttributes.add(we);this.__builtAgainst=Ae,L(this,"ready",{instance:this.__controller.instance});return}this.__controller.update(ye)}__tearDown(){const ye=this.__controller;this.__controller=null,this.__builtAgainst=null,ye&&(L(this,"destroyed",{instance:ye.instance}),ye.destroy())}}for(const Ee of[...ee.properties,...ee.scalars])Ee in ae.Base.prototype||Object.defineProperty(ge.prototype,Ee,{get(){return this.__props[Ee]},set(ye){this.__write(Ee,ye)},configurable:!0,enumerable:!0});return ge}function D(ae,se,ee){if(typeof ae!="function")throw new TypeError(`${se} needs ${ee}: ${se}({ ${ee} }).`)}function $(){const ae=globalThis.HTMLElement;return typeof ae=="function"?ae:null}function P(ae){D(ae&&ae.createKPI,"createLatticeKPIElement","createKPI");const se=$();return se?E({viewer:"kpi",Base:se,mount:(ee,ie)=>ae.createKPI(ee,ie)}):null}function k(ae){D(ae&&ae.createChart,"createLatticeChartElement","createChart");const se=$();return se?E({viewer:"chart",Base:se,mount:(ee,ie)=>ae.createChart({...ie,container:ee})}):null}function N(ae){D(ae&&ae.createKanban,"createLatticeKanbanElement","createKanban");const se=$();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=$();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=$();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=$();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=$();return se?E({viewer:"tabs",Base:se,mount:(ie,de)=>{const he=new Map,ge=typeof ie.querySelectorAll=="function"?[...ie.querySelectorAll("template[data-tab]")]:[];for(const Ae of ge)Ae.parentNode===ie&&he.set(Ae.getAttribute("data-tab"),Ae);const ye=(Array.isArray(de.tabs)&&de.tabs.length?de.tabs:[...he.keys()].map(Ae=>({id:Ae,label:he.get(Ae).getAttribute("data-label")||Ae}))).map(Ae=>{const pe=Ae,we=he.get(pe.id);return we?{...pe,view:be=>{const Ne=we.content.cloneNode(!0),Ie=[...Ne.childNodes];return be.appendChild(Ne),{destroy(){for(const Ve of Ie)Ve.parentNode&&Ve.parentNode.removeChild(Ve)}}}}:pe});return ae.createTabs(ie,{...de,tabs:ye,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=$();if(!se)return null;class ee extends se{__scope=null;__config={};constructor(){super(),R(this,"config")}get config(){return{...this.__config}}set config(de){!de||typeof de!="object"||(this.__config={...this.__config,...de},this.__scope&&this.__scope.router&&x("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 de=h(this);this.__scope=A({createDataRouter:ae.createDataRouter,config:{...de,...this.__config}}),this[o]=this.__scope}disconnectedCallback(){const de=this.__scope;if(this.__scope=null,this[o]=null,!de)return;const he=de.router;de.destroy(),he&&L(this,"destroyed",{instance:he})}}return ee}function ne(ae={}){const se={},ee=(ie,de,he)=>{if(typeof de!="function")return;const ge=he();ge&&(se[ie]=ge)};return ee("LatticeGridElement",ae.createGrid,()=>le(ae.createGrid)),ee("LatticeKPIElement",ae.createKPI,()=>P({createKPI:ae.createKPI})),ee("LatticeChartElement",ae.createChart,()=>k({createChart:ae.createChart})),ee("LatticeKanbanElement",ae.createKanban,()=>N({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:r,de=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[ge,Ee]of Object.entries(de)){const ye=ie+he[ge],Ae=se.get?se.get(ye):void 0;if(Ae){ee[ye]=Ae;continue}se.define(ye,Ee),ee[ye]=Ee}return ee}function le(ae){const se=$();if(!se)return null;class ee extends se{static get observedAttributes(){return w()}__connected=!1;__teardownPending=!1;__published=!1;__publishedAs=a;__scope=null;__predicates=void 0;__rowUpdates=void 0;__release=[];constructor(){super(),this.__controller=new z(this,{createGrid:ae});for(const de of["rows","columns","config","predicates","rowUpdates",...Object.values(g)])R(this,de)}get grid(){return this.__controller.grid}get instance(){return this.__controller.grid}get rows(){return this.__controller.config().rows}set rows(de){this.__controller.configure({rows:de})}get columns(){return this.__controller.config().columns}set columns(de){this.__controller.configure({columns:de})}get config(){return this.__controller.config()}set config(de){this.__controller.configure(de)}get predicates(){return this.__predicates}set predicates(de){const he=this.__published?this.__controller.grid:null;he&&v(he,de,this.__predicates),this.__predicates=de}get rowUpdates(){return this.__rowUpdates}set rowUpdates(de){if(Object.is(de,this.__rowUpdates))return;this.__rowUpdates=de;const he=this.__published?this.__controller.grid:null;he&&de&&he.rows.apply(de)}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__scope){const de=d(this);de&&this.__release.push(de),this.__scope=b(this)}this.__controller.connect(),queueMicrotask(()=>this.__publish())}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()),this.__controller.disconnect())}attributeChangedCallback(de,he,ge){this.__controller.attributeChanged(de,ge)}__publish(){if(!this.__connected||this.__published)return;const de=this.__controller.grid;if(!de)return;this.__published=!0,this.__predicates&&v(de,this.__predicates,{});const he=typeof this.getAttribute=="function"?this.getAttribute("name"):null;this.__publishedAs=he||a;const ge=this.__scope;ge&&ge.grids.publish(this.__publishedAs,de);const Ee=typeof this.getAttribute=="function"?this.getAttribute("route"):null;if(ge&&Ee!==null){const ye=this.getAttribute("route-options");ge.attach(de,c(Ee),ye===null?{}:c(ye))}this.__rowUpdates&&de.rows.apply(this.__rowUpdates),L(this,"grid-ready",{grid:de})}__settleTeardown(){if(!this.__teardownPending)return;this.__teardownPending=!1;const de=this.__controller.grid,he=this.__scope;this.__scope=null,this.__published=!1;for(const ge of this.__release.splice(0))try{ge()}catch{}de&&he&&(L(this,"grid-destroyed",{grid:de}),he.detach(de),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(de){this.__controller.configure({[ie]:de})},configurable:!0,enumerable:!0});return ee}}),Le("packages/modules/webcomponent/index.js",function(e,K){"use strict";Object.defineProperty(e,"TAG_NAME",{enumerable:!0,get:function(){return V}}),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 S}});const Q=K("packages/dom/src/index.js"),x=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 V="lattice-grid";function z(g=x){return I(g)}function w(g={}){const l=globalThis.customElements,d=g.tagName||V;if(!l||typeof l.define!="function")return null;const a=l.get?l.get(d):void 0;if(a)return a;const r=z(g.createGrid||x);return r?(l.define(d,r),r):null}w();const S=w});try{Wn("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.89.0";async function he(){return ae}const W="1.89.0",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=Wn("packages/modules/webcomponent/index.js"),ro=zt.GridElementController,io=zt.observedAttributeNames,oo=zt.domEventName,so=zt.ATTRIBUTE_CONFIG,ao=zt.EVENT_PREFIX,lo=zt.createLatticeElements,uo=zt.defineLatticeElements,co=zt.ELEMENT_TAGS,fo=zt.createLatticeKPIElement,ho=zt.createLatticeChartElement,po=zt.createLatticeKanbanElement,mo=zt.createLatticeCalendarElement,go=zt.createLatticeGanttElement,yo=zt.createLatticeLayoutElement,bo=zt.createLatticeTabsElement,wo=zt.createLatticeRouterElement,vo=zt.adoptLatticeStyles,ko=zt.latticeStyleSheets,So=zt.VIEWER_EVENTS,Oo=zt.VIEWER_APPLY,jo=zt.viewerHandlerName,Ao=zt.createViewerController,Po=zt.EVENT_NAMES,Co=zt.dashedName,Eo=zt.createCurrencyType,To=zt.createUnitType,Mo=zt.registerUnitSystem,No=zt.createStat,Ro=zt.createHeadlessGrid,Lo=zt.duckdbAdapter,Fo=zt.createPushdownSource,xo=zt.TAG_NAME,Io=zt.createLatticeGridElement,$o=zt.defineLatticeGrid;var Do=zt.default;export{so as ATTRIBUTE_CONFIG,co as ELEMENT_TAGS,Po as EVENT_NAMES,ao as EVENT_PREFIX,ro as GridElementController,xo as TAG_NAME,Oo as VIEWER_APPLY,So as VIEWER_EVENTS,vo as adoptLatticeStyles,Eo as createCurrencyType,Ro as createHeadlessGrid,mo as createLatticeCalendarElement,ho as createLatticeChartElement,lo as createLatticeElements,go as createLatticeGanttElement,Io as createLatticeGridElement,fo as createLatticeKPIElement,po as createLatticeKanbanElement,yo as createLatticeLayoutElement,wo as createLatticeRouterElement,bo as createLatticeTabsElement,Fo as createPushdownSource,No as createStat,To as createUnitType,Ao as createViewerController,Co as dashedName,Do as default,uo as defineLatticeElements,$o as defineLatticeGrid,oo as domEventName,Lo as duckdbAdapter,ko as latticeStyleSheets,io as observedAttributeNames,Mo as registerUnitSystem,jo as viewerHandlerName};
59
+ `;return r}catch{return""}}function H(l,d){const a=B.get(l);if(a)return a.sheet;const r=W(l);if(!r)return null;const t=d.CSSStyleSheet,n=new t;try{n.replaceSync(r)}catch{return null}n[Q]=!0;let i=null;const f=d.MutationObserver;return typeof f=="function"&&String(l.tagName).toLowerCase()==="style"&&(i=new f(()=>{try{n.replaceSync(String(l.textContent||""))}catch{}}),i.observe(l,{childList:!0,characterData:!0,subtree:!0})),B.set(l,{sheet:n,stop:()=>i&&i.disconnect()}),n}function V(l){return l?l.nodeType===9?l:l.ownerDocument||globalThis.document||null:globalThis.document||null}function z(l){const d=l||globalThis.document;return!d||typeof d.querySelectorAll!="function"?[]:[...d.querySelectorAll("style,link[rel]")].filter(X)}function w(l={}){if(!_())return[];const d=l.document||globalThis.document,a=d&&d.defaultView||globalThis,r=[];for(const t of z(d)){const n=H(t,a);n&&!r.includes(n)&&r.push(n)}return r}function S(l,d={}){const a=()=>{};if(!l||typeof l!="object")return a;const r=d.document||V(l);if(!r)return a;const t=r.defaultView||globalThis;let n=I.get(l);n||(n=new Map,I.set(l,n));const i=[],f=_(),u=s=>{if(n.has(s))return;const p=f?H(s,t):null;if(p){n.set(s,p);const O=l.adoptedStyleSheets||[];O.includes(p)||(l.adoptedStyleSheets=[...O,p]);return}if(String(s.tagName).toLowerCase()!=="link"||typeof l.appendChild!="function")return;const y=r.createElement("link");y.setAttribute("rel","stylesheet"),y.setAttribute("href",s.getAttribute("href")||""),y.setAttribute("data-lattice","adopted"),l.appendChild(y),i.push(y),n.set(s,y)};for(const s of z(r))u(s);let o=null;const m=t.MutationObserver,c=r.head||r.documentElement;typeof m=="function"&&c&&(o=new m(s=>{for(const p of s)for(const y of p.addedNodes||[])X(y)&&u(y)}),o.observe(c,{childList:!0}));let h=!1;return()=>{if(h)return;h=!0,o&&o.disconnect();const s=l.adoptedStyleSheets||[],p=new Set([...n.values()]);l.adoptedStyleSheets=s.filter(y=>!p.has(y));for(const y of i)y.parentNode&&y.parentNode.removeChild(y);n.clear()}}function g(l){if(!l||typeof l.getRootNode!="function"||typeof l.getAttribute=="function"&&String(l.getAttribute("lattice-styles")||"")==="off")return null;const d=l.getRootNode();return!d||d.nodeType!==11||!d.host?null:S(d)}}),Le("packages/modules/webcomponent/elements.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_GRID_NAME",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_TAG_PREFIX",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VIEWER_ALIASES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"VIEWER_BINDING",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"coerceElementAttribute",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"attributeConfig",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createElementScope",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"scopeFor",{enumerable:!0,get:function(){return b}}),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 T}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return N}}),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 x=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,V=K("packages/modules/webcomponent/controller.js"),z=V.GridElementController,w=V.observedAttributeNames,S=V.domEventName,g=V.ATTRIBUTE_CONFIG,d=K("packages/modules/webcomponent/styles.js").adoptIntoHostRoot,a="default",r="lattice-",t=Object.freeze({grid:"grid",kpi:"kpi",chart:"chart",kanban:"kanban",calendar:"calendar",gantt:"gantt",layout:"layout",tabs:"tabs",router:"router"}),n=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}}),i=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"]),o=Symbol.for("lattice.webcomponent.routerScope"),m=new WeakMap;function c(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 de of ie){if(f.has(de)||u.has(de)||se&&se.has(de)||de.startsWith("data-")||de.startsWith("aria-"))continue;const he=c(ae.getAttribute(de));he!==void 0&&(ee[s(de)]=he)}return ee}function s(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 y(ae){const se=[];for(const ee of p(ae))f.has(ee)||u.has(ee)||ee.startsWith("data-")||ee.startsWith("aria-")||se.push(s(ee));return se}function O(){const ae=new Map,se=new Set;return{publish(ee,ie){const de=ee||a;ie?ae.set(de,ie):ae.delete(de);for(const he of[...se])he()},get(ee){return ae.get(ee||a)||null},names(){return[...ae.keys()]},subscribe(ee){return se.add(ee),()=>{se.delete(ee)}}}}function A(ae={}){const se=typeof ae.createDataRouter=="function"?ae.createDataRouter:null;let ee=null,ie=!1;return{grids:O(),get router(){return ee},attach(he,ge,Ee){ie||!se||(ee||(ee=se(ae.config||{})),ee.attach(he,ge,Ee||{}))},detach(he){if(!(ie||!ee))try{ee.detach(he)}catch{}},destroy(){ie=!0;const he=ee;ee=null,he&&he.destroy()}}}function b(ae){let se=ae&&ae.parentNode||null;for(;se;){if(se[o])return se[o];se=se.parentNode||se.host||null}const ie=(ae&&typeof ae.getRootNode=="function"?ae.getRootNode():ae&&ae.ownerDocument||null)||globalThis.document||globalThis;let de=m.get(ie);return de||(de=A(),m.set(ie,de)),de}function v(ae,se,ee){const ie=se&&typeof se=="object"?se:{},de=ee&&typeof ee=="object"?ee:{};for(const[he,ge]of Object.entries(ie))Object.is(de[he],ge)||ae.filters.where(he,typeof ge=="function"?ge:null);for(const he of Object.keys(de))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 j=new Set(["instance","config","grid","gridName","router"]);function F(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||j.has(se)||se.startsWith("__"))return;const ee=Object.getOwnPropertyDescriptor(ae,se);if(ee&&typeof ee.get=="function")return;if(F(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(de){this.__write(se,de)},configurable:!0,enumerable:!0}),ee&&(ae[se]=ie)}function T(ae){let se=!1;for(const ee of Object.getOwnPropertyNames(ae)){if(ee.startsWith("__")||j.has(ee))continue;const ie=Object.getOwnPropertyDescriptor(ae,ee);!ie||typeof ie.get=="function"||!ie.enumerable||(C(ae,ee),se=!0)}return se}function L(ae,se,ee){if(!ae||typeof ae.dispatchEvent!="function")return;const ie=globalThis.CustomEvent,de={detail:ee,bubbles:!0,composed:!0};ae.dispatchEvent(typeof ie=="function"?new ie(se,de):{type:se,...de})}function E(ae){const se=ae.viewer,ee=i[se],ie=ae.label||ee.label,de=ae.mount,he=X[se]||[];class ge 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 ye of["config","grid","gridName",...ee.properties,...ee.scalars])R(this,ye);T(this)}get instance(){return this.__controller?this.__controller.instance:null}move(ye,Ae){const pe=this.instance;return pe&&typeof pe.move=="function"?pe.move(ye,Ae):Promise.resolve(!1)}get grid(){return this.__props.grid}set grid(ye){this.__write("grid",ye)}get gridName(){const ye=this.__props.gridName;if(typeof ye=="string")return ye;const Ae=typeof this.getAttribute=="function"?this.getAttribute("grid-name"):null;return Ae===null?void 0:Ae}set gridName(ye){this.__write("gridName",ye)}get config(){return{...this.__props}}set config(ye){if(!(!ye||typeof ye!="object")){for(const[Ae,pe]of Object.entries(ye))this.__props[Ae]=pe;this.__schedule()}}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__wired){this.__wired=!0;const ye=d(this);ye&&this.__release.push(ye);const Ae=b(this);this.__scope=Ae,ee.fromContext&&this.__release.push(Ae.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())}}T(this);for(const ye of y(this))C(this,ye);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 ye of this.__release.splice(0))try{ye()}catch{}this.__tearDown()}}__write(ye,Ae){this.__props[ye]=Ae,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 ye=this.__scope;return ye?ye.grids.get(this.gridName):null}__resolve(){const ye={...h(this,this.__ownAttributes),...this.__props};if(delete ye.gridName,ee.fromContext){const pe=this.__boundGrid();pe?ye[ee.fromContext]=pe:delete ye[ee.fromContext]}const Ae=n[se];Ae&&Ae(ye);for(const pe of he)ye[W(pe)]=we=>L(this,S(pe),we);return ye}__settle(){if(!this.__connected)return;T(this);const ye=this.__resolve(),Ae=ee.fromContext&&ye[ee.fromContext]||null;if(this.__controller&&!Object.is(this.__builtAgainst,Ae)&&this.__tearDown(),!this.__controller){for(const we of ee.requires)if(ye[we]===void 0||ye[we]===null)return;if(ee.fromContext&&!Ae&&ye.rows===void 0)return;const pe=new Set(p(this));this.__controller=H({viewer:se,mount:de,element:this,props:ye,name:ie});for(const we of p(this))pe.has(we)||this.__ownAttributes.add(we);this.__builtAgainst=Ae,L(this,"ready",{instance:this.__controller.instance});return}this.__controller.update(ye)}__tearDown(){const ye=this.__controller;this.__controller=null,this.__builtAgainst=null,ye&&(L(this,"destroyed",{instance:ye.instance}),ye.destroy())}}for(const Ee of[...ee.properties,...ee.scalars])Ee in ae.Base.prototype||Object.defineProperty(ge.prototype,Ee,{get(){return this.__props[Ee]},set(ye){this.__write(Ee,ye)},configurable:!0,enumerable:!0});return ge}function D(ae,se,ee){if(typeof ae!="function")throw new TypeError(`${se} needs ${ee}: ${se}({ ${ee} }).`)}function $(){const ae=globalThis.HTMLElement;return typeof ae=="function"?ae:null}function P(ae){D(ae&&ae.createKPI,"createLatticeKPIElement","createKPI");const se=$();return se?E({viewer:"kpi",Base:se,mount:(ee,ie)=>ae.createKPI(ee,ie)}):null}function k(ae){D(ae&&ae.createChart,"createLatticeChartElement","createChart");const se=$();return se?E({viewer:"chart",Base:se,mount:(ee,ie)=>ae.createChart({...ie,container:ee})}):null}function N(ae){D(ae&&ae.createKanban,"createLatticeKanbanElement","createKanban");const se=$();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=$();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=$();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=$();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=$();return se?E({viewer:"tabs",Base:se,mount:(ie,de)=>{const he=new Map,ge=typeof ie.querySelectorAll=="function"?[...ie.querySelectorAll("template[data-tab]")]:[];for(const Ae of ge)Ae.parentNode===ie&&he.set(Ae.getAttribute("data-tab"),Ae);const ye=(Array.isArray(de.tabs)&&de.tabs.length?de.tabs:[...he.keys()].map(Ae=>({id:Ae,label:he.get(Ae).getAttribute("data-label")||Ae}))).map(Ae=>{const pe=Ae,we=he.get(pe.id);return we?{...pe,view:be=>{const Ne=we.content.cloneNode(!0),Ie=[...Ne.childNodes];return be.appendChild(Ne),{destroy(){for(const Ve of Ie)Ve.parentNode&&Ve.parentNode.removeChild(Ve)}}}}:pe});return ae.createTabs(ie,{...de,tabs:ye,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=$();if(!se)return null;class ee extends se{__scope=null;__config={};constructor(){super(),R(this,"config")}get config(){return{...this.__config}}set config(de){!de||typeof de!="object"||(this.__config={...this.__config,...de},this.__scope&&this.__scope.router&&x("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 de=h(this);this.__scope=A({createDataRouter:ae.createDataRouter,config:{...de,...this.__config}}),this[o]=this.__scope}disconnectedCallback(){const de=this.__scope;if(this.__scope=null,this[o]=null,!de)return;const he=de.router;de.destroy(),he&&L(this,"destroyed",{instance:he})}}return ee}function ne(ae={}){const se={},ee=(ie,de,he)=>{if(typeof de!="function")return;const ge=he();ge&&(se[ie]=ge)};return ee("LatticeGridElement",ae.createGrid,()=>le(ae.createGrid)),ee("LatticeKPIElement",ae.createKPI,()=>P({createKPI:ae.createKPI})),ee("LatticeChartElement",ae.createChart,()=>k({createChart:ae.createChart})),ee("LatticeKanbanElement",ae.createKanban,()=>N({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:r,de=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[ge,Ee]of Object.entries(de)){const ye=ie+he[ge],Ae=se.get?se.get(ye):void 0;if(Ae){ee[ye]=Ae;continue}se.define(ye,Ee),ee[ye]=Ee}return ee}function le(ae){const se=$();if(!se)return null;class ee extends se{static get observedAttributes(){return w()}__connected=!1;__teardownPending=!1;__published=!1;__publishedAs=a;__scope=null;__predicates=void 0;__rowUpdates=void 0;__release=[];constructor(){super(),this.__controller=new z(this,{createGrid:ae});for(const de of["rows","columns","config","predicates","rowUpdates",...Object.values(g)])R(this,de)}get grid(){return this.__controller.grid}get instance(){return this.__controller.grid}get rows(){return this.__controller.config().rows}set rows(de){this.__controller.configure({rows:de})}get columns(){return this.__controller.config().columns}set columns(de){this.__controller.configure({columns:de})}get config(){return this.__controller.config()}set config(de){this.__controller.configure(de)}get predicates(){return this.__predicates}set predicates(de){const he=this.__published?this.__controller.grid:null;he&&v(he,de,this.__predicates),this.__predicates=de}get rowUpdates(){return this.__rowUpdates}set rowUpdates(de){if(Object.is(de,this.__rowUpdates))return;this.__rowUpdates=de;const he=this.__published?this.__controller.grid:null;he&&de&&he.rows.apply(de)}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__scope){const de=d(this);de&&this.__release.push(de),this.__scope=b(this)}this.__controller.connect(),queueMicrotask(()=>this.__publish())}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()),this.__controller.disconnect())}attributeChangedCallback(de,he,ge){this.__controller.attributeChanged(de,ge)}__publish(){if(!this.__connected||this.__published)return;const de=this.__controller.grid;if(!de)return;this.__published=!0,this.__predicates&&v(de,this.__predicates,{});const he=typeof this.getAttribute=="function"?this.getAttribute("name"):null;this.__publishedAs=he||a;const ge=this.__scope;ge&&ge.grids.publish(this.__publishedAs,de);const Ee=typeof this.getAttribute=="function"?this.getAttribute("route"):null;if(ge&&Ee!==null){const ye=this.getAttribute("route-options");ge.attach(de,c(Ee),ye===null?{}:c(ye))}this.__rowUpdates&&de.rows.apply(this.__rowUpdates),L(this,"grid-ready",{grid:de})}__settleTeardown(){if(!this.__teardownPending)return;this.__teardownPending=!1;const de=this.__controller.grid,he=this.__scope;this.__scope=null,this.__published=!1;for(const ge of this.__release.splice(0))try{ge()}catch{}de&&he&&(L(this,"grid-destroyed",{grid:de}),he.detach(de),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(de){this.__controller.configure({[ie]:de})},configurable:!0,enumerable:!0});return ee}}),Le("packages/modules/webcomponent/index.js",function(e,K){"use strict";Object.defineProperty(e,"TAG_NAME",{enumerable:!0,get:function(){return V}}),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 S}});const Q=K("packages/dom/src/index.js"),x=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 V="lattice-grid";function z(g=x){return I(g)}function w(g={}){const l=globalThis.customElements,d=g.tagName||V;if(!l||typeof l.define!="function")return null;const a=l.get?l.get(d):void 0;if(a)return a;const r=z(g.createGrid||x);return r?(l.define(d,r),r):null}w();const S=w});try{Wn("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.89.1";async function he(){return ae}const W="1.89.1",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=Wn("packages/modules/webcomponent/index.js"),ro=zt.GridElementController,io=zt.observedAttributeNames,oo=zt.domEventName,so=zt.ATTRIBUTE_CONFIG,ao=zt.EVENT_PREFIX,lo=zt.createLatticeElements,uo=zt.defineLatticeElements,co=zt.ELEMENT_TAGS,fo=zt.createLatticeKPIElement,ho=zt.createLatticeChartElement,po=zt.createLatticeKanbanElement,mo=zt.createLatticeCalendarElement,go=zt.createLatticeGanttElement,yo=zt.createLatticeLayoutElement,bo=zt.createLatticeTabsElement,wo=zt.createLatticeRouterElement,vo=zt.adoptLatticeStyles,ko=zt.latticeStyleSheets,So=zt.VIEWER_EVENTS,Oo=zt.VIEWER_APPLY,jo=zt.viewerHandlerName,Ao=zt.createViewerController,Po=zt.EVENT_NAMES,Co=zt.dashedName,Eo=zt.createCurrencyType,To=zt.createUnitType,Mo=zt.registerUnitSystem,No=zt.createStat,Ro=zt.createHeadlessGrid,Lo=zt.duckdbAdapter,Fo=zt.createPushdownSource,xo=zt.TAG_NAME,Io=zt.createLatticeGridElement,$o=zt.defineLatticeGrid;var Do=zt.default;export{so as ATTRIBUTE_CONFIG,co as ELEMENT_TAGS,Po as EVENT_NAMES,ao as EVENT_PREFIX,ro as GridElementController,xo as TAG_NAME,Oo as VIEWER_APPLY,So as VIEWER_EVENTS,vo as adoptLatticeStyles,Eo as createCurrencyType,Ro as createHeadlessGrid,mo as createLatticeCalendarElement,ho as createLatticeChartElement,lo as createLatticeElements,go as createLatticeGanttElement,Io as createLatticeGridElement,fo as createLatticeKPIElement,po as createLatticeKanbanElement,yo as createLatticeLayoutElement,wo as createLatticeRouterElement,bo as createLatticeTabsElement,Fo as createPushdownSource,No as createStat,To as createUnitType,Ao as createViewerController,Co as dashedName,Do as default,uo as defineLatticeElements,$o as defineLatticeGrid,oo as domEventName,Lo as duckdbAdapter,ko as latticeStyleSheets,io as observedAttributeNames,Mo as registerUnitSystem,jo as viewerHandlerName};
60
60
 
61
61
  //# sourceMappingURL=webcomponent.esm.min.js.map