@toclocoinc/lattice-grid 1.101.7 → 1.101.8
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.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/angular/package.json +1 -1
- package/docs/API.html +8 -6
- package/docs/api/adapters.html +1 -1
- package/docs/api/ai.html +1 -1
- package/docs/api/alarms.html +1 -1
- package/docs/api/calendar.html +1 -1
- package/docs/api/charts.html +1 -1
- package/docs/api/dashboard.html +1 -1
- package/docs/api/data-router.html +1 -1
- package/docs/api/deckgl.html +1 -1
- package/docs/api/designer.html +1 -1
- package/docs/api/form.html +5 -3
- package/docs/api/gantt.html +1 -1
- package/docs/api/geometry.html +1 -1
- package/docs/api/grid.html +2 -2
- package/docs/api/index.html +2 -2
- package/docs/api/kanban.html +1 -1
- package/docs/api/kpi.html +1 -1
- package/docs/api/layout.html +1 -1
- package/docs/api/leaflet.html +1 -1
- package/docs/api/list.html +1 -1
- package/docs/api/mapview.html +1 -1
- package/docs/api/mock-socket.html +1 -1
- package/docs/api/presets.html +1 -1
- package/docs/api/scheduler.html +1 -1
- package/docs/api/shell.html +1 -1
- package/docs/api/tabs.html +1 -1
- package/docs/api/types.html +1 -1
- package/docs/api-detail.html +4 -4
- package/docs/warnings.json +1 -1
- package/lattice-grid.d.ts +1 -1
- package/lattice-grid.esm.min.js +2 -2
- package/lattice-grid.min.cjs +2 -2
- package/lattice-grid.min.js +2 -2
- package/locales/all.d.ts +1 -1
- package/locales/all.esm.min.js +1 -1
- package/locales/all.min.cjs +1 -1
- package/locales/all.min.js +1 -1
- package/locales/ar.d.ts +1 -1
- package/locales/ar.esm.min.js +1 -1
- package/locales/ar.min.cjs +1 -1
- package/locales/ar.min.js +1 -1
- package/locales/cs-CZ.d.ts +1 -1
- package/locales/cs-CZ.esm.min.js +1 -1
- package/locales/cs-CZ.min.cjs +1 -1
- package/locales/cs-CZ.min.js +1 -1
- package/locales/da-DK.d.ts +1 -1
- package/locales/da-DK.esm.min.js +1 -1
- package/locales/da-DK.min.cjs +1 -1
- package/locales/da-DK.min.js +1 -1
- package/locales/de-DE.d.ts +1 -1
- package/locales/de-DE.esm.min.js +1 -1
- package/locales/de-DE.min.cjs +1 -1
- package/locales/de-DE.min.js +1 -1
- package/locales/el-GR.d.ts +1 -1
- package/locales/el-GR.esm.min.js +1 -1
- package/locales/el-GR.min.cjs +1 -1
- package/locales/el-GR.min.js +1 -1
- package/locales/en-US.d.ts +1 -1
- package/locales/en-US.esm.min.js +1 -1
- package/locales/en-US.min.cjs +1 -1
- package/locales/en-US.min.js +1 -1
- package/locales/es-ES.d.ts +1 -1
- package/locales/es-ES.esm.min.js +1 -1
- package/locales/es-ES.min.cjs +1 -1
- package/locales/es-ES.min.js +1 -1
- package/locales/fi-FI.d.ts +1 -1
- package/locales/fi-FI.esm.min.js +1 -1
- package/locales/fi-FI.min.cjs +1 -1
- package/locales/fi-FI.min.js +1 -1
- package/locales/fr-CA.d.ts +1 -1
- package/locales/fr-CA.esm.min.js +1 -1
- package/locales/fr-CA.min.cjs +1 -1
- package/locales/fr-CA.min.js +1 -1
- package/locales/fr-FR.d.ts +1 -1
- package/locales/fr-FR.esm.min.js +1 -1
- package/locales/fr-FR.min.cjs +1 -1
- package/locales/fr-FR.min.js +1 -1
- package/locales/hu-HU.d.ts +1 -1
- package/locales/hu-HU.esm.min.js +1 -1
- package/locales/hu-HU.min.cjs +1 -1
- package/locales/hu-HU.min.js +1 -1
- package/locales/it-IT.d.ts +1 -1
- package/locales/it-IT.esm.min.js +1 -1
- package/locales/it-IT.min.cjs +1 -1
- package/locales/it-IT.min.js +1 -1
- package/locales/ja-JP.d.ts +1 -1
- package/locales/ja-JP.esm.min.js +1 -1
- package/locales/ja-JP.min.cjs +1 -1
- package/locales/ja-JP.min.js +1 -1
- package/locales/nb-NO.d.ts +1 -1
- package/locales/nb-NO.esm.min.js +1 -1
- package/locales/nb-NO.min.cjs +1 -1
- package/locales/nb-NO.min.js +1 -1
- package/locales/nl-NL.d.ts +1 -1
- package/locales/nl-NL.esm.min.js +1 -1
- package/locales/nl-NL.min.cjs +1 -1
- package/locales/nl-NL.min.js +1 -1
- package/locales/pl-PL.d.ts +1 -1
- package/locales/pl-PL.esm.min.js +1 -1
- package/locales/pl-PL.min.cjs +1 -1
- package/locales/pl-PL.min.js +1 -1
- package/locales/pt-BR.d.ts +1 -1
- package/locales/pt-BR.esm.min.js +1 -1
- package/locales/pt-BR.min.cjs +1 -1
- package/locales/pt-BR.min.js +1 -1
- package/locales/ro-RO.d.ts +1 -1
- package/locales/ro-RO.esm.min.js +1 -1
- package/locales/ro-RO.min.cjs +1 -1
- package/locales/ro-RO.min.js +1 -1
- package/locales/sv-SE.d.ts +1 -1
- package/locales/sv-SE.esm.min.js +1 -1
- package/locales/sv-SE.min.cjs +1 -1
- package/locales/sv-SE.min.js +1 -1
- package/locales/uk-UA.d.ts +1 -1
- package/locales/uk-UA.esm.min.js +1 -1
- package/locales/uk-UA.min.cjs +1 -1
- package/locales/uk-UA.min.js +1 -1
- package/modules/ai.d.ts +1 -1
- package/modules/ai.esm.min.js +1 -1
- package/modules/ai.min.cjs +1 -1
- package/modules/ai.min.js +1 -1
- package/modules/alarms.d.ts +1 -1
- package/modules/alarms.esm.min.js +1 -1
- package/modules/alarms.min.cjs +1 -1
- package/modules/alarms.min.js +1 -1
- package/modules/angular.d.ts +1 -1
- package/modules/angular.esm.min.js +1 -1
- package/modules/angular.min.cjs +1 -1
- package/modules/angular.min.js +1 -1
- package/modules/calendar.d.ts +1 -1
- package/modules/calendar.esm.min.js +1 -1
- package/modules/calendar.min.cjs +1 -1
- package/modules/calendar.min.js +1 -1
- package/modules/chart-alluvial.d.ts +1 -1
- package/modules/chart-alluvial.esm.min.js +1 -1
- package/modules/chart-alluvial.min.cjs +1 -1
- package/modules/chart-alluvial.min.js +1 -1
- package/modules/chart-arc.d.ts +1 -1
- package/modules/chart-arc.esm.min.js +1 -1
- package/modules/chart-arc.min.cjs +1 -1
- package/modules/chart-arc.min.js +1 -1
- package/modules/chart-barrace.d.ts +1 -1
- package/modules/chart-barrace.esm.min.js +1 -1
- package/modules/chart-barrace.min.cjs +1 -1
- package/modules/chart-barrace.min.js +1 -1
- package/modules/chart-bubblemap.d.ts +1 -1
- package/modules/chart-bubblemap.esm.min.js +1 -1
- package/modules/chart-bubblemap.min.cjs +1 -1
- package/modules/chart-bubblemap.min.js +1 -1
- package/modules/chart-bump.d.ts +1 -1
- package/modules/chart-bump.esm.min.js +1 -1
- package/modules/chart-bump.min.cjs +1 -1
- package/modules/chart-bump.min.js +1 -1
- package/modules/chart-calendar.d.ts +1 -1
- package/modules/chart-calendar.esm.min.js +1 -1
- package/modules/chart-calendar.min.cjs +1 -1
- package/modules/chart-calendar.min.js +1 -1
- package/modules/chart-choropleth.d.ts +1 -1
- package/modules/chart-choropleth.esm.min.js +1 -1
- package/modules/chart-choropleth.min.cjs +1 -1
- package/modules/chart-choropleth.min.js +1 -1
- package/modules/chart-decomposition.d.ts +1 -1
- package/modules/chart-decomposition.esm.min.js +1 -1
- package/modules/chart-decomposition.min.cjs +1 -1
- package/modules/chart-decomposition.min.js +1 -1
- package/modules/chart-diverging.d.ts +1 -1
- package/modules/chart-diverging.esm.min.js +1 -1
- package/modules/chart-diverging.min.cjs +1 -1
- package/modules/chart-diverging.min.js +1 -1
- package/modules/chart-dumbbell.d.ts +1 -1
- package/modules/chart-dumbbell.esm.min.js +1 -1
- package/modules/chart-dumbbell.min.cjs +1 -1
- package/modules/chart-dumbbell.min.js +1 -1
- package/modules/chart-fan.d.ts +1 -1
- package/modules/chart-fan.esm.min.js +1 -1
- package/modules/chart-fan.min.cjs +1 -1
- package/modules/chart-fan.min.js +1 -1
- package/modules/chart-forcetree.d.ts +1 -1
- package/modules/chart-forcetree.esm.min.js +1 -1
- package/modules/chart-forcetree.min.cjs +1 -1
- package/modules/chart-forcetree.min.js +1 -1
- package/modules/chart-hexbin.d.ts +1 -1
- package/modules/chart-hexbin.esm.min.js +1 -1
- package/modules/chart-hexbin.min.cjs +1 -1
- package/modules/chart-hexbin.min.js +1 -1
- package/modules/chart-hexmap.d.ts +1 -1
- package/modules/chart-hexmap.esm.min.js +1 -1
- package/modules/chart-hexmap.min.cjs +1 -1
- package/modules/chart-hexmap.min.js +1 -1
- package/modules/chart-icicle.d.ts +1 -1
- package/modules/chart-icicle.esm.min.js +1 -1
- package/modules/chart-icicle.min.cjs +1 -1
- package/modules/chart-icicle.min.js +1 -1
- package/modules/chart-markermap.d.ts +1 -1
- package/modules/chart-markermap.esm.min.js +1 -1
- package/modules/chart-markermap.min.cjs +1 -1
- package/modules/chart-markermap.min.js +1 -1
- package/modules/chart-motion.d.ts +1 -1
- package/modules/chart-motion.esm.min.js +1 -1
- package/modules/chart-motion.min.cjs +1 -1
- package/modules/chart-motion.min.js +1 -1
- package/modules/chart-pack.d.ts +1 -1
- package/modules/chart-pack.esm.min.js +1 -1
- package/modules/chart-pack.min.cjs +1 -1
- package/modules/chart-pack.min.js +1 -1
- package/modules/chart-parallel.d.ts +1 -1
- package/modules/chart-parallel.esm.min.js +1 -1
- package/modules/chart-parallel.min.cjs +1 -1
- package/modules/chart-parallel.min.js +1 -1
- package/modules/chart-pictorial.d.ts +1 -1
- package/modules/chart-pictorial.esm.min.js +1 -1
- package/modules/chart-pictorial.min.cjs +1 -1
- package/modules/chart-pictorial.min.js +1 -1
- package/modules/chart-polararea.d.ts +1 -1
- package/modules/chart-polararea.esm.min.js +1 -1
- package/modules/chart-polararea.min.cjs +1 -1
- package/modules/chart-polararea.min.js +1 -1
- package/modules/chart-polarscatter.d.ts +1 -1
- package/modules/chart-polarscatter.esm.min.js +1 -1
- package/modules/chart-polarscatter.min.cjs +1 -1
- package/modules/chart-polarscatter.min.js +1 -1
- package/modules/chart-pyramid.d.ts +1 -1
- package/modules/chart-pyramid.esm.min.js +1 -1
- package/modules/chart-pyramid.min.cjs +1 -1
- package/modules/chart-pyramid.min.js +1 -1
- package/modules/chart-radialbar.d.ts +1 -1
- package/modules/chart-radialbar.esm.min.js +1 -1
- package/modules/chart-radialbar.min.cjs +1 -1
- package/modules/chart-radialbar.min.js +1 -1
- package/modules/chart-ridgeline.d.ts +1 -1
- package/modules/chart-ridgeline.esm.min.js +1 -1
- package/modules/chart-ridgeline.min.cjs +1 -1
- package/modules/chart-ridgeline.min.js +1 -1
- package/modules/chart-roc.d.ts +1 -1
- package/modules/chart-roc.esm.min.js +1 -1
- package/modules/chart-roc.min.cjs +1 -1
- package/modules/chart-roc.min.js +1 -1
- package/modules/chart-scatter3d.d.ts +1 -1
- package/modules/chart-scatter3d.esm.min.js +1 -1
- package/modules/chart-scatter3d.min.cjs +1 -1
- package/modules/chart-scatter3d.min.js +1 -1
- package/modules/chart-serpentine.d.ts +1 -1
- package/modules/chart-serpentine.esm.min.js +1 -1
- package/modules/chart-serpentine.min.cjs +1 -1
- package/modules/chart-serpentine.min.js +1 -1
- package/modules/chart-slope.d.ts +1 -1
- package/modules/chart-slope.esm.min.js +1 -1
- package/modules/chart-slope.min.cjs +1 -1
- package/modules/chart-slope.min.js +1 -1
- package/modules/chart-spiral.d.ts +1 -1
- package/modules/chart-spiral.esm.min.js +1 -1
- package/modules/chart-spiral.min.cjs +1 -1
- package/modules/chart-spiral.min.js +1 -1
- package/modules/chart-splom.d.ts +1 -1
- package/modules/chart-splom.esm.min.js +1 -1
- package/modules/chart-splom.min.cjs +1 -1
- package/modules/chart-splom.min.js +1 -1
- package/modules/chart-tree.d.ts +1 -1
- package/modules/chart-tree.esm.min.js +1 -1
- package/modules/chart-tree.min.cjs +1 -1
- package/modules/chart-tree.min.js +1 -1
- package/modules/chart-venn.d.ts +1 -1
- package/modules/chart-venn.esm.min.js +1 -1
- package/modules/chart-venn.min.cjs +1 -1
- package/modules/chart-venn.min.js +1 -1
- package/modules/chart-voronoi.d.ts +1 -1
- package/modules/chart-voronoi.esm.min.js +1 -1
- package/modules/chart-voronoi.min.cjs +1 -1
- package/modules/chart-voronoi.min.js +1 -1
- package/modules/chart-waffle.d.ts +1 -1
- package/modules/chart-waffle.esm.min.js +1 -1
- package/modules/chart-waffle.min.cjs +1 -1
- package/modules/chart-waffle.min.js +1 -1
- package/modules/chart-wordcloud.d.ts +1 -1
- package/modules/chart-wordcloud.esm.min.js +1 -1
- package/modules/chart-wordcloud.min.cjs +1 -1
- package/modules/chart-wordcloud.min.js +1 -1
- package/modules/charts.d.ts +1 -1
- package/modules/charts.esm.min.js +1 -1
- package/modules/charts.min.cjs +1 -1
- package/modules/charts.min.js +1 -1
- package/modules/dashboard.d.ts +1 -1
- package/modules/dashboard.esm.min.js +1 -1
- package/modules/dashboard.min.cjs +1 -1
- package/modules/dashboard.min.js +1 -1
- package/modules/data-router.d.ts +1 -1
- package/modules/data-router.esm.min.js +1 -1
- package/modules/data-router.min.cjs +1 -1
- package/modules/data-router.min.js +1 -1
- package/modules/deckgl.d.ts +1 -1
- package/modules/deckgl.esm.min.js +1 -1
- package/modules/deckgl.min.cjs +1 -1
- package/modules/deckgl.min.js +1 -1
- package/modules/designer.d.ts +1 -1
- package/modules/designer.esm.min.js +1 -1
- package/modules/designer.min.cjs +1 -1
- package/modules/designer.min.js +1 -1
- package/modules/devtools.d.ts +1 -1
- package/modules/devtools.esm.min.js +1 -1
- package/modules/devtools.min.cjs +1 -1
- package/modules/devtools.min.js +1 -1
- package/modules/dhtmlx-compat.d.ts +1 -1
- package/modules/dhtmlx-compat.esm.min.js +1 -1
- package/modules/dhtmlx-compat.min.cjs +1 -1
- package/modules/dhtmlx-compat.min.js +1 -1
- package/modules/form.d.ts +4 -2
- package/modules/form.esm.min.js +198 -178
- package/modules/form.esm.min.js.map +2 -2
- package/modules/form.min.cjs +198 -178
- package/modules/form.min.js +198 -178
- package/modules/form.min.js.map +2 -2
- package/modules/gantt.d.ts +1 -1
- package/modules/gantt.esm.min.js +1 -1
- package/modules/gantt.min.cjs +1 -1
- package/modules/gantt.min.js +1 -1
- package/modules/geo-europe-nuts.d.ts +1 -1
- package/modules/geo-europe-nuts.esm.min.js +1 -1
- package/modules/geo-europe-nuts.min.cjs +1 -1
- package/modules/geo-europe-nuts.min.js +1 -1
- package/modules/geo-uk.d.ts +1 -1
- package/modules/geo-uk.esm.min.js +1 -1
- package/modules/geo-uk.min.cjs +1 -1
- package/modules/geo-uk.min.js +1 -1
- package/modules/geo-us-states.d.ts +1 -1
- package/modules/geo-us-states.esm.min.js +1 -1
- package/modules/geo-us-states.min.cjs +1 -1
- package/modules/geo-us-states.min.js +1 -1
- package/modules/geo-world-110m.d.ts +1 -1
- package/modules/geo-world-110m.esm.min.js +1 -1
- package/modules/geo-world-110m.min.cjs +1 -1
- package/modules/geo-world-110m.min.js +1 -1
- package/modules/geo-world-50m.d.ts +1 -1
- package/modules/geo-world-50m.esm.min.js +1 -1
- package/modules/geo-world-50m.min.cjs +1 -1
- package/modules/geo-world-50m.min.js +1 -1
- package/modules/geometry.d.ts +1 -1
- package/modules/geometry.esm.min.js +1 -1
- package/modules/geometry.min.cjs +1 -1
- package/modules/geometry.min.js +1 -1
- package/modules/htmx.d.ts +1 -1
- package/modules/htmx.esm.min.js +2 -2
- package/modules/htmx.min.cjs +2 -2
- package/modules/htmx.min.js +2 -2
- package/modules/kanban.d.ts +1 -1
- package/modules/kanban.esm.min.js +1 -1
- package/modules/kanban.min.cjs +1 -1
- package/modules/kanban.min.js +1 -1
- package/modules/kpi.d.ts +1 -1
- package/modules/kpi.esm.min.js +1 -1
- package/modules/kpi.min.cjs +1 -1
- package/modules/kpi.min.js +1 -1
- package/modules/layout.d.ts +1 -1
- package/modules/layout.esm.min.js +1 -1
- package/modules/layout.min.cjs +1 -1
- package/modules/layout.min.js +1 -1
- package/modules/leaflet.d.ts +1 -1
- package/modules/leaflet.esm.min.js +1 -1
- package/modules/leaflet.min.cjs +1 -1
- package/modules/leaflet.min.js +1 -1
- package/modules/list.d.ts +1 -1
- package/modules/list.esm.min.js +1 -1
- package/modules/list.min.cjs +1 -1
- package/modules/list.min.js +1 -1
- package/modules/mapview.d.ts +1 -1
- package/modules/mapview.esm.min.js +1 -1
- package/modules/mapview.min.cjs +1 -1
- package/modules/mapview.min.js +1 -1
- package/modules/mock-socket.d.ts +1 -1
- package/modules/mock-socket.esm.min.js +1 -1
- package/modules/mock-socket.min.cjs +1 -1
- package/modules/mock-socket.min.js +1 -1
- package/modules/presets.d.ts +1 -1
- package/modules/presets.esm.min.js +1 -1
- package/modules/presets.min.cjs +1 -1
- package/modules/presets.min.js +1 -1
- package/modules/react.d.ts +1 -1
- package/modules/react.esm.min.js +1 -1
- package/modules/react.min.cjs +1 -1
- package/modules/react.min.js +1 -1
- package/modules/scheduler.d.ts +1 -1
- package/modules/scheduler.esm.min.js +1 -1
- package/modules/scheduler.min.cjs +1 -1
- package/modules/scheduler.min.js +1 -1
- package/modules/shell.d.ts +1 -1
- package/modules/shell.esm.min.js +1 -1
- package/modules/shell.min.cjs +1 -1
- package/modules/shell.min.js +1 -1
- package/modules/svelte.d.ts +1 -1
- package/modules/svelte.esm.min.js +1 -1
- package/modules/svelte.min.cjs +1 -1
- package/modules/svelte.min.js +1 -1
- package/modules/tabs.d.ts +1 -1
- package/modules/tabs.esm.min.js +1 -1
- package/modules/tabs.min.cjs +1 -1
- package/modules/tabs.min.js +1 -1
- package/modules/vue.d.ts +1 -1
- package/modules/vue.esm.min.js +1 -1
- package/modules/vue.min.cjs +1 -1
- package/modules/vue.min.js +1 -1
- package/modules/webcomponent.d.ts +1 -1
- package/modules/webcomponent.esm.min.js +2 -2
- package/modules/webcomponent.min.cjs +2 -2
- package/modules/webcomponent.min.js +2 -2
- package/package.json +1 -1
package/lattice-grid.min.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.101.
|
|
2
|
+
* Lattice Grid 1.101.8, core + DOM renderer
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
6
|
(function(mr){"use strict";var Ys=!0,Yn=Object.create(null),Xn=Object.create(null);function Ie(e,U){Yn[e]=U}function In(e){var U=Xn[e];if(U)return U;var te=Object.create(null);Xn[e]=te;var N=Yn[e];if(!N)throw new Error("[lattice] missing module: "+e);return N(te,In),te}Ie("packages/core/src/internal/predicates.js",function(e,U){"use strict";Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return D}});function te(q){return q!==null&&typeof q=="object"&&!Array.isArray(q)}function N(q){return typeof q=="function"}function X(q){return q==null}function B(q){return q==null||q===""}function D(q){return typeof q!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(q))?!0:!!(q.prototype&&Object.getOwnPropertyNames(q.prototype).length>1)}}),Ie("packages/core/src/internal/warn.js",function(e,U){"use strict";Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return f}});const te=new Set,N=2e3;function X(a){if(te.add(a),te.size>N){const r=te.values().next().value;r!==void 0&&te.delete(r)}}const B=[],D=500;function q(a,r,t){B.push({key:a,level:r,message:t.map(s=>typeof s=="string"?s:K(s)).join(" "),at:Date.now()}),B.length>D&&B.shift()}function K(a){if(a instanceof Error)return a.message;try{return JSON.stringify(a)}catch{return String(a)}}function x(){return B.map(a=>({...a}))}function G(a){if(a.length===0||typeof a[0]!="string")return a;const r=a[0].replace(/^\[lattice\]\s*/,"");return r===a[0]?a:[r,...a.slice(1)]}function z(a,...r){if(te.has(a))return;X(a);const t=G(r);q(a,"warn",t),console.warn("[lattice]",...t)}function j(a,...r){if(te.has(a))return;X(a);const t=G(r);q(a,"info",t),console.info("[lattice]",...t)}function O(){te.clear(),B.length=0}function b(a,r){const t=new Error(`[lattice] ${a}`);throw r!==void 0&&(t.cause=r),t}function u(a,r){a||b(r)}const f=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})()}),Ie("packages/core/src/formatting/rules.js",function(e,U){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return E}});const N=U("packages/core/src/internal/predicates.js").isFunction,B=U("packages/core/src/internal/warn.js").warnOnce,D=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),q=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),K=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 x($,S){const R=Number($),L=Number(S);if($!==null&&$!==""&&S!==null&&S!==""&&Number.isFinite(R)&&Number.isFinite(L))return R<L?-1:R>L?1:0;const A=String($??"").toLowerCase(),C=String(S??"").toLowerCase();return A<C?-1:A>C?1:0}function G($){return $==null||$===""}function z($,S){if(!S||typeof S!="object")return!1;const{op:R}=S,L=S.value,T=S.value2;switch(R){case"blank":return G($);case"notBlank":return!G($);case"true":return $===!0;case"false":return $===!1;default:break}if(G($))return!1;switch(R){case"eq":return x($,L)===0;case"ne":return x($,L)!==0;case"gt":return x($,L)>0;case"gte":return x($,L)>=0;case"lt":return x($,L)<0;case"lte":return x($,L)<=0;case"between":return x($,L)>=0&&x($,T)<=0;case"outside":return x($,L)<0||x($,T)>0;case"contains":return String($).toLowerCase().includes(String(L??"").toLowerCase());case"notContains":return!String($).toLowerCase().includes(String(L??"").toLowerCase());case"startsWith":return String($).toLowerCase().startsWith(String(L??"").toLowerCase());case"endsWith":return String($).toLowerCase().endsWith(String(L??"").toLowerCase());default:return!1}}function j($,S,R){const L=ee=>{const ne=String(ee).replace("#",""),se=ne.length===3?ne.split("").map(oe=>oe+oe).join(""):ne;return[0,2,4].map(oe=>parseInt(se.slice(oe,oe+2),16)||0)},[T,A,C]=L($),[H,Y,Z]=L(S),_=Math.max(0,Math.min(1,R)),J=(ee,ne)=>Math.round(ee+(ne-ee)*_);return`#${[J(T,H),J(A,Y),J(C,Z)].map(ee=>ee.toString(16).padStart(2,"0")).join("")}`}function O($){const S=[];for(const H of $||[]){if(H==null||H==="")continue;const Y=H instanceof Date?H.getTime():Number(H);Number.isFinite(Y)&&S.push(Y)}if(!S.length)return null;S.sort((H,Y)=>H-Y);let R=0,L=0,T=0;for(const H of S){R++;const Y=H-L;L+=Y/R,T+=Y*(H-L)}const A=b(S,.25),C=b(S,.75);return{n:S.length,min:S[0],max:S[S.length-1],mean:L,stddev:S.length>1?Math.sqrt(T/(S.length-1)):0,median:b(S,.5),q1:A,q3:C,iqr:C-A,sorted:S}}function b($,S){if(!$.length)return 0;const R=($.length-1)*Math.max(0,Math.min(1,S)),L=Math.floor(R),T=Math.ceil(R);return L===T?$[L]:$[L]+(R-L)*($[T]-$[L])}function u($){for(const S of Array.isArray($)?$:[])if(!(!S||typeof S!="object")&&(S.when&&q.includes(S.when.op)||S.scale&&S.scale.from||S.dataBar&&!(Number.isFinite(Number(S.dataBar.min))&&Number.isFinite(Number(S.dataBar.max)))||S.iconSet&&!Array.isArray(S.iconSet.thresholds)))return!0;return!1}function f($,S){const R=Number($.value),L=T=>b(S.sorted,T);switch($.op){case"topPercent":{const T=a(R,10);return{op:"gte",value:L(1-T)}}case"bottomPercent":{const T=a(R,10);return{op:"lte",value:L(T)}}case"topN":{const T=Math.max(1,Math.floor(R)||1),A=Math.max(0,S.sorted.length-T);return{op:"gte",value:S.sorted[A]}}case"bottomN":{const T=Math.max(1,Math.floor(R)||1),A=Math.min(S.sorted.length-1,T-1);return{op:"lte",value:S.sorted[A]}}case"aboveMean":return{op:"gt",value:S.mean};case"belowMean":return{op:"lt",value:S.mean};case"aboveMedian":return{op:"gt",value:S.median};case"belowMedian":return{op:"lt",value:S.median};case"zAbove":return S.stddev?{op:"gte",value:S.mean+(Number.isFinite(R)?R:2)*S.stddev}:null;case"zBelow":return S.stddev?{op:"lte",value:S.mean-(Number.isFinite(R)?R:2)*S.stddev}:null;case"outlier":{const T=(Number.isFinite(R)&&R>0?R:1.5)*S.iqr;return S.iqr?{op:"outside",value:S.q1-T,value2:S.q3+T}:null}default:return null}}function a($,S){const R=Number.isFinite($)?$:S,L=R>1?R/100:R;return Math.max(0,Math.min(1,L))}function r($,S){if($.from==="minmax")return{...$,min:S.min,max:S.max};if($.from==="quantile")return{...$,min:b(S.sorted,a(Number($.low),5)),max:b(S.sorted,a(Number($.high),95))};if($.from==="stddev"){const R=Number.isFinite(Number($.deviations))?Number($.deviations):2;return{...$,min:S.mean-R*S.stddev,max:S.mean+R*S.stddev}}return $}function t($,S){const R=Array.isArray($)?$:[];return!S||!S.n?R.map(L=>L&&u([L])?{...L,enabled:!1}:L):R.map(L=>{if(!L||typeof L!="object")return L;if(L.scale&&L.scale.from)return{...L,scale:r(L.scale,S)};if(L.dataBar)return{...L,dataBar:s(L.dataBar,S)};if(L.iconSet)return{...L,iconSet:i(L.iconSet,S)};if(!L.when||!q.includes(L.when.op))return L;const T=f(L.when,S);return T?{...L,when:T}:{...L,enabled:!1}})}function s($,S){const R=Number.isFinite(Number($.min))?Number($.min):void 0,L=Number.isFinite(Number($.max))?Number($.max):void 0;if(R!==void 0&&L!==void 0)return{...$,min:R,max:L};if($.from==="quantile")return{...$,min:R??b(S.sorted,a(Number($.low),5)),max:L??b(S.sorted,a(Number($.high),95))};if($.from==="stddev"){const T=Number.isFinite(Number($.deviations))?Number($.deviations):2;return{...$,min:R??S.mean-T*S.stddev,max:L??S.mean+T*S.stddev}}return{...$,min:R??S.min,max:L??S.max}}function i($,S){if(Array.isArray($.thresholds))return $;const R=n($),L=[];for(let T=1;T<R;T++)L.push(b(S.sorted,T/R));return{...$,thresholds:L}}function n($){if(Array.isArray($.icons)&&$.icons.length>=2)return $.icons.length;if(Number.isFinite(Number($.count))&&Number($.count)>=2)return Math.floor(Number($.count));const S=k[$.set];return S?S.length:3}function c($){return`url("data:image/svg+xml,${encodeURIComponent($)}")`}function o($){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${$}"/></svg>`}function l($,S){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${S==="up"?"8,2 14,13 2,13":S==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${$}"/></svg>`}function h($,S){const R="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 L=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${S*16} 16">`;for(let T=0;T<S;T++){const A=T<$?"#f5a623":"#d0d0d0";L+=`<path transform="translate(${T*16},0)" d="${R}" fill="${A}"/>`}return`${L}</svg>`}const w=Object.freeze([l("#c0392b","down"),l("#e0a800","right"),l("#2e7d32","up")]),g=Object.freeze([o("#d13438"),o("#f5a623"),o("#2e9e44")]),k=Object.freeze({arrows:w,trafficLights:g,ratings:Object.freeze([1,2,3,4,5].map($=>h($,5)))}),d=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function p($){if(Array.isArray($.icons)&&$.icons.length>=2)return $.icons.map(L=>/^\s*(url\(|data:|<)/.test(String(L))&&String(L).trim().startsWith("<")?c(String(L)):String(L));const S=$.set||"arrows";if(S==="ratings"){const L=n($),T=[];for(let A=1;A<=L;A++)T.push(c(h(A,L)));return T}const R=k[S];return R?R.map(c):(B(`iconSet:${S}`,`unknown icon set '${S}'; falling back to arrows.`),w.map(c))}function m($){const S=Number($.min),L=Number($.max)-S,T=$.colour||$.color||"#5b9bd5",A=$.negativeColour||$.negativeColor||"#d13438",C=$.direction==="rtl"?"left":"right",H=Z=>Math.max(0,Math.min(1,(Z-S)/L))*100,Y=L?Math.max(0,Math.min(100,(0-S)/L*100)):0;return Z=>{if(G(Z))return null;const _=Number(Z);if(!Number.isFinite(_)||!L)return null;const J=H(_),ee=Math.min(J,Y),ne=Math.max(J,Y),se=_>=0?T:A;return{backgroundImage:`linear-gradient(to ${C}, transparent ${ee}%, ${se} ${ee}%, ${se} ${ne}%, transparent ${ne}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function v($){const S=p($),R=$.reverse?[...S].reverse():S,L=(Array.isArray($.thresholds)?$.thresholds:[]).map(Number).filter(Number.isFinite),T=Number.isFinite(Number($.size))?Number($.size):16,A=$.set==="ratings"?T*n($):T;return C=>{if(G(C))return null;const H=Number(C);if(!Number.isFinite(H))return null;let Y=0;for(const _ of L)H>=_&&Y++;const Z=R[Math.min(Y,R.length-1)];return Z?{backgroundImage:Z,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${A}px ${T}px`,paddingLeft:`${A+4}px`}:null}}function y($){const S=Array.isArray($.colours)&&$.colours.length>=2?$.colours:["#f8f9fa","#1a6bc7"],R=Number($.min),L=Number($.max),T=L-R,A=S.length-1,C=[];for(let Y=0;Y<=A;Y++)C.push(A?Y/A:0);const H=Number($.mid);if($.mid!==void 0&&$.mid!==null)if(S.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${S.length} were given, so "mid" was ignored.`);else if(Number.isFinite(H)&&T&&H>Math.min(R,L)&&H<Math.max(R,L)){const Y=A/2,Z=Math.max(0,Math.min(1,(H-R)/T));for(let _=0;_<=A;_++)C[_]=_<=Y?Y?_/Y*Z:Z:Z+(_-Y)/(A-Y)*(1-Z)}else Number.isFinite(H)&&B("formatting.scale.mid.range",`a scale's "mid" (${H}) is outside its min..max range, so it was ignored.`);return Y=>{const Z=Number(Y);if(!Number.isFinite(Z)||!T)return null;const _=Math.max(0,Math.min(1,(Z-R)/T));let J=0;for(;J<A-1&&_>C[J+1];)J++;const ee=C[J+1]-C[J],ne=ee>0?(_-C[J])/ee:0;return{background:j(S[J],S[J+1],Math.max(0,Math.min(1,ne)))}}}function E($,S=null){const R=u($)?t($,S):$,L=(Array.isArray(R)?R:[]).filter(C=>C&&typeof C=="object");if(!L.length)return()=>null;const T=L.map(C=>C.scale?{scale:y(C.scale),enabled:C.enabled!==!1}:C.dataBar?{scale:m(C.dataBar),enabled:C.enabled!==!1}:C.iconSet?{scale:v(C.iconSet),enabled:C.enabled!==!1}:{when:C.when,style:C.style,stop:C.stopIfTrue!==!1,enabled:C.enabled!==!1}),A=M(T)?I():null;return(C,H)=>{const Y=C?C.value:void 0;let Z=null;H&&(H.mode=0);for(const _ of T){if(!_.enabled)continue;if(_.scale){const ne=_.scale(Y);ne&&(Z={...Z||{},...ne});continue}if(!z(Y,_.when))continue;let J;const ee=N(_.style);if(ee?H&&A?(J=_.style(A.enter(C)),A.mode>H.mode&&(H.mode=A.mode)):J=_.style(C):J=_.style,J&&(Z=Z?{...Z,...J}:ee?J:{...J}),_.stop)break}return Z}}function M($){return $.some(S=>S.enabled&&!S.scale&&N(S.style))}const F=new Set(["value","colId","column"]),V=new Set(["row","data","index"]);function I(){let $={};const S={mode:0,enter(T){return $=T||{},S.mode=0,L}},R=T=>{if(F.has(T))return;const A=V.has(T)?1:2;A>S.mode&&(S.mode=A)},L=new Proxy({},{get(T,A){return R(A),$[A]},has(T,A){return R(A),A in $},set(T,A,C){return S.mode=2,$[A]=C,!0},ownKeys(){return S.mode=2,Reflect.ownKeys($)},getOwnPropertyDescriptor(T,A){S.mode=2;const C=Object.getOwnPropertyDescriptor($,A);return C?{value:$[A],enumerable:C.enumerable,configurable:!0,writable:!0}:void 0}});return S}}),Ie("packages/core/src/formula/parse.js",function(e,U){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return G}}),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 te="num",N="str",X="ref",B="name",D="op",q="end",K=["<=",">=","<>","!="],x="+-*/^%(),<>=";class G extends Error{constructor(i,n){super(i),this.name="FormulaError",this.at=n}}function z(s){const i=[];let n=0;for(;n<s.length;){const c=s[n];if(c===" "||c===" "||c===`
|
|
7
|
-
`||c==="\r"){n++;continue}if(c>="0"&&c<="9"){n=O(s,n,i);continue}if(c==="."&&s[n+1]>="0"&&s[n+1]<="9"){n=O(s,n,i);continue}if(c==='"'||c==="'"){n=b(s,n,i);continue}if(c==="["){const l=s.indexOf("]",n+1);if(l<0)throw new G("a [column reference] was opened and never closed",n);i.push({kind:X,value:s.slice(n+1,l).trim(),at:n}),n=l+1;continue}if(j(c)){n=u(s,n,i);continue}const o=s.slice(n,n+2);if(K.includes(o)){i.push({kind:D,value:o==="!="?"<>":o,at:n}),n+=2;continue}if(x.includes(c)){i.push({kind:D,value:c,at:n}),n++;continue}throw new G(`unexpected character ${JSON.stringify(c)}`,n)}return i.push({kind:q,value:null,at:s.length}),i}function j(s){return/[A-Za-z_À-]/.test(s)}function O(s,i,n){let c=i,o=!1;for(;c<s.length;){const l=s[c];if(l>="0"&&l<="9"){c++;continue}if(l==="."&&!o){o=!0,c++;continue}if((l==="e"||l==="E")&&/[0-9+-]/.test(s[c+1]||"")){for(c+=2;c<s.length&&s[c]>="0"&&s[c]<="9";)c++;break}break}return n.push({kind:te,value:Number(s.slice(i,c)),at:i}),c}function b(s,i,n){const c=s[i];let o=i+1,l="";for(;o<s.length;){if(s[o]===c){if(s[o+1]===c){l+=c,o+=2;continue}return n.push({kind:N,value:l,at:i}),o+1}l+=s[o],o++}throw new G("a string was opened and never closed",i)}function u(s,i,n){let c=i;for(;c<s.length&&/[A-Za-z0-9_.À-]/.test(s[c]);)c++;const o=s.slice(i,c);let l=c;for(;l<s.length&&s[l]===" ";)l++;return n.push({kind:s[l]==="("?B:X,value:o,at:i}),c}const f={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function a(s){const i=String(s??"").replace(/^\s*=/,"");if(!i.trim())throw new G("the formula is empty");const n=z(i);let c=0;const o=()=>n[c],l=()=>n[c++],h=v=>{const y=o();if(y.kind!==D||y.value!==v)throw new G(`expected ${JSON.stringify(v)}`,y.at);c++},w=v=>{let y=g();for(;;){const E=o();if(E.kind!==D)break;const M=f[E.value];if(!M||M<v)break;c++;const F=w(E.value==="^"?M:M+1);y={kind:"bin",op:E.value,left:y,right:F}}return y},g=()=>{const v=o();return v.kind===D&&(v.value==="-"||v.value==="+")?(c++,{kind:"unary",op:v.value,arg:g()}):k()},k=()=>{let v=d();for(;o().kind===D&&o().value==="%";)c++,v={kind:"unary",op:"%",arg:v};return v},d=()=>{const v=l();if(v.kind===te)return{kind:"num",value:v.value};if(v.kind===N)return{kind:"str",value:v.value};if(v.kind===X)return{kind:"ref",name:v.value};if(v.kind===B){h("(");const y=[];if(!(o().kind===D&&o().value===")"))for(;;){if(y.push(w(1)),o().kind===D&&o().value===","){c++;continue}break}return h(")"),{kind:"call",name:String(v.value).toUpperCase(),args:y}}if(v.kind===D&&v.value==="("){const y=w(1);return h(")"),y}throw v.kind===q?new G("the formula ends unexpectedly",v.at):new G(`unexpected ${JSON.stringify(v.value)}`,v.at)},p=w(1),m=o();if(m.kind!==q)throw new G(`unexpected ${JSON.stringify(m.value)}: is an operator missing?`,m.at);return p}function r(s){const i=new Set,n=c=>{if(!(!c||typeof c!="object")){if(c.kind==="ref"){i.add(String(c.name));return}if(c.kind==="bin"){n(c.left),n(c.right);return}if(c.kind==="unary"){n(c.arg);return}if(c.kind==="call")for(const o of c.args)n(o)}};return n(s),[...i]}function t(s){return typeof s=="string"&&/^\s*=/.test(s)&&s.trim()!=="="}}),Ie("packages/core/src/formula/evaluate.js",function(e,U){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return O}});const N=U("packages/core/src/formula/parse.js").FormulaError;function X(b){if(b==null||b==="")return 0;if(typeof b=="boolean")return b?1:0;if(b instanceof Date)return b.getTime();const u=typeof b=="number"?b:Number(String(b).replace(/[,\s]/g,""));if(!Number.isFinite(u))throw new N(`${JSON.stringify(b)} is not a number`);return u}function B(b){return b==null?"":String(b)}function D(b){if(typeof b=="boolean")return b;if(b==null||b==="")return!1;if(typeof b=="number")return b!==0;const u=String(b).trim().toLowerCase();return u==="false"||u==="no"||u==="0"?!1:u!==""}function q(b){const u=[];for(const f of b){if(Array.isArray(f)){for(const a of f)a!=null&&a!==""&&u.push(X(a));continue}f==null||f===""||u.push(X(f))}return u}function K(b,u){const f=10**u,a=b*f;return Math.sign(a)*Math.round(Math.abs(a)+Number.EPSILON*Math.abs(a))/f}function x(b,u){if(!b.length)return 0;const f=b.slice().sort((s,i)=>s-i),a=(f.length-1)*Math.min(1,Math.max(0,u)),r=Math.floor(a),t=Math.ceil(a);return r===t?f[r]:f[r]+(a-r)*(f[t]-f[r])}function G(b,u){let f=0,a=0,r=0;for(const s of b){f++;const i=s-a;a+=i/f,r+=i*(s-a)}const t=u?f-1:f;return t>0?Math.sqrt(r/t):0}const z={SUM:b=>q(b).reduce((u,f)=>u+f,0),AVERAGE:b=>{const u=q(b);return u.length?u.reduce((f,a)=>f+a,0)/u.length:0},MIN:b=>{const u=q(b);return u.length?Math.min(...u):0},MAX:b=>{const u=q(b);return u.length?Math.max(...u):0},COUNT:b=>q(b).length,PRODUCT:b=>q(b).reduce((u,f)=>u*f,1),ROUND:b=>K(X(b[0]),b.length>1?X(b[1]):0),ROUNDDOWN:b=>{const u=10**(b.length>1?X(b[1]):0),f=X(b[0])*u;return(f<0?Math.ceil(f):Math.floor(f))/u},ROUNDUP:b=>{const u=10**(b.length>1?X(b[1]):0),f=X(b[0])*u;return(f<0?Math.floor(f):Math.ceil(f))/u},ABS:b=>Math.abs(X(b[0])),FLOOR:b=>Math.floor(X(b[0])),CEILING:b=>Math.ceil(X(b[0])),SQRT:b=>Math.sqrt(X(b[0])),POWER:b=>X(b[0])**X(b[1]),MOD:b=>{const u=X(b[1]);if(u===0)throw new N("MOD by zero");return(X(b[0])%u+u)%u},IF:b=>D(b[0])?b[1]:b.length>2?b[2]:!1,AND:b=>b.every(D),OR:b=>b.some(D),NOT:b=>!D(b[0]),COALESCE:b=>b.find(u=>u!=null&&u!=="")??null,CONCAT:b=>b.map(B).join(""),LEN:b=>B(b[0]).length,UPPER:b=>B(b[0]).toUpperCase(),LOWER:b=>B(b[0]).toLowerCase(),TRIM:b=>B(b[0]).trim(),LEFT:b=>B(b[0]).slice(0,b.length>1?X(b[1]):1),RIGHT:b=>{const u=b.length>1?X(b[1]):1;return u<=0?"":B(b[0]).slice(-u)},MEDIAN:b=>x(q(b),.5),PERCENTILE:b=>{const u=X(b[b.length-1]);return x(q(b.slice(0,-1)),u>1?u/100:u)},QUARTILE1:b=>x(q(b),.25),QUARTILE3:b=>x(q(b),.75),STDEV:b=>G(q(b),!0),STDEVP:b=>G(q(b),!1),VAR:b=>{const u=G(q(b),!0);return u*u},VARP:b=>{const u=G(q(b),!1);return u*u},COUNTDISTINCT:b=>{const u=new Set;for(const f of b){const a=Array.isArray(f)?f:[f];for(const r of a)r!=null&&r!==""&&u.add(r)}return u.size},IQR:b=>{const u=q(b);return x(u,.75)-x(u,.25)}};z.AVG=z.AVERAGE,z.CEIL=z.CEILING,z.POW=z.POWER,z.STDEVS=z.STDEV,z.PERCENTILEINC=z.PERCENTILE;function j(b,u){const f=Number(b),a=Number(u);if(b!==null&&b!==""&&u!==null&&u!==""&&Number.isFinite(f)&&Number.isFinite(a))return f<a?-1:f>a?1:0;const t=B(b).toLowerCase(),s=B(u).toLowerCase();return t<s?-1:t>s?1:0}function O(b,u={}){const f=typeof u.lookup=="function"?u.lookup:null,a=u.functions?{...z,...u.functions}:z,r=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!f)throw new N(`there is no column called ${JSON.stringify(t.name)} here`);const s=f(String(t.name));if(s===void 0)throw new N(`there is no column called ${JSON.stringify(t.name)}`);return s}case"unary":{if(t.op==="%")return X(r(t.arg))/100;const s=X(r(t.arg));return t.op==="-"?-s:s}case"bin":{const s=t.op;if(s==="=")return j(r(t.left),r(t.right))===0;if(s==="<>")return j(r(t.left),r(t.right))!==0;if(s==="<")return j(r(t.left),r(t.right))<0;if(s==="<=")return j(r(t.left),r(t.right))<=0;if(s===">")return j(r(t.left),r(t.right))>0;if(s===">=")return j(r(t.left),r(t.right))>=0;const i=X(r(t.left)),n=X(r(t.right));if(s==="+")return i+n;if(s==="-")return i-n;if(s==="*")return i*n;if(s==="^")return i**n;if(s==="/"){if(n===0)throw new N("division by zero");return i/n}throw new N(`unknown operator ${JSON.stringify(s)}`)}case"call":{const s=u.lazy&&u.lazy[t.name];if(typeof s=="function")return s(t.args,r,u);const i=a[t.name];if(typeof i!="function")throw new N(`there is no function called ${t.name}`);return i(t.args.map(r),u)}default:throw new N("the formula could not be read")}};return r(b)}}),Ie("packages/core/src/formula/index.js",function(e,U){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return j}});const te=U("packages/core/src/formula/parse.js"),N=te.parseFormula,X=te.referencesOf,B=te.looksLikeFormula,D=te.FormulaError,q=te.tokenise,K=U("packages/core/src/formula/evaluate.js"),x=K.evaluateAst,G=K.FUNCTIONS;function z(O){const{grid:b,row:u,data:f}=O||{},a=n=>String(n).toLowerCase().replace(/[\s_-]/g,""),r=b&&b.columns&&typeof b.columns.all=="function"?b.columns.all():[],t=b&&b.permissions,s=t&&typeof t.isReadable=="function"?n=>t.isReadable(n):()=>!0,i=new Set;for(const n of r)s(n)||(i.add(a(n.id)),n.field&&i.add(a(n.field)),n.title&&i.add(a(n.title)));return n=>{const c=a(n);if(i.has(c))throw new D(`"${n}" cannot be read`);for(const o of r)if(a(o.id)===c||o.field&&a(o.field)===c||o.title&&a(o.title)===c)return u&&b.rows&&typeof b.rows.value=="function"?b.rows.value(u.key,o.id):f?f[o.field||o.id]:void 0;if(f&&typeof f=="object"){for(const o of Object.keys(f))if(a(o)===c){if(!s(o))throw new D(`"${n}" cannot be read`);return f[o]}}}}function j(O,b={}){try{const u=N(O);return{ok:!0,value:x(u,{lookup:z(b),functions:b.formulaFunctions}),references:X(u)}}catch(u){return{ok:!1,error:u instanceof D?u.message:"the formula could not be read",at:u instanceof D?u.at:void 0}}}}),Ie("packages/core/src/internal/version.js",function(e,U){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return X}});const te="1.101.7";async function N(){return te}const X="1.101.7"}),Ie("packages/core/src/internal/merge.js",function(e,U){"use strict";Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return K}});const N=U("packages/core/src/internal/predicates.js").isObject;function X(x,G,z){if(x!==void 0)return x===!0?{enabled:!0,...z}:x===!1?{enabled:!1}:N(x)?x:{[G]:x,enabled:!0}}function B(x){return x==null?[]:Array.isArray(x)?x:[x]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function q(x,G){if(!N(x))return N(G)?{...G}:G;if(!N(G))return G===void 0?x:G;const z={...x};for(const j of Object.keys(G)){if(D.has(j))continue;const O=G[j];O!==void 0&&(z[j]=N(O)&&N(z[j])?q(z[j],O):O)}return z}function K(x,G){if(!N(x)||!N(G)||x===G)return G;const z=Object.create(Object.getPrototypeOf(x));return Object.assign(z,x,G),z}}),Ie("packages/core/src/internal/schedule.js",function(e,U){"use strict";Object.defineProperty(e,"now",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return K}});function te(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const N=typeof requestAnimationFrame=="function";function X(x){return N?requestAnimationFrame(x):setTimeout(()=>x(te()),16)}function B(x){x!=null&&(N?cancelAnimationFrame(x):clearTimeout(x))}function D(x){let G=null,z=null;const j=()=>{G=null;const b=z;z=null,x(...b||[])},O=(...b)=>{z=b,G===null&&(G=X(j))};return O.cancel=()=>{B(G),G=null,z=null},O.flush=()=>{G!==null&&(B(G),j())},O}function q(x,G){let z=null,j=null;const O=()=>{if(z=null,j===null)return;const f=j;j=null,x(...f),b()},b=()=>{z=setTimeout(O,G),typeof z?.unref=="function"&&z.unref()},u=(...f)=>{z===null?(x(...f),b()):(j=f,clearTimeout(z),b())};return u.flush=()=>{if(z!==null&&clearTimeout(z),z=null,j===null)return;const f=j;j=null,x(...f)},u.cancel=()=>{z!==null&&clearTimeout(z),z=null,j=null},u.pending=()=>z!==null||j!==null,u}function K(x,G=50){return typeof requestIdleCallback=="function"?requestIdleCallback(x,{timeout:G}):setTimeout(()=>x({timeRemaining:()=>0,didTimeout:!0}),1)}}),Ie("packages/core/src/internal/paths.js",function(e,U){"use strict";Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return q}});const te=new Map;function N(K){let x=te.get(K);if(x)return x;if(!K.includes("."))x=G=>G?.[K];else{const G=K.split("."),z=G.length;x=j=>{let O=j;for(let b=0;b<z;b++){if(O==null)return;O=O[G[b]]}return O}}return te.set(K,x),x}const X=new Map;function B(K){let x=X.get(K);if(x)return x;if(!K.includes("."))x=(G,z)=>{G!=null&&(G[K]=z)};else{const G=K.split("."),z=G.length-1;x=(j,O)=>{let b=j;for(let u=0;u<z;u++){if(b==null)return;const f=G[u];b[f]==null&&(b[f]={}),b=b[f]}b!=null&&(b[G[z]]=O)}}return X.set(K,x),x}function D(K,x){return N(x)(K)}function q(K,x,G){B(x)(K,G)}}),Ie("packages/core/src/internal/compare.js",function(e,U){"use strict";Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return X}});const te=new Map;function N(B,D){const q=`${B||""}|${D?JSON.stringify(D):""}`;let K=te.get(q);return K||(K=new Intl.Collator(B||void 0,{numeric:!0,sensitivity:"variant",...D}),te.set(q,K)),K}function X(B,D){if(B===D)return 0;if(B==null)return 1;if(D==null)return-1;if(typeof B=="number"&&typeof D=="number")return Number.isNaN(B)?Number.isNaN(D)?0:1:Number.isNaN(D)||B<D?-1:B>D?1:0;const q=String(B),K=String(D);return q<K?-1:q>K?1:0}}),Ie("packages/core/src/defaults.js",function(e,U){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return j}});const N=U("packages/core/src/internal/predicates.js").isObject,B=U("packages/core/src/internal/merge.js").merge,q=U("packages/core/src/internal/warn.js").warnOnce;let K=null;class x extends Error{}function G(O,b=new Set){if(Array.isArray(O)){if(b.has(O))throw new x;b.add(O);const f=O.map(a=>G(a,b));return b.delete(O),f}if(!N(O)||Object.getPrototypeOf(O)!==Object.prototype&&Object.getPrototypeOf(O)!==null)return O;if(b.has(O))throw new x;b.add(O);const u={};for(const[f,a]of Object.entries(O))u[f]=G(a,b);return b.delete(O),u}function z(O){if(O===void 0)return G(K??{});if(O===null)return K=null,{};if(!N(O))return q("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(O)?"an array":typeof O}. The call was ignored and the defaults are unchanged.`),G(K??{});try{K=G(O)}catch(b){if(!(b instanceof x))throw b;return q("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."),G(K??{})}return G(K)}function j(O){return K===null?O:B(G(K),O)}}),Ie("packages/core/src/internal/uid.js",function(e,U){"use strict";Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return N}});let te=0;function N(X="l"){return`${X}${(++te).toString(36)}`}}),Ie("packages/core/src/events/names.js",function(e,U){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return X}});const te=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),N=new Set(te);function X(B){return B==="*"||N.has(B)}}),Ie("packages/core/src/events/bus.js",function(e,U){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return f}});const te=U("packages/core/src/internal/warn.js"),N=te.warnOnce,X=te.DEV,D=U("packages/core/src/internal/uid.js").uid,K=U("packages/core/src/events/names.js").isKnownEvent,x="*";function G(a,r){!X||K(r)||N(`bus.unknown:${r}`,`${a}('${r}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const z=new Set(["api","user","init","ai"]),j=new WeakMap;function O(a){let r=j.get(a);return r||(r=D("h"),j.set(a,r)),r}function b(){return typeof performance=="object"&&performance?performance.now():Date.now()}function u(a){if(!a||typeof a!="object")return{};const r={};for(const[t,s]of Object.entries(a))t!=="grid"&&(s==null?r[t]=String(s):Array.isArray(s)?r[t]=`[${s.length}]`:typeof s=="object"?r[t]=s.key?`row ${s.key}`:"{…}":typeof s=="function"?r[t]="[function]":r[t]=String(s).slice(0,60));return r}class f{#e=new Map;#t=!1;#n=[];#r=200;#i=new Map;#s=null;#o=!1;#l=0;constructor(r=null){this.#s=r}attach(r){this.#s=r}get grid(){return this.#s}get destroyed(){return this.#o}on(r,t){if(typeof t!="function")return N(`bus.handler:${r}`,`on('${r}') needs a function; ignored.`),()=>{};G("on",r);let s=this.#e.get(r);return s||(s=[],this.#e.set(r,s)),s.push(t),()=>this.off(r,t)}once(r,t){if(typeof t!="function")return N(`bus.handler:${r}`,`once('${r}') needs a function; ignored.`),()=>{};G("once",r);const s=i=>{this.off(r,t),t(i)};return this.#i.set(t,s),this.on(r,s)}off(r,t){if(t===void 0){this.#e.delete(r);return}const s=this.#e.get(r);if(!s)return;const i=this.#i.get(t),n=i&&s.includes(i)?i:t,c=s.indexOf(n);c>=0&&s.splice(c,1),i&&n===i&&this.#i.delete(t),s.length===0&&this.#e.delete(r)}count(r){const t=this.#e.get(r),s=r===x?null:this.#e.get(x);return(t?t.length:0)+(s?s.length:0)}#a(r,t,s,i,n){this.#n.push({type:r,origin:t,listeners:(i?i.length:0)+(n?n.length:0),payload:u(s),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(r,t){this.#t=!!r,Number.isFinite(t)&&t>0&&(this.#r=Math.floor(t)),r||(this.#n=[])}eventLog(){return this.#n.map(r=>({...r}))}clearEventLog(){this.#n=[]}counts(){const r={};for(const[t,s]of this.#e)r[t]=s.length;return r}emit(r,t,s){const i=s??(t&&t.origin),n=z.has(i)?i:"api",c={...t||null,type:r,origin:n,grid:this.#s};if(this.#o)return c;const o=this.#e.get(r),l=r===x?void 0:this.#e.get(x);if(this.#t&&this.#a(r,n,t,o,l),!o&&!l)return c;const h=this.#t?b():0;this.#l++;try{o&&this.#c(o.slice(),c,r),l&&this.#c(l.slice(),c,x)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=b()-h)}return c}emitBefore(r,t,s){const i=s??(t&&t.origin),n=z.has(i)?i:"user";let c=!1,o=null;const l=p=>{c=!0,p!=null&&o===null&&(o=String(p))},h={...t||null,type:r,origin:n,grid:this.#s,get defaultPrevented(){return c},get reason(){return o},preventDefault(p){l(p)}};if(this.#o)return!0;const w=this.#e.get(r);this.#t&&this.#a(r,n,t,w,void 0);const g=w?w.slice():[];if(g.length===0)return!0;const k=()=>(c&&o===null&&(o="prevented"),c&&t&&typeof t=="object"&&(t.reason=o),!c),d=[];for(const p of g)try{const m=p(h);m&&typeof m.then=="function"?d.push(m):m===!1&&l("prevented")}catch(m){l("error"),N(`bus.beforeThrow:${r}:${O(p)}`,`a '${r}' before-handler threw; the action was cancelled.`,m)}return d.length===0?k():Promise.allSettled(d).then(p=>{for(const m of p)m.status==="rejected"?(l("error"),N(`bus.beforeReject:${r}`,`a '${r}' before-handler rejected; the action was cancelled.`,m.reason)):m.value===!1&&l("prevented");return k()})}#c(r,t,s){for(let i=0;i<r.length;i++)try{r[i](t)}catch(n){N(`bus.throw:${s}:${O(r[i])}`,`a '${s}' handler threw; other handlers were unaffected.`,n)}}clear(){this.#e.clear(),this.#i.clear()}destroy(){this.clear(),this.#o=!0,this.#s=null}}}),Ie("packages/core/src/registry/free-tier-notice.js",function(e,U){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return te}});const te="Free for non-commercial use: latticegrid.dev/free"}),Ie("packages/core/src/registry/licence.js",function(e,U){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return I}});const N=U("packages/core/src/internal/warn.js").warnOnce,X=U("packages/core/src/registry/free-tier-notice.js"),B=X.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return X.FREE_TIER_NOTICE}});const D="lattice-grid",q=1,K="LG1",x=64,G="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",j=(()=>{const $=new Int16Array(128).fill(-1);for(let S=0;S<z.length;S++)$[z.charCodeAt(S)]=S;return $[43]=62,$[47]=63,$})();function O($){if(typeof $!="string")return null;let S="";for(let H=0;H<$.length;H++){const Y=$.charCodeAt(H);if(Y!==61){if(Y>127||j[Y]<0)return null;S+=$[H]}}const R=S.length;if(R%4===1)return null;const L=new Uint8Array(Math.floor(R*3/4));let T=0,A=0,C=0;for(let H=0;H<R;H++)T=T<<6|j[S.charCodeAt(H)],A+=6,A>=8&&(A-=8,L[C++]=T>>A&255);return C===L.length?L:L.subarray(0,C)}function b($){let S="",R=0;for(;R+2<$.length;R+=3){const T=$[R]<<16|$[R+1]<<8|$[R+2];S+=z[T>>18&63]+z[T>>12&63]+z[T>>6&63]+z[T&63]}const L=$.length-R;if(L===1){const T=$[R]<<16;S+=z[T>>18&63]+z[T>>12&63]}else if(L===2){const T=$[R]<<16|$[R+1]<<8;S+=z[T>>18&63]+z[T>>12&63]+z[T>>6&63]}return S}function u($){const S=new Uint8Array($.length);for(let R=0;R<$.length;R++)S[R]=$.charCodeAt(R)&127;return S}function f($){if(typeof TextDecoder=="function")return new TextDecoder().decode($);let S="";for(let R=0;R<$.length;R++)S+=String.fromCharCode($[R]);return S}function a($){const S={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof $=="string"?$:""};if(typeof $!="string"||$.length===0)return{...S,reason:"missing"};const R=$.trim(),L=R.split(".");if(L.length!==3)return S;const[T,A,C]=L;if(T!==K)return{...S,reason:"prefix"};const H=O(A),Y=O(C);if(!H||!Y)return S;let Z;try{Z=JSON.parse(f(H))}catch{return S}return Z===null||typeof Z!="object"?S:{ok:!0,reason:null,product:typeof Z.p=="string"?Z.p:null,issuedTo:typeof Z.t=="string"?Z.t:null,expires:typeof Z.e=="string"?Z.e:null,terms:typeof Z.terms=="string"?Z.terms:null,features:Array.isArray(Z.f)?Z.f.slice():[],deployments:Array.isArray(Z.d)?Z.d.slice():[],version:typeof Z.v=="number"?Z.v:0,message:u(A),signature:Y,raw:R}}function r($,S){if(!$)return!1;const R=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test($)?`${$}T23:59:59.999Z`:$);return Number.isNaN(R)?!0:S>R}function t($){return $==="non-commercial"?"non-commercial":"commercial"}let s=null,i=null,n=null;function c(){const $=globalThis.crypto;return $&&$.subtle?$.subtle:null}async function o($){if(s&&i===$)return s;const S=c();if(!S)return null;const R=O($);if(!R)return null;try{const L=await S.importKey("raw",R,{name:"Ed25519"},!1,["verify"]);return s=L,i=$,L}catch{return null}}async function l(){return n!==null||(n=await o(G)!==null),n}async function h($,S={}){const R=S.warn!==!1,L=S.product||D,T=S.publicKey||G,A=S.now??Date.now(),C=S.host??g(),H=w(C)?"":` ${B}`,Y=a($);if(!Y.ok){const ne=Y.reason==="missing"?"missing":"malformed";return R&&N(`licence.${ne}`,ne==="missing"?`no licence key supplied. The grid renders in full and carries a trial watermark on any host other than localhost. Get a key at latticegrid.dev.${H}`:`licence key could not be read. The grid will render with a watermark.${H}`),{valid:!1,reason:ne,terms:"commercial"}}const Z={product:Y.product||void 0,issuedTo:Y.issuedTo||void 0,expires:Y.expires||void 0,terms:t(Y.terms)};if(Y.product!==L)return R&&N("licence.product",`licence key is for '${Y.product}', not '${L}'. The grid will render with a watermark.`),{valid:!1,...Z,reason:"product"};if(r(Y.expires,A))return R&&N("licence.expired",`licence expired on ${Y.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...Z,reason:"expired"};const _=Y.deployments||[];if(_.length&&C&&!w(C)&&!k(C,_))return R&&N("licence.domain",`licence key is not valid for ${C}; it covers ${_.join(", ")}. The grid will render with a watermark.`),{valid:!1,...Z,reason:"domain"};const J=await o(T);if(!J){const ne=!!Y.signature&&Y.signature.length===x;return R&&N("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),ne?{valid:!0,...Z,reason:"unverified"}:{valid:!1,...Z,reason:"signature"}}let ee=!1;try{ee=await c().verify({name:"Ed25519"},J,Y.signature,Y.message)}catch{ee=!1}return ee?{valid:!0,...Z}:(R&&N("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...Z,reason:"signature"})}function w($){const S=String($??g()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!S||S==="localhost"||S.endsWith(".localhost")||S==="::1"||S==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(S)}function g(){const $=globalThis.location;return $&&typeof $.hostname=="string"?$.hostname:null}function k($,S){const R=d($);return!R||!Array.isArray(S)?!1:S.some(L=>{const T=d(L);if(!T)return!1;if(T==="*")return!0;if(T.startsWith("*.")){const A=T.slice(2);return R===A||R.endsWith(`.${A}`)}return R===T})}function d($){return String($??"").trim().toLowerCase().replace(/\.$/,"")}class p{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#i;#s=new Set;constructor(S={}){this.#i=S}set(S){this.#e=typeof S=="string"?S.trim():"";const R=a(this.#e);return this.#t=R.ok?{valid:!r(R.expires,Date.now())&&R.product===(this.#i.product||D),product:R.product||void 0,issuedTo:R.issuedTo||void 0,expires:R.expires||void 0,terms:t(R.terms),reason:"pending"}:{valid:!1,reason:R.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const S=this.#e;return this.#n=h(S,this.#i).then(R=>{if(this.#e===S){this.#t=R;for(const L of this.#s)L(R)}return R}),this.#n}onSettled(S){return this.#s.add(S),()=>this.#s.delete(S)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!w(this.#r)}setHost(S){this.#r=S}state(){return this.#t.valid?"licensed":w(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#s.clear()}}const m=Symbol.for("lattice-grid/licence/holder");function v(){const $=globalThis,S=$&&$[m];if(S&&typeof S.set=="function"&&typeof S.watermark=="function")return S;const R=new p;if($)try{$[m]=R}catch{}return R}const y=v();function E($){return y.set($)}function M(){return y.info()}function F(){return y.watermark()}function V(){return y.state()}function I(){return y}}),Ie("packages/core/src/registry/registry.js",function(e,U){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return s}});const te=U("packages/core/src/internal/warn.js"),N=te.warnOnce,X=te.DEV,D=U("packages/core/src/internal/predicates.js").isFunction,q=U("packages/core/src/registry/licence.js"),K=q.LicenceHolder,x=q.sharedLicence,G=["renderer","editor","filter","dataType","totalFn","pipe","component"],z=["all","header","body","totals","panels"];class j{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#i;#s=null;#o=null;#l=new Set;#a=new Map;constructor(n={}){for(const c of G)this.#t.set(c,new Map);this.#i=n.holder||x(),this.#o=n.grid??null,this.#s=this.#i.onSettled(()=>{this.#f({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),n.licence&&this.setLicence(n.licence)}registerModules(n,c={}){c.licence&&this.setLicence(c.licence),c.grid!==void 0&&(this.#o=c.grid);const o=Array.isArray(n)?n:[n],l=[];for(const h of o){if(!h||typeof h!="object"||typeof h.name!="string"||!h.name){N("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(h.name)){X&&this.#u(this.#e.get(h.name),h);continue}if(!D(h.install)){N(`registry.module.install:${h.name}`,`module '${h.name}' has no install() and was ignored.`);continue}const w={registry:this,grid:this.#o};try{h.install(w)}catch(g){N(`registry.module.throw:${h.name}`,`module '${h.name}' threw during install; it was not registered.`,g);continue}this.#e.set(h.name,h);for(const g of O(h))this.#n.add(g);l.push(h.name),this.#f({reason:"module",name:h.name,capabilities:this.capabilities(),regions:f(h)})}return l}unregisterModule(n){const c=this.#e.get(n);if(!c)return!1;if(D(c.uninstall))try{c.uninstall({registry:this,grid:this.#o})}catch(o){N(`registry.module.uninstall:${n}`,`module '${n}' threw during uninstall.`,o)}return this.#e.delete(n),this.#c(),this.#f({reason:"unmodule",name:n,capabilities:this.capabilities(),regions:f(c)}),!0}modules(){return[...this.#e.values()]}has(n){return this.#e.has(n)}#c(){this.#n.clear();for(const n of this.#e.values())for(const c of O(n))this.#n.add(c)}#u(n,c){!n||n===c||b(n,c)||N(`registry.module.reconfigure:${c.name}`,`module '${c.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(n){return this.#n.has(n)}onChange(n){return D(n)?(this.#r.add(n),this.#a.set(n,this.#o),()=>{this.#r.delete(n),this.#a.delete(n)}):()=>{}}#f(n){for(const c of[...this.#r])try{c(n)}catch(o){N("registry.onChange.throw","a registry change handler threw.",o)}}register(n,c,o){const l=this.#t.get(n);if(!l){N(`registry.kind:${n}`,`unknown registry kind '${n}'; expected one of ${G.join(", ")}.`);return}if(!c||typeof c!="string"){N(`registry.name:${n}`,`register('${n}', ...) needs a name.`);return}l.has(c)&&l.get(c)!==o&&N(`registry.replace:${n}:${c}`,`'${c}' was already registered as a ${n} and has been replaced.`),l.set(c,o),this.#f({reason:"register",name:c,kind:n,capabilities:this.capabilities(),regions:a(n)})}registerAll(n,c){if(c)for(const o of Object.keys(c))this.register(n,o,c[o])}get(n,c){const o=this.#t.get(n);return o?o.get(c):void 0}names(n){const c=this.#t.get(n);return c?[...c.keys()]:[]}#d(n,c){const o=this.#t.get(n).get(c);return o!==void 0?o:this.#t.get("component").get(c)}renderer(n){return this.#d("renderer",n)}editor(n){return this.#d("editor",n)}filter(n){return this.#d("filter",n)}dataType(n){return this.get("dataType",n)}totalFn(n){return this.get("totalFn",n)}pipe(n){return this.get("pipe",n)}setLicence(n){return this.#i.set(n)}licence(){return this.#i.info()}licenceVerified(){return this.#i.verify()}watermark(){return this.#i.watermark()}attach(n){n!=null&&(this.#l.add(n),this.#o=n)}detach(n){if(n!=null){this.#l.delete(n);for(const[c,o]of[...this.#a])o===n&&(this.#r.delete(c),this.#a.delete(c));if(this.#o===n){const c=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#o=c}this.#l.size===0&&this.#s&&(this.#s(),this.#s=null)}}destroy(n){if(n!=null){this.detach(n);return}for(const c of[...this.#e.keys()])this.unregisterModule(c);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#s&&this.#s(),this.#s=null,this.#o=null}}function O(i){const n=i.capabilities,c=Array.isArray(n)?n.filter(o=>typeof o=="string"):[];return[i.name,...c]}function b(i,n){return i.install!==n.install||i.uninstall!==n.uninstall||(i.version||"")!==(n.version||"")?!1:u(O(i),O(n))&&u(f(i),f(n))}function u(i,n){const c=new Set(i),o=new Set(n);if(c.size!==o.size)return!1;for(const l of c)if(!o.has(l))return!1;return!0}function f(i){const n=i.regions;return!Array.isArray(n)||n.length===0?["all"]:n.filter(c=>z.includes(c))}function a(i){switch(i){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const r=new j;function t(){return r}function s(i,n={}){return r.registerModules(i,n)}}),Ie("packages/core/src/internal/text.js",function(e,U){"use strict";Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return B}});function te(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(/^./,K=>K.toUpperCase()):""}const N={"&":"&","<":"<",">":">",'"':""","'":"'"};function X(D){const q=D==null?"":String(D);return/[&<>"']/.test(q)?q.replace(/[&<>"']/g,K=>N[K]):q}function B(D){return String(D).replace(/\w\S*/g,q=>q[0].toUpperCase()+q.slice(1).toLowerCase())}}),Ie("packages/core/src/format/mask.js",function(e,U){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return q}});const te=new Set(["0","#","?",",","."]),N="\0";function X(x){const G=[];let z="",j=!1;for(let O=0;O<x.length;O++){const b=x[O];if(b==="\\"){z+=b+(x[O+1]??""),O+=1;continue}if(b==='"'){j=!j,z+=b;continue}if(b===";"&&!j){G.push(z),z="";continue}z+=b}return G.push(z),G}function B(x){let G="",z="",j="",O=1,b=!1,u=!1;const f=l=>{u?z+=l:G+=l};for(let l=0;l<x.length;l++){const h=x[l];if(h==="\\"){f(x[l+1]??""),l+=1;continue}if(h==='"'){const w=x.indexOf('"',l+1);f(w===-1?x.slice(l+1):x.slice(l+1,w)),l=w===-1?x.length:w;continue}if(h==="%"){O*=100,f("%");continue}if(h==="@"){b=!0,f("\0");continue}if(te.has(h)){j+=h,u=!0;continue}f(h)}let a=-1;for(let l=j.length-1;l>=0;l--){const h=j[l];if(h==="0"||h==="#"||h==="?"){a=l;break}}let r=!1,t="";for(let l=0;l<j.length;l++){const h=j[l];if(h===","){l>a?O/=1e3:r=!0;continue}t+=h}const s=t.indexOf("."),i=s===-1?t:t.slice(0,s),n=s===-1?"":t.slice(s+1);let c=0;for(const l of i)l==="0"&&(c+=1);let o=0;for(const l of n)l==="0"&&(o+=1);return{prefix:G,suffix:z,minInt:c,minDec:o,maxDec:n.length,grouping:r,scale:O,hasNumber:a!==-1,isText:b}}function D(x,G){const z=new Intl.NumberFormat(G,{minimumIntegerDigits:Math.max(x.minInt,1),minimumFractionDigits:x.minDec,maximumFractionDigits:Math.max(x.maxDec,x.minDec),useGrouping:x.grouping}),{prefix:j,suffix:O,scale:b,hasNumber:u}=x;return f=>{if(!u)return j+O;const a=b===1?f:f*b;return j+z.format(a)+O}}function q(x,G){const j=X(String(x)).map(B),O=j.map(t=>D(t,G)),b=0,u=j.length>1?1:-1,f=j.length>2?2:-1,a=j.length>3?3:-1,r=t=>{if(t==null||t==="")return"";if(typeof t!="number"||Number.isNaN(t)){const s=Number(t);if(Number.isNaN(s))return a===-1?String(t):(j[a].prefix+j[a].suffix).split("\0").join(String(t));t=s}return t===0&&f!==-1?O[f](0):t<0&&u!==-1?O[u](-t):O[b](t)};return r.spec={mask:x},{format:r,ooxml:K(String(x))}}function K(x){return x.trim()}}),Ie("packages/core/src/format/pattern.js",function(e,U){"use strict";Object.defineProperty(e,"parseNumberPattern",{enumerable:!0,get:function(){return D}});const N=U("packages/core/src/format/mask.js").splitSections;function X(q){let K="",x="",G="",z="",j=!1,O=!1,b=!1,u=!1;const f=r=>{b?x+=r:K+=r};for(let r=0;r<q.length;r++){const t=q[r];if(t==="\\"){f(q[r+1]??""),r+=1;continue}if(t==='"'){const s=q.indexOf('"',r+1);f(s===-1?q.slice(r+1):q.slice(r+1,s)),r=s===-1?q.length:s;continue}if(t==="%"){O=!0;continue}if(t==="0"||t==="#"){b=!0,u?z+=t:G+=t;continue}if(t===","){u||(j=!0);continue}if(t==="."&&!u){u=!0;continue}f(t)}if(!b)return{hasDigit:!1,prefix:K,suffix:x,minDec:0,maxDec:0,grouping:!1,percent:O};let a=0;for(const r of z)r==="0"&&(a+=1);return{hasDigit:!0,prefix:K,suffix:x,minDec:a,maxDec:z.length,grouping:j,percent:O}}function B(q,K){const x=K.trim(),G=q.trim();return x.startsWith("(")&&x.endsWith(")")&&x.slice(1,-1).trim()===G?"parentheses":x.endsWith("-")?"suffix":"minus"}function D(q){if(typeof q!="string")return null;const K=N(q);if(K.length===0)return null;const x=X(K[0]);if(!x.hasDigit)return null;const G={style:x.percent?"percent":"decimal",prefix:x.prefix,suffix:x.suffix,minDecimals:x.minDec,maxDecimals:Math.max(x.maxDec,x.minDec),thousandsSeparator:x.grouping?void 0:!1};if(K.length>1&&(G.negative=B(K[0],K[1])),K.length>2){const z=X(K[2]);z.hasDigit||(G.zeroDisplay=z.prefix+z.suffix)}return G}}),Ie("packages/core/src/format/number.js",function(e,U){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return K}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/internal/warn.js").warnOnce,q=U("packages/core/src/format/pattern.js").parseNumberPattern;function K(x,G){const z=typeof x=="string"?{pattern:x}:x||{};let j=z;if(typeof z.pattern=="string"){const v=q(z.pattern);if(v){const{pattern:y,...E}=z;j={...v,...E}}else B(`format:pattern:${z.pattern}`,`invalid number format pattern "${z.pattern}"; the value will use the default number format`)}const O=j.locale||G||void 0,b=j.style||"decimal",u=typeof j.scale=="number"?j.scale:1,f=j.nullDisplay??"",a=j.zeroDisplay,r=j.prefix||"",t=j.suffix||"",s=j.negative||"minus",i=j.signed===!0,n={style:b,notation:j.notation||"standard"};b==="currency"&&(n.currency=j.currency||"USD",j.currencyDisplay&&(n.currencyDisplay=j.currencyDisplay)),typeof j.decimals=="number"?(n.minimumFractionDigits=j.decimals,n.maximumFractionDigits=j.decimals):(typeof j.minDecimals=="number"&&(n.minimumFractionDigits=j.minDecimals),typeof j.maxDecimals=="number"&&(n.maximumFractionDigits=j.maxDecimals),n.minimumFractionDigits>(n.maximumFractionDigits??20)&&(n.maximumFractionDigits=n.minimumFractionDigits)),j.thousandsSeparator===!1&&(n.useGrouping=!1),n.notation==="compact"&&(n.compactDisplay=j.compactDisplay||"short");const c=new Intl.NumberFormat(O,n),o=typeof j.thousandsSeparator=="string"?j.thousandsSeparator:null,l=typeof j.decimalSeparator=="string"?j.decimalSeparator:null;let h=",",w=".";if(o||l)for(const v of c.formatToParts(12345.6))v.type==="group"?h=v.value:v.type==="decimal"&&(w=v.value);const g=v=>{let y=v;return o&&(y=y.split(h).join("")),l&&(y=y.split(w).join("")),o&&(y=y.split("").join(o)),l&&(y=y.split("").join(l)),y},k=!!(o||l),d=r!==""&&b==="currency",p=v=>{let y;if(d){const E=c.formatToParts(v);let M=!1;y="";for(const F of E)y+=F.value,!M&&F.type==="currency"&&(y+=r,M=!0);M||(y=r+y)}else y=r+c.format(v);return k&&(y=g(y)),y+t},m=v=>{if(N(v)||v==="")return f;const y=typeof v=="number"?v:Number(v);if(Number.isNaN(y))return f;const E=u===1?y:y*u;return E===0&&a!==void 0?a:E<0?s==="parentheses"?`(${p(-E)})`:s==="suffix"?`${p(-E)}-`:p(E):i&&E>0?`+${p(E)}`:p(E)};return m.negativeClass=j.negativeClass||null,m.spec=j,m}}),Ie("packages/core/src/format/date.js",function(e,U){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return t}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/internal/warn.js").warnOnce,D=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function q(s){const i=[];let n=0,c="";const o=()=>{c&&(i.push({token:null,text:c}),c="")};for(;n<s.length;){const l=s[n];if(l==="'"){if(s[n+1]==="'"){c+="'",n+=2;continue}const w=s.indexOf("'",n+1);if(w===-1){c+=s.slice(n+1),n=s.length;continue}c+=s.slice(n+1,w),n=w+1;continue}const h=D.find(w=>s.startsWith(w,n));if(h){o(),i.push({token:h,text:h}),n+=h.length;continue}/[A-Za-z]/.test(l)&&B(`date.pattern.token:${l}`,`the date pattern "${s}" contains '${l}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${D.join(" ")}.`),c+=l,n+=1}return o(),i}const K=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function x(s){if(N(s)||s==="")return null;if(s instanceof Date)return Number.isNaN(s.getTime())?null:s;if(typeof s=="number")return Number.isNaN(s)?null:new Date(s);if(typeof s=="string"){const i=K.exec(s.trim());if(i){const[,c,o,l,h="0",w="0",g="0"]=i;return new Date(+c,+o-1,+l,+h,+w,+g)}const n=new Date(s);return Number.isNaN(n.getTime())?null:n}return null}function G(s,i){return String(s).padStart(i,"0")}function z(s){if(!s)return c=>({year:c.getFullYear(),month:c.getMonth()+1,day:c.getDate(),hour:c.getHours(),minute:c.getMinutes(),second:c.getSeconds(),ms:c.getMilliseconds(),weekday:c.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),n={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return c=>{const o={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:c.getMilliseconds(),weekday:0};for(const l of i.formatToParts(c))switch(l.type){case"year":o.year=Number(l.value);break;case"month":o.month=Number(l.value);break;case"day":o.day=Number(l.value);break;case"hour":o.hour=Number(l.value)%24;break;case"minute":o.minute=Number(l.value);break;case"second":o.second=Number(l.value);break;case"weekday":o.weekday=n[l.value]??0;break;default:break}return o}}function j(s,i,n){const c=q(s),o=z(n),l=new Set(c.filter(d=>d.token).map(d=>d.token)),h=l.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:n}):null,w=l.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:n}):null,g=l.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:n}):null,k=l.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:n}):null;return d=>{const p=o(d);let m="";for(const v of c){if(!v.token){m+=v.text;continue}switch(v.token){case"yyyy":m+=G(p.year,4);break;case"yy":m+=G(p.year%100,2);break;case"MMMM":m+=w.format(d);break;case"MMM":m+=h.format(d);break;case"MM":m+=G(p.month,2);break;case"M":m+=String(p.month);break;case"dd":m+=G(p.day,2);break;case"d":m+=String(p.day);break;case"EEEE":m+=k.format(d);break;case"EEE":m+=g.format(d);break;case"HH":m+=G(p.hour,2);break;case"H":m+=String(p.hour);break;case"hh":m+=G(p.hour%12===0?12:p.hour%12,2);break;case"h":m+=String(p.hour%12===0?12:p.hour%12);break;case"mm":m+=G(p.minute,2);break;case"m":m+=String(p.minute);break;case"ss":m+=G(p.second,2);break;case"s":m+=String(p.second);break;case"SSS":m+=G(p.ms,3);break;case"a":m+=p.hour<12?"AM":"PM";break;default:m+=v.text;break}}return m}}const O=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function b(s,i){const n=s||{},c=n.locale||i||void 0,o=n.nullDisplay??"",l=n.timeZone;let h;if(n.pattern)h=j(n.pattern,c,l);else if(n.dateStyle||n.timeStyle){const p={timeZone:l};n.dateStyle&&(p.dateStyle=n.dateStyle),n.timeStyle&&(p.timeStyle=n.timeStyle);const m=new Intl.DateTimeFormat(c,p);h=v=>m.format(v)}else{const p=new Intl.DateTimeFormat(c,{dateStyle:"medium",timeZone:l});h=m=>p.format(m)}const w=n.relative?new Intl.RelativeTimeFormat(c,{numeric:"auto"}):null,k=(typeof n.relative=="object"&&n.relative?n.relative.threshold??7:7)*24*36e5,d=(p,m)=>{const v=x(p);if(!v)return o;if(w){const y=m&&typeof m.now=="number"?m.now:Date.now(),E=v.getTime()-y;if(Math.abs(E)<k){for(const[M,F]of O)if(Math.abs(E)>=F||M==="second")return w.format(Math.round(E/F),M)}}return h(v)};return d.spec=n,d}function u(s){if(N(s)||s==="")return null;if(typeof s=="string"){const c=/^(\d{4}-\d{2}-\d{2})/.exec(s.trim());if(c)return c[1];const o=x(s);return o?u(o):null}const i=x(s);if(!i)return null;const n=c=>String(c).padStart(2,"0");return`${i.getFullYear()}-${n(i.getMonth()+1)}-${n(i.getDate())}`}function f(s,i){if(N(s)||s==="")return null;if(typeof s=="string"){const c=s.trim();if(a.test(c)){const h=x(c);return h?r(h,i):null}const o=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(c);if(o){const[,h,w,g,k]=o;return`${h}T${w}:${g}${k&&k!=="00"?`:${k}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(c))return`${c}T00:00`;const l=x(c);return l?f(l):null}const n=x(s);return n?r(n,i):null}const a=/(?:Z|[+-]\d{2}:?\d{2})$/i;function r(s,i){const n=h=>String(h).padStart(2,"0");if(i)try{const h=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(s).reduce((k,d)=>(d.type!=="literal"&&(k[d.type]=d.value),k),{}),w=h.hour==="24"?"00":h.hour,g=Number(h.second);return`${h.year}-${h.month}-${h.day}T${w}:${h.minute}`+(g?`:${h.second}`:"")}catch{}const c=`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())}`,o=s.getSeconds(),l=`${n(s.getHours())}:${n(s.getMinutes())}${o?`:${n(o)}`:""}`;return`${c}T${l}`}function t(s,i){const n=N(s)||s===""?null:String(s),c=N(i)||i===""?null:String(i);return n===null?c===null?0:1:c===null||n<c?-1:n>c?1:0}}),Ie("packages/core/src/format/boolean.js",function(e,U){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return q}});const N=U("packages/core/src/internal/predicates.js").isNil,X={true:"☑",false:"☐",null:""},B={true:"◉",false:"◯",null:""};function D(K){if(N(K)||K==="")return null;if(typeof K=="boolean")return K;if(typeof K=="number")return K!==0;const x=String(K).trim().toLowerCase();return x==="true"||x==="yes"||x==="y"||x==="1"?!0:x==="false"||x==="no"||x==="n"||x==="0"?!1:null}function q(K,x){const G=K||{},z=G.display||"text",j=G.trueLabel??"Yes",O=G.falseLabel??"No",b=G.nullLabel??"";let u=j,f=O;const a=b;z==="checkbox"?(u=X.true,f=X.false):z==="switch"?(u=B.true,f=B.false):z==="icon"&&(u=G.trueIcon??j,f=G.falseIcon??O);const r=t=>{const s=D(t);return s===null?a:s?u:f};return r.display=z,r.labels={true:j,false:O,null:b},r.locale=x,r.spec=G,r}}),Ie("packages/core/src/format/text.js",function(e,U){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return D}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/internal/text.js").titleCase;function D(q,K){const x=q||{},G=x.locale||K||void 0,z=x.nullDisplay??"",j=x.emptyDisplay??"",O=x.transform||"none",b=typeof x.truncate=="number"?{chars:x.truncate}:x.truncate||null,u=b?b.chars:0,f=b?b.ellipsis??"…":"",a=t=>{switch(O){case"upper":return G?t.toLocaleUpperCase(G):t.toUpperCase();case"lower":return G?t.toLocaleLowerCase(G):t.toLowerCase();case"title":return B(t);default:return t}},r=t=>{if(N(t))return z;let s=typeof t=="string"?t:String(t);return s===""?j:(O!=="none"&&(s=a(s)),u>0&&s.length>u&&(s=s.slice(0,u)+f),s)};return r.spec=x,r}}),Ie("packages/core/src/format/shorthand.js",function(e,U){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return K}});const te=["currency","number","percent","date","boolean","text","relative"],N=/[#0?@;"\\]/,X=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function B(x){return typeof x!="string"||x===""||q(x)?!1:N.test(x)}function D(x){return typeof x!="string"||x===""||q(x)?!1:X.test(x)}function q(x){const G=x.indexOf(":"),z=G===-1?x:x.slice(0,G);return te.includes(z)?z:null}function K(x){const G=q(x);if(!G)return null;const z=x.indexOf(":"),j=z===-1?"":x.slice(z+1),O=j===""?[]:j.split(":");switch(G){case"currency":{const b={type:"number",style:"currency",currency:O[0]||"USD"};return O[1]!==void 0&&O[1]!==""&&(b.decimals=Number(O[1])),b}case"number":{const b={type:"number",style:"decimal"};return O[0]!==void 0&&O[0]!==""&&(b.decimals=Number(O[0])),b}case"percent":{const b={type:"number",style:"percent"};return O[0]!==void 0&&O[0]!==""&&(b.decimals=Number(O[0])),b}case"date":return{type:"date",pattern:j||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const b=j.split("/"),u={type:"boolean",display:"text"};return b[0]!==void 0&&b[0]!==""&&(u.trueLabel=b[0]),b[1]!==void 0&&b[1]!==""&&(u.falseLabel=b[1]),b[2]!==void 0&&(u.nullLabel=b[2]),u}case"text":{const b={type:"text"};return O[0]&&(b.transform=O[0]),O[1]!==void 0&&O[1]!==""&&(b.truncate=Number(O[1])),b}default:return null}}}),Ie("packages/core/src/format/index.js",function(e,U){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return y}});const te=U("packages/core/src/internal/predicates.js"),N=te.isFunction,X=te.isObject,D=U("packages/core/src/internal/warn.js").warnOnce,q=U("packages/core/src/format/number.js"),K=q.compileNumber,x=U("packages/core/src/format/date.js"),G=x.compileDate,z=x.scanPattern,j=U("packages/core/src/format/boolean.js"),O=j.compileBoolean,b=U("packages/core/src/format/text.js"),u=b.compileText,f=U("packages/core/src/format/mask.js"),a=f.compileMask,r=U("packages/core/src/format/shorthand.js"),t=r.parseShorthand,s=r.looksLikeMask,i=r.looksLikeDatePattern,c=U("packages/core/src/format/pattern.js").parseNumberPattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return q.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return x.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return x.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return x.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return x.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return j.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return j.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return b.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return f.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return f.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return f.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return r.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return r.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return r.looksLikeDatePattern}});const o=new Set(["decimal","currency","percent","unit"]),l=new Set(["type","locale"]),h={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale","pattern"]),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"])},w=new Set(["number","date","boolean","text"]);function g(V,I){const $=V.type;if($===void 0||w.has($)||!o.has(String($)))return;const S=I?`"${I}"`:"with no id";D(`format:unknown-style-key:${I||""}:${$}`,`column ${S} has format: { type: "${$}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${$}" instead?`)}function k(V,I,$){const S=h[I],R=$?`"${$}"`:"with no id";for(const L of V){if(l.has(L)||S.has(L))continue;const T=Object.keys(h).find(A=>A!==I&&h[A].has(L));T?D(`format:inapplicable:${$||""}:${L}`,`column ${R} has format key "${L}", which applies to a ${T} column, not the ${I} column it was applied to; it is ignored.`):D(`format:unknown:${$||""}:${L}`,`column ${R} has an unrecognised format key "${L}" for its ${I} format; it is ignored.`)}}function d(V){if(V.type==="number"||V.type==="date"||V.type==="boolean"||V.type==="text")return!0;const I=o.has(String(V.style));return!!(V.pattern||V.dateStyle||V.timeStyle||V.relative||V.timeZone||V.trueLabel||V.falseLabel||V.display||V.trueIcon||V.falseIcon||V.transform||V.truncate||V.emptyDisplay||I||V.currency||V.decimals!==void 0||V.minDecimals!==void 0||V.maxDecimals!==void 0||V.notation||V.negative||V.scale!==void 0||V.prefix||V.suffix||V.zeroDisplay!==void 0)}function p(V,I){if(V.type==="number"||V.type==="date"||V.type==="boolean"||V.type==="text")return V.type;if(V.pattern){if(s(V.pattern))return"number";if(i(V.pattern))return"date"}if(V.dateStyle||V.timeStyle||V.relative||V.timeZone)return"date";if(V.trueLabel||V.falseLabel||V.display||V.trueIcon||V.falseIcon)return"boolean";if(V.transform||V.truncate||V.emptyDisplay)return"text";if(V.style||V.currency||V.decimals!==void 0||V.minDecimals!==void 0||V.maxDecimals!==void 0||V.notation||V.negative||V.scale!==void 0||V.prefix||V.suffix||V.zeroDisplay!==void 0)return"number";const $=I&&I.base;return $==="number"?"number":$==="date"||$==="dateString"?"date":$==="boolean"?"boolean":"text"}function m(V,I=null,$=void 0,S=void 0,R=void 0){if(V==null||V==="")return null;const L=X(V)?Object.keys(V):null;if(typeof V=="function"){const C=(H,Y)=>String(V({...Y||{},value:H,locale:$})??"");return C.ooxml=I&&I.excel||"General",C}if(typeof V=="string"){if(s(V)){const{format:H,ooxml:Y}=a(V,$);return H.ooxml=Y,H}const C=t(V)||(i(V)?{type:"date",pattern:V}:null);return C?m(C,I,$,S,R):(D(`format:${V}`,`unrecognised format string "${V}"; the value will be stringified`),null)}if(!X(V))return D("format:shape","format must be a spec object or a string; ignoring",V),null;if(I&&N(I.format)&&!d(V)||I&&N(I.format)&&Array.isArray(I.formatPatterns)&&V.type===void 0)return null;const T=p(V,I);T==="date"&&S&&V.timeZone===void 0&&(V={...V,timeZone:S}),g(V,R),k(L||Object.keys(V),T,R);let A;switch(T){case"number":A=K(V,$);break;case"date":A=G(V,$);break;case"boolean":A=O(V,$);break;default:A=u(V,$);break}return A.ooxml=y(V,T,$,I),A.kind=T,A}const v={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 y(V,I,$=void 0,S=null){if(I==="date"){if(V.pattern){let C="";for(const H of z(V.pattern))C+=H.token?v[H.token]??H.text:H.text;return C}return S&&S.excel||"yyyy-mm-dd"}if(I==="boolean")return"General";if(I==="text")return"@";if(typeof V.pattern=="string"&&c(V.pattern))return String(V.pattern).trim();if(V.notation==="compact"||V.notation==="scientific")return"General";const R=typeof V.decimals=="number"?V.decimals:typeof V.minDecimals=="number"?V.minDecimals:V.style==="currency"?2:0;let T=`${V.thousandsSeparator===!1?"":"#,#"}#0${R>0?`.${"0".repeat(R)}`:""}`,A="";return V.style==="currency"&&(A+=E(F(V.currency||"USD",$))),V.prefix&&(A+=E(V.prefix)),T=A+T,V.style==="percent"&&(T=`${T}%`),V.suffix&&(T+=E(V.suffix)),V.negative==="parentheses"?`${T};(${T})`:V.negative==="suffix"?`${T};${T}-`:T}function E(V){return`"${String(V).split('"').join("")}"`}const M=new Map;function F(V,I){const $=`${V}|${I||""}`;let S=M.get($);if(S!==void 0)return S;S=V;try{const L=new Intl.NumberFormat(I,{style:"currency",currency:V}).formatToParts(0).find(T=>T.type==="currency");L&&(S=L.value)}catch{}return M.set($,S),S}}),Ie("packages/core/src/columns/types/temporal.js",function(e,U){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Ye}});const te=U("packages/core/src/internal/predicates.js"),N=te.isNil,X=te.isFunction,B=U("packages/core/src/format/date.js"),D=B.toDate,q=B.compilePattern,K=B.compileDate,x=B.toIsoDateTime,G=B.compareIso,z=864e5,j=Object.freeze({}),O=1e3,b=60*O,u=60*b,f=24*u,a=7*f,r=new WeakMap;function t(Oe,_e){const je=Oe&&Oe.locale||"",we=Oe&&Oe.column;if(!we)return je?{locale:je}:j;const He=r.get(we);if(He&&He.locale===je)return He.bag;const Ke=we.typeOptions||we[_e]||(s(we.format)?we.format:null),Xe={...Ke||j,locale:Ke&&Ke.locale||je||void 0};return r.set(we,{locale:je,bag:Xe}),Xe}function s(Oe){return Oe!==null&&typeof Oe=="object"&&!Array.isArray(Oe)&&!(Oe instanceof Date)}function i(Oe,_e){const je=Oe===null||Number.isNaN(Oe)?null:Oe,we=_e===null||Number.isNaN(_e)?null:_e;return je===null?we===null?0:1:we===null||je<we?-1:je>we?1:0}const n=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,c=/^(\d{3,6})$/;function o(Oe,_e,je,we){return!(Oe>=0&&Oe<=23)||!(_e>=0&&_e<=59)||!(je>=0&&je<=59)||!(we>=0&&we<=999)?null:Oe*u+_e*b+je*O+we}function l(Oe){if(N(Oe))return null;const _e=String(Oe).trim();if(_e==="")return null;const je=c.exec(_e);if(je){const wt=je[1];if(wt.length===5)return null;const pt=wt.length===3?1:2;return o(Number(wt.slice(0,pt)),Number(wt.slice(pt,pt+2)),Number(wt.slice(pt+2,pt+4)||0),0)}const we=n.exec(_e);if(!we)return null;let He=Number(we[1]);const Ke=Number(we[2]||0),Xe=Number(we[3]||0),nt=we[4]?Number(we[4].padEnd(3,"0")):0,it=we[5]?we[5][0].toLowerCase():null;if(it){if(He<1||He>12)return null;He=He%12,it==="p"&&(He+=12)}return o(He,Ke,Xe,nt)}function h(Oe){return N(Oe)||Oe===""?null:typeof Oe=="number"?Number.isFinite(Oe)?(Oe%f+f)%f:null:Oe instanceof Date?Number.isNaN(Oe.getTime())?null:Oe.getHours()*u+Oe.getMinutes()*b+Oe.getSeconds()*O+Oe.getMilliseconds():l(Oe)}const w=new Map;function g(Oe){const _e=Oe.pattern||"",je=Oe.timeStyle||(Oe.seconds?"medium":"short"),we=`${Oe.locale||""}|${_e}|${je}`;let He=w.get(we);if(He)return He;if(_e)He=q(_e,Oe.locale||void 0,"UTC");else{const Ke=new Intl.DateTimeFormat(Oe.locale||void 0,{timeStyle:je,timeZone:"UTC"});He=Xe=>Ke.format(Xe)}return w.set(we,He),He}function k(Oe,_e){const je=_e||j;if(Oe==null||typeof Oe!="number"||!Number.isFinite(Oe))return je.nullDisplay??"";const we=(Oe%f+f)%f;return g(je)(new Date(we))}function d(Oe){return Oe instanceof Date?!Number.isNaN(Oe.getTime()):typeof Oe=="number"?Number.isFinite(Oe)&&Oe>=0&&Oe<f:typeof Oe!="string"||!Oe.includes(":")?!1:l(Oe)!==null}function p(Oe){const _e=h(Oe);return _e==null?"":k(_e,{pattern:_e%O===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const m=new Map;function v(Oe){const _e=Oe||"";let je=m.get(_e);return je||(je=new Intl.DateTimeFormat("en-GB",{timeZone:Oe||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),m.set(_e,je)),je}function y(Oe,_e){const je={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const we of v(_e).formatToParts(new Date(Oe)))we.type==="year"?je.year=Number(we.value):we.type==="month"?je.month=Number(we.value):we.type==="day"?je.day=Number(we.value):we.type==="hour"?je.hour=Number(we.value)%24:we.type==="minute"?je.minute=Number(we.value):we.type==="second"&&(je.second=Number(we.value));return je}function E(Oe,_e){const je=y(Oe,_e);return Date.UTC(je.year,je.month-1,je.day,je.hour,je.minute,je.second,0)-Math.floor(Oe/1e3)*1e3}function M(Oe,_e){const je=Oe.hour||0,we=Oe.minute||0,He=Oe.second||0,Ke=Oe.ms||0;if(!_e)return new Date(Oe.year,Oe.month-1,Oe.day,je,we,He,Ke).getTime();const Xe=Date.UTC(Oe.year,Oe.month-1,Oe.day,je,we,He,Ke);let nt=Xe-E(Xe,_e);return nt=Xe-E(nt,_e),nt}const F=/(?:Z|[+-]\d{2}:?\d{2})$/i,V=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function I(Oe,_e){if(N(Oe))return null;const je=String(Oe).trim();if(je==="")return null;const we=_e&&_e.timeZone||void 0;if(!F.test(je)){const He=V.exec(je);if(He){const Ke=(He[4]||"").trim(),Xe=Ke===""?0:l(Ke);if(Xe===null)return null;const nt=M({year:Number(He[1]),month:Number(He[2]),day:Number(He[3]),hour:Math.floor(Xe/u),minute:Math.floor(Xe/b)%60,second:Math.floor(Xe/O)%60,ms:Xe%O},we);return Number.isNaN(nt)?null:new Date(nt)}}return D(je)}function $(Oe){if(typeof Oe=="number")return Number.isFinite(Oe)?Oe:null;const _e=D(Oe);return _e?_e.getTime():null}const S=new Map;function R(Oe){const _e=[Oe.locale||"",Oe.pattern||"",Oe.dateStyle||"",Oe.timeStyle||"",Oe.timeZone||"",Oe.seconds?"1":""].join("|");let je=S.get(_e);if(je)return je;const we=Oe.pattern?{type:"date",pattern:Oe.pattern,timeZone:Oe.timeZone}:{type:"date",dateStyle:Oe.dateStyle||"medium",timeStyle:Oe.timeStyle||(Oe.seconds?"medium":"short"),timeZone:Oe.timeZone};return je=K(we,Oe.locale||void 0),S.set(_e,je),je}function L(Oe,_e){const je=_e||j,we=$(Oe);return we==null?je.nullDisplay??"":R(je)(we)}function T(Oe){return Oe instanceof Date?!Number.isNaN(Oe.getTime()):typeof Oe!="string"||!V.test(Oe.trim())?!1:I(Oe)!==null}const A=Object.freeze([{key:"w",ms:a,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:f,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:u,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:b,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:O,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),C=new Map;for(const Oe of A)for(const _e of Oe.names)C.set(_e,Oe);const H=Object.freeze(A.filter(Oe=>Oe.key!=="w")),Y=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,Z=/^\d+(?:\.\d+)?$/,_=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function J(Oe){const _e=Oe&&Oe.defaultUnit?C.get(String(Oe.defaultUnit).toLowerCase()):null;return _e?_e.ms:b}function ee(Oe){return(Oe&&Oe.defaultUnit?C.get(String(Oe.defaultUnit).toLowerCase()):null)||C.get("m")}function ne(Oe,_e){if(N(Oe))return null;let je=String(Oe).trim().toLowerCase();if(je==="")return null;let we=1;if(je[0]==="-"?(we=-1,je=je.slice(1).trim()):je[0]==="+"&&(je=je.slice(1).trim()),je==="")return null;const He=_.exec(je);if(He){const it=He[3]!==void 0,wt=Number(He[1])*u+Number(He[2])*b+(it?Number(He[3])*O:0)+(He[4]?Number(He[4].padEnd(3,"0")):0);return we*wt}if(Z.test(je))return Math.round(we*Number(je)*J(_e||j));let Ke=je,Xe=0,nt=0;for(;Ke!=="";){const it=Y.exec(Ke);if(!it)return null;const wt=C.get(it[2]);if(!wt)return null;Xe+=Number(it[1])*wt.ms,Ke=Ke.slice(it[0].length),nt++}return nt===0?null:Math.round(we*Xe)}function se(Oe){return N(Oe)||Oe===""?null:typeof Oe=="number"?Number.isFinite(Oe)?Oe:null:ne(Oe)}const oe=new Map;function fe(Oe,_e,je){const we=`${je||""}|${_e.intl}`;let He=oe.get(we);if(He===void 0){try{He=new Intl.NumberFormat(je||void 0,{style:"unit",unit:_e.intl,unitDisplay:"long"})}catch{He=null}oe.set(we,He)}return He?He.format(Oe):`${Oe} ${Oe===1?_e.long[0]:_e.long[1]}`}function pe(Oe,_e){return String(Oe).padStart(_e,"0")}function he(Oe,_e){const je=_e||j;if(Oe==null||typeof Oe!="number"||!Number.isFinite(Oe))return je.nullDisplay??"";const we=je.style||"short",He=Oe<0;let Ke=Math.round(Math.abs(Oe));const Xe=He?"-":"";if(Ke===0&&je.zeroDisplay!=null)return je.zeroDisplay;if(we==="clock"){const pt=Math.floor(Ke/u),St=Math.floor(Ke/b)%60,Ct=Math.floor(Ke/O)%60;return`${Xe}${pe(pt,2)}:${pe(St,2)}:${pe(Ct,2)}`}if(Ke===0){const pt=ee(je);return we==="long"?fe(0,pt,je.locale):`0${pt.key}`}const nt=je.weeks===!0?A:H,it=typeof je.maxUnits=="number"&&je.maxUnits>0?je.maxUnits:je.maxUnits===void 0?2:1/0,wt=[];for(const pt of nt){if(wt.length>=it)break;const St=Math.floor(Ke/pt.ms);St!==0&&(Ke-=St*pt.ms,wt.push(we==="long"?fe(St,pt,je.locale):`${St}${pt.key}`))}return Xe+wt.join(" ")}function Re(Oe){if(typeof Oe!="string")return!1;const _e=Oe.trim();return _e===""||_.test(_e)||!/[a-z]/i.test(_e)?!1:ne(_e)!==null}const Ue=Date.UTC(1899,11,30),Le=new Map;function ie(Oe,_e){const je=Oe||"";let we=Le.get(je);we||(we=new Intl.DateTimeFormat("en-GB",{timeZone:Oe||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),Le.set(je,we));const He=typeof _e=="number"?_e:Date.now();for(const Ke of we.formatToParts(new Date(He)))if(Ke.type==="timeZoneName")return Ke.value;return""}function ge(Oe){if(Oe)return Oe;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function ke(Oe,_e){const je=ge(Oe),we=ie(Oe,_e);return we?`${je} (${we})`:je}function Se(Oe,_e){if(Oe&&Oe.timeZone)return Oe.timeZone;const je=_e&&_e.grid;return(je&&X(je.get)?je.get("timeZone"):void 0)||void 0}function Ae(Oe,_e){const je=_e||j,we=$(Oe);if(we==null)return je.nullDisplay??"";const He=R(je)(we);if(!je.showOrigin)return He;const Ke=je.originZone;return Ke?Ke===(je.timeZone||ge(je.timeZone))?He:`${He} (${ke(Ke,we)})`:`${He} (no origin recorded)`}function xe(Oe,_e,je,we){if(_e==="instant"||!_e)return Oe;const He=y(Oe,je);if(_e==="month")return M({year:He.year,month:He.month,day:1},je);if(_e==="week"){const Ke=we>=1&&we<=7?we:1,nt=((new Date(Date.UTC(He.year,He.month-1,He.day)).getUTCDay()+6)%7+1-Ke+7)%7,it=new Date(Date.UTC(He.year,He.month-1,He.day-nt));return M({year:it.getUTCFullYear(),month:it.getUTCMonth()+1,day:it.getUTCDate()},je)}return M({year:He.year,month:He.month,day:He.day},je)}function me(Oe,_e){const je=Oe&&Oe.group,we=je&&je.granularity||"day";if(we==="instant")return null;const He=je&&je.weekStart;return Ke=>typeof Ke=="number"?xe(Ke,we,_e,He):Ke}const ye={time:{base:"number",storage:"float64",matches:d,format:Oe=>k(h(Oe.value),t(Oe,"time")),parse:Oe=>l(Oe.text),compare:(Oe,_e)=>i(h(Oe),h(_e)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Oe=>{const _e=h(Oe);return _e===null?null:_e/z},toStorage:Oe=>h(Oe),toClipboard:p,fromClipboard:l},datetime:{base:"dateString",storage:"dictionary",matches:T,format:Oe=>L(Oe.value,t(Oe,"datetime")),parse:Oe=>x(I(Oe.text,t(Oe,"datetime"))??Oe.text),compare:G,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Oe,_e)=>x(Oe,_e&&_e.timeZone),toClipboard:Oe=>N(Oe)?"":String(Oe),fromClipboard:Oe=>x(Oe)},duration:{base:"number",storage:"float64",matches:Re,format:Oe=>he(se(Oe.value),t(Oe,"duration")),parse:Oe=>ne(Oe.text,t(Oe,"duration")),compare:(Oe,_e)=>i(se(Oe),se(_e)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Oe=>{const _e=se(Oe);return _e===null?null:_e/z},toStorage:Oe=>se(Oe),toClipboard:Oe=>he(se(Oe),{style:"short",maxUnits:-1}),fromClipboard:Oe=>ne(Oe)},timestamp:{base:"number",storage:"float64",format:Oe=>{const _e=t(Oe,"timestamp");return Ae(Oe.value,{..._e,timeZone:Se(_e,Oe)})},parse:Oe=>{const _e=t(Oe,"timestamp"),je=I(Oe.text,{timeZone:Se(_e,Oe)});return je?je.getTime():null},compare:(Oe,_e)=>i($(Oe),$(_e)),groupProjector:(Oe,_e)=>me(Oe,_e),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Oe,_e)=>{const je=$(Oe);if(je==null)return null;const we=y(je,_e&&_e.timeZone||void 0);return(Date.UTC(we.year,we.month-1,we.day,we.hour,we.minute,we.second)-Ue)/z},toStorage:Oe=>$(Oe),toClipboard:Oe=>{const _e=$(Oe);return _e==null?"":new Date(_e).toISOString()},fromClipboard:Oe=>$(Oe)}},Te=["datetime","time","duration"],Ye=ye}),Ie("packages/core/src/internal/lru.js",function(e,U){"use strict";Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return te}});class te{#e;#t=new Map;#n;constructor(X=256,B=null){this.#e=X,this.#n=B}get size(){return this.#t.size}get max(){return this.#e}set max(X){this.#e=X,this.#r()}has(X){return this.#t.has(X)}get(X){const B=this.#t;if(!B.has(X))return;const D=B.get(X);return B.delete(X),B.set(X,D),D}peek(X){return this.#t.get(X)}set(X,B){const D=this.#t;return D.has(X)&&D.delete(X),D.set(X,B),this.#r(),B}delete(X){const B=this.#t.get(X);return this.#t.delete(X)&&this.#n&&this.#n(B,X),B}clear(){if(this.#n)for(const[X,B]of this.#t)this.#n(B,X);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const X=this.#t;for(;X.size>this.#e;){const B=X.keys().next().value,D=X.get(B);X.delete(B),this.#n&&this.#n(D,B)}}}}),Ie("packages/core/src/columns/types/network.js",function(e,U){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/internal/lru.js").Lru,D=4294967295,q=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function K(S){if(N(S))return null;if(typeof S=="string")return x(S);const R=Number(S);return Number.isFinite(R)?R<0?R<-2147483648?null:R>>>0:R>D?null:Math.trunc(R)>>>0:null}function x(S){if(N(S))return null;const R=String(S).trim();if(R==="")return null;const L=q.exec(R);if(!L)return null;let T=0;for(let A=1;A<=4;A++){const C=L[A];if(C.length>1&&C.charCodeAt(0)===48)return null;const H=Number(C);if(H>255)return null;T=T*256+H}return T}function G(S){const R=K(S);return R===null?"":`${R>>>24&255}.${R>>>16&255}.${R>>>8&255}.${R&255}`}function z(S){return typeof S=="string"&&x(S)!==null}function j(S,R){const L=K(S),T=K(R);return L===null?T===null?0:1:T===null||L<T?-1:L>T?1:0}const O=64,b=D*O+32,u=/^(?:0|[1-9]\d?)$/;function f(S,R){return S*O+R}function a(S){if(N(S))return null;if(typeof S=="string"){const T=r(S);return T===null?null:a(T)}if(typeof S=="object"){const T=K(S.address),A=Number(S.prefix);return T===null||!Number.isInteger(A)||A<0||A>32?null:{address:T,prefix:A}}const R=Number(S);if(!Number.isInteger(R)||R<0||R>b)return null;const L=R%O;return L>32?null:{address:(R-L)/O,prefix:L}}function r(S){if(N(S))return null;const R=String(S).trim();if(R==="")return null;const L=R.indexOf("/");if(L<0)return null;const T=x(R.slice(0,L));if(T===null)return null;const A=R.slice(L+1).trim();if(!u.test(A))return null;const C=Number(A);return C>32?null:f(T,C)}function t(S){const R=a(S);return R?`${G(R.address)}/${R.prefix}`:""}function s(S){return typeof S=="string"&&r(S)!==null}function i(S,R){const L=a(S),T=a(R);return L?T?L.address!==T.address?L.address<T.address?-1:1:L.prefix-T.prefix:-1:T?1:0}function n(S){return S===0?0:4294967295<<32-S>>>0}function c(S){const R=a(S);return R?(R.address&n(R.prefix))>>>0:null}function o(S){const R=a(S);return R?(R.address&n(R.prefix)|~n(R.prefix)>>>0)>>>0:null}function l(S){const R=a(S);return R?2**(32-R.prefix):null}function h(S){const R=a(S);return R?R.prefix===32?1:R.prefix===31?2:2**(32-R.prefix)-2:null}function w(S,R){const L=a(S);if(!L)return!1;const T=K(R);if(T===null)return!1;const A=n(L.prefix);return(T&A)>>>0===(L.address&A)>>>0}function g(S,R){const L=c(S),T=c(R);return L===null||T===null?!1:L<=o(R)&&T<=o(S)}const k=/^[0-9a-fA-F]{1,4}$/,d=new B(512);function p(S){if(N(S))return null;let R=String(S).trim();if(R==="")return null;const L=R.indexOf("%");if(L>=0&&(R=R.slice(0,L)),R==="")return null;if(R.indexOf(".")>=0){const Z=R.lastIndexOf(":");if(Z<0)return null;const _=x(R.slice(Z+1));if(_===null)return null;R=`${R.slice(0,Z+1)}${(_>>>16&65535).toString(16)}:${(_&65535).toString(16)}`}const T=R.split("::");if(T.length>2)return null;const A=m(T[0]);if(A===null)return null;if(T.length===1)return A.length===8?A:null;const C=m(T[1]);if(C===null)return null;const H=8-A.length-C.length;if(H<1)return null;const Y=A.slice();for(let Z=0;Z<H;Z++)Y.push(0);for(const Z of C)Y.push(Z);return Y}function m(S){if(S==="")return[];const R=[];for(const L of S.split(":")){if(!k.test(L))return null;R.push(parseInt(L,16))}return R}function v(S){if(typeof S!="string")return p(S);if(d.has(S))return d.get(S);const R=p(S);return d.set(S,R),R}function y(S){if(S[0]===0&&S[1]===0&&S[2]===0&&S[3]===0&&S[4]===0&&S[5]===65535)return`::ffff:${G((S[6]<<16|S[7])>>>0)}`;let R=-1,L=0,T=-1,A=0;for(let Y=0;Y<8;Y++)S[Y]===0?(T<0?(T=Y,A=1):A++,A>L&&(L=A,R=T)):(T=-1,A=0);if(L<2)return S.map(Y=>Y.toString(16)).join(":");const C=S.slice(0,R).map(Y=>Y.toString(16)).join(":"),H=S.slice(R+L).map(Y=>Y.toString(16)).join(":");return`${C}::${H}`}function E(S){const R=p(S);return R===null?null:y(R)}function M(S){return E(S)??""}function F(S){return typeof S=="string"&&S.indexOf(":")>=0&&p(S)!==null}function V(S,R){const L=v(S),T=v(R);if(!L)return T?1:0;if(!T)return-1;for(let A=0;A<8;A++)if(L[A]!==T[A])return L[A]<T[A]?-1:1;return 0}const I=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:z,parse:S=>x(S.text),compare:j,format:S=>G(S.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:S=>K(S),toClipboard:S=>G(S),fromClipboard:S=>x(S)},cidr:{base:"number",storage:"float64",matches:s,parse:S=>r(S.text),compare:i,format:S=>t(S.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:S=>{const R=a(S);return R===null?null:f(R.address,R.prefix)},toClipboard:S=>t(S),fromClipboard:S=>r(S)},ipv6:{base:"text",storage:"dictionary",matches:F,parse:S=>E(S.text),compare:V,format:S=>M(S.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:S=>E(S),toClipboard:S=>M(S),fromClipboard:S=>E(S)}}),$=I}),Ie("packages/core/src/i18n/catalogue.js",function(e,U){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return B}});const N=U("packages/core/src/registry/free-tier-notice.js").FREE_TIER_NOTICE,X=Object.freeze({"count.rows":{one:"{count} row",other:"{count} rows"},"count.comments":{one:"{count} comment",other:"{count} comments"},"comments.someUnresolved":"{comments}, {unresolved} unresolved","comments.allResolved":"{comments}, all resolved","count.unresolvedComments":{one:"{count} unresolved comment",other:"{count} unresolved comments"},"count.items":{one:"{count} item",other:"{count} items"},"count.keys":{one:"{count} key",other:"{count} keys"},"count.values":{one:"value",other:"values"},"count.waiting":{one:"{count} waiting",other:"{count} waiting"},"count.rowsAdded":{one:"{count} row added",other:"{count} rows added"},"count.rowsRemoved":{one:"{count} row removed",other:"{count} rows removed"},"value.empty":"empty","a11y.sort.cleared":"Sort cleared","a11y.sort.by":"Sorted by {columns}","a11y.sort.column":"{column} {direction}","a11y.sort.ascending":"ascending","a11y.sort.descending":"descending","a11y.filter.cleared":"Filter cleared, {rows}","a11y.filter.applied":"Filtered to {shown} of {total}","a11y.find.count":{one:"{current} of {count} match",other:"{current} of {count} matches"},"a11y.find.countLoaded":{one:"{current} of {count} match in loaded rows",other:"{current} of {count} matches in loaded rows"},"a11y.find.none":"No matches","a11y.find.noneLoaded":"No matches in loaded rows","a11y.selection.cleared":"Selection cleared","a11y.selection.count":{one:"{count} row selected",other:"{count} rows selected"},"tabs.tablist":"Tabs","a11y.tabs.selected":"{label} tab selected","a11y.scrollbar.horizontal":"Horizontal scrollbar","a11y.scrollbar.vertical":"Vertical scrollbar","designer.canvas":"Dashboard canvas","designer.chrome":"Designer tools","designer.page":"Page {n}","a11y.designer.edit":"Edit mode","a11y.designer.view":"View mode","layout.region":"Dashboard layout","layout.move":"Move {title}","layout.resize":"Resize {title}","layout.close":"Close {title}","a11y.layout.grabbed":"{title} grabbed, column {x} of {columns}, row {y}","a11y.layout.position":"{title}, column {x} of {columns}, row {y}","a11y.layout.dropped":"{title} dropped, column {x} of {columns}, row {y}","a11y.layout.cancelled":"{title} move cancelled","a11y.layout.resizeCancelled":"{title} resize cancelled","a11y.layout.reverted":"{title} returned to column {x}, row {y}","a11y.layout.resizeGrabbed":"{title} resize grabbed, {w} by {h} cells","a11y.layout.resizeStep":"{title}, {w} by {h} cells","a11y.layout.resized":"{title} resized to {w} by {h} cells","a11y.layout.closed":"{title} closed","layout.maximise":"Maximise {title}","layout.minimise":"Minimise {title}","layout.restore":"Restore {title}","a11y.layout.maximised":"{title} maximised, filling the dashboard; press Escape to restore it","a11y.layout.minimised":"{title} minimised","a11y.layout.restored":"{title} restored to column {x}, row {y}","a11y.group.cleared":"Grouping cleared","a11y.group.by":"Grouped by {columns}","a11y.group.expanded":"{label} expanded, {rows} shown","a11y.group.collapsed":"{label} collapsed, {rows} shown","a11y.page.position":"Page {page} of {pages}","a11y.updates.paused":"Updates paused","a11y.updates.resumed":"Updates resumed","a11y.edit.refusedOne":"Edit to {column} was refused and put back to {value}{reason}","a11y.edit.refusedMany":{one:"{count} edit was refused and put back{reason}",other:"{count} edits were refused and put back{reason}"},"a11y.edit.reason":", {reason}","a11y.history.undo":"Undid {label}","a11y.history.redo":"Redid {label}","a11y.history.undoLast":"Undid the last change","a11y.history.redoLast":"Redid the last change","a11y.column.cannotResize":"{column} cannot be resized","a11y.column.resized":"{column} is {width} pixels wide","a11y.column.atMinimum":"{column} is at its narrowest, {width} pixels","a11y.column.atMaximum":"{column} is at its widest, {width} pixels","a11y.column.cannotMove":"{column} cannot be moved","a11y.column.alreadyFirst":"{column} is already first in its group","a11y.column.alreadyLast":"{column} is already last in its group","a11y.column.cannotMoveThere":"{column} cannot be moved there","a11y.column.moved":"{column} moved to position {at} of {of}","a11y.group.formed":"{column} grouped with {other} in a new band","a11y.group.dissolved":"band {group} dissolved","a11y.group.renamed":"band renamed to {group}","a11y.group.moved":"band {group} moved to position {at} of {of}","a11y.column.addedToGroup":"{column} added to band {group}","a11y.column.removedFromGroup":"{column} removed from its band","a11y.column.notInGroup":"{column} is not in a band","a11y.column.cannotGroup":"{column} cannot be grouped","a11y.group.cannotMove":"band {group} cannot be moved there","columngroup.newGroup":"New group","columngroup.rename":"Rename band","columngroup.dissolve":"Dissolve band","columngroup.group":"Group with adjacent column","columngroup.untitled":"Untitled band","panel.bandCollapse":"Collapse band {band}","panel.bandExpand":"Expand band {band}","panel.bandVisible":"Show or hide every column in band {band}","panel.bandRenameFor":"Rename band {band}","panel.bandDissolveFor":"Dissolve band {band}","header.filter":"Filter {column}","header.menu":"Column menu for {column}","header.toggleGroup":"Toggle {group}","header.dragHint":"Drag {column} to reorder, or onto another column to group","header.dragRole":"draggable column header","header.group":"group","header.selectAllRows":"Select all rows","header.clearSelection":"Clear selection","cell.selectRow":"Select row","cell.detail.show":"Show detail","cell.detail.hide":"Hide detail","cell.detail.showInPane":"Show in the detail pane","cell.detail.showingInPane":"Showing in the detail pane","cell.group.expand":"Expand","cell.group.collapse":"Collapse","cell.delta.up":"up","cell.delta.down":"down","cell.delta.unchanged":"unchanged","cell.delta.moved":"{direction} {magnitude}","cell.delta.describedUnchanged":"{label}, unchanged","cell.delta.described":"{label}, {direction} by {magnitude}","cell.qr.of":"QR code for {text}","cell.qr.empty":"No QR code","cell.barcode.of":"Barcode for {text}","cell.barcode.empty":"No barcode","cell.barcode.invalid":"Invalid value for this barcode","cell.rating.of":"{rating} of {max}","cell.rating.empty":"Not rated","cell.stage.of":"Stage {current} of {total}: {label}","cell.stage.empty":"No stage","a11y.panel.cannotMove":"{column} cannot be moved","a11y.panel.alreadyFirst":"{column} is already first","a11y.panel.alreadyLast":"{column} is already last","a11y.panel.moved":"{column} moved to position {at} of {of}","a11y.panel.removedFrom":"{column} removed from {list}","a11y.panel.addedTo":"{column} added to {list}","a11y.panel.cannotAddTo":"{column} cannot be added to {list}","a11y.annotate.erased":"Annotation removed","a11y.annotate.noMarks":"No annotations to erase","a11y.annotate.focusedMark":"Mark {at} of {of} selected","a11y.annotate.confirmClear":"Clear all annotations? Choose Clear or Keep.","a11y.annotate.cleared":"All annotations cleared","a11y.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"a11y.range.cleared":{one:"{count} cell cleared",other:"{count} cells cleared"},"paste.preview.title":"Review paste","paste.preview.summary":{one:"{changes} cell will change, {rejected} rejected.",other:"{changes} cells will change, {rejected} rejected."},"paste.preview.changesHeading":{one:"{count} change",other:"{count} changes"},"paste.preview.rejectedHeading":{one:"{count} rejected",other:"{count} rejected"},"paste.preview.colOld":"Current","paste.preview.colNew":"New","paste.preview.colCell":"Cell","paste.preview.colReason":"Reason","paste.preview.empty":"This paste would change nothing.","paste.preview.confirm":"Apply","paste.preview.cancel":"Cancel","paste.preview.reason.permission":"Not permitted","paste.preview.reason.readOnly":"Read-only","paste.preview.reason.validation":"Invalid value","paste.preview.reason.locked":"Being edited","paste.preview.reason.missing":"No such cell","a11y.paste.previewOpened":{one:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel.",other:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel."},"a11y.paste.cancelled":"Paste cancelled; nothing changed","status.total":"{rows}","status.counting":"Counting rows…","status.shownOfTotal":"{shown} of {total}","status.selected":"{count} selected","status.selectedAcrossSource":"{count} selected across the source","status.selectedAcrossSourceCounting":"All matching rows selected, counting…","status.count":"Count {count}","status.loading":"Loading {count}…","status.loadingOf":"Loading {loaded} of {total} ({percent}%)","status.stat.sum":"Sum","status.stat.min":"Min","status.stat.max":"Max","status.stat.avg":"Avg","status.paused":"Paused","status.pausedWaiting":"Paused · {waiting}","status.coalesced":"{count} coalesced","status.hiddenComments":"{comments} on hidden rows","pagination.label":"Pagination","pagination.first":"First page","pagination.previous":"Previous page","pagination.next":"Next page","pagination.last":"Last page","pagination.page":"Page","pagination.ofPages":"of {pages}","pagination.summary":"{from}–{to} of {total}","pagination.pageSize":"Rows per page","pagination.range":"{from}–{to}","pagination.counting":"{from}–{to}, counting…","pagination.jump":"Page number, press Enter to jump","pagination.jumpBounded":"Page number, 1 to {pages}, press Enter to jump","panel.columns":"Columns","panel.filters":"Filters","panel.views":"Views","panel.quickFilter":"Quick filter","find.label":"Find in grid","find.placeholder":"Find in grid","find.next":"Next match","find.previous":"Previous match","find.close":"Close find","find.matchCase":"Match case","find.wholeCell":"Whole cell","find.columnScope":"Search in","find.allColumns":"All columns","find.count":"{current} of {total}","find.countPartial":"{current} of {total} so far","find.none":"No matches","find.searching":"Searching…","find.loadedRows":"in loaded rows","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","insights.subset":"Filtered subset vs whole","insights.dataset":"This grid vs another dataset","insights.groups":"Group comparison","insights.noFilter":"Filter the grid to compare the subset against the whole.","insights.by":"Group by","insights.test":"Test","insights.effect":"Effect size","insights.interval":"Confidence interval","insights.pValue":"p-value","insights.smallSample":"small sample — interpret with care","insights.needGroups":"Choose two columns with groups to compare.","insights.empty":"No columns to analyse.","insights.anomalies":"Anomalies","insights.anomalyCount":"{count} flagged of {n}","insights.anomalyMethod":"Method","insights.anomalyThreshold":"Threshold","anomaly.chip":"{count} anomalies flagged","anomaly.chipActive":"Showing {count} anomalies — clear","compare.first":"First column","compare.second":"Second column","compare.needTwo":"Two numeric columns are needed to compare","compare.noPairs":"No rows have a value in both","compare.pairs":"{count} pairs","compare.pearson":"Correlation (Pearson)","compare.spearman":"Rank correlation (Spearman)","compare.kendall":"Kendall’s tau","compare.covariance":"Covariance","compare.slope":"Slope","compare.intercept":"Intercept","compare.r2":"R²","compare.stdError":"Standard error","compare.weighted":"Weighted average","panel.zone.group":"row groups","panel.zone.values":"values","panel.zone.pivot":"pivot columns","groupZone.label":"Row groups","groupZone.title":"Group by","groupZone.hint":"Drag a column here to group rows by its values","groupZone.chip":"{column}, group {at} of {of}","groupZone.remove":"Stop grouping by {column}","groupZone.add":"Add a group","total.sum":"Sum","total.avg":"Average","total.min":"Min","total.max":"Max","total.count":"Count","total.countValues":"Count of values","total.first":"First","total.last":"Last","total.custom":"Total","total.median":"Median","total.p25":"25th percentile","total.p75":"75th percentile","total.p90":"90th percentile","total.p95":"95th percentile","total.p99":"99th percentile","total.iqr":"Interquartile range","total.mad":"Median absolute deviation","total.variance":"Variance","total.varianceP":"Variance (population)","total.stddev":"Standard deviation","total.stddevP":"Standard deviation (population)","total.range":"Range","total.distinct":"Distinct","total.mode":"Mode","total.skewness":"Skewness","total.kurtosis":"Kurtosis","total.geomean":"Geometric mean","total.harmean":"Harmonic mean","total.sumSquares":"Sum of squares","total.weightedAvg":"Weighted average","total.argmin":"Lowest by","total.argmax":"Highest by","total.hhi":"Concentration (HHI)","total.entropy":"Entropy","total.evenness":"Evenness","total.top3Share":"Top 3 share","total.top10Share":"Top 10 share","total.gini":"Gini coefficient","total.trimmedMean":"Trimmed mean","total.winsorizedMean":"Winsorized mean","total.robustOutliers":"Outliers (robust)","total.jarqueBera":"Jarque–Bera","total.passRate":"Pass rate","total.failureCount":"Failures","stats.column":"Column","stats.choose":"Choose a column to profile","stats.noColumns":"No numeric columns to profile","stats.noValues":"Nothing numeric in this column","stats.count":"Count","stats.present":"Present","stats.missing":"Missing","stats.distinct":"Distinct","stats.min":"Minimum","stats.max":"Maximum","stats.mean":"Mean","stats.median":"Median","stats.q1":"Lower quartile","stats.q3":"Upper quartile","stats.iqr":"Interquartile range","stats.stddev":"Standard deviation","stats.outliers":"Outliers","stats.distribution":"Distribution","stats.distribution.detail":"Distribution: rows per range","stats.bin":"{count} between {from} and {to}","stats.topValues":"Top values","stats.section.shape":"Shape","stats.section.robust":"Robust","stats.section.concentration":"Concentration","stats.section.capability":"Capability","stats.cp":"Cp","stats.cpk":"Cpk","stats.pp":"Pp","stats.ppk":"Ppk","stats.outOfSpec":"Out of specification","stats.filtered":"Over the {count} filtered rows","stats.unavailable":"Not computed by the source: {stats}.","stats.unavailable.notPlain":"`{column}` is not a plain column the engine can name","stats.unavailable.where":"a `where` predicate is in force ({list}), which only the browser can run","stats.unavailable.filter":"the grid's filter did not fully push to the engine","stats.unavailable.quick":"the quick search did not push to the engine","stats.unavailable.client":'the source did not compute "{fn}" in the engine ({reason}); set the pushdown source\'s `{setting}`',"stats.unavailable.outliers":"the count of values outside Tukey's fences is not an engine aggregate","stats.unavailable.histogram":"the shape of the column is not an engine aggregate","stats.unavailable.topValues":"the source did not answer a grouped count in the engine","regression.noModel":"No model configured. Set predictors and a response on the panel.","regression.cannotFit":"The model cannot be fitted over the current rows.","regression.observations":"Fitted over {count} rows","regression.r2":"R²","regression.adjR2":"Adjusted R²","regression.coefficients":"Coefficients","regression.term":"Term","regression.estimate":"Estimate ± SE","regression.stdError":"Std error","regression.t":"t","regression.p":"p","regression.vif":"Variance inflation (VIF)","regression.heteroscedasticity":"Heteroscedasticity (Breusch–Pagan)","regression.heteroscedastic":"Heteroscedastic: BP {statistic}, p {p}","regression.homoscedastic":"No heteroscedasticity detected: BP {statistic}, p {p}","menu.sortAscending":"Sort ascending","menu.sortDescending":"Sort descending","menu.clearSort":"Clear sort","menu.groupBy":"Group by this column","menu.ungroup":"Stop grouping by this column","menu.hideColumn":"Hide column","menu.pinStart":"Pin to start","menu.pinEnd":"Pin to end","menu.unpin":"Unpin","menu.autosize":"Fit to content","ai.valuesNotAmongOptions":'{values} {shown} not among the options for "{column}"',"menu.clearCells":{one:"Clear cell",other:"Clear {count} cells"},"menu.fillDown":"Fill down","menu.copy":"Copy","menu.copyWithHeaders":"Copy with headers","menu.paste":"Paste","menu.filterEllipsis":"Filter…","menu.columnStatistics":"Column statistics","menu.pinColumn":"Pin column","menu.sizeToFit":"Size to fit content","menu.sizeAllToFit":"Size all columns to fit","menu.width":"Width","menu.narrower":"Narrower","menu.wider":"Wider","menu.moveColumn":"Move column","menu.moveLeft":"Move left","menu.moveRight":"Move right","menu.moveToStart":"Move to start","menu.moveToEnd":"Move to end","menu.unpivot":"Remove from pivot","menu.pivotBy":"Pivot by this column","menu.stopTotalling":"Stop totalling","menu.totalColumn":"Total this column","menu.aggregate":"Aggregate","menu.aggregateNone":"None","menu.aggregateGroup":"Group subtotals","menu.aggregateGrand":"Grand total","menu.aggregateSame":"Same as total","menu.redactColumn":"Redact column","menu.stopRedacting":"Stop redacting","menu.stopRedactingAll":"Stop redacting everything","menu.sortGroupsAscending":"Sort groups ascending","menu.sortGroupsDescending":"Sort groups descending","menu.filterGroups":"Filter groups…","menu.expandAll":"Expand all","menu.collapseAll":"Collapse all","menu.clearGrouping":"Clear grouping","menu.colour":"Colour","menu.importCsv":"Import rows from CSV…","import.title":"Import rows","import.clipboard":"the clipboard","import.summary":{one:"{count} row from {name}",other:"{count} rows from {name}"},"import.opened":{one:"Import preview open, {count} row",other:"Import preview open, {count} rows"},"import.done":{one:"{count} row imported",other:"{count} rows imported"},"import.confirm":"Import","import.cancel":"Cancel","import.colSource":"Column","import.colField":"Maps to","import.colType":"Type","import.skip":"— skip —","import.mapLabel":'Map "{source}" to a field',"import.modeLabel":"On import","import.sheetLabel":"Sheet","import.append":"Add to existing rows","import.replace":"Replace all rows","menu.deleteRow":{one:"Delete row",other:"Delete {count} rows"},"toolbar.undo":"Undo","toolbar.redo":"Redo","toolbar.undoLabelled":"Undo {label}","toolbar.redoLabelled":"Redo {label}","toolbar.exportCsv":"Export to CSV","toolbar.exportExcel":"Export to Excel","toolbar.clipboard":"Copy visible rows to the clipboard","toolbar.print":"Print","toolbar.pause":"Hold incoming updates","toolbar.resume":"Resume updates","toolbar.applyHeld":{one:"Apply {count} held update",other:"Apply {count} held updates"},"toolbar.restoreView":"Restore the default view","toolbar.maximiseGrid":"Maximise the grid to fill the window","toolbar.restoreSize":"Restore the grid to the page (Esc)","toolbar.annotate.pen":"Draw freehand","toolbar.annotate.arrow":"Draw an arrow","toolbar.annotate.rect":"Draw a rectangle","toolbar.annotate.highlight":"Highlight","toolbar.annotate.erase":"Erase","toolbar.annotate.clearAll":"Clear all annotations","toolbar.annotate.clearAllConfirm":"Clear","toolbar.annotate.clearAllKeep":"Keep","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","overlay.loadingRows":"Loading rows {from} to {to}","overlay.rowError":"Failed to load","comments.panel":"Cell comments","comments.close":"Close comments","comments.write":"Write a comment","comments.post":"Comment","comments.delete":"Delete","comments.valueMoved":"Written when the value was {was}: it is now {now}.","comments.resolve":"Resolve","comments.reopen":"Reopen","comments.loading":"Loading…","comments.empty":"No comments yet.","comments.unknownAuthor":"Unknown","comments.edited":"{time} (edited)","comments.cellTitle":"{column}: {row}","presence.hidden":{one:"{count} not in view",other:"{count} not in view"},"presence.someoneElse":"someone else","a11y.presence.refused":"This cell is being edited by {name}","presence.peer":"{name}: jump to their cursor","presence.peerIdle":"{name}, idle: jump to their cursor","presence.peerHidden":"{name}, not in the current view","facets.filter":"{column} distribution filter","header.totalOf":"{total} of {column}","diff.before":"Was: {value}","diff.empty":"(empty)","kanban.columnCards":{one:"{title}, {count} card",other:"{title}, {count} cards"},"kanban.laneCards":{one:"{lane}, {title}, {count} card",other:"{lane}, {title}, {count} cards"},"kanban.blocked":"Blocked","kanban.ready":"Ready","kanban.blockedBy":{one:"blocked by {count} card",other:"blocked by {count} cards"},"kanban.card.assignedTo":"Assigned to {names}","kanban.card.overdue":"Overdue","kanban.card.dueSoon":"Due soon","kanban.card.progress":"{percent}% complete","kanban.card.checklist":"{done} of {total} done","gantt.lag":"+{days}d","gantt.lead":"{days}d","gantt.a11y.moved":"{name} moved to {date}","gantt.a11y.day":"day {day}","gantt.a11y.resized":"{name} resized to {days} days","gantt.a11y.linkFrom":"Linking from {name}. Focus the successor and press L.","gantt.a11y.linked":"Linked {from} to {to}, finish to start.","gantt.a11y.linkCancelled":"Link cancelled.","gantt.a11y.deleted":"{name} deleted.","gantt.a11y.readOnly":"Read-only.","gantt.row.moveHandle":"Drag to reorder or re-parent {name}","gantt.a11y.rowMoved":"{name} moved.","gantt.a11y.rowReparented":"{name} moved under {parent}.","gantt.a11y.rowPromoted":"{name} moved to the top level.","gantt.a11y.rowMoveCancelled":"Move cancelled.","gantt.a11y.copied":"{count} tasks copied.","gantt.a11y.cut":"{count} tasks cut.","gantt.a11y.pasted":"{count} tasks pasted.","gantt.task.newName":"New task","gantt.a11y.taskAdded":"{name} added.","gantt.menu.addAbove":"Add task above","gantt.menu.addBelow":"Add task below","gantt.menu.addChild":"Add subtask","gantt.menu.addSuccessor":"Add successor","gantt.menu.addPredecessor":"Add predecessor","gantt.menu.toMilestone":"Convert to milestone","gantt.menu.toTask":"Convert to task","gantt.menu.delete":"Delete task","gantt.a11y.linkCycle":"Linking {from} to {to} would create a cycle; link not created.","gantt.a11y.linkCreated":"{from} linked to {to}, {type}.","gantt.a11y.linkDeleted":"Link from {from} to {to} deleted.","gantt.a11y.linkLabel":"Link, {from} to {to}, {type}","gantt.linkEditor.title":"Edit link from {from} to {to}","gantt.linkEditor.type":"Link type","gantt.linkEditor.lag":"Lag, in days","gantt.linkEditor.apply":"Apply","gantt.linkEditor.delete":"Delete link","gantt.linkEditor.cancel":"Cancel","gantt.a11y.undone":"Undone.","gantt.a11y.redone":"Redone.","gantt.a11y.nothingToUndo":"Nothing to undo.","gantt.a11y.nothingToRedo":"Nothing to redo.","gantt.workload.title":"Resource workload","gantt.workload.resource":"Resource","gantt.workload.total":"Total","gantt.workload.unassigned":"Unassigned","gantt.workload.ungrouped":"No group","gantt.workload.cell":"{hours} h from {date}","gantt.workload.over":"{hours} h from {date}, over a capacity of {capacity} h","gantt.workload.expand":"Show {name}’s tasks","gantt.workload.collapse":"Hide {name}’s tasks","gantt.workload.expandGroup":"Show the {name} group","gantt.workload.collapseGroup":"Hide the {name} group","gantt.workload.unitToggle":"Hours / % / Cost","gantt.workload.unitHours":"Showing hours","gantt.workload.unitPercent":"Showing percent of capacity","gantt.workload.unitCost":"Showing cost","gantt.workload.cellPercent":"{percent}% from {date}","gantt.workload.overPercent":"{percent}% from {date}, over capacity","gantt.workload.cellNoCapacity":"No available hours from {date}","gantt.workload.cellCost":"{cost} from {date}","gantt.workload.otherProjectLabel":"{name} (other project)","gantt.workload.external":"External booking","gantt.a11y.hoursSet":"{name}: {hours} h from {date}","gantt.a11y.hoursCleared":"{name}: no hours from {date}","gantt.a11y.hoursRefused":"{date} is not a working day; {name} was not changed.","gantt.histogram.title":"Resource histogram","gantt.histogram.tableTitle":"Resource histogram data","gantt.histogram.resource":"Resource","gantt.histogram.period":"Period","gantt.histogram.hours":"Hours","gantt.histogram.percent":"Percent of capacity","gantt.histogram.cost":"Cost","gantt.histogram.capacity":"Capacity","gantt.histogram.overAllocated":"Over-allocated","gantt.histogram.yes":"Yes","gantt.histogram.no":"No","gantt.histogram.tip":"{name}, {from} to {to}: {value}{capacity}{tasks}","gantt.histogram.tipHours":"{hours} h","gantt.histogram.tipPercent":"{percent}% of capacity","gantt.histogram.tipCost":"{cost}","gantt.histogram.tipCapacity":", capacity {hours} h","gantt.histogram.tipTasks":" ({tasks})","gantt.histogram.tipOver":", over capacity","gantt.histogram.tipNoCapacity":"no available hours","gantt.picker.title":"Assign resources to {name}","gantt.picker.open":"Edit assignments for {name}","gantt.picker.search":"Search resources","gantt.picker.list":"Resources","gantt.picker.selected":"Assigned resources","gantt.picker.load":"{load}% booked of {capacity}% over these dates","gantt.picker.none":"No matching resources","gantt.picker.units":"{name}, units in percent","gantt.picker.remove":"Remove {name}","gantt.picker.apply":"Apply","gantt.picker.cancel":"Cancel","gantt.picker.warn":"{name} would be over-allocated: {load}% booked of {capacity}%","gantt.picker.ok":"No resource would be over-allocated","gantt.picker.assign":"Assign","gantt.col.effort":"Effort","gantt.col.units":"Units","gantt.unscheduled":"Unscheduled","gantt.col.unscheduled":"Unscheduled","gantt.inactive":"Inactive","gantt.col.inactive":"Inactive","gantt.col.slack":"Slack","gantt.col.deadline":"Deadline","gantt.col.constraint":"Constraint","gantt.col.constraintDate":"Constraint date","gantt.col.earlyStart":"Early start","gantt.col.lateStart":"Late start","gantt.col.lateFinish":"Late finish","gantt.col.baselineStart":"Baseline start","gantt.col.baselineEnd":"Baseline finish","gantt.col.variance":"Variance","gantt.col.note":"Note","gantt.col.sequence":"#","gantt.col.predecessors":"Predecessors","gantt.col.successors":"Successors","gantt.link.invalid":"Cannot read “{token}” as a link. Write a task number, a type and a lag, like 3FS+2; links not changed.","gantt.link.unknownRef":"No task is numbered “{token}”; links not changed.","gantt.link.self":"“{token}” links a task to itself; links not changed.","gantt.link.duplicate":"“{token}” repeats a link already listed; links not changed.","gantt.link.cycle":"“{token}” would create a cycle; links not changed.","gantt.constraint.ASAP":"As soon as possible","gantt.constraint.MSO":"Must start on","gantt.constraint.MFO":"Must finish on","gantt.constraint.ALAP":"As late as possible","gantt.constraint.SNET":"Start no earlier than","gantt.constraint.SNLT":"Start no later than","gantt.constraint.FNET":"Finish no earlier than","gantt.constraint.FNLT":"Finish no later than","gantt.row.ancestor":"Shown because a task inside it matches the filter","gantt.progress.handle":"Drag to set the progress of {name}","gantt.a11y.progress":"{name} {percent}% complete","gantt.col.name":"Task name","gantt.col.start":"Start","gantt.col.end":"Finish","gantt.col.duration":"Duration","gantt.col.assignee":"Assignee","gantt.col.progress":"%","gantt.col.wbs":"WBS","gantt.zoom.label":"Zoom","gantt.zoom.day":"Day","gantt.zoom.week":"Week","gantt.zoom.month":"Month","gantt.zoom.quarter":"Quarter","gantt.zoom.fit":"Fit to plan","gantt.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","gantt.tip.effort":"{hours}h","gantt.tip.row":"{label}: {value}","gantt.tip.start":"Start","gantt.tip.end":"End","gantt.tip.date":"Date","gantt.tip.durationLabel":"Duration","gantt.tip.durationValue":"{days} days","gantt.tip.complete":"Complete","gantt.tip.effortLabel":"Effort","gantt.tip.effortValue":"{hours} h","gantt.tip.assigned":"Assigned","gantt.tip.cost":"Cost","gantt.tip.slackLabel":"Slack","gantt.tip.slackValue":"{days} days","gantt.tip.deadline":"Deadline","gantt.mode.fixedDuration":"Fixed duration","gantt.mode.fixedEffort":"Fixed effort","gantt.mode.fixedUnits":"Fixed units","gantt.scurve.spi":"SPI {index}","gantt.scurve.cpi":"CPI {index}","gantt.print.page":"Page {page} of {pages}","gantt.print.printed":"Printed {date}","gantt.dataBand.title":"Data band","gantt.dataBand.name":"Task","gantt.dataBand.resource":"Resource","gantt.dataBand.total":"Total","gantt.dataBand.unassigned":"Unassigned","gantt.dataBand.collapse":"Collapse {name}","gantt.dataBand.expand":"Expand {name}","gantt.dataBand.cell":"{name}, {date}: {value}","gantt.issues.title":"Scheduling conflicts","gantt.issues.empty":"No scheduling conflicts","gantt.issues.count":"{count} scheduling conflicts","gantt.issues.toggle":"Toggle the conflicts panel","gantt.issues.cycle":"Circular dependency: {tasks}","gantt.issues.constraint":"{task} cannot meet its {constraint} constraint of {date}","gantt.issues.lock":"{task} is locked but a dependency would move it","gantt.issues.deadline":"{task} finishes after its deadline of {date}","gantt.issues.fixRemoveLink":"Remove link","gantt.issues.fixAsap":"Set as soon as possible","gantt.issues.fixUnlock":"Unlock task","gantt.issues.fixClearDeadline":"Clear deadline","gantt.resize.startHandle":"Drag to change the start of {name}","gantt.a11y.resizedStart":"{name} start moved to {date}, now {days} days","gantt.a11y.startEdge":"Start edge can be resized: drag the left edge, or press Ctrl+Shift+Left or Right.","gantt.a11y.chain":"Dependency chain highlighted: {preds} predecessors, {succs} successors.","timeline.scrub":"Scrub through recent changes","timeline.goLive":"Go live","timeline.returnToPresent":"Return to the present","a11y.fillHandle":"Drag to fill","panel.icons":"Icons","value.tooLong":"Too long","shortcuts.title":"Keyboard shortcuts","shortcuts.close":"Close keyboard shortcuts","shortcuts.hint":"Press Escape to close.","shortcuts.or":"or","a11y.reorder.moved":"Moved to position {position} of {total}","a11y.reorder.sorted":"Rows cannot be reordered while the grid is sorted","a11y.reorder.filtered":"Rows cannot be reordered while a filter is applied","a11y.reorder.grouped":"Rows cannot be reordered while the grid is grouped","a11y.reorder.grab":"Reorder row","a11y.reorder.sortedManual":"Rows cannot be reordered while the grid is sorted. Press Alt+Shift+M, or the Manual order button in the heading, to order them by hand","a11y.reorder.groupDerived":"The row cannot join that group: the group is worked out from the value, so there is no single value to give it","a11y.reorder.groupReadOnly":"The row cannot join that group: its grouping value cannot be edited","a11y.reorder.invalid":"The row cannot join that group: the new value was not valid","a11y.reorder.vetoed":"The move was declined; the row stays where it was","a11y.reorder.vetoedBecause":"The move was declined ({reason}); the row stays where it was","a11y.reorder.refused":"The row cannot be moved there","a11y.reorder.regrouped":"Moved into {group}","a11y.rowOrder.entered":"Manual order: the rows keep their places and can be moved by hand","a11y.rowOrder.exited":"Manual order ended; the rows follow the sort","rowOrder.button":"Manual order","rowOrder.enter":"Order the rows by hand instead of by the sort","rowOrder.exit":"Return to the sorted order","a11y.transfer.moved":"Row moved to the other grid","a11y.transfer.copied":"Row copied to the other grid","a11y.transfer.refused":"That grid does not accept this row","a11y.transfer.declined":"The drop was declined; the row stays where it was","a11y.transfer.stale":"The drop target changed while it was being confirmed; the row stays where it was","shortcuts.group.grid":"In the data","shortcuts.group.header":"On a column heading","shortcuts.group.panel":"In the column list","shortcut.moveCell":"Move the focused cell","shortcut.rowEnds":"First / last cell of the row","shortcut.gridEnds":"First cell of the first row / last cell of the last row","shortcut.pageRows":"Move one viewport of rows","shortcut.nextCell":"Leave the grid for the next / previous focusable element (arrows move between cells)","shortcut.undo":"Undo the last edit, paste, fill or clear","shortcut.redo":"Redo the step that was undone","shortcut.startEdit":"Start editing the focused cell","shortcut.toggleRow":"Toggle selection of the focused row","shortcut.cancel":"Cancel the current edit or drag","shortcut.expandCollapse":"Expand / collapse a group or tree row","shortcut.focusHeader":"Move focus to the column header","shortcut.focusPanel":"Move focus to the tool panel","shortcut.contextMenu":"Open the context menu for the focused cell","shortcut.moveRow":"Move the focused row, when row reorder is enabled","shortcut.manualOrder":"Order the rows by hand, or return to the sort, when row reorder allows a manual order","shortcut.headingMove":"Move between headings","shortcut.headingEnds":"First / last heading","shortcut.headingSort":"Sort by the column, Shift to add to the sort","shortcut.headingResize":"Resize the column, Ctrl for a coarse step","shortcut.headingAutosize":"Size the column to its content","shortcut.headingReorder":"Move the column","shortcut.headingMenu":"Open the column menu","shortcut.headingExit":"Return focus to the data","shortcut.listGroup":"Group by the column, or stop grouping by it","shortcut.listValues":"Add the column to values, or take it out","shortcut.listPivot":"Pivot by the column, or stop pivoting by it","shortcut.listMove":"Move the column","shortcut.find":"Find in the grid","tags.label":"Show columns","tags.all":"All columns","tags.showing":"Showing {tag}","form.title":"Edit row","form.save":"Save","form.cancel":"Cancel","form.loading":"Loading…","form.loadFailed":"Could not load this record.","form.loadTimeout":"The record did not arrive in time.","form.retry":"Try again","form.choose":"Choose…","form.newTitle":"New row","form.createFailed":"Could not add this record.","presentation.cards":"Showing records as cards","presentation.table":"Showing records as a table","editor.format":"Format","editor.codeHint":"Tab indents · Esc cancels · Ctrl+Enter saves","editor.colours":"Colours","editor.customColour":"Custom colour","editor.hexValue":"Hex value","editor.hexPlaceholder":"#rrggbb","editor.clearColour":"Clear colour","editor.time":"Time","editor.noIcon":"No icon","editor.selectAll":"Select all","editor.passwordHint":"Enter the value twice to save it.","editor.clearRating":"Clear rating","editor.clear":"Clear","editor.value":"Value","editor.currency":"Currency","editor.richtext.formatting":"Formatting","editor.richtext.richText":"Rich text","editor.richtext.placeholder":"Start writing…","editor.richtext.linkLabel":"Link address","editor.richtext.linkPlaceholder":"https://","editor.richtext.linkAdd":"Add link","editor.richtext.bold":"Bold (Ctrl+B)","editor.richtext.italic":"Italic (Ctrl+I)","editor.richtext.underline":"Underline (Ctrl+U)","editor.richtext.strike":"Strikethrough","editor.richtext.heading":"Paragraph style","editor.richtext.alignLeft":"Align left","editor.richtext.alignCenter":"Align centre","editor.richtext.alignRight":"Align right","editor.richtext.ul":"Bulleted list","editor.richtext.ol":"Numbered list","editor.richtext.color":"Text colour","editor.richtext.link":"Link (Ctrl+K)","editor.richtext.image":"Insert image","editor.richtext.clear":"Clear formatting","editor.richtext.source":"HTML source","editor.richtext.undo":"Undo (Ctrl+Z)","editor.richtext.redo":"Redo (Ctrl+Y)","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":N,"filter.op.contains":"Contains","filter.op.notContains":"Does not contain","filter.op.equals":"Equals","filter.op.notEqual":"Does not equal","filter.op.startsWith":"Starts with","filter.op.endsWith":"Ends with","filter.op.blank":"Is blank","filter.op.notBlank":"Is not blank","filter.op.lessThan":"Less than","filter.op.lessThanOrEqual":"Less than or equal","filter.op.greaterThan":"Greater than","filter.op.greaterThanOrEqual":"Greater than or equal","filter.op.inRange":"In range","filter.op.matches":"Matches","filter.op.before":"Before","filter.op.after":"After","filter.op.relative":"Relative to today","filter.rel.today":"Today","filter.rel.yesterday":"Yesterday","filter.rel.tomorrow":"Tomorrow","filter.rel.lastNDays":"Last N days","filter.rel.nextNDays":"Next N days","filter.rel.thisWeek":"This week","filter.rel.lastWeek":"Last week","filter.rel.thisMonth":"This month","filter.rel.lastMonth":"Last month","filter.rel.thisQuarter":"This quarter","filter.rel.quarterToDate":"Quarter to date","filter.rel.thisYear":"This year","filter.rel.yearToDate":"Year to date","filter.operator":"Operator","filter.join":"Join","filter.value":"Value","filter.from":"From","filter.to":"To","filter.addCondition":"Add condition","filter.noConditions":"No conditions","filter.removeCondition":"Remove condition","filter.search":"Search","filter.searchValues":"Search values","filter.noMatches":"No values match","filter.selectAll":"Select all","filter.clear":"Clear","filter.all":"All","filter.allExcept":"All but {count}","filter.loadingValues":"Loading values…","filter.topValues":"Top {shown} of {total} values","filter.valuesFailed":"Values could not be loaded: {error}","filter.valuesUnsupported":"This source cannot list the values of {column}; filter by condition instead.","filter.true":"True","filter.false":"False","filter.expression":"Filter expression","filter.column":"Column","filter.relativePeriod":"Relative period","filter.days":"Number of days","filter.tab.set":"Values","filter.tab.text":"Text","filter.tab.number":"Number","filter.tab.date":"Date","filter.tab.advanced":"Advanced","filterRow.label":"Filter row","filterRow.conditions":{one:"{count} condition",other:"{count} conditions"},"chart.empty":"Nothing to chart","chart.summary":"{type} chart of {measure} by {dimension}","chart.summaryShare":"{type} chart of {measure}","chart.summaryType":"{type} chart","chart.summaryGauge":"{type} chart of {measure}, {fn}: {value}","chart.waterfallTotal":"Total","chart.summaryEngine":"Figures computed by the data engine over every matching row","chart.summaryEngineViewport":"{count} points in this view, fetched from the data engine","chart.summaryEngineDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells counted by the data engine","chart.summaryClientDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells computed in the browser","chart.viewportOverCap":"{count} rows in this view, more than the {cap} this map draws; zoom in or narrow the filter","chart.dataTable":"Chart data","chart.viewportFilter.label":"Map view","chart.annotate.rail":"Drawing tools","chart.annotate.select":"Select and move a drawing","chart.annotate.trendLine":"Trend line","chart.annotate.horizontalLine":"Horizontal line","chart.annotate.verticalLine":"Vertical line","chart.annotate.channel":"Parallel channel","chart.annotate.fibonacci":"Fibonacci retracement","chart.annotate.arrow":"Arrow","chart.annotate.pen":"Freehand pen","chart.annotate.pen.described":"Freehand drawing from {from} to {to}","chart.annotate.measure-x":"Date range","chart.annotate.measure-y":"Price range","chart.annotate.measure-xy":"Date and price range","chart.annotate.measure.bars":{one:"{count} bar",other:"{count} bars"},"chart.annotate.measure.points":{one:"{count} point",other:"{count} points"},"chart.annotate.measure.volume":"Vol {value}","chart.annotate.measure.seconds":"{count}s","chart.annotate.measure.minutes":"{count}m","chart.annotate.measure.hours":"{count}h","chart.annotate.measure.days":"{count}d","chart.annotate.measure.weeks":"{count}w","chart.annotate.measure.months":"{count}mo","chart.annotate.measure.years":"{count}y","chart.annotate.measure":"Measure","chart.annotate.measure.dx":"Δx {value}","chart.annotate.measure.dy":"Δy {value}","chart.annotate.measure.pct":"{value}%","chart.annotate.measure.categories":{one:"{count} category",other:"{count} categories"},"chart.annotate.measure.slope.perDay":"Slope {value} per day","chart.annotate.measure.slope.perCategory":"Slope {value} per category","chart.annotate.measure.slope.perUnit":"Slope {value} per unit","chart.annotate.measure.dur.d":"{count} d","chart.annotate.measure.dur.h":"{count} h","chart.annotate.measure.dur.min":"{count} min","chart.annotate.measure.dur.s":"{count} s","chart.annotate.measure.dur.ms":"{count} ms","chart.annotate.measure.announce":"Measurement: {readout}","chart.annotate.measure.start":"Measure start: {x}, {y}","chart.annotate.text":"Text","chart.annotate.callout":"Callout","chart.annotate.note":"Note","chart.annotate.delete":"Delete the selected drawing","chart.annotate.editLabel":"Annotation text","chart.zoom.toolbar":"Zoom controls","chart.zoom.in":"Zoom in","chart.zoom.out":"Zoom out","chart.zoom.left":"Pan left","chart.zoom.right":"Pan right","chart.zoom.reset":"Reset the zoom","chart.legendMore":{one:"+{count} more",other:"+{count} more"},"chart.type.line":"Line","chart.type.area":"Area","chart.type.bar":"Bar","chart.type.pie":"Pie","chart.type.donut":"Donut","chart.type.sunburst":"Sunburst","chart.type.scatter":"Scatter","chart.type.step":"Step","chart.type.rangeArea":"Range","chart.type.horizontalBar":"Horizontal bar","chart.type.waterfall":"Waterfall","chart.type.floatingBar":"Floating bar","chart.type.horizontalFloatingBar":"Horizontal floating bar","chart.type.populationPyramid":"Population pyramid","chart.type.bullet":"Bullet","chart.type.bubble":"Bubble","chart.type.histogram":"Histogram","chart.type.boxplot":"Box plot","chart.type.forest":"Forest plot","chart.type.qq":"QQ plot","chart.type.ecdf":"ECDF","chart.type.lorenz":"Lorenz","chart.type.correlogram":"Correlogram","chart.type.control":"Control","chart.type.capability":"Capability","chart.type.movingRange":"Moving range","chart.type.treemap":"Treemap","chart.type.combo":"Combination","chart.type.pareto":"Pareto","chart.type.heatmap":"Heat map","chart.type.radar":"Radar","chart.type.gauge":"Gauge","chart.type.funnel":"Funnel","chart.type.candlestick":"Candlestick","chart.type.ohlc":"OHLC","chart.type.polarArea":"Polar area","chart.type.nightingale":"Nightingale rose","chart.type.rose":"Rose","chart.type.radialBar":"Radial bar","chart.type.polarScatter":"Polar scatter","chart.type.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.pyramid":"Pyramid","chart.type.pictorial":"Pictorial","chart.type.serpentine":"Serpentine timeline","chart.type.spiral":"Spiral timeline","chart.edit.aggregated":"This value is a total of several rows, so it cannot be dragged.","chart.edit.refused":"That change was not applied.","chart.edit.refusedWhy":"That change was not applied: {reason}","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","chart.type.forceTree":"Force-directed tree","chart.type.pack":"Packed circles","chart.type.tree":"Tree","chart.type.voronoiTreemap":"Voronoi treemap","chart.type.alluvial":"Alluvial","chart.type.arc":"Arc diagram","chart.type.barRace":"Bar chart race","chart.type.bubblemap":"Bubble map","chart.type.bump":"Bump chart","chart.type.calendar":"Calendar heat map","chart.type.choropleth":"Choropleth map","chart.type.decomposition":"Decomposition tree","chart.type.diverging":"Diverging bar","chart.type.dumbbell":"Dumbbell","chart.type.fan":"Fan chart","chart.type.hexbin":"Hexagonal bin","chart.type.hexmap":"Hex map","chart.type.icicle":"Icicle","chart.type.markermap":"Marker map","chart.type.motion":"Motion chart","chart.type.parallel":"Parallel coordinates","chart.type.ridgeline":"Ridgeline","chart.type.roc":"ROC curve","chart.type.scatter3d":"3D scatter","chart.type.slope":"Slope chart","chart.type.splom":"Scatter plot matrix","chart.type.venn":"Venn diagram","chart.type.waffle":"Waffle","chart.type.wordCloud":"Word cloud","chart.tasksDropped":{one:"{count} more task not shown",other:"{count} more tasks not shown"},"chart.geoUnmatched":{one:"{count} row could not be placed on the map",other:"{count} rows could not be placed on the map"},"chart.r2":"R² {value}","ai.insights":"Insights","ai.explainView":"Explain this view","ai.explain":"Explain","ai.ask":"Ask","ai.apply":"Apply","ai.discard":"Discard","ai.propose":"Propose","ai.approve":"Approve","ai.thinking":"Thinking…","ai.applying":"Applying…","ai.applied":"Applied: {what}","ai.couldNotApply":"Could not apply: {why}","ai.applyFailed":"it failed","ai.discarded":"Discarded.","ai.discardedNothingWritten":"Discarded. Nothing was written.","ai.nothingWritten":"Nothing was written.","ai.nothingWrittenVetoed":"Nothing was written — a before-handler vetoed it.","ai.scope":"Scope: {scope}","ai.unsafeQuery":"I could not turn that into a safe query: {why}","ai.nothingToDo":"nothing to do","ai.insightsFailed":"Could not generate insights right now. The grid is unaffected.","ai.modelUnreachable":"Could not reach the model right now. The grid is unaffected.","ai.flagged":{one:"{count} unverified figure was removed as ungrounded.",other:"{count} unverified figures were removed as ungrounded."},"ai.askPlaceholder":"Ask your data: “EMEA deals over 50k, biggest first”","ai.askLabel":"Ask your data","ai.actorPlaceholder":"Ask AI to change data: “set the Network Upgrade project to In Progress”","ai.actorLabel":"Ask AI to change data","editor.password.show":"Show value","editor.password.hide":"Hide value","editor.password.showField":"Show {column}","editor.password.hideField":"Hide {column}","facets.computing":"Computing…","facets.suppressed.cardinality":"Too many distinct values to chart","facets.suppressed.rows":"Too many rows to chart","facets.suppressed.streaming":"Paused while live data is streaming","facets.suppressed.noProvider":"No distribution available for this data source","facets.suppressed.type":"This column has no chartable distribution","facets.bucketOf":"{count} of {whole} rows","history.undo":"Undo","history.redo":"Redo","history.described":"{action} {label}","history.nothingToUndo":"Nothing to undo","history.nothingToRedo":"Nothing to redo","history.undoDisabled":"Undo (nothing to undo)","history.redoDisabled":"Redo (nothing to redo)","a11y.presence.joined":"{name} joined","a11y.presence.left":"{name} left","prompt.asking":"Asking…","prompt.moreNotes":{one:"and {count} more",other:"and {count} more"},"shortcuts.key.cmd":"Cmd","timeline.live":"Live","timeline.recording":"recording…","panel.zoneHint.group":"Drag a column here to group rows by its values","panel.zoneHint.values":"Drag a column here to total it","panel.zoneHint.pivot":"Drag a column here to pivot across its values","panel.zoneHint.any":"Drag a column here","panel.rowsOf":"{shown} of {total} rows","views.empty":"No saved views yet. Set the grid up as you want it, then save it below.","views.applied":"Applied","views.matchesGrid":"Matches the grid as it is","views.delete":"Delete","views.confirmDelete":"Delete {name}?","views.confirmDeleteLabel":"Confirm deleting {name}","gantt.row.expand":"Expand {name}","gantt.row.collapse":"Collapse {name}","gantt.resource.over":"{name} — over-allocated","kanban.board":"Board","kanban.requiredTitle":"Required fields","kanban.requiredSave":"Save","kanban.requiredCancel":"Cancel","kanban.moveRefused":'Move refused: a card in "{from}" cannot move to "{to}".',"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"}),B=Object.freeze(Object.keys(X))}),Ie("packages/core/src/i18n/format.js",function(e,U){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return O}});const N=U("packages/core/src/internal/predicates.js").isFunction,X=/\{(\w+)\}/g,B=new Map,D=new Map;function q(b){const u=b||"";if(B.has(u))return B.get(u);let f=null;try{f=new Intl.PluralRules(b||void 0)}catch{f=null}return B.set(u,f),f}function K(b,u,f="conjunction"){const a=Array.isArray(b)?b.filter(s=>s!=null&&s!==""):[];if(a.length===0)return"";if(a.length===1)return String(a[0]);const r=`${u||""}|${f}`;let t=D.get(r);if(t===void 0){try{t=new Intl.ListFormat(u||void 0,{style:"long",type:f})}catch{t=null}D.set(r,t)}return t?t.format(a.map(String)):a.map(String).join(", ")}function x(b,u){return b==null?"":typeof b=="number"?Number.isFinite(b)?b.toLocaleString(u||void 0,{maximumFractionDigits:20}):"":String(b)}function G(b,u,f){if(typeof b=="string")return b;if(!b||typeof b!="object")return"";const a=u&&typeof u.count=="number"?u.count:null;if(a===null)return b.other??"";const r=q(f),t=r?r.select(a):a===1?"one":"other";return b[t]??b.other??""}function z(b,u={},f){const a=G(b,u,f);return a?a.replace(X,(r,t)=>Object.prototype.hasOwnProperty.call(u,t)?x(u[t],f):r):""}function j(b,u,f="en-GB"){return typeof b=="string"&&b?b:typeof u=="string"&&u?u:f}function O(b,u){const f=b?b[u]:void 0;return f==null||N(f)?u:f}}),Ie("packages/core/src/i18n/registry.js",function(e,U){"use strict";Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"localeCatalogue",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"registeredTags",{enumerable:!0,get:function(){return q}});const N=U("packages/core/src/i18n/catalogue.js").EN_GB,X=new Map([["en-gb",N]]);function B(K,x){const G=typeof K=="string"?K.toLowerCase():"";return!G||!x||typeof x!="object"?!1:(X.set(G,x),!0)}function D(K){if(typeof K!="string"||!K)return null;const x=K.toLowerCase(),G=X.get(x);if(G)return G;const z=x.split("-")[0],j=X.get(z);if(j)return j;for(const[O,b]of X)if(O.split("-")[0]===z)return b;return null}function q(){return[...X.keys()]}}),Ie("packages/core/src/i18n/index.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return i}});const te=U("packages/core/src/i18n/catalogue.js"),N=te.EN_GB,X=te.MESSAGE_KEYS,B=U("packages/core/src/i18n/format.js"),D=B.formatMessage,q=B.formatList,K=B.lookup,x=B.resolveLocale,z=U("packages/core/src/internal/predicates.js").isFunction,O=U("packages/core/src/internal/warn.js").warnOnce,b=U("packages/core/src/i18n/registry.js"),u=b.registerLocale,f=b.localeCatalogue;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return te.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return te.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return B.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return B.resolveLocale}}),Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return b.registerLocale}});const a="en-GB";class r{#e=a;#t=N;constructor(c={}){this.configure(c)}configure(c={}){this.#e=x(c.locale,c.declared,a);const o=c.messages,l=f(this.#e);if(!l&&this.#e.toLowerCase()!=="en-gb"&&(!o||typeof o!="object")&&O(`i18n:locale:not-loaded:${this.#e.toLowerCase()}`,`locale "${this.#e}" is not loaded: import "@toclocoinc/lattice-grid/locales/${this.#e}" to add its text; English is used until then.`),!o||typeof o!="object"){this.#t=l?{...N,...l}:N;return}const w=Object.keys(o).filter(g=>!(g in N));w.length&&O(`i18n:unknown:${w[0]}`,`message keys not in the catalogue and so ignored: ${w.slice(0,5).join(", ")}${w.length>5?`, and ${w.length-5} more`:""}`),this.#t={...N,...l||{},...o}}get locale(){return this.#e}t(c,o){return D(K(this.#t,c),o||{},this.#e)}list(c,o){return q(c,this.#e,o)}number(c,o){const l=Number(c);return Number.isFinite(l)?l.toLocaleString(this.#e,o||{maximumFractionDigits:20}):""}}const t=new r;function s(n){return n instanceof r?n:new r(n||{})}function i(n){const c=n&&typeof n=="object"?n:{},o=X.filter(h=>{const w=c[h];return w==null||w===""||z(w)}),l=Object.keys(c).filter(h=>!(h in N));return{missing:o,unknown:l}}}),Ie("packages/core/src/columns/types/structured.js",function(e,U){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const te=U("packages/core/src/internal/predicates.js"),N=te.isNil,X=te.isObject,D=U("packages/core/src/i18n/index.js").defaultMessages,q=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function K(r,t){const s=t||{},i=s.emptyDisplay??q.emptyDisplay;if(N(r)||r==="")return i;const c=[...typeof s.char=="string"&&s.char!==""?s.char:q.char][0]||q.char,o=s.fixedLength??q.fixedLength,l=Number.isFinite(s.length)&&Number(s.length)>0?Math.floor(Number(s.length)):q.length,h=typeof r=="string"?r:typeof r=="number"||typeof r=="boolean"||typeof r=="bigint"?String(r):null;let w=0;if(h!==null){const g=Number.isFinite(s.lastVisible)?Math.floor(Number(s.lastVisible)):q.lastVisible,k=[...h];if(w=g>0&&g<k.length?g:0,w>0){const d=k.slice(k.length-w).join(""),p=Math.max(1,(o?l:k.length)-w);return c.repeat(p)+d}return c.repeat(o?l:Math.max(1,k.length))}return c.repeat(l)}const x=48;function G(r){try{const t=JSON.stringify(r);return t===void 0?null:t}catch{return null}}function z(r,t){if(N(r))return"";const s=Number.isFinite(t&&t.inlineLimit)?Number(t.inlineLimit):x;if(typeof r=="string")return r.length>s?`${r.slice(0,s-1)}…`:r;if(typeof r!="object")return String(r);const i=G(r);if(i!==null&&i.length<=s)return i;if(Array.isArray(r)){const c=r.length;return`[${D.t("count.items",{count:c})}]`}const n=Object.keys(r).length;return`{${D.t("count.keys",{count:n})}}`}function j(r,t){if(r==null)return"null";const s=typeof r;if(s==="number"||s==="boolean"||s==="bigint")return String(r);if(s==="string")return JSON.stringify(r);if(s!=="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=>j(o,i)).join(",")}]`:`{${Object.keys(r).sort().map(o=>`${JSON.stringify(o)}:${j(r[o],i)}`).join(",")}}`)}function O(r,t){if(N(r))return N(t)?0:1;if(N(t))return-1;const s=j(r),i=j(t);return s<i?-1:s>i?1:0}function b(r){if(N(r))return null;const t=String(r);if(t.trim()==="")return null;try{return JSON.parse(t)}catch{return t}}function u(r){const t=r&&r.cell&&r.cell.props;return X(t)?t:{}}const f=Object.freeze({json:{base:"object",storage:"object",format:r=>z(r&&r.value,u(r&&r.column)),parse:r=>b(r&&r.text),compare:O,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:r=>{if(N(r))return"";if(typeof r=="string")return r;try{const t=JSON.stringify(r,null,2);return t===void 0?String(r):t}catch{return String(r)}},fromClipboard:r=>b(r)},secret:{base:"text",storage:"object",format:r=>K(r&&r.value,u(r&&r.column)),parse:r=>{const t=r&&r.text;return N(t)||String(t)===""?null:String(t)},compare:(r,t)=>{const s=N(r)||r==="",i=N(t)||t==="";return s===i?0:s?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:r=>K(r),fromClipboard:r=>N(r)||String(r)===""?null:String(r)}}),a=f}),Ie("packages/core/src/columns/types/unit.js",function(e,U){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/internal/warn.js").warnOnce;function D(A,C,H,Y){return Object.freeze({symbol:A,factor:C,aliases:Object.freeze(H||[]),binary:!!(Y&&Y.binary),prefix:Y&&Y.prefix||null,auto:!(Y&&Y.auto===!1)})}function q(A,C,H,Y){return D(A,C,H,Y)}const K=Object.freeze({data:Object.freeze([D("B",1,["byte","bytes"]),D("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),D("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),D("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),D("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),D("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),D("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),D("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),D("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),D("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([D("bps",1,["bit","bits","bit/s","b/s"]),D("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),D("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),D("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),D("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([D("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),D("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),D("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),D("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),D("in",.0254,["inch","inches"],{auto:!1}),D("ft",.3048,["foot","feet"],{auto:!1}),D("yd",.9144,["yard","yards"],{auto:!1}),D("m",1,["metre","metres","meter","meters"]),D("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),D("mi",1609.344,["mile","miles"],{auto:!1}),D("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([D("mg",.001,["milligram","milligrams"]),D("g",1,["gram","grams"]),D("oz",28.349523125,["ounce","ounces"],{auto:!1}),D("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),D("kg",1e3,["kilogram","kilograms"]),D("st",6350.29318,["stone"],{auto:!1}),D("t",1e6,["tonne","tonnes","ton"],{auto:!1}),D("ton (US)",907184.74,["ton","shortton"],{auto:!1}),D("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([D("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),D("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),D("ms",.001,["msec","msecs","millisecond","milliseconds"]),D("s",1,["sec","secs","second","seconds"]),D("m",60,["min","mins","minute","minutes"]),D("h",3600,["hr","hrs","hour","hours"]),D("d",86400,["day","days"])]),speed:Object.freeze([D("mm/s",.001,["millimetre/s","millimeter/s"]),D("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),D("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),D("mph",.44704,["mile/h","miles/h"],{auto:!1}),D("kn",1852/3600,["knot","knots"],{auto:!1}),D("m/s",1,["metre/s","meter/s","mps"]),D("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([D("mm/s²",.001,["mm/s2"]),D("ft/s²",.3048,["ft/s2"],{auto:!1}),D("m/s²",1,["m/s2","metre/s2","meter/s2"]),D("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([D("mm²",1e-6,["mm2"]),D("cm²",1e-4,["cm2"]),D("in²",64516e-8,["in2","sqin"],{auto:!1}),D("ft²",.09290304,["ft2","sqft"],{auto:!1}),D("yd²",.83612736,["yd2","sqyd"],{auto:!1}),D("m²",1,["m2","sqm"]),D("ha",1e4,["hectare","hectares"],{auto:!1}),D("ac",4046.8564224,["acre","acres"],{auto:!1}),D("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([D("µL",1e-6,["ul","microlitre","microliter"]),D("mL",.001,["millilitre","milliliter"]),D("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),D("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),D("L",1,["litre","litres","liter","liters"]),D("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),D("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),D("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),D("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([D("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),D("J",1,["joule","joules"]),D("cal",4.184,["calorie","calories"],{auto:!1}),D("kJ",1e3,["kilojoule","kilojoules"]),D("BTU",1055.05585262,["btu"],{auto:!1}),D("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),D("MJ",1e6,["megajoule","megajoules"]),D("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),D("GJ",1e9,["gigajoule","gigajoules"]),D("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([D("mW",.001,["milliwatt","milliwatts"]),D("W",1,["watt","watts"]),D("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),D("kW",1e3,["kilowatt","kilowatts"]),D("hp",745.6998715822702,["horsepower"],{auto:!1}),D("MW",1e6,["megawatt","megawatts"]),D("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([D("mN",.001,["millinewton","millinewtons"]),D("N",1,["newton","newtons"]),D("lbf",4.4482216152605,["poundforce"],{auto:!1}),D("kgf",9.80665,["kilogramforce"],{auto:!1}),D("kN",1e3,["kilonewton","kilonewtons"]),D("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([D("Pa",1,["pascal","pascals"]),D("mbar",100,["millibar"],{auto:!1}),D("inH₂O",249.0889,["inh2o"],{auto:!1}),D("mmHg",133.322387415,["torr"],{auto:!1}),D("kPa",1e3,["kilopascal","kilopascals"]),D("inHg",3386.388640341,["inhg"],{auto:!1}),D("psi",6894.757293168361,["lbf/in2"],{auto:!1}),D("bar",1e5,[],{auto:!1}),D("atm",101325,["atmosphere","atmospheres"],{auto:!1}),D("MPa",1e6,["megapascal","megapascals"]),D("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([D("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),D("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),D("kN·m",1e3,["knm","kn.m"],{auto:!1}),D("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([D("kg/m³",1,["kg/m3"]),D("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),D("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),D("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([D("L/min",1/6e4,["lpm","l/min"],{auto:!1}),D("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),D("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),D("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),D("cfm",.0004719474432,["ft3/min"],{auto:!1}),D("L/s",.001,["lps","l/s"],{auto:!1}),D("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([D("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),D("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),D("mrad",.001,["milliradian","milliradians"],{auto:!1}),D("mil",Math.PI/3200,["nato-mil"],{auto:!1}),D("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),D("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),D("rad",1,["radian","radians"]),D("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([D("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),D("rad/s",1,["radps","radians/s"]),D("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),D("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([D("ppt",1e-12,["partspertrillion"],{auto:!1}),D("ppb",1e-9,["partsperbillion"]),D("ppm",1e-6,["partspermillion"]),D("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),D("‰",.001,["permille","permil"],{auto:!1}),D("%",.01,["pct","percent"]),D("×",1,["x","ratio","times"])]),molarity:Object.freeze([D("pM",1e-12,["picomolar","picomolarity"]),D("nM",1e-9,["nanomolar","nanomolarity"]),D("µM",1e-6,["um-molar","micromolar","micromolarity"]),D("mM",.001,["millimolar","millimolarity"]),D("M",1,["molar","mol/l","mol/L","molarity"]),D("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([D("mg/s",1e-6,["milligrams/s"]),D("g/s",.001,["grams/s"]),D("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),D("kg/s",1,["kilograms/s","kgps"]),D("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),D("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),D("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([D("µPa·s",1e-6,["upas","micropascalsecond"]),D("cP",.001,["centipoise"],{auto:!1}),D("mPa·s",.001,["mpas","millipascalsecond"]),D("P",.1,["poise"],{auto:!1}),D("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([D("cSt",1e-6,["centistokes","centistoke"]),D("mm²/s",1e-6,["mm2/s"],{auto:!1}),D("St",1e-4,["stokes","stoke"],{auto:!1}),D("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([D("mW/(m·K)",.001,["mw/mk"]),D("W/(m·K)",1,["w/mk","wmk"]),D("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),D("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([D("J/(kg·K)",1,["j/kgk","jkgk"]),D("kJ/(kg·K)",1e3,["kj/kgk"]),D("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([D("nSv/h",1e-9,["nsvh"]),D("µSv/h",1e-6,["usv/h","usvh"]),D("mSv/h",.001,["msvh"]),D("Sv/h",1,["svh"]),D("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),x=Symbol("ambiguous"),G=new Map,z=new Map;function j(A,C){const H=String(A||"").trim();if(!H)throw new Error("[lattice] a unit system needs a name");if(K[H]||z.has(H))throw new Error(`[lattice] unit system "${H}" already exists`);const Y=[...C||[]];if(!Y.length)throw new Error(`[lattice] unit system "${H}" has no units`);if(!Y.some(_=>_.factor===1))throw new Error(`[lattice] unit system "${H}" has no base unit (none with factor 1)`);const Z=new Set;for(const _ of Y){if(Z.has(_.symbol))throw new Error(`[lattice] unit system "${H}" declares "${_.symbol}" twice`);Z.add(_.symbol)}return z.set(H,Object.freeze(Y)),G.delete(H),H}function O(){return[...Object.keys(K),...z.keys()]}function b(A){const C=u(A);return C?C.units:[]}function u(A){const C=String(A||""),H=G.get(C);if(H!==void 0)return H;const Y=K[C]||z.get(C);if(!Y)return G.set(C,null),null;const Z=Object.freeze([...Y].sort((se,oe)=>se.factor-oe.factor)),_=new Map,J=new Map,ee=(se,oe)=>{const fe=_.get(se);fe===void 0?_.set(se,oe):fe!==oe&&_.set(se,x)};for(const se of Z){ee(se.symbol.toLowerCase(),se);for(const oe of se.aliases)ee(oe.toLowerCase(),se);if(se.prefix){const oe=J.get(se.prefix)||[];oe.push(se),J.set(se.prefix,oe)}}const ne={units:Z,byToken:_,byPrefix:J,decimal:Z.filter(se=>!se.binary&&se.auto),binary:Z.some(se=>se.binary)?Z.filter(se=>(se.binary||se.factor===1)&&se.auto):null};return G.set(C,ne),ne}function f(A,C){return C&&A.binary||A.decimal}function a(A,C){const H=u(A);if(!H||N(C))return null;const Y=H.units.find(_=>_.symbol===String(C));if(Y)return Y;const Z=H.byToken.get(String(C).trim().toLowerCase());return Z&&Z!==x?Z:null}const r=new WeakMap;function t(A){const C=A||{};if(typeof C=="object"&&C!==null){const _=r.get(C);if(_!==void 0)return _}const H=C.system||"data",Y=u(H);let Z=null;if(!Y)B(`unit:system:${H}`,`unknown unit system "${H}"; known systems are ${O().join(", ")}`);else{let _=C.unit?a(H,C.unit):null;_||(C.unit&&B(`unit:unit:${H}:${C.unit}`,`unknown unit "${C.unit}" in system "${H}"; falling back to ${Y.units[0].symbol}`),_=Y.units.find(J=>J.factor===1)||Y.units[0]),Z={index:Y,base:_,binary:C.binary===!0}}return typeof C=="object"&&C!==null&&r.set(C,Z),Z}const s=new WeakMap;function i(A,C){if(!A||!C||!Array.isArray(A.compound)||A.compound.length===0)return null;const H=s.get(A);if(H!==void 0)return H;const Y=new Set,Z=[];for(const J of A.compound){const ee=a(A.system||"data",J);if(!ee){B(`unit:compound:${A.system}:${J}`,`unknown compound unit "${J}" in system "${A.system||"data"}"; ignoring it`);continue}Y.has(ee.symbol)||(Y.add(ee.symbol),Z.push(ee))}Z.sort((J,ee)=>ee.factor-J.factor);const _=Z.length>=2?Z:null;return s.set(A,_),_}function n(A,C,H){return C===H||C.factor===H.factor?A:A*C.factor/H.factor}const c=new Map;function o(A){const C=A||"",H=c.get(C);if(H)return H;const Y={group:",",decimal:"."};try{for(const Z of new Intl.NumberFormat(A||void 0).formatToParts(12345.6))Z.type==="group"?Y.group=Z.value:Z.type==="decimal"&&(Y.decimal=Z.value)}catch{}return c.set(C,Y),Y}const l=/[\s ]/g,h=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,w=/^[^\d+\-(.,\s]+\s*/,g=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function k(A,C){const{group:H,decimal:Y}=o(C);let Z=String(A).replace(l,"");if(Z==="")return null;const _=Y?Z.indexOf(Y):-1;if(H&&H!==Y){if(_>=0&&Z.indexOf(H,_+Y.length)>=0)return null;Z=Z.split(H).join("")}if(Y&&Y!=="."&&(Z=Z.split(Y).join(".")),!g.test(Z))return null;const J=Number(Z);return Number.isFinite(J)?J:null}function d(A,C,H){const Y=String(A).trim().replace(/\.$/,"");if(Y==="")return null;const Z=C.units.find(oe=>oe.symbol===Y);if(Z)return Z;const _=Y.toLowerCase(),J=C.byToken.get(_);if(J===x)return null;if(J)return J;const ee=C.byPrefix.get(_);if(!ee||!ee.length)return null;const ne=f(C,H),se=ee.filter(oe=>ne.includes(oe));return se.length===1?se[0]:null}function p(A,C,H,Y){let Z=A,_=0,J=!1,ee=!1;for(;Z!=="";){const ne=h.exec(Z)[0];if(ne==="")return null;const se=k(ne,Y&&Y.locale);if(se===null)return null;Z=Z.slice(ne.length).trim();const oe=Z.search(/[+-]?[\d]/),fe=(oe>=0?Z.slice(0,oe):Z).trim();if(Z=oe>=0?Z.slice(oe).trim():"",fe===""){if(J)return null;ee=!0,_+=n(se,H[0],C.base)}else{const pe=d(fe,C.index,C.binary);if(!pe)return null;_+=n(se,pe,C.base)}if(J=!0,ee&&Z!=="")return null}return J?_:null}function m(A,C){if(N(A))return null;if(typeof A=="number")return Number.isFinite(A)?A:null;const H=t(C);if(!H)return null;let Y=String(A).trim();if(Y==="")return null;let Z=!1;Y.startsWith("(")&&Y.endsWith(")")&&(Z=!0,Y=Y.slice(1,-1).trim());const _=i(C,H);if(_){Y.startsWith("-")&&(Z=!0,Y=Y.slice(1).trim());const he=p(Y,H,_,C);return he===null?null:Z?-he:he}let J=null;const ee=w.exec(Y);if(ee&&ee[0]){const he=d(ee[0].trim(),H.index,H.binary);he&&(J=he,Y=Y.slice(ee[0].length).trim())}const ne=h.exec(Y)[0],se=k(ne,C&&C.locale);if(se===null)return null;const oe=Y.slice(ne.length).trim();if(J&&oe!=="")return null;const fe=J||(oe===""?H.base:d(oe,H.index,H.binary));if(!fe)return null;const pe=n(se,fe,H.base);return Z?-pe:pe}const v=new Map;function y(A,C,H,Y){const Z=`${A||""}|${C}|${H}|${Y?1:0}`;let _=v.get(Z);return _||(_=new Intl.NumberFormat(A||void 0,{minimumFractionDigits:C,maximumFractionDigits:H,useGrouping:Y}),v.set(Z,_)),_}function E(A,C){if(!Number.isFinite(A)||A===0)return Math.max(0,C-1);const H=Math.floor(Math.log10(Math.abs(A)));return Math.min(20,Math.max(0,C-1-H))}function M(A,C){if(!Number.isFinite(A)||A===0)return A;const H=Math.ceil(Math.log10(Math.abs(A))),Y=10**(C-H);return Math.round(A*Y)/Y}function F(A,C,H){if(!H||H===C.base.symbol)return C.base;if(H!=="auto")return V(C,H);if(A===0||!Number.isFinite(A))return C.base;const Y=Math.abs(A)*C.base.factor,Z=f(C.index,C.binary);let _=Z[0];for(const ne of Z)Y>=ne.factor&&(_=ne);if(Y>=_.factor)return _;let J=_;for(const ne of C.index.units)ne.binary!==C.binary&&ne.factor!==1||ne.factor<=Y&&ne.factor>(J===_?0:J.factor)&&(J=ne);if(J!==_)return J;let ee=_;for(const ne of C.index.units)ne.binary!==C.binary&&ne.factor!==1||ne.factor<ee.factor&&(ee=ne);return ee.factor<C.base.factor?ee:C.base}function V(A,C){const H=A.index.units.find(Z=>Z.symbol===C);if(H)return H;const Y=A.index.byToken.get(String(C).toLowerCase());return Y&&Y!==x?Y:(B(`unit:display:${C}`,`unknown display unit "${C}"; rendering in ${A.base.symbol}`),A.base)}function I(A,C,H,Y){const Z=A<0;let _=Math.abs(A)*C.base.factor;const J=typeof Y.decimals=="number"?Y.decimals:Y.minDecimals??0,ee=typeof Y.decimals=="number"?Y.decimals:Y.maxDecimals??Math.max(J,2),ne=Y.space??" ",se=[];for(let fe=0;fe<H.length;fe++){const pe=H[fe],he=fe===H.length-1;let Re=he?_/pe.factor:Math.floor(_/pe.factor);if(_-=Re*pe.factor,he){const Le=10**ee;Re=Math.round(Re*Le)/Le+0}const Ue=he?y(Y.locale,J,ee,Y.group!==!1):y(Y.locale,0,0,Y.group!==!1);se.push(`${Ue.format(Re)}${ne}${pe.symbol}`)}const oe=se.join(" ");return Z?`-${oe}`:oe}function $(A,C){const H=C||{},Y=H.nullDisplay??"";if(N(A)||A==="")return Y;const Z=typeof A=="number"?A:Number(A);if(!Number.isFinite(Z))return Y;const _=t(H);if(!_)return String(Z);const J=i(H,_);if(J)return I(Z,_,J,H);const ee=typeof H.significantFigures=="number"&&H.significantFigures>0?H.significantFigures:0,ne=ee?M(Z,ee):Z,se=F(ne,_,H.display),oe=n(ne,_.base,se);let fe=typeof H.decimals=="number"?H.decimals:H.minDecimals??0,pe=typeof H.decimals=="number"?H.decimals:H.maxDecimals??Math.max(fe,2);ee&&(fe=E(oe,ee),pe=fe);const he=y(H.locale,fe,pe,H.group!==!1).format(oe),Re=H.space??" ";return H.placement==="prefix"?`${se.symbol}${H.space??""}${he}`:`${he}${Re}${se.symbol}`}function S(A,C){const H=N(A)||Number.isNaN(A)?null:Number(A),Y=N(C)||Number.isNaN(C)?null:Number(C);return H===null||Number.isNaN(H)?Y===null||Number.isNaN(Y)?0:1:Y===null||Number.isNaN(Y)||H<Y?-1:H>Y?1:0}function R(A){const C=typeof A.decimals=="number"&&A.decimals>0?`.${"0".repeat(A.decimals)}`:"";return`${typeof A.decimals=="number"?`#,##0${C}`:"#,##0.##"}" ${A.symbol}"`}function L(A){const C={system:"data",...A||{}},H=t(C),Y=H?H.base.symbol:String(C.unit||""),Z=Object.freeze({...C,unit:Y}),_=Object.freeze({...Z,display:Y,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[Z.locale||"",Z]]),ee=ne=>{const se=ne||"";let oe=J.get(se);return oe||(oe=Object.freeze({...Z,locale:ne||void 0}),J.set(se,oe)),oe};return{base:"number",extends:"number",storage:"float64",unitConfig:Z,format:ne=>$(ne.value,ne.locale?ee(ne.locale):Z),parse:ne=>m(ne.text,ne.locale?ee(ne.locale):Z),compare:S,defaults:{filter:"number",editor:"unit",align:"end",total:C.total||"sum"},...C.totals?{totals:C.totals}:{},excel:C.excel||R({decimals:C.decimals,symbol:Y}),toStorage:ne=>typeof ne=="number"?Number.isFinite(ne)?ne:null:typeof ne=="string"?m(ne,Z):N(ne)?null:m(String(ne),Z),toClipboard:ne=>$(ne,_),fromClipboard:ne=>m(ne,Z)}}const T=L}),Ie("packages/core/src/columns/types/engineering.js",function(e,U){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return D}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/columns/types/unit.js").createUnitType;function D(x){const G=2*Math.PI/x;return z=>{let j=0,O=0,b=0;for(const f of z||[]){if(N(f))continue;const a=Number(f);Number.isFinite(a)&&(j+=Math.cos(a*G),O+=Math.sin(a*G),b+=1)}return!b||Math.hypot(j,O)/b<1e-12?null:(Math.atan2(O,j)/G%x+x)%x}}function q(x){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:D(x)}}}const K=Object.freeze({metres:B({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:B({system:"length",unit:"mm",maxDecimals:2}),kilometres:B({system:"length",unit:"km",maxDecimals:3}),grams:B({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:B({system:"mass",unit:"kg",maxDecimals:3}),tonnes:B({system:"mass",unit:"t",maxDecimals:3}),seconds:B({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:B({system:"duration",unit:"ms",maxDecimals:3}),hours:B({system:"duration",unit:"h",maxDecimals:2}),speed:B({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:B({system:"speed",unit:"km/h",maxDecimals:1}),mph:B({system:"speed",unit:"mph",maxDecimals:1}),knots:B({system:"speed",unit:"kn",maxDecimals:1}),acceleration:B({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:B({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:B({system:"area",unit:"ha",maxDecimals:4}),volume:B({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:B({system:"volume",unit:"m³",maxDecimals:3}),energy:B({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:B({system:"energy",unit:"kWh",maxDecimals:2}),power:B({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:B({system:"power",unit:"kW",maxDecimals:2}),force:B({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:B({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:B({system:"pressure",unit:"bar",maxDecimals:3}),psi:B({system:"pressure",unit:"psi",maxDecimals:1}),torque:B({system:"torque",unit:"N·m",maxDecimals:2}),density:B({system:"density",unit:"kg/m³",maxDecimals:2}),flow:B({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:B({system:"flow",unit:"L/min",maxDecimals:1}),radians:B({system:"angle",unit:"rad",maxDecimals:4,totals:q(2*Math.PI)}),degrees:B({system:"angle",unit:"°",maxDecimals:2,totals:q(360)}),rpm:B({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:B({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:B({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:B({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:B({system:"fraction",unit:"bp",maxDecimals:1}),molarity:B({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:B({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:B({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:B({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:B({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:B({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:B({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:B({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Ie("packages/core/src/columns/types/si.js",function(e,U){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return j}});const te=U("packages/core/src/columns/types/unit.js"),N=te.defineUnit,X=te.registerUnitSystem,B=te.createUnitType,D=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})]),q=Object.freeze(["p","n","µ","m","","k","M","G"]);function K(O){const b=String(O.base),u=new Set([...O.prefixes||q,""]),f=[];for(const a of D){if(!u.has(a.symbol))continue;const r=`${a.symbol}${b}`,t=[];if(O.name){t.push(`${a.name}${O.name}`,`${a.name}${O.name}s`);const s=a.name.slice(-1);if(s&&O.name.startsWith(s)){const i=`${a.name.slice(0,-1)}${O.name}`;t.push(i,`${i}s`)}}a.symbol==="µ"&&t.push(`u${b}`),a.factor===1&&O.aliases&&t.push(...O.aliases),f.push(N(r,a.factor,t))}for(const a of O.extra||[])f.push(a);return f}function x(O,b){const u=K(b);return X(O,u)}function G(O,b,u){return x(O,b),B({system:O,unit:b.base,display:"auto",maxDecimals:3,...u||{}})}const z=Object.freeze({voltage:G("voltage",{base:"V",name:"volt"}),current:G("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:G("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:G("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:G("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:G("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[N("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),N("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:G("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:G("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[N("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:G("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:G("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:G("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:G("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:G("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:G("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:G("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[N("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:G("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),j=G}),Ie("packages/core/src/columns/types/temperature.js",function(e,U){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const N=U("packages/core/src/internal/predicates.js").isNil,X=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:f=>f+273.15,fromKelvin:f=>f-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:f=>(f+459.67)*(5/9),fromKelvin:f=>f*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:f=>f,fromKelvin:f=>f}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:f=>f*(5/9),fromKelvin:f=>f*(9/5)})});function B(f){if(N(f))return null;const a=String(f).trim();if(a==="")return null;for(const[t,s]of Object.entries(X))if(a===t||a===s.symbol)return{key:t,scale:s};const r=a.toLowerCase();for(const[t,s]of Object.entries(X))if(s.aliases.includes(r))return{key:t,scale:s};return null}function D(f,a,r){const t=B(a),s=B(r);return!t||!s||!Number.isFinite(Number(f))?null:t.key===s.key?Number(f):s.scale.fromKelvin(t.scale.toKelvin(Number(f)))}const q=new Map;function K(f,a,r){const t=`${f||""}|${a}|${r}`;let s=q.get(t);return s||(s=new Intl.NumberFormat(f||void 0,{minimumFractionDigits:a,maximumFractionDigits:r}),q.set(t,s)),s}function x(f,a){const r=a||{},t=r.nullDisplay??"";if(N(f)||f==="")return t;const s=Number(f);if(!Number.isFinite(s))return t;const i=B(r.scale||"C");if(!i)return String(s);const n=B(r.display||r.scale||"C")||i,c=n.key===i.key?s:n.scale.fromKelvin(i.scale.toKelvin(s)),o=typeof r.decimals=="number"?r.decimals:null,l=o??r.minDecimals??0,h=o??r.maxDecimals??1;return`${K(r.locale,l,h).format(c)}${r.space??" "}${n.scale.symbol}`}const G=/^[+-]?[\d\s., ]*\d/;function z(f,a){const r=String(f).trim();if(r==="")return null;const t=new Intl.NumberFormat(a||void 0).formatToParts(1.1).find(c=>c.type==="decimal")?.value||".",s=t===","?".":",",i=r.split(s).join("").split(/[\s ]/).join("").replace(t,"."),n=Number(i);return Number.isFinite(n)?n:null}function j(f,a){if(N(f))return null;const r=a||{},t=B(r.scale||"C");if(!t)return null;if(typeof f=="number")return Number.isFinite(f)?f:null;let s=String(f).trim();if(s==="")return null;let i=!1;s.startsWith("(")&&s.endsWith(")")&&(i=!0,s=s.slice(1,-1).trim());const n=G.exec(s);if(!n)return null;const c=z(n[0],r.locale);if(c===null)return null;const o=s.slice(n[0].length).trim();if(o==="")return i?-c:c;const l=B(o);if(!l)return null;const h=l.key===t.key?c:t.scale.fromKelvin(l.scale.toKelvin(c));return i?-h:h}function O(f){const a=Object.freeze({scale:"C",...f||{}}),t=(B(a.scale)||B("C")).scale.symbol,s=Object.freeze({...a,display:a.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),i=new Map([[a.locale||"",a]]),n=c=>{const o=c||"";let l=i.get(o);return l||(l=Object.freeze({...a,locale:c||void 0}),i.set(o,l)),l};return{base:"number",extends:"number",storage:"float64",temperatureConfig:a,format:c=>x(c.value,c.locale?n(c.locale):a),parse:c=>j(c.text,c.locale?n(c.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:c=>typeof c=="number"?Number.isFinite(c)?c:null:typeof c=="string"?j(c,a):N(c)?null:j(String(c),a),toClipboard:c=>x(c,s),fromClipboard:c=>j(c,a)}}const b=Object.freeze({celsius:O({scale:"C"}),fahrenheit:O({scale:"F"}),kelvin:O({scale:"K"})}),u=O}),Ie("packages/core/src/columns/types/radix.js",function(e,U){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/internal/warn.js").warnOnce,D=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}),q=Object.freeze({2:1,8:3,16:4}),K=Object.freeze({2:"0b",8:"0o",16:"0x"}),x=Object.freeze({2:4,8:3,16:2}),G=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),z=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),j=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),O=/[\s\u00a0\u202f_,']/g,b=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,u=Object.freeze([8,16,32,53]),f=new WeakSet,a=new WeakMap,r=new Map,t=new WeakMap,s=new WeakMap,i=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function n($){if($==null)return 16;const S=typeof $=="string"?$.toLowerCase():$,R=D[S];return R||(B(`radix:base:${String($)}`,`unsupported radix ${String($)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function c($,S){return Math.ceil($/q[S])}function o($,S){if(!$)return S?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!S)return{min:0,max:2**$-1};const R=2**($-1);return{min:-R,max:R-1}}function l($){return z[$]||"hexadecimal"}function h($){if(typeof $=="string"){const S=i[$];return S||B(`radix:preset:${$}`,`unknown radix preset "${$}"; known presets are ${Object.keys(i).join(", ")}`),{...S||{}}}if($&&typeof $.preset=="string"){const S=i[$.preset];return S||B(`radix:preset:${$.preset}`,`unknown radix preset "${$.preset}"; known presets are ${Object.keys(i).join(", ")}`),{...S||{},...$}}return $||{}}function w($){const S=h($),R=n(S.radix),L=q[R];let T=null;if(S.bitWidth!==void 0&&S.bitWidth!==null&&S.bitWidth!==!1){const ne=Number(S.bitWidth);u.includes(ne)?T=ne:B(`radix:width:${String(S.bitWidth)}`,`unsupported bitWidth ${String(S.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let A=S.signed!==!1;!A&&T===null&&(B("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),T=32);const C=S.prefix===void 0||S.prefix===!0?K[R]:S.prefix===!1?"":String(S.prefix);let H=0;S.pad===!0?H=T?c(T,R):0:typeof S.pad=="number"&&S.pad>0&&(H=Math.floor(S.pad));let Y=0;S.group===!0?Y=x[R]:typeof S.group=="number"&&S.group>0&&(Y=Math.floor(S.group));const Z=o(T,A),_=typeof S.min=="number"?Math.max(Z.min,S.min):Z.min,J=typeof S.max=="number"?Math.min(Z.max,S.max):Z.max,ee=Object.freeze({radix:R,bits:L,prefix:C,uppercase:S.uppercase!==!1,pad:H,group:Y,groupSeparator:typeof S.groupSeparator=="string"?S.groupSeparator:" ",bitWidth:T,signed:A,min:_,max:J<_?_:J,nullDisplay:typeof S.nullDisplay=="string"?S.nullDisplay:"",name:l(R)});return f.add(ee),ee}function g($){if($&&f.has($))return $;if(typeof $=="string"){let S=r.get($);return S||(S=w($),r.set($,S)),S}if($&&typeof $=="object"){let S=a.get($);return S||(S=w($),a.set($,S)),S}return g("hex")}function k($){return $<0?-Math.round(-$):Math.round($)}function d($,S,R){if(S<=0||$.length<=S)return $;const L=$.length%S||S,T=[$.slice(0,L)];for(let A=L;A<$.length;A+=S)T.push($.slice(A,A+S));return T.join(R)}function p($){const S=g($),{radix:R,prefix:L,uppercase:T,pad:A,group:C,groupSeparator:H,signed:Y,bitWidth:Z,nullDisplay:_}=S,J=Z?2**Z:0,ee=ne=>{if(N(ne)||ne==="")return _;const se=typeof ne=="number"?ne:Number(ne);if(!Number.isFinite(se))return _;const oe=k(se);let fe="",pe=oe;oe<0&&(Y?(fe="-",pe=-oe):pe=(oe%J+J)%J);let he=pe.toString(R);return he=T?he.toUpperCase():he.toLowerCase(),A>0&&he.length<A&&(he=he.padStart(A,"0")),C>0&&(he=d(he,C,H)),fe+L+he};return ee.options=S,ee}function m($,S){const R=g(S);let L=t.get(R);return L||(L=p(R),t.set(R,L)),L($)}function v($){const S=g($),{radix:R,groupSeparator:L,signed:T,min:A,max:C}=S,H=G[R],Y=Z=>{if(N(Z))return{ok:!0,value:null,reason:"blank"};let _=String(Z);if(L&&L!==""&&(_=_.split(L).join("")),_=_.replace(O,""),_==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((_[0]==="-"||_[0]==="+")&&(J=_[0]==="-",_=_.slice(1)),_==="")return{ok:!1,value:null,reason:"digits"};let ee=null;for(const[se,oe]of j){const fe=se.exec(_);if(!fe)continue;const pe=_.slice(fe[0].length);if(pe==="")break;if(!G[oe].test(pe))return{ok:!1,value:null,reason:"digits"};ee=parseInt(pe,oe);break}if(ee===null)if(H.test(_))ee=parseInt(_,R);else if(b.test(_))ee=Number(_);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(ee))return{ok:!1,value:null,reason:"digits"};const ne=k(J?-ee:ee);return!T&&ne<0?{ok:!1,value:ne,reason:"negative"}:ne<A||ne>C?{ok:!1,value:ne,reason:"range"}:{ok:!0,value:ne,reason:"ok"}};return Y.options=S,Y}function y($,S){const R=g(S);let L=s.get(R);return L||(L=v(R),s.set(R,L)),L($)}function E($,S){const R=y($,S);return R.ok?R.value:null}function M($,S){const R=N($)||Number.isNaN($)?null:Number($),L=N(S)||Number.isNaN(S)?null:Number(S);return R===null?L===null?0:1:L===null||R<L?-1:R>L?1:0}function F($){const S=$.min>=-2147483648&&$.max<=2147483647;return $.bitWidth&&S?"int32":"float64"}function V($){const S=w($),R=p(S),L=v(S);return{base:"number",extends:"number",storage:F(S),matches:null,format:T=>R(T.value),parse:T=>{const A=L(T.text);return A.ok?A.value:null},compare:M,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:T=>R(T),fromClipboard:T=>{const A=L(T);return A.ok?A.value:null},radix:S,formatValue:R,parseText:L}}const I=V}),Ie("packages/core/src/columns/types/aggregable.js",function(e,U){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return D}});const N=U("packages/core/src/internal/predicates.js").isNil;function X(z){const j=[];for(const O of z||[]){if(N(O))continue;const b=Number(O);Number.isFinite(b)&&j.push(b)}return j}function B(z){return j=>{const O=X(j);if(!O.length)return null;let b=0;for(const u of O)b+=10**(u/z);return z*Math.log10(b)}}function D(z){return j=>{const O=X(j);if(!O.length)return null;let b=0;for(const u of O)b+=10**(u/z);return z*Math.log10(b/O.length)}}function q(z,j){const O=j&&j.column,u=(O&&O.typeOptions||{}).weight,f=j&&j.valueAt;if(!u||typeof f!="function")return null;let a=0,r=0;for(let t=0;t<z.length;t++){if(N(z[t]))continue;const s=Number(z[t]);if(!Number.isFinite(s))continue;const i=f(u,t);if(N(i))continue;const n=Number(i);!Number.isFinite(n)||n<=0||(a+=s*n,r+=n)}return r===0?null:a/r}function K(z={}){const j=z.factor===20?20:10,O=typeof z.suffix=="string"?z.suffix:"",b=Number.isInteger(z.decimals)?z.decimals:1;return{base:"number",storage:"float64",name:z.name||"logarithmic",format:u=>{const f=u&&u.value;return N(f)||!Number.isFinite(Number(f))?"":`${Number(f).toFixed(b)}${O}`},parse:u=>{const f=String((u&&u.text)??"").replace(O,"").trim();if(!f)return null;const a=Number(f);return Number.isFinite(a)?a:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:B(j),avg:D(j)}}}}function x(z={}){const j=Number.isInteger(z.decimals)?z.decimals:1,O=z.percent===!0;return{base:"number",storage:"float64",name:z.name||"ratio",format:b=>{const u=b&&b.value;return N(u)||!Number.isFinite(Number(u))?"":O?`${Number(u).toFixed(j)}%`:Number(u).toFixed(j)},parse:b=>{const u=String((b&&b.text)??"").replace("%","").trim();if(!u)return null;const f=Number(u);return Number.isFinite(f)?f:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:q}}}}const G=Object.freeze({decibel:K({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:K({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:x({name:"ratio"}),percentRate:x({name:"percentRate",percent:!0})})}),Ie("packages/core/src/columns/types/currency.js",function(e,U){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return f}}),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 s}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const N=U("packages/core/src/internal/predicates.js").isNil,X="⚠ no rate";function B(c){if(N(c))return null;const o=String(c).trim().toUpperCase();return o===""?null:o}function D(c){if(N(c))return null;if(typeof c=="object"&&!Array.isArray(c)){const o=Number(c.amount),l=B(c.code);return!l||!Number.isFinite(o)?null:{amount:o,code:l}}if(Array.isArray(c)&&c.length===2){const o=Number(c[0]),l=B(c[1]);return!l||!Number.isFinite(o)?null:{amount:o,code:l}}return null}const q=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),K=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),x=/[+-]?[\d\s., ]*\d/;function G(c,o){const l=String(c).trim();if(l==="")return null;const h=new Intl.NumberFormat(o||void 0).formatToParts(1.1).find(d=>d.type==="decimal")?.value||".",w=h===","?".":",",g=l.split(w).join("").split(/[\s ]/).join("").replace(h,"."),k=Number(g);return Number.isFinite(k)?k:null}function z(c,o){const l=o||{},h=B(l.code);if(N(c))return null;const w=D(c);if(w)return w;if(typeof c=="number")return Number.isFinite(c)&&h?{amount:c,code:h}:null;let g=String(c).trim();if(g==="")return null;let k=!1;g.startsWith("(")&&g.endsWith(")")&&(k=!0,g=g.slice(1,-1).trim());let d=null;for(const[M,F]of Object.entries(q)){if(g.startsWith(M)){d=F,g=g.slice(M.length).trim();break}if(g.endsWith(M)){d=F,g=g.slice(0,-M.length).trim();break}}const p=x.exec(g);if(!p)return null;const m=G(p[0],l.locale);if(m===null)return null;const v=(g.slice(0,p.index)+" "+g.slice(p.index+p[0].length)).trim();!d&&v!==""&&(d=B(v));const y=d||h;return y?{amount:k?-m:m,code:y}:null}function j(c,o){if(typeof c=="function")return(l,h)=>{if(l===h)return 1;const w=c(l,h);return typeof w=="number"&&Number.isFinite(w)&&w>0?w:null};if(c&&typeof c=="object"){const l=c;return(h,w)=>{if(h===w)return 1;const g=Number(l[h]),k=Number(l[w]);return!Number.isFinite(g)||!Number.isFinite(k)||g<=0||k<=0?null:k/g}}return(l,h)=>l===h?1:null}function O(c,o,l){if(!c)return null;if(c.code===o)return c.amount;const h=l(c.code,o);return h===null?null:c.amount*h}const b=new Map;function u(c,o,l){const h=`${c||""}|${o}|${l??""}`;let w=b.get(h);if(!w){const g={style:"currency",currency:o};typeof l=="number"&&(g.minimumFractionDigits=l,g.maximumFractionDigits=l);try{w={fmt:new Intl.NumberFormat(c||void 0,g),currency:!0}}catch{w={fmt:new Intl.NumberFormat(c||void 0,typeof l=="number"?{minimumFractionDigits:l,maximumFractionDigits:l}:{}),currency:!1}}b.set(h,w)}return w}function f(c,o){const l=o||{},h=l.nullDisplay??"",w=D(c);if(!w)return h;const g=B(l.display)||w.code;let k=w.amount,d=w.code;if(g!==w.code){const v=l.rateFn||j(l.rates,l.rateBase),y=O(w,g,v);if(y===null)return`${l.missingRate??X} ${w.code}→${g}`;k=y,d=g}const{fmt:p,currency:m}=u(l.locale,d,l.decimals);return m?p.format(k):`${p.format(k)} ${d}`}function a(c){const o=D(c);return o?`${o.amount} ${o.code}`:""}function r(c){const o=c||{},l=B(o.display),h=o.rateFn||j(o.rates,o.rateBase);return(w,g)=>{const k=D(w),d=D(g);if(!k&&!d)return 0;if(!k)return 1;if(!d)return-1;if(l){const p=O(k,l,h),m=O(d,l,h);if(p!==null&&m!==null)return p===m?0:p<m?-1:1}return k.code===d.code?k.amount===d.amount?0:k.amount<d.amount?-1:1:k.code<d.code?-1:1}}function t(c){const o=c||{},l=(w,g)=>{const k=[];for(const y of w||[]){const E=D(y);E&&k.push(E)}if(!k.length)return null;if(new Set(k.map(y=>y.code)).size===1){const y=k[0].code;return{amount:g(k.map(E=>E.amount)),code:y}}const p=B(o.display);if(!p)return`${o.missingRate??X}: mixed currencies, no display currency set`;const m=o.rateFn||j(o.rates,o.rateBase),v=[];for(const y of k){const E=O(y,p,m);if(E===null)return`${o.missingRate??X}: ${y.code}→${p}`;v.push(E)}return{amount:g(v),code:p}},h=w=>w.reduce((g,k)=>g+k,0);return{sum:w=>l(w,h),avg:w=>l(w,g=>h(g)/g.length),min:w=>l(w,g=>Math.min(...g)),max:w=>l(w,g=>Math.max(...g))}}function s(c){const o=Object.freeze({code:"USD",...c||{}}),l=j(o.rates,o.rateBase),h=Object.freeze({...o,rateFn:l}),w=t(h),g=r(h),k=new Map([[o.locale||"",h]]),d=v=>{const y=v||"";let E=k.get(y);return E||(E=Object.freeze({...h,locale:v||void 0}),k.set(y,E)),E},p=K[B(o.display||o.code)]||"",m=typeof o.decimals=="number"&&o.decimals>0?`.${"0".repeat(o.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:h,format:v=>f(v.value,v.locale?d(v.locale):h),parse:v=>z(v.text,v.locale?d(v.locale):h),compare:g,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:w},excel:o.excel||(p?`"${p}"#,##0${m}`:`#,##0${m}`),toStorage:v=>{const y=D(v);return y||(typeof v=="string"||typeof v=="number"?z(v,h):null)},toClipboard:v=>a(v),fromClipboard:v=>z(v,h)}}const i=Object.freeze({currency:s({code:"USD"}),usd:s({code:"USD"}),eur:s({code:"EUR"}),gbp:s({code:"GBP"}),jpy:s({code:"JPY",decimals:0})}),n=s}),Ie("packages/core/src/columns/types/index.js",function(e,U){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return M}});const te=U("packages/core/src/columns/types/temporal.js"),N=te.TEMPORAL_TYPES,X=U("packages/core/src/columns/types/network.js"),B=X.NETWORK_TYPES,D=U("packages/core/src/columns/types/structured.js"),q=D.STRUCTURED_TYPES,K=U("packages/core/src/columns/types/unit.js"),x=K.createUnitType,G=K.UNIT_SYSTEMS,z=K.parseUnit,j=K.formatUnit,O=K.registerUnitSystem,b=K.unitSystemNames,u=K.unitsOf,f=K.defineUnit,a=U("packages/core/src/columns/types/engineering.js"),r=a.ENGINEERING_TYPES,t=U("packages/core/src/columns/types/si.js"),s=t.SI_TYPES,i=t.createSiType,n=t.createSiSystem,c=t.siUnits,o=t.SI_PREFIXES,l=U("packages/core/src/columns/types/temperature.js"),h=l.TEMPERATURE_TYPES,w=l.createTemperatureType,g=l.convertTemperature,k=l.formatTemperature,d=l.parseTemperature,p=l.TEMPERATURE_SCALES,m=U("packages/core/src/columns/types/radix.js"),v=m.createRadixType,y=m.RADIX_PRESETS,E=m.parseRadix,M=m.formatRadix,F=U("packages/core/src/columns/types/aggregable.js"),V=F.AGGREGABLE_TYPES,I=U("packages/core/src/columns/types/currency.js"),$=I.CURRENCY_TYPES,S=I.createCurrencyType,R=I.parseMoney,L=I.formatMoney,T=I.convertMoney,A=I.toMoney,C=I.rateFunction,H=I.moneyComparator,Y=I.normaliseCode,Z=I.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return K.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 l.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return l.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return l.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return l.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return l.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return l.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return l.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return I.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return I.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return I.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return I.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return I.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return I.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return I.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return I.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return I.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return I.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return te.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return X.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return D.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 te.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return te.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return te.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return te.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return te.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return te.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return X.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return X.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return X.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return X.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return X.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return X.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return X.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return X.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return X.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return X.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return X.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return D.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return D.summariseJson}});const _=Object.freeze({...N,...B,...q,...V,hex:v(y.hex),hex8:v(y.hex8),hex16:v(y.hex16),hex32:v(y.hex32),binary:v(y.binary),binary8:v(y.binary8),octal:v(y.octal),bytes:x({system:"data",unit:"B",display:"auto"}),megabytes:x({system:"data",unit:"MB"}),gigabytes:x({system:"data",unit:"GB"}),bitrate:x({system:"bitrate",unit:"Mbps"}),gigabits:x({system:"bitrate",unit:"Gbps"}),...r,...s,...h,...$});{const J=new Set;for(const ee of[N,B,q,V,r,s,h,$])for(const ne of Object.keys(ee)){if(J.has(ne))throw new Error(`[lattice] data type "${ne}" is declared twice`);J.add(ne)}}}),Ie("packages/core/src/compute/handle.js",function(e,U){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return s}});const te=U("packages/core/src/internal/compare.js"),N=te.collator,X=te.defaultCompare,D=U("packages/core/src/internal/warn.js").warnOnce;function q(i){const n=new Uint32Array(i);for(let c=0;c<i;c++)n[c]=c;return n}function K(i,n){if(n&&typeof n.count=="number")return n.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const c=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):c?i.kind==="bitset"?typeof c.size=="number"?c.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(D(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${c.length*8}`),c.length*8):c.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const x=new WeakMap;function G(i){const n=i.constructor;if(!n)return"unknown";const c=x.get(n);if(c)return c;let o="unknown";try{let l=null;typeof n.from=="function"?l=n.from([!1,!0]):(l=new n(8),l.set(1));const h=l&&l.words;h&&h.length&&(h[0]===2?o="lsb":h[0]===64&&(o="msb"))}catch{o="unknown"}return x.set(n,o),o}function z(i){if(!i)return()=>0;const n=i instanceof Uint8Array?i:i.words;if(n instanceof Uint8Array){const c=i instanceof Uint8Array?"lsb":G(i);if(c==="lsb")return o=>n[o>>>3]>>>(o&7)&1;if(c==="msb")return o=>n[o>>>3]>>>7-(o&7)&1}return typeof i.get=="function"?c=>i.get(c)?1:0:()=>0}function j(i){return!i||!i.presence?null:z(i.presence)}function O(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function b(i,n){return i?typeof i.valueOf=="function"?i.valueOf(n):typeof i.values=="function"?i.values()[n]:null:null}function u(i,n){const c=i.offsets,o=i.values;if(!c||!o)return[];const l=c[n],h=c[n+1];if(!(h>l))return[];const w=i.dict,g=new Array(h-l);for(let k=l;k<h;k++)g[k-l]=w?b(w,o[k]):o[k];return g}function f(i){if(!i)return()=>{};const n=i.values,c=j(i),o=i.kind;if(o==="dictionary"){const l=i.dict;return c?h=>c(h)?b(l,n[h]):null:h=>b(l,n[h])}if(o==="bitset"){const l=z(n);return c?h=>c(h)?l(h)===1:null:h=>l(h)===1}if(o==="multi")return c?l=>c(l)?u(i,l):null:l=>u(i,l);if(!n&&typeof i.get=="function"){const l=i.get.bind(i);return h=>{const w=l(h);return w===void 0?null:w}}return c?l=>{if(!c(l))return null;const h=n[l];return h===void 0?null:h}:l=>{const h=n[l];return h===void 0?null:h}}function a(i,n){if(i<n)return-1;if(i>n)return 1;if(i===n){const l=Object.is(i,-0),h=Object.is(n,-0);return l===h?0:l?-1:1}const c=Number.isNaN(i),o=Number.isNaN(n);return c&&o?0:c?1:-1}function r(i){const n=N(i);return(c,o)=>{if(c===o)return 0;const l=typeof c,h=typeof o;if(l==="string"&&h==="string")return n.compare(c,o);if(l==="number"&&h==="number")return a(c,o);if(l==="boolean"&&h==="boolean")return c===o?0:c?1:-1;if(c instanceof Date||o instanceof Date){const w=c instanceof Date?c.getTime():Number(c),g=o instanceof Date?o.getTime():Number(o);return a(w,g)}return X(c,o)}}function t(i,n){if(i&&typeof i.ranks=="function")return i.ranks(n);const c=i&&typeof i.values=="function"?i.values():[],o=c.length,l=r(n),h=new Array(o);for(let g=0;g<o;g++)h[g]=g;h.sort((g,k)=>l(c[g],c[k])||g-k);const w=new Uint32Array(o);for(let g=0;g<o;g++)w[h[g]]=g;return w}function s(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Ie("packages/core/src/compute/filter.js",function(e,U){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return pe}});const N=U("packages/core/src/internal/predicates.js").isBlank,B=U("packages/core/src/internal/merge.js").toArray,q=U("packages/core/src/internal/warn.js").warnOnce,K=U("packages/core/src/format/date.js"),x=K.toDate,G=K.toIsoDate,z=U("packages/core/src/compute/handle.js"),j=z.bitReader,O=z.dictSize,b=z.dictValue,u=z.presenceReader,f=z.valueComparator,a=z.valueReader,r=/^\d{4}-\d{2}-\d{2}$/,t="\0null\0";function s(he,Re){const Ue=he&&he.pool;if(Ue){const Le=Ue.mask||Ue.acquireMask||Ue.acquire||Ue.take;if(typeof Le=="function"){const ie=Le.call(Ue,Re);if(ie&&ie.length>=Re)return ie}}return new Uint8Array(Re)}function i(he,Re){const Ue=he&&he.pool;if(!Ue||!Re)return;const Le=Ue.release||Ue.releaseMask||Ue.free||Ue.recycle;typeof Le=="function"&&Le.call(Ue,Re)}function n(he,Re,Ue){return he.fill(Ue,0,Re),he}function c(he){return he==null||typeof he=="number"&&Number.isNaN(he)}function o(he,Re){if(he==null)return he;if(Re==="number")return typeof he=="number"?he:Number(he);if(Re==="date"||Re==="dateString"){const Ue=G(he);return Ue===null?l(he):Ue}return Re==="boolean"?typeof he=="boolean"?he:he==="true"||he===1?!0:he==="false"||he===0?!1:!!he:he}function l(he){return he instanceof Date?he.getTime():typeof he=="number"?he:Date.parse(String(he))}function h(he){return typeof he=="number"?he:he instanceof Date?he.getTime():he==null||he===""?NaN:Number(he)}function w(he,Re){const Ue=typeof he=="string"?he:String(he);return Re?Ue:Ue.toLowerCase()}function g(he,Re){return he==null?t:typeof he=="string"?Re?he:he.toLowerCase():he instanceof Date?he.getTime():he}function k(he,Re,Ue){const Le=new Set;for(const ie of B(he)){const ge=o(ie,Ue);Le.add(g(ge,Re)),typeof ge=="string"&&ge!==""&&Number.isFinite(Number(ge))?Le.add(Number(ge)):typeof ge=="number"&&Number.isFinite(ge)&&Le.add(g(String(ge),Re))}return Le}function d(he,Re,Ue){if(he==null||Re===null||Re===void 0)return he==null&&Re==null;const Le=typeof he,ie=typeof Re;return Le==="string"&&ie==="string"?Ue?he===Re:he.toLowerCase()===Re.toLowerCase():he instanceof Date||Re instanceof Date?l(he)===l(Re):Le==="number"&&ie==="number"?he===Re||Number.isNaN(he)&&Number.isNaN(Re):Le==="number"&&ie==="string"?he===Number(Re):Le==="string"&&ie==="number"?Number(he)===Re:Le==="boolean"||ie==="boolean"?he===Re:Array.isArray(he)&&Array.isArray(Re)?he.length===Re.length&&he.every((ge,ke)=>d(ge,Re[ke],Ue)):he===Re}function p(he,Re){try{if(he instanceof RegExp){const Ue=he.flags.replace(/[gy]/g,"");return new RegExp(he.source,Re||Ue.includes("i")?Ue:`${Ue}i`)}return new RegExp(String(he),Re?"":"i")}catch(Ue){return q(`regex:${String(he)}`,`filter operator "matches" received an invalid pattern: ${String(he)}`,Ue),null}}function m(he,Re){if(he&&he.type==="datetime"&&v.has(he.op))return V(he,Re);const Ue=I(he,Re),Le=he&&he.type;return Le!=="date"&&Le!=="dateString"?Ue:ie=>Ue(typeof ie=="string"&&r.test(ie)?ie:G(ie)??ie)}const v=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),y=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,E=new Map;function M(he,Re){let Ue=E.get(Re);if(Ue===void 0){try{Ue=new Intl.DateTimeFormat("en-CA",{timeZone:Re,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{Ue=null}E.set(Re,Ue)}if(!Ue)return null;const Le={};for(const ie of Ue.formatToParts(he))ie.type!=="literal"&&(Le[ie.type]=ie.value);return Le}function F(he,Re){if(he==null||he==="")return null;if(typeof he=="string"){const ge=y.exec(he.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 Ue=x(he);if(!Ue)return null;const Le=Ue.getUTCMilliseconds(),ie=Re?M(Ue,Re):null;return ie?Date.UTC(+ie.year,+ie.month-1,+ie.day,ie.hour==="24"?0:+ie.hour,+ie.minute,+ie.second,Le):Date.UTC(Ue.getFullYear(),Ue.getMonth(),Ue.getDate(),Ue.getHours(),Ue.getMinutes(),Ue.getSeconds(),Le)}function V(he,Re){const Ue=typeof he.timeZone=="string"&&he.timeZone?he.timeZone:void 0,Le=ke=>F(ke,Ue),ie=Array.isArray(he.value)?he.value.map(Le):Le(he.value),ge=I({...he,type:"number",value:ie},Re);return ke=>ge(F(ke))}function I(he,Re){const Ue=he&&he.op,Le=!!(he&&he.caseSensitive),ie=he&&he.type,ge=f(Re),ke=Se=>Ae=>!Se(Ae);switch(Ue){case"eq":{const Se=o(he.value,ie);return Ae=>d(Ae,Se,Le)}case"ne":{const Se=o(he.value,ie);return Ae=>!d(Ae,Se,Le)}case"lt":case"lte":case"gt":case"gte":{const Se=o(he.value,ie);if(c(Se))return()=>!1;const Ae=Ue==="lt"?-1:Ue==="lte"?0:Ue==="gt"?1:2;return xe=>{if(c(xe))return!1;const me=ge(xe,Se);return Ae===-1?me<0:Ae===0?me<=0:Ae===1?me>0:me>=0}}case"between":case"notBetween":{const Se=B(he.value),Ae=o(Se[0],ie),xe=o(Se[1],ie),me=he.bounds||"[]",ye=me.charAt(0)!=="(",Te=me.charAt(1)!==")";if(c(Ae)||c(xe))return Ue==="between"?()=>!1:()=>!0;const Ye=Oe=>{if(c(Oe))return!1;const _e=ge(Oe,Ae),je=ge(Oe,xe);return(ye?_e>=0:_e>0)&&(Te?je<=0:je<0)};return Ue==="between"?Ye:ke(Ye)}case"in":case"notIn":{const Se=k(he.value,Le,ie),Ae=xe=>Se.has(g(xe,Le));return Ue==="in"?Ae:ke(Ae)}case"contains":case"notContains":{const Se=w(o(he.value,ie),Le),Ae=xe=>xe==null?!1:w(xe,Le).includes(Se);return Ue==="contains"?Ae:ke(Ae)}case"startsWith":{const Se=w(o(he.value,ie),Le);return Ae=>Ae==null?!1:w(Ae,Le).startsWith(Se)}case"endsWith":{const Se=w(o(he.value,ie),Le);return Ae=>Ae==null?!1:w(Ae,Le).endsWith(Se)}case"matches":{const Se=p(he.value,Le);return Se?Ae=>Ae==null?!1:Se.test(String(Ae)):()=>!1}case"blank":return Se=>N(Se)||Array.isArray(Se)&&Se.length===0;case"notBlank":return Se=>!(N(Se)||Array.isArray(Se)&&Se.length===0);case"containsAny":case"containsNone":{const Se=k(he.value,Le,ie),Ae=xe=>{const me=xe==null?[]:B(xe);for(let ye=0;ye<me.length;ye++)if(Se.has(g(me[ye],Le)))return!0;return!1};return Ue==="containsAny"?Ae:ke(Ae)}case"containsAll":{const Se=B(he.value).map(Ae=>g(o(Ae,ie),Le));return Ae=>{const xe=Ae==null?[]:B(Ae);if(Se.length===0)return!0;const me=new Set(xe.map(ye=>g(ye,Le)));for(let ye=0;ye<Se.length;ye++)if(!me.has(Se[ye]))return!1;return!0}}default:{const Se=pe(Ue);return Se?Se.compile(he.value):(q(`op:${String(Ue)}`,`unknown filter operator "${String(Ue)}"; the condition is refused rather than matching every row`),()=>!1)}}}function $(he,Re,Ue){return m(Re,Ue)(he)}const S=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),R=new Set(["containsAny","containsAll","containsNone"]);function L(he,Re,Ue){const Le=he&&he.op,ie=S[Le]||Le,ge=m({...he,op:ie,type:Re.type},Ue),ke=Re.items,Se=Ae=>{const xe=ke(Ae);if(!xe)return!1;for(let me=0;me<xe.length;me++)if(ge(xe[me]))return!0;return!1};return S[Le]?Ae=>!Se(Ae):Se}function T(he,Re,Ue,Le){const ie=u(he);if(ie){const Se=Re?1:0;for(let Ae=0;Ae<Le;Ae++)Ue[Ae]=ie(Ae)===Se?1:0;return Ue}const ge=he.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return n(Ue,Le,Re?1:0);const ke=a(he);for(let Se=0;Se<Le;Se++){const Ae=ke(Se),xe=N(Ae)||Array.isArray(Ae)&&Ae.length===0;Ue[Se]=xe===Re?0:1}return Ue}function A(he,Re,Ue,Le){const ie=he.dict,ge=O(ie),ke=new Uint8Array(ge);for(let me=0;me<ge;me++)ke[me]=Re(b(ie,me))?1:0;const Se=he.values,Ae=u(he);if(!Ae){for(let me=0;me<Le;me++)Ue[me]=ke[Se[me]];return Ue}const xe=Re(null)?1:0;for(let me=0;me<Le;me++)Ue[me]=Ae(me)===1?ke[Se[me]]:xe;return Ue}function C(he,Re,Ue,Le){const ie=j(he.values),ge=Re(!0)?1:0,ke=Re(!1)?1:0,Se=u(he);if(!Se){for(let xe=0;xe<Le;xe++)Ue[xe]=ie(xe)===1?ge:ke;return Ue}const Ae=Re(null)?1:0;for(let xe=0;xe<Le;xe++)Ue[xe]=Se(xe)===0?Ae:ie(xe)===1?ge:ke;return Ue}function H(he,Re,Ue,Le,ie){const ge=he.values,ke=Re.type,Se=Re.op;let Ae=!0;switch(Se){case"eq":case"ne":{const me=h(o(Re.value,ke)),ye=typeof Re.value=="number"&&Number.isNaN(Re.value),Te=Se==="ne"?1:0;if(ye)for(let Ye=0;Ye<ie;Ye++)Le[Ye]=(Number.isNaN(ge[Ye])?1:0)^Te;else for(let Ye=0;Ye<ie;Ye++)Le[Ye]=(ge[Ye]===me?1:0)^Te;break}case"lt":{const me=h(o(Re.value,ke));for(let ye=0;ye<ie;ye++)Le[ye]=ge[ye]<me?1:0;break}case"lte":{const me=h(o(Re.value,ke));for(let ye=0;ye<ie;ye++)Le[ye]=ge[ye]<=me?1:0;break}case"gt":{const me=h(o(Re.value,ke));for(let ye=0;ye<ie;ye++)Le[ye]=ge[ye]>me?1:0;break}case"gte":{const me=h(o(Re.value,ke));for(let ye=0;ye<ie;ye++)Le[ye]=ge[ye]>=me?1:0;break}case"between":case"notBetween":{const me=B(Re.value),ye=h(o(me[0],ke)),Te=h(o(me[1],ke)),Ye=Re.bounds||"[]",Oe=Ye.charAt(0)!=="(",_e=Ye.charAt(1)!==")",je=Se==="notBetween"?1:0;if(Oe&&_e)for(let we=0;we<ie;we++)Le[we]=(ge[we]>=ye&ge[we]<=Te?1:0)^je;else if(Oe)for(let we=0;we<ie;we++)Le[we]=(ge[we]>=ye&ge[we]<Te?1:0)^je;else if(_e)for(let we=0;we<ie;we++)Le[we]=(ge[we]>ye&ge[we]<=Te?1:0)^je;else for(let we=0;we<ie;we++)Le[we]=(ge[we]>ye&ge[we]<Te?1:0)^je;break}case"in":case"notIn":{const me=new Set;for(const Te of B(Re.value)){const Ye=h(o(Te,ke));Number.isNaN(Ye)||me.add(Ye)}const ye=Se==="notIn"?1:0;for(let Te=0;Te<ie;Te++)Le[Te]=(me.has(ge[Te])?1:0)^ye;break}default:Ae=!1;break}if(!Ae)return!1;const xe=u(he);if(xe){const me=Ue(null)?1:0;for(let ye=0;ye<ie;ye++)xe(ye)===0&&(Le[ye]=me)}return!0}function Y(he,Re,Ue,Le){const ie=a(he);for(let ge=0;ge<Le;ge++)Ue[ge]=Re(ie(ge))?1:0;return Ue}function Z(he,Re,Ue){const Le=Re.count|0,ie=Ue||s(Re,Le);if(!he)return n(ie,Le,1);const ge=typeof Re.handle=="function"?Re.handle(he.col):void 0,ke=typeof Re.custom=="function"?Re.custom:null;if(!ge){if(ke){for(let me=0;me<Le;me++)ie[me]=ke(he,me)?1:0;return ie}return q(`filter:col:${String(he.col)}`,`filter references unknown column "${String(he.col)}"; the condition is refused rather than matching every row`),n(ie,Le,0)}const Se=he.op;if(Se==="blank"||Se==="notBlank")return T(ge,Se==="notBlank",ie,Le);const Ae=typeof Re.itemwise=="function"?Re.itemwise(he.col):null;if(Ae&&!pe(Se)&&!R.has(Se))return Y(ge,L(he,Ae,Re.locale),ie,Le);const xe=m(he,Re.locale);switch(ge.kind){case"dictionary":return A(ge,xe,ie,Le);case"bitset":return C(ge,xe,ie,Le);case"float64":case"int32":return H(ge,he,xe,ie,Le)?ie:Y(ge,xe,ie,Le);default:return Y(ge,xe,ie,Le)}}function _(he,Re,Ue){if(!he)return n(s(Re,Ue),Ue,1);if(Array.isArray(he.conditions)){const Le=he.conditions.filter(ke=>ke!=null),ie=he.op==="or"?"or":he.op==="not"?"not":"and";if(Le.length===0)return n(s(Re,Ue),Ue,1);const ge=_(Le[0],Re,Ue);for(let ke=1;ke<Le.length;ke++){const Se=_(Le[ke],Re,Ue);if(ie==="or")for(let Ae=0;Ae<Ue;Ae++)ge[Ae]|=Se[Ae];else for(let Ae=0;Ae<Ue;Ae++)ge[Ae]&=Se[Ae];i(Re,Se)}if(ie==="not")for(let ke=0;ke<Ue;ke++)ge[ke]^=1;return ge}return Z(he,Re,s(Re,Ue))}function J(he,Re){return _(he,Re,Re.count|0)}function ee(he,Re){if(!he||!Re)return he||null;const Ue=he;if(Array.isArray(Ue.conditions)){if((Ue.op==="or"?"or":Ue.op==="not"?"not":"and")!=="and")return ne(Ue,Re)?null:he;const ie=[];for(const ge of Ue.conditions){const ke=ee(ge,Re);ke&&ie.push(ke)}return ie.length?{...Ue,op:"and",conditions:ie}:null}return Ue.col===Re?null:he}function ne(he,Re){if(!he||typeof he!="object")return!1;const Ue=he;if(Ue.col===Re)return!0;if(Array.isArray(Ue.conditions)){for(const Le of Ue.conditions)if(ne(Le,Re))return!0}return!1}function se(he,Re,Ue){if(Ue&&Ue.length>=Re){let ke=0;for(let Se=0;Se<Re;Se++)he[Se]&&(Ue[ke++]=Se);return Ue.subarray(0,ke)}let Le=0;for(let ke=0;ke<Re;ke++)Le+=he[ke]?1:0;const ie=new Uint32Array(Le);let ge=0;for(let ke=0;ke<Re;ke++)he[ke]&&(ie[ge++]=ke);return ie}const oe=new Map;function fe(he){if(!(!he||typeof he!="object"))for(const[Re,Ue]of Object.entries(he))Ue&&typeof Ue.compile=="function"&&oe.set(Re,Ue)}function pe(he){return typeof he=="string"?oe.get(he):void 0}}),Ie("packages/core/src/columns/datatypes.js",function(e,U){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return L}});const te=U("packages/core/src/internal/compare.js"),N=te.collator,X=te.defaultCompare,B=U("packages/core/src/internal/predicates.js"),D=B.isNil,q=B.isObject,K=B.isFunction,G=U("packages/core/src/internal/warn.js").fail,j=U("packages/core/src/internal/text.js").titleCase,O=U("packages/core/src/format/date.js"),b=O.toDate,u=O.toIsoDate,f=O.compareIso,r=U("packages/core/src/format/boolean.js").toTriState,s=U("packages/core/src/columns/types/index.js").EXTENDED_TYPES,i=U("packages/core/src/formula/index.js"),n=i.evaluateFormula,c=i.looksLikeFormula,l=U("packages/core/src/compute/filter.js").declareOperators,h=/^\d{4}-\d{2}-\d{2}$/;function w(T){return T.getHours()===0&&T.getMinutes()===0&&T.getSeconds()===0&&T.getMilliseconds()===0}const g=new Map;function k(T){const A=T||"",C=g.get(A);if(C)return C;const H={group:",",decimal:"."};try{for(const Y of new Intl.NumberFormat(T||void 0).formatToParts(12345.6))Y.type==="group"?H.group=Y.value:Y.type==="decimal"&&(H.decimal=Y.value)}catch{}return g.set(A,H),H}const d=/\d\s*[*/^]\s*[\d.(]/;function p(T,A){if(D(T))return null;let C=String(T).trim();if(C===""||C.startsWith("=")||d.test(C))return null;let H=1;C.startsWith("(")&&C.endsWith(")")&&(H=-1,C=C.slice(1,-1));const Y=C.endsWith("%"),{group:Z,decimal:_}=k(A);if(C=C.replace(/[\s\u00a0\u202f\u2009']/g,""),Z&&Z!=="."&&Z!==","&&(C=C.split(Z).join("")),C=C.replace(/[^0-9eE+\-.,]/g,""),_===","?C=C.split(".").join("").replace(",","."):C=C.split(",").join(""),C===""||C==="-"||C==="+")return null;const J=Number(C);return Number.isNaN(J)?null:H*(Y?J/100:J)}function m(T,A){const C=D(T)||Number.isNaN(T)?null:Number(T),H=D(A)||Number.isNaN(A)?null:Number(A);return C===null?H===null?0:1:H===null||C<H?-1:C>H?1:0}function v(T,A){const C=r(T),H=r(A);return C===null?H===null?0:1:H===null?-1:C===H?0:C?1:-1}function y(T,A){const C=b(T),H=b(A);if(!C)return H?1:0;if(!H)return-1;const Y=C.getTime(),Z=H.getTime();return Y<Z?-1:Y>Z?1:0}const E=new Map;function M(T){const A=b(T.value);if(!A)return"";const C=T.locale||"";let H=E.get(C);return H||(H=new Intl.DateTimeFormat(T.locale||void 0,{dateStyle:"medium"}),E.set(C,H)),H.format(A)}const F={boolean:{base:"boolean",storage:"bitset",matches:T=>typeof T=="boolean",parse:T=>r(T.text),compare:v,format:T=>r(T.value)===null?"":r(T.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:T=>r(T)===null?"":String(r(T)),fromClipboard:T=>r(T)},number:{base:"number",storage:"float64",matches:T=>typeof T=="number"&&!Number.isNaN(T),parse:T=>{if(c(T.text)){const A=n(T.text,T);if(!A.ok)return null;const C=Number(A.value);return Number.isFinite(C)?C:null}return p(T.text,T.locale)},compare:m,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:T=>D(T)?"":String(T),fromClipboard:(T,A)=>p(T,A&&A.locale)},date:{base:"dateString",storage:"dictionary",matches:T=>typeof T=="string"&&h.test(T)&&!Number.isNaN(Date.parse(T))||T instanceof Date&&!Number.isNaN(T.getTime())&&w(T),parse:T=>u(T.text),compare:f,format:M,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:T=>u(T),toClipboard:T=>D(T)?"":String(T),fromClipboard:T=>u(T)},dateString:{base:"dateString",storage:"dictionary",matches:T=>typeof T=="string"&&h.test(T)&&!Number.isNaN(Date.parse(T)),parse:T=>u(T.text),compare:f,format:M,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:T=>u(T),toClipboard:T=>D(T)?"":String(T),fromClipboard:T=>u(T)},text:{base:"text",storage:"dictionary",matches:T=>typeof T=="string",parse:T=>T.text===""?null:String(T.text),compare:(T,A)=>D(T)?D(A)?0:1:D(A)?-1:N().compare(String(T),String(A)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:T=>D(T)?"":String(T),fromClipboard:T=>T},image:{base:"text",storage:"dictionary",parse:T=>T.text===""||T.text==null?null:String(T.text).trim(),compare:(T,A)=>D(T)?D(A)?0:1:D(A)?-1:N().compare(String(T),String(A)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:T=>D(T)?"":String(T),fromClipboard:T=>T},lookup:{base:"text",storage:"dictionary",parse:T=>{if(T.text===""||T.text==null)return null;const A=T.column&&T.column.lookup,C=A&&K(A.options)?A.options():null;if(!C)return T.text;const H=String(T.text),Y=C.find(J=>String(J.id)===H);if(Y)return Y.id;const Z=H.trim().toLowerCase(),_=C.find(J=>String(J.label).toLowerCase()===Z);return _?_.id:T.text},compare:X,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:T=>D(T)?"":String(T),fromClipboard:T=>T},object:{base:"object",storage:"object",matches:T=>T!==null&&typeof T=="object"&&!(T instanceof Date),parse:T=>{try{return T.text===""?null:JSON.parse(T.text)}catch{return T.text}},compare:(T,A)=>X(T,A),format:T=>{const A=T.value;if(D(A))return"";if(typeof A=="string")return A;try{return JSON.stringify(A)}catch{return String(A)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:T=>D(T)?"":typeof T=="string"?T:JSON.stringify(T),fromClipboard:T=>T}},V=["boolean","number","date","dateString","datetime","text","object"];function I(T,A,C,H){const Y=C.get(T);if(Y)return Y;H.includes(T)&&G(`circular data type extends chain: ${[...H,T].join(" → ")}`);const Z=A[T];Z||G(`unknown data type "${T}"`);let _=null;Z.extends&&(_=I(Z.extends,A,C,[...H,T]));const J={..._||{},...Z,name:T,defaults:{..._&&_.defaults||{},...Z.defaults||{}}};return J.base||(J.base=_&&_.base||"text"),J.storage||(J.storage=_&&_.storage||"object"),C.set(T,J),J}function $(T,A){const C={...F,...s};if(A&&typeof A.dataType=="function"&&typeof A.names=="function")for(const Y of A.names("dataType")){const Z=A.dataType(Y);Z&&(C[Y]=Z)}if(q(T))for(const[Y,Z]of Object.entries(T))C[Y]=Z;const H=new Map;for(const Y of V)I(Y,C,H,[]);I("lookup",C,H,[]);for(const Y of Object.keys(C))I(Y,C,H,[]);for(const Y of H.values())l(Y.operators);return H}function S(T,A){if(T.base==="text"&&(!T.compare||T.compare===F.text.compare)){const C=N(A);return(H,Y)=>D(H)?D(Y)?0:1:D(Y)?-1:C.compare(String(H),String(Y))}return T.compare||X}function R(T,A){return A?T.multiStorage||"multi":T.storage||"object"}function L(T){return j(String(T).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Ie("packages/core/src/columns/infer.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return K}});const N=U("packages/core/src/internal/warn.js").infoOnce,B=U("packages/core/src/internal/predicates.js").isNil,D=100;function q(x,G,z={}){const j=z.sampleSize??D,O=[];for(let b=0;b<x.length&&O.length<j;b++){const u=x[b];B(u)||typeof u=="number"&&Number.isNaN(u)||O.push(u)}if(O.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[b,u]of G){if(typeof u.matches!="function")continue;let f=!0;for(let a=0;a<O.length;a++)if(!u.matches(O[a])){f=!1;break}if(f)return{type:b,unanimous:!0,sampled:O.length}}return z.quiet||N(`infer:${z.colId||"?"}`,`column "${z.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:O.length}}function K(x,G,z,j,O={}){const b=O.sampleSize??D,u=[];for(let f=0;f<G.length&&u.length<b;f++){const a=z(G[f]);B(a)||typeof a=="number"&&Number.isNaN(a)||u.push(a)}return q(u,j,{...O,colId:x}).type}}),Ie("packages/core/src/columns/graph.js",function(e,U){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return j}});const te=U("packages/core/src/internal/warn.js"),N=te.DEV,X=te.fail,B=te.warnOnce,q=U("packages/core/src/internal/predicates.js").isFunction,K="*";function x(O){const b=O.value||{};if(!q(b.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const f=b.pure!==!1;return b.deps===K?{computed:!0,wholeRow:!0,deps:[],pure:f}:Array.isArray(b.deps)?{computed:!0,wholeRow:!1,deps:b.deps.slice(),pure:f}:(B(`deps:missing:${O.id}`,`computed column "${O.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:f})}function G(O){const b=new Map;for(const h of O)b.set(h.id,h);const u=new Map,f=new Map,a=new Set,r=new Set,t=new Set,s=new Set;for(const h of O){const w=x(h);if(!w.computed){u.set(h.id,[]);continue}r.add(h.id),(w.pure?t:s).add(h.id),w.wholeRow&&a.add(h.id);const g=[],k=[];for(const d of w.deps)(b.has(d)?g:k).push(d);u.set(h.id,g),k.length&&f.set(h.id,k)}for(const h of t)for(const w of u.get(h))s.has(w)&&X(`pure computed column "${h}" depends on impure column "${w}". Mark it \`value.pure: false\` or make the dependency pure.`);const i=[],n=new Map,c=[],o=h=>{const w=n.get(h);if(w!=="done"){if(w==="open"){const g=c.indexOf(h);X(`circular column dependency: ${[...c.slice(g),h].join(" → ")}`)}n.set(h,"open"),c.push(h);for(const g of u.get(h)||[])b.has(g)&&o(g);c.pop(),n.set(h,"done"),i.push(h)}};for(const h of O)o(h.id);const l=new Map;for(const h of O)l.set(h.id,[]);for(const h of O)for(const w of u.get(h.id)||[]){const g=l.get(w);g&&!g.includes(h.id)&&g.push(h.id)}if(a.size)for(const h of O){if(r.has(h.id))continue;const w=l.get(h.id);for(const g of a)w.includes(g)||w.push(g)}return{order:i,dependents:l,pure:t,impure:s,computed:r,deps:u,wholeRow:a,external:f,index:b}}function z(O,b){const u=Array.isArray(b)?b:[b],f=new Set,a=[...u];for(;a.length;){const r=a.shift();for(const t of O.dependents.get(r)||[])f.has(t)||(f.add(t),a.push(t))}for(const r of u)f.delete(r);return O.order.filter(r=>f.has(r))}function j(O,b,u){if(!N)return O;const f=b instanceof Set?b:new Set(b);return new Proxy(O,{get(a,r){return typeof r=="string"&&!f.has(r)&&!Object.hasOwn(a,r)&&B(`undeclared:${u}:${r}`,`computed column "${u}" read undeclared dependency "${r}". Add it to \`value.deps\` or the value will go stale.`),a[r]}})}}),Ie("packages/core/src/model/rowkey.js",function(e,U){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return r}});const N=U("packages/core/src/internal/warn.js").warnOnce,B=U("packages/core/src/internal/paths.js").pathGetter,D=U("packages/core/src/internal/predicates.js"),q=D.isFunction,K=D.isBlank,x=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],G="";function z(t){if(t===null)return"\0n";if(t===void 0)return"\0u";const s=typeof t;if(s==="string")return t;if(s==="number"||s==="bigint"||s==="boolean")return String(t);if(t instanceof Date)return`\0d${t.getTime()}`;try{return`\0o${JSON.stringify(t)}`}catch{return"\0o?"}}function j(t){if(t.length===1)return z(t[0]);let s="";for(let i=0;i<t.length;i++)i&&(s+=G),s+=z(t[i]);return s}function O(t,s={}){const i=s.warn!==!1;if(q(t)){const n=t;return{stable:!0,fields:[],disabled:[],key(c,o){try{const l=n(c);return Array.isArray(l)?j(l):z(l)}catch(l){return N("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",l),`#${o??-1}`}},keyEmpty(c){try{const o=n(c);return Array.isArray(o)?o.length===0||o.some(K):K(o)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(t)&&t.length>0){const n=t.filter(l=>typeof l=="string"),c=n.map(l=>B(l)),o=c.length;return{stable:!0,fields:n,disabled:[],key(l){const h=new Array(o);for(let w=0;w<o;w++)h[w]=c[w](l);return j(h)},keyEmpty(l){for(let h=0;h<o;h++)if(K(c[h](l)))return!0;return!1},missingFields(l){const h=[];for(let w=0;w<o;w++)K(c[w](l))&&h.push(n[w]);return h}}}if(typeof t=="string"&&t.length>0){const n=B(t);return{stable:!0,fields:[t],disabled:[],key(c){return z(n(c))},keyEmpty(c){return K(n(c))},missingFields(c){return K(n(c))?[t]:[]}}}return i&&N("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,c){if(n===null||typeof n!="object")return`#${c??0}:${String(n)}`;let o=b.get(n);return o===void 0&&(o=`#${u++}`,b.set(n,o)),o}}}const b=new WeakMap;let u=0;function f(t,s){if(!t||t.stable===!1||!q(t.keyEmpty)||!Array.isArray(s)||s.length===0)return;let i=0,n=null,c;for(let w=0;w<s.length;w++){const g=s[w];t.keyEmpty(g)&&(i++,n===null&&(n=q(t.missingFields)?t.missingFields(g):[],c=g))}if(i===0)return;const o=t.fields.length?t.fields.join(","):"(function)",l=n&&n.length?n.join(", "):t.fields.length?t.fields.join(", "):"the rowKey function",h=c!==null&&typeof c=="object"?Object.keys(c).join(", ")||"(no fields)":String(c);N(`rowKey.emptyValue:${o}`,`rowKey ${l} is missing on ${i} of ${s.length} rows; the first such row has: ${h}. 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 a(t){return j(t)}function r(t){return t.split(G)}}),Ie("packages/core/src/columns/lookup.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return t}});const te=U("packages/core/src/internal/compare.js"),N=te.collator,X=te.defaultCompare,B=U("packages/core/src/internal/predicates.js"),D=B.isFunction,q=B.isNil,x=U("packages/core/src/internal/warn.js").warnOnce,z=U("packages/core/src/model/rowkey.js").compositeKey,j=", ",O="";function b(s,i,n,c){if(s===null||typeof s!="object")return{id:s,label:s==null?"":String(s)};const o=s[i],l=s[n],h={id:o,label:l==null?String(o??""):String(l)};s.disabled&&(h.disabled=!0),s.variant&&(h.variant=s.variant),s.icon&&(h.icon=s.icon);const w=c?s[c]:s.group;return w!==void 0&&(h.group=w),h}function u(s,i,n=0,c=[],o=[]){for(const l of s||[]){const h=l&&typeof l=="object"?l[i]:null;if(o.push({raw:l,depth:n,path:c}),Array.isArray(h)&&h.length){const w=String(l&&typeof l=="object"?l.label??l.name??l.id??"":l);u(h,i,n+1,[...c,w],o)}}return o}function f(s){return!!s&&typeof s=="object"&&!Array.isArray(s)&&D(s.router&&s.router.subscribe)}class a{#e;#t;#n;#r;#i=[];#s=new Map;#o=new Map;#l=0;#a="idle";#c=null;#u;#f=null;#d=new Map;constructor(i,n={}){this.#e=i||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#u=N(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??j}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#i}setLocale(i){this.#n=i,this.#u=N(i)}#h(i){const n=this.#e,c=n.valueKey||"id",o=n.labelKey||"label",l=n.childrenKey||"children";this.#i=u(i,l).map(h=>{const w=b(h.raw,c,o,n.groupKey);return h.depth&&(w.depth=h.depth,w.path=h.path),w}),this.#s=new Map,this.#o=new Map,this.#i.forEach((h,w)=>{this.#s.set(h.id,h),this.#o.set(h.id,w)}),this.#a="ready",this.#l+=1}load(){if(this.#c)return this.#c;const i=this.#e.options;if(Array.isArray(i)||i===void 0)return this.#c=Promise.resolve(this.#i),this.#c;if(f(i))return this.#c=this.#p(i),this.#c;if(!D(i))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.#c=Promise.resolve([]),this.#c;this.#a="loading";let n;try{n=i()}catch(c){return this.#a="error",x(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,c),this.#c=Promise.resolve([]),this.#c}return!n||!D(n.then)?(this.#h(n),this.#c=Promise.resolve(this.#i),this.#r&&this.#r(this),this.#c):(this.#c=n.then(c=>(this.#h(c),this.#r&&this.#r(this),this.#i),c=>(this.#a="error",x(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,c),[])),this.#c)}refresh(){return this.#c=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#i)):this.load()}#p(i){if(this.#f)return Promise.resolve(this.#i);const n=this.#e,c=n.valueKey||"id",o=n.labelKey||"label",l=n.groupKey,h=D(i.map)?i.map:null,w=k=>b(h?h(k):k,c,o,l).id,g=k=>this.#m(k,h,c,o,l);return i.router.subscribe(i.predicate,g,{rowKey:w}),this.#f=()=>{D(i.router.detach)&&i.router.detach(g)},this.#a="ready",Promise.resolve(this.#i)}#m(i,n,c,o,l){const h=i&&i.add||[],w=i&&i.update||[],g=i&&i.remove||[];if(!(!h.length&&!w.length&&!g.length)){for(const k of h)this.#g(k,n,c,o,l);for(const k of w)this.#g(k,n,c,o,l);for(const k of g){if(!this.#d.has(k))continue;const d=this.#d.get(k);this.#d.delete(k),this.#s.delete(d);const p=this.#i.findIndex(m=>m.id===d);p>=0&&this.#i.splice(p,1)}this.#o=new Map(this.#i.map((k,d)=>[k.id,d])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(i,n,c,o,l){const h=b(n?n(i):i,c,o,l);this.#d.set(z([h.id]),h.id);const w=this.#i.findIndex(g=>g.id===h.id);w>=0?this.#i[w]=h:this.#i.push(h),this.#s.set(h.id,h)}destroy(){this.#f&&(this.#f(),this.#f=null)}search(i,n){const c=this.#e;if(!D(c.search)){const h=String(i||"").toLowerCase();return Promise.resolve(h===""?this.#i:this.#i.filter(w=>w.label.toLowerCase().includes(h)))}const o=c.valueKey||"id",l=c.labelKey||"label";return Promise.resolve(c.search(i,n)).then(h=>(h||[]).map(w=>b(w,o,l,c.groupKey)))}option(i){return this.#s.get(i)}has(i){return this.#s.has(i)}label(i){if(q(i)||i==="")return"";const n=this.#s.get(i);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(i)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const c=this.#e.unknownLabel;return D(c)?String(c(i)??""):typeof c=="string"?c:String(i)}text(i){if(this.multiple){const n=r(i);return n.length===0?"":n.map(c=>this.label(c)).join(this.separator)}return this.label(i)}dictionary(){return this.#i.map(i=>i.id)}sorted(){const i=this.sortBy;if(i==="optionOrder"||i==="count")return this.#i.slice();if(i==="value")return this.#i.slice().sort((c,o)=>X(c.id,o.id));const n=this.#u;return this.#i.slice().sort((c,o)=>n.compare(c.label,o.label))}comparator(){const i=this.sortBy,n=this.multiple,c=this.#u,o=this.#o;if(n&&i==="count")return(h,w)=>r(h).length-r(w).length;const l=n?h=>r(h)[0]:h=>h;return i==="value"?(h,w)=>X(l(h),l(w)):i==="optionOrder"?(h,w)=>{const g=o.has(l(h))?o.get(l(h)):Number.MAX_SAFE_INTEGER,k=o.has(l(w))?o.get(l(w)):Number.MAX_SAFE_INTEGER;return g-k}:(h,w)=>{const g=l(h),k=l(w);return q(g)?q(k)?0:1:q(k)?-1:c.compare(this.label(g),this.label(k))}}groupKey(i){return this.multiple?r(i).map(c=>String(c)).sort().join(O):q(i)?"":String(i)}countValues(i){return this.multiple?r(i).length:q(i)?0:1}contains(i,n,c){const o=this.multiple?r(i):q(i)?[]:[i],l=Array.isArray(n)?n:[n];switch(c){case"containsAll":return l.every(h=>o.includes(h));case"containsNone":return!l.some(h=>o.includes(h));default:return l.some(h=>o.includes(h))}}exportText(i,n="label"){return n==="value"?this.multiple?r(i).join(this.separator):q(i)?"":String(i):this.text(i)}exportColumns(){const i=this.multiple;return this.#i.map(n=>({id:n.id,label:n.label,has:c=>i?r(c).includes(n.id):c===n.id}))}}function r(s){return Array.isArray(s)?s:q(s)||s===""?[]:[s]}function t(s,i={}){const n=s.lookup;if(!n)return null;const c=new a(n,{colId:s.id,locale:i.locale,onChange:i.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&c.load(),c}}),Ie("packages/core/src/columns/value.js",function(e,U){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return a}});const N=U("packages/core/src/internal/paths.js").getPath,X=U("packages/core/src/internal/predicates.js"),B=X.isFunction,D=X.isNil,K=U("packages/core/src/internal/lru.js").Lru,G=U("packages/core/src/internal/warn.js").warnOnce,j=U("packages/core/src/columns/graph.js").depsProxy,O="\0";function b(i,n={}){const c=n.locale,o=n.grid??null,l=n.context,h=i.value&&i.value.format,w=i.formatter||null,g=i.dataType&&i.dataType.format,k=i.lookup||null,d=(p,m,v)=>({value:p,data:v,row:m,column:i,colId:i.id,grid:o,context:l,locale:c});if(B(h))return(p,m,v)=>{const y=h(d(p,m,v));return y==null?"":String(y)};if(w){if(k){const p=w.kind==="text";return(m,v,y)=>w(p?k.text(m):m,d(m,v,y))}return(p,m,v)=>w(p,d(p,m,v))}return B(g)?(p,m,v)=>{const y=g(d(p,m,v));return y==null?"":String(y)}:k?p=>k.text(p):p=>D(p)?"":typeof p=="string"?p:String(p)}function u(i,n){!i||!i.value||i.value.pure!==!1||G(`impure:${n}:${i.id}`,`column "${i.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${n}. The result is not stable across passes.`)}class f{#e;#t;#n;#r;#i;#s;#o=new K(4096);constructor(n){this.#e=n.columns instanceof Map?n.columns:new Map((n.columns||[]).map(c=>[c.id,c])),this.#t=n.graph,this.#n=n.grid??null,this.#r=n.context,this.#s=n.stored||null,this.#i=n.rowKey||a}get graph(){return this.#t}setGraph(n){this.#t=n,this.#o.clear()}beginPass(){this.#o.clear()}endPass(){this.#o.clear()}invalidate(n){if(this.#o.size===0)return;const c=n&&n.rows?new Set([...n.rows].map(String)):null,o=n&&n.columns?[...n.columns]:null;if(!c&&!o){this.#o.clear();return}const l=o?this.#l(o):null;for(const h of[...this.#o.keys()]){const w=String(h).split(O);w.length===3&&(c&&!c.has(w[0])||l&&!l.has(w[2])||this.#o.delete(h))}}#l(n){const c=new Set,o=this.#t,l=[...n];for(;l.length;){const h=l.pop();if(!c.has(h)){c.add(h);for(const w of o?o.dependents.get(h)||[]:[])l.push(w)}}return c}value(n,c,o){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return;if(!l.computed)return this.#c(l,c,o);if(l.value.pure!==!1&&this.#s&&o&&o.physical!=null&&this.#s.has(l.id))return this.#s.get(l.id,o.physical);if(l.volatile)return this.compute(l,c,o);if(l.value.pure===!1)return this.compute(l,c,o);const h=`${this.#a(c,o)}${O}${l.id}`;if(this.#o.has(h))return this.#o.get(h);const w=this.compute(l,c,o);return this.#o.set(h,w),w}#a(n,c){return`${this.#i(n,c)}${O}${r(n)}`}#c(n,c,o){if(this.#s&&o&&o.physical!=null&&this.#s.has(n.id))return this.#s.get(n.id,o.physical);if(n.field)return n.read?n.read(c):N(c,n.field)}compute(n,c,o){const l=this.#t,h=l&&l.wholeRow.has(n.id);let w;if(h)w=c??{};else{w={};const k=l&&l.deps.get(n.id)||[];for(const p of k)w[p]=this.value(p,c,o);const d=l&&l.external.get(n.id)||[];for(const p of d)w[p]=N(c,p);w=j(w,[...k,...d],n.id)}const g={data:c,row:o,column:n,grid:this.#n,context:this.#r};return n.value.compute(w,g)}values(n,c){const o={},l=this.#t?this.#t.order:[...this.#e.keys()];for(const h of l)o[h]=this.value(h,n,c);return o}text(n,c,o){const l=typeof n=="string"?this.#e.get(n):n;return l?l.formatValue(this.value(l,c,o),o,c):""}key(n,c,o){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return"";const h=this.value(l,c,o);return B(l.value.key)?String(l.value.key(this.#u(l,h,c,o))):l.lookup?l.lookup.groupKey(h):D(h)?"":String(h)}quickFilterText(n,c,o){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return"";if(B(l.value.quickFilterText)){const h=this.value(l,c,o);return String(l.value.quickFilterText(this.#u(l,h,c,o))??"")}return this.text(l,c,o)}#u(n,c,o,l){return{value:c,data:o,row:l,column:n,colId:n.id,grid:this.#n,context:this.#r}}parse(n,c,o,l){const h=typeof n=="string"?this.#e.get(n):n;if(!h)return c;const w={text:c,value:this.value(h,o,l),data:o,row:l,column:h,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(h.value.parse)?h.value.parse(w):h.dataType&&B(h.dataType.parse)?h.dataType.parse(w):c}validate(n,c,o,l,h){const w=typeof n=="string"?this.#e.get(n):n;if(!w||!B(w.edit.validate))return!0;const g=w.edit.validate({value:c,oldValue:o,data:l,row:h,column:w,grid:this.#n,context:this.#r});return g===!0||g===void 0?!0:String(g)}apply(n,c,o,l){const h=typeof n=="string"?this.#e.get(n):n;if(!h)return!1;const w=this.value(h,o,l);if(B(h.value.apply)){const g=h.value.apply({value:c,oldValue:w,data:o,row:l,column:h,grid:this.#n,context:this.#r});return this.#f(h,o,l),g!==!1}return h.field?w===c?!1:(h.write(o,c),this.#f(h,o,l),!0):(G(`apply:${h.id}`,`column "${h.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(n,c,o,l){const h=typeof n=="string"?this.#e.get(n):n;if(!h)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const w=this.value(h,o,l),g=this.parse(h,c,o,l),k=this.validate(h,g,w,o,l);if(k!==!0)return{ok:!1,value:g,oldValue:w,changed:!1,error:k};const d=this.apply(h,g,o,l);return{ok:!0,value:g,oldValue:w,changed:d}}#f(n,c,o){if(this.#o.size===0)return;const l=this.#a(c,o);this.#o.delete(`${l}${O}${n.id}`);for(const h of this.#t?this.#t.dependents.get(n.id)||[]:[])this.#o.delete(`${l}${O}${h}`)}}function a(i,n){return n&&n.key!=null?String(n.key):r(i)}function r(i){if(i&&typeof i=="object"){let n=t.get(i);return n===void 0&&(n=`#${s++}`,t.set(i,n)),n}return String(i)}const t=new WeakMap;let s=0}),Ie("packages/core/src/model/shadow.js",function(e,U){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return f}}),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 N=U("packages/core/src/internal/warn.js").warnOnce,X=2e5,B=20,D=1e3,q=50;function K(l){return Math.min(D,Math.max(q,Math.floor(l)))}const x=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"]),G=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"]),j=.6745,O=3.5,b=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),u=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),f=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(l,h){if(!h)return null;const w=Number.isFinite(Number(h.lower))?Number(h.lower):null,g=Number.isFinite(Number(h.upper))?Number(h.upper):null;if(w===null&&g===null||!Number.isFinite(l))return null;if(w!==null&&l<w||g!==null&&l>g)return b.FAIL;const k=Number.isFinite(Number(h.warnLower))?Number(h.warnLower):null,d=Number.isFinite(Number(h.warnUpper))?Number(h.warnUpper):null;return k!==null&&l<k||d!==null&&l>d?b.WARN:b.PASS}function r(l,h,w){if(!h||typeof h!="object")return null;if(h.kind!=="time")return h.kind!==void 0&&N(`shadow.history.window.kind:${l}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${h.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 g=h.minutes!=null?Number(h.minutes)*6e4:Number(h.span);if(!(g>0))return N(`shadow.history.window.span:${l}`,"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 k=Math.max(2,Math.floor(w)||B);return{span:g,bucketMs:Math.max(1,Math.floor(g/k))}}class t{#e;#t=new Map;#n=new Map;#r=new Map;#i=new Map;#s=new Map;#o=new Map;#l=0;#a;#c;#u;#f;#d=new Map;#h=null;#p=null;#m=null;constructor(h){this.#e=h.colId,this.#a=Math.max(2,h.depth||B),this.#c=Math.max(1,h.max||X),this.#u=h.now||(()=>Date.now()),this.#f=r(this.#e,h.historyWindow,this.#a),this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#f}observe(h,w){const g=c(w);if(g===null)return;if(!this.#n.has(h)){this.#p=null,this.#m=null,this.#g(),this.#t.set(h,g),this.#n.set(h,g),this.#r.set(h,0),this.#i.set(h,this.#u()),this.#s.set(h,[g]),this.#f&&this.#d.set(h,[g]),this.#o.set(h,0);return}const k=this.#n.get(h);if(k===g)return;this.#p=null,this.#m=null,this.#n.set(h,g),this.#r.set(h,(this.#r.get(h)||0)+1),this.#i.set(h,this.#u());const d=this.#s.get(h)||[];d.push(g),d.length>this.#a&&d.splice(0,d.length-this.#a),this.#s.set(h,d);const p=Math.sign(g-k),m=this.#o.get(h)||0;this.#o.set(h,Math.sign(m)===p?m+p:p)}#g(){if(this.#n.size<this.#c)return;const h=this.#n.keys().next().value;h!==void 0&&(this.#t.delete(h),this.#n.delete(h),this.#r.delete(h),this.#i.delete(h),this.#s.delete(h),this.#d.delete(h),this.#o.delete(h),this.#l++)}rebase(){for(const[h,w]of this.#n)this.#t.set(h,w);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#i.clear(),this.#s.clear(),this.#d.clear(),this.#o.clear(),this.#l=0,this.#p=null,this.#m=null,this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}retain(h){const w=h instanceof Set?h:new Set(h);let g=0;for(const k of[...this.#n.keys()])w.has(k)||(this.#t.delete(k),this.#n.delete(k),this.#r.delete(k),this.#i.delete(k),this.#s.delete(k),this.#d.delete(k),this.#o.delete(k),g++);return g&&(this.#p=null,this.#m=null),g}advanceHistoryWindow(h=this.#u()){const w=this.#f;if(!w)return 0;const g=Math.floor(h/w.bucketMs),k=g-this.#h;if(!(k>0))return 0;const d=Math.min(k,this.#a);for(const[p,m]of this.#d){const v=this.#n.get(p);for(let y=0;y<d;y++)m.push(v);m.length>this.#a&&m.splice(0,m.length-this.#a)}return this.#h=g,k}read(h,w,g,k){switch(h){case"updates":return this.#r.has(w)?this.#r.get(w):0;case"updatedAt":{const d=this.#i.get(w);return d===void 0?null:new Date(d)}case"sinceUpdate":{const d=this.#i.get(w);return d===void 0?null:this.#u()-d}case"firstValue":return this.#t.has(w)?this.#t.get(w):null;case"delta":return this.#n.has(w)?this.#n.get(w)-this.#t.get(w):null;case"deltaPercent":{if(!this.#n.has(w))return null;const d=this.#t.get(w);return d?(this.#n.get(w)-d)/Math.abs(d)*100:null}case"rate":{const d=this.#s.get(w),p=this.#i.get(w);if(!d||d.length<2||p===void 0)return null;const m=this.#u()-p,v=d[d.length-1]-d[d.length-2];return m>0?v/m*1e3:v}case"history":return this.#f?this.#d.has(w)?[...this.#d.get(w)]:null:this.#s.has(w)?[...this.#s.get(w)]:null;case"streak":return this.#o.has(w)?this.#o.get(w):0;case"specStatus":return this.#n.has(w)?a(this.#n.get(w),k):null;default:return u.includes(h)?this.#A(h,w,g,k):null}}#b(h){if(h){if(this.#m&&this.#m.only===h)return this.#m.view;const w=this.#y(h);return this.#m={only:h,view:w},w}return this.#p?this.#p:(this.#p=this.#y(null),this.#p)}#y(h){const w=[];for(const[F,V]of this.#n)h&&!h.has(F)||w.push(V);const g=w.sort((F,V)=>F-V);let k=0,d=0,p=0,m=0;for(const F of g){m+=F,k++;const V=F-d;d+=V/k,p+=V*(F-d)}const v=[];for(const[F,V]of this.#t)h&&!h.has(F)||v.push(V);const y=k?s(g):0,E=g.map(F=>Math.abs(F-y)).sort((F,V)=>F-V),M=k?s(E):0;return{sorted:g,baseline:v.sort((F,V)=>F-V),sum:m,mean:k?d:0,sd:k>1?Math.sqrt(p/(k-1)):0,median:y,mad:M}}#A(h,w,g,k){if(!this.#n.has(w)||g&&!g.has(w))return null;const d=this.#n.get(w),p=this.#b(g),m=p.sorted.length;if(!m)return null;switch(h){case"rank":return m-n(p.sorted,d)+1;case"rankAsc":return i(p.sorted,d)+1;case"rankChange":{if(!this.#t.has(w)||!p.baseline.length)return null;const v=p.baseline.length-n(p.baseline,this.#t.get(w))+1,y=m-n(p.sorted,d)+1;return v-y}case"percentile":return n(p.sorted,d)/m*100;case"quartile":{const v=n(p.sorted,d)/m;return Math.min(4,Math.max(1,Math.ceil(v*4)))}case"zScore":return p.sd?(d-p.mean)/p.sd:null;case"anomalyScore":return p.mad?j*(d-p.median)/p.mad:null;case"anomalyFlag":{if(!p.mad)return null;const v=k&&Number.isFinite(Number(k.threshold))?Number(k.threshold):O;return Math.abs(j*(d-p.median)/p.mad)>v}case"shareOfTotal":return p.sum?d/p.sum*100:null;default:return null}}}function s(l){const h=l.length;if(!h)return 0;const w=(h-1)*.5,g=Math.floor(w),k=Math.ceil(w);return g===k?l[g]:l[g]+(w-g)*(l[k]-l[g])}function i(l,h){let w=0,g=l.length;for(;w<g;){const k=w+g>>1;l[k]<h?w=k+1:g=k}return w}function n(l,h){let w=0,g=l.length;for(;w<g;){const k=w+g>>1;l[k]<=h?w=k+1:g=k}return w}function c(l){if(l==null||l==="")return null;if(l instanceof Date){const w=l.getTime();return Number.isFinite(w)?w:null}const h=typeof l=="number"?l:Number(l);return Number.isFinite(h)?h:null}function o(l){const h=[];for(const w of l||[]){const g=w.shadow;if(!g)continue;const k=typeof g=="string"?{kind:g}:g,d=k.kind;x.includes(d)&&(G.includes(d)||z.includes(d)||h.push({colId:w.id||w.field,of:k.of||w.field||w.id,kind:d,depth:k.depth,historyWindow:d==="history"?k.window:void 0}))}return h}}),Ie("packages/core/src/columns/model.js",function(e,U){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return Re}});const te=U("packages/core/src/internal/merge.js"),N=te.expand,X=te.merge,B=te.toArray,D=U("packages/core/src/internal/warn.js"),q=D.fail,K=D.warnOnce,x=U("packages/core/src/internal/paths.js"),G=x.getPath,z=x.pathGetter,j=x.pathSetter,b=U("packages/core/src/internal/text.js").humanise,u=U("packages/core/src/internal/predicates.js"),f=u.isFunction,a=u.isObject,t=U("packages/core/src/internal/uid.js").uid,i=U("packages/core/src/format/index.js").compileFormat,n=U("packages/core/src/columns/datatypes.js"),c=n.comparatorFor,o=n.createTypeRegistry,l=n.storageKind,h=U("packages/core/src/columns/infer.js"),w=h.inferColumnType,g=h.DEFAULT_SAMPLE,k=U("packages/core/src/columns/graph.js"),d=k.buildGraph,p=k.affectedBy,v=U("packages/core/src/columns/lookup.js").createLookup,y=U("packages/core/src/columns/value.js"),E=y.compileDisplay,M=y.ValuePipeline,F=y.warnImpureUse,I=U("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,$=Object.freeze({geometry:"geometry",list:"list"}),S={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},R={centre:"center"},L=new Set(["start","center","end","left","right"]);function T(Le){if(typeof Le!="string")return;const ie=Le.toLowerCase();return R[ie]?R[ie]:L.has(ie)?ie:void 0}function A(Le){if(typeof Le!="string")return;const ie=Le.toLowerCase();return ie==="center"||ie==="centre"?"middle":ie==="top"||ie==="middle"||ie==="bottom"?ie:void 0}const C=["cell","layout","header"];function H(Le){if(!a(Le))return{};const ie={...Le},ge=(ke,Se)=>{if(Le[ke]===void 0)return;const Ae=N(Le[ke],Se);Ae&&C.includes(ke)&&!a(Le[ke])&&delete Ae.enabled,ie[ke]=Ae};return ge("sort","direction"),ge("filter","type"),ge("cell","render"),ge("edit","editor"),ge("layout","width"),ge("group","index"),ge("pivot","index"),ge("header","render"),ge("facet","strategy"),ie}function Y(Le,ie){const ge={...Le||{}},ke=a(ie)&&a(ie.layout)&&ie.layout.width!==void 0;return ge.fit==="content"&&!ke&&delete ge.width,ge}const Z=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","diff","edit","export","facet","field","filter","filterRow","format","grandTotal","group","groupTotal","header","headerControls","id","layout","lookup","nullable","pivot","preset","quickFilter","rowSpan","running","shadow","showWhen","sort","spec","tags","title","total","type","typeOptions","validation","value","verticalAlign"]),_=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function J(Le,ie,ge,ke){const Se=ge==="columnGroup"?"column group":"column";for(const Ae of Object.keys(Le))if(!ie.has(Ae)){if(Ae==="timeZone"&&ge==="column"){K("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${ke}". 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}K(`${ge}.unknown:${Ae}`,`'${Ae}' is not a configuration key this grid recognises, so it had no effect on ${Se} "${ke}". Check the spelling against the reference.`)}}function ee(Le){a(Le.cell)&&Le.cell.autoHeight!==void 0&&K("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${Le.id||Le.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function ne(Le,ie){const ge=ie&&f(Le.defaultsFor)?Le.defaultsFor(ie):null,ke={...Le.defaults||{},...a(ge)?ge:{}},Se={};return ke.align&&(Se.align=ke.align,Se.cell={align:ke.align},Se.header={align:ke.align}),ke.filter&&(Se.filter=ke.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:ke.filter}),ke.editor&&(Se.edit=ke.editor==="none"?{editor:null}:{editor:ke.editor}),ke.total&&(Se.total=ke.total),ke.render&&(Se.cell={...Se.cell||{},render:ke.render}),Le.export&&(Se.export={...Le.export}),Se}function se(Le){if(typeof Le=="string")return Le.trim()?[Le.trim()]:[];if(!Array.isArray(Le))return[];const ie=[];for(const ge of Le){if(typeof ge!="string")continue;const ke=ge.trim();ke&&!ie.includes(ke)&&ie.push(ke)}return ie}class oe{#e=new Map;#t=[];#n=[];#r=new WeakMap;#i;#s;#o;#l;#a;#c;#u(ie,ge,ke){const Se=this.#f(ie,ge,ke);if(typeof Se!="string"||!this.#d)return Se??null;const Ae=ge&&ge.totals&&ge.totals.implement;if(Ae&&f(Ae[Se])){const me=Ae[Se];return me.totalName=Se,me}const xe=this.#d.totalFn?.(Se);return f(xe)?xe:Se}#f(ie,ge,ke){if(typeof ie!="string")return ie;const Se=ge&&ge.totals&&ge.totals.supported;if(!Array.isArray(Se)||Se.includes(ie))return ie;const Ae=Se.length?Se.join(", "):"none";return q(`column "${ke}" is typed ${ge.name||"a type"}, for which the total "${ie}" is not meaningful. Supported: ${Ae}. Aggregating it anyway would produce a confident wrong number.`),ie}#d;#h;#p;#m;#g;#b;#y=!1;#A;#w;constructor(ie={}){this.#s=H(ie.columnDefaults||{}),this.#o=ie.columnPresets||{},this.#a=ie.locale,this.#l=ie.timeZone,this.#c=A(ie.verticalAlign),this.#d=ie.registry||null,this.#h=ie.grid||null,this.#p=ie.context,this.#A=ie.sampleSize??g,this.#w=ie.onChange||null,this.#b=f(ie.rowKey)?ie.rowKey:void 0,this.#i=o(ie.dataTypes,this.#d);const{leaves:ge,groups:ke}=Re(ie.columns||[]);this.#n=ke;for(const Se of ge){Se.facet!==void 0&&this.#r.set(Se.def,Se.facet);const Ae=this.#O(Se.def,null);if(Ae.groupPath=Se.path,this.#e.has(Ae.id)){K(`columns.duplicate:${Ae.id}`,`two columns resolve to the id '${Ae.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}Se.column=Ae,this.#e.set(Ae.id,Ae),this.#t.push(Ae.id)}this.#E(ie.stored||null)}#O(ie,ge){J(ie,Z,"column",ie.id||ie.field||"(unnamed)"),ee(ie);const ke=H(ie),Se=B(ie.preset),Ae=Se.map(Ke=>{const Xe=this.#o[Ke];return Xe?H(Xe):(K(`preset:${Ke}`,`unknown column preset "${Ke}"; ignoring`),{})}),xe=this.#S(ke,Ae,ge),me=this.#i.get(xe)||this.#i.get("text");if(!this.#i.has(xe)&&ie.type){const Ke=$[xe];K(`type:${xe}`,`unknown data type "${xe}"; falling back to "text"`+(Ke?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Ke}'.`:""))}const ye=f(me.items)?this.#T(ke,Ae,ie.id||ie.field||"(unnamed)"):null;let Te=S;Te=X(Te,this.#s),ie.type!==!1&&(Te=X(Te,ne(me,ye)));for(const Ke of Ae)Te=X(Te,Ke);this.#r.has(ie)&&(Te=X(Te,H({facet:this.#r.get(ie)}))),Te=X(Te,ke);const Ye=Te.edit;Ye&&Ye.editor&&Ye.enabled!==!0&&!f(Ye.enabled)&&(ie.edit||{}).editor&&K(`column.editor-not-enabled:${ie.id||ie.field}`,`column '${ie.id||ie.field}' names the editor '${Ye.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Oe=ie.id||ie.field||t("col");if(ie.shadow&&!f(Te.value&&Te.value.compute)){const Ke=typeof ie.shadow=="string"?{kind:ie.shadow}:ie.shadow,Xe=Ke.of||ie.field||Oe,nt=I.includes(Ke.kind),it=nt?Ke.model||Ke:null,wt=nt&&it?[...Array.isArray(it.predictors)?it.predictors:[],it.response].filter(Boolean):null;Te.value={...Te.value||{},deps:wt&&wt.length?wt:Ke.orderBy&&Ke.orderBy!==Xe?[Xe,Ke.orderBy]:[Xe],pure:!1,compute:(pt,St)=>{const Ct=St.grid&&St.grid.statistics;if(!Ct)return null;const Mt=St.row&&St.row.key||Ct.keyOf(St.data);if(!Mt)return null;if(nt){if(!f(Ct.fitShadow))return null;const at=Ke.model?{...Ke.model,threshold:Ke.threshold}:Ke;return Ct.fitShadow(Ke.kind,Mt,at)}return Ct.shadow(Xe,Ke.kind,Mt,Ke.scope,Ke)}}}if(ie.running&&!f(Te.value&&Te.value.compute)){const Ke=typeof ie.running=="string"?{kind:ie.running}:ie.running,Xe=Ke.of||ie.field||Oe;Te.value={...Te.value||{},deps:[Xe],pure:!1,compute:(nt,it)=>{const wt=it.grid&&it.grid.statistics;if(!wt||!f(wt.running))return null;const pt=it.row&&it.row.key||wt.keyOf(it.data);return pt?wt.running(Xe,Ke.kind||"total",pt):null}},ie.sort===void 0&&(Te.sort={...Te.sort||{},enabled:!1})}const _e=ie.field??(f(Te.value&&Te.value.compute)?null:ie.id??null),je=f(Te.value&&Te.value.compute),we={id:Oe,field:_e,shadow:ie.shadow||null,running:ie.running||null,spec:ie.spec||null,validation:ie.validation||null,volatile:!!(ie.shadow||ie.running),title:Te.title??b(_e||Oe),type:me.name,dataType:me,itemType:ye,nullable:Te.nullable!==!1,align:T(ke.cell&&ke.cell.align||ke.align||Te.cell&&Te.cell.align||Te.align||me.defaults&&me.defaults.align)||"start",verticalAlign:A(ke.cell&&ke.cell.verticalAlign||ke.verticalAlign||Te.cell&&Te.cell.verticalAlign||Te.verticalAlign)||this.#c,rowSpan:f(Te.rowSpan)?Te.rowSpan:null,colSpan:f(Te.colSpan)?Te.colSpan:null,value:{pure:!0,...Te.value||{}},cell:{...Te.cell||{}},edit:{...Te.edit||{}},sort:{...Te.sort||{}},filter:{...Te.filter||{}},group:{enabled:!1,index:-1,explode:!1,...Te.group||{}},pivot:{enabled:!1,index:-1,...Te.pivot||{}},total:this.#u(Te.total,me,ie.id||ie.field||"(unnamed)"),groupTotal:Te.groupTotal===void 0?null:this.#u(Te.groupTotal,me,ie.id||ie.field||"(unnamed)"),grandTotal:Te.grandTotal===void 0?null:this.#u(Te.grandTotal,me,ie.id||ie.field||"(unnamed)"),tags:se(Te.tags),typeOptions:Te.typeOptions??null,...a(Te[xe])?{[xe]:Te[xe]}:{},layout:Y(Te.layout,ke),header:{...Te.header||{}},contextMenu:Te.contextMenu===void 0?null:Te.contextMenu,facet:{...Te.facet||{}},export:{...Te.export||{}},allowGroup:Te.allowGroup!==!1,allowPivot:Te.allowPivot!==!1,allowTotal:Te.allowTotal!==!1,quickFilter:Te.quickFilter!==!1,def:ie,format:Te.format,presets:Se,inferred:ge!=null&&!ie.type,computed:je,diff:ie.diff===void 0?void 0:!!ie.diff,read:_e?z(_e):null,write:_e?j(_e):null};we.cell.align=T(ke.cell&&ke.cell.align)||we.align,we.header.align=T(ke.header&&ke.header.align)||we.align;const He=Te.lookup||null;return we.lookup=He?v({id:Oe,lookup:He},{locale:this.#a,onChange:()=>{this.#w&&this.#w("lookup",{colId:Oe})}}):null,we.group.explode&&we.lookup&&we.lookup.multiple&&K(`explode:${Oe}`,`column "${Oe}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#v(we),we}#v(ie){ie.formatter=i(ie.format,ie.dataType,this.#a,this.#l,ie.id),ie.formatValue=E(ie,{locale:this.#a,grid:this.#h,context:this.#p}),ie.itemCompare=ie.itemType?c(ie.itemType,this.#a):null,ie.compare=f(ie.value.compare)?ie.value.compare:ie.lookup?ie.lookup.comparator():f(ie.dataType.compareFor)?ie.dataType.compareFor(ie):c(ie.dataType,this.#a),ie.excel=ie.formatter&&ie.formatter.ooxml||ie.dataType&&ie.dataType.excel||"General",ie.storeKind=l(ie.dataType,!!(ie.lookup&&ie.lookup.multiple))}#T(ie,ge,ke){let Se=a(ie.typeOptions)?ie.typeOptions:null;for(let ye=ge.length-1;!Se&&ye>=0;ye--)a(ge[ye].typeOptions)&&(Se=ge[ye].typeOptions);!Se&&a(this.#s.typeOptions)&&(Se=this.#s.typeOptions);const Ae=Se&&Se.of!==void 0?Se.of:"text",xe=typeof Ae=="string"?this.#i.get(Ae):void 0;return xe&&!f(xe.items)&&xe.storage!=="object"?xe:(K(`type:of:${String(Ae)}`,`column "${ke}" names "${String(Ae)}" as its item type (typeOptions.of), which is not ${xe?"a scalar data type":"a known data type"}; its items are read as text.`),this.#i.get("text"))}#S(ie,ge,ke){if(ie.type===!1)return"text";if(ie.type)return ie.type;for(let Se=ge.length-1;Se>=0;Se--)if(ge[Se].type)return ge[Se].type;if(this.#s.type)return this.#s.type;if(ie.shadow){const Se=typeof ie.shadow=="string"?ie.shadow:ie.shadow.kind;if(Se==="fitInfluence")return"boolean";if(Se==="fitPredicted"||Se==="fitResidual"||Se==="fitStdResidual"||Se==="fitLeverage"||Se==="fitCooksD"||Se==="tsTrend"||Se==="tsSeasonal"||Se==="tsResidual"||Se==="tsCoverage"||Se==="tsSmoothed"||Se==="tsSmoothingAlpha"||Se==="tsSmoothingBeta")return"number"}return ke||(ie.lookup?"lookup":"text")}#E(ie){const ge=this.all();this.#m=d(ge),this.#g?this.#g.setGraph(this.#m):this.#g=new M({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:ie||null,rowKey:this.#b});const ke=this.#g;for(const Se of ge)Se.getValue=(Ae,xe)=>ke.value(Se,Ae,xe)}all(){return this.#t.map(ie=>this.#e.get(ie))}visible(){return this.all().filter(ie=>!ie.layout.hidden)}get(ie){return this.#e.get(ie)}groups(){const ie=ge=>{const ke=[];for(const Se of ge)Array.isArray(Se.columns)?ke.push({...Se,columns:ie(Se.columns)}):Se.column&&ke.push(Se.column);return ke};return ie(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#i}affectedBy(ie){return p(this.#m,ie)}value(ie,ge,ke){return this.#g.value(ie,ge,ke)}text(ie,ge,ke){return this.#g.text(ie,ge,ke)}checkImpure(ie,ge){F(this.#e.get(ie),ge)}setLocale(ie){this.#a=ie;for(const ge of this.all())ge.lookup&&ge.lookup.setLocale(ie),this.#v(ge);this.#w&&this.#w("locale",{locale:ie})}infer(ie){const ge={};if(this.#y||!Array.isArray(ie)||ie.length===0)return ge;this.#y=!0;let ke=!1;for(const Se of this.all()){const Ae=Se.def;if(Ae.type!==void 0||!Se.field||Se.computed||Se.lookup||this.#N(Se))continue;const xe=Se.read||(Te=>G(Te,Se.field)),me=w(Se.id,ie,xe,this.#i,{sampleSize:this.#A});if(me===Se.type)continue;ge[Se.id]=me;const ye=this.#O(Ae,me);ye.groupPath=Se.groupPath,ye.layout={...ye.layout,...fe(Se.layout)},this.#e.set(Se.id,ye),Ue(this.#n,Se.id,ye),ke=!0}return ke&&this.#E(null),ge}redecorate(ie,ge,ke={}){const Se=this.#e.get(ie);if(!Se){K(`redecorate:${ie}`,`columns.decorate('${ie}', …): no column with id '${ie}'.`);return}const Ae=Se.def||{},xe={...a(Ae.cell)?Ae.cell:{}};xe.decoration=ge??void 0,ke&&"variant"in ke&&(xe.variant=ke.variant);const me={...Ae,cell:xe};this.#r.has(Ae)&&this.#r.set(me,this.#r.get(Ae));const ye=this.#O(me,Se.type);return ye.groupPath=Se.groupPath,ye.layout={...ye.layout,...fe(Se.layout)},Se.lookup&&Se.lookup!==ye.lookup&&f(Se.lookup.destroy)&&Se.lookup.destroy(),this.#e.set(ie,ye),Ue(this.#n,ie,ye),this.#E(null),this.#w&&this.#w("decorate",{colId:ie}),ye}destroy(){for(const ie of this.#e.values())ie.lookup&&f(ie.lookup.destroy)&&ie.lookup.destroy()}#N(ie){for(const ge of ie.presets){const ke=this.#o[ge];if(ke&&ke.type)return!0}return!!this.#s.type}#P(ie){return!ie.computed&&f(ie.dataType&&ie.dataType.toStorage)}storeReader(ie){if(ie.computed)return ge=>this.#g.value(ie,ge,null);if(this.#P(ie)){const ge=ie.dataType.toStorage,ke={timeZone:this.#l,colId:ie.id,itemType:ie.itemType||null};return Se=>ge(ie.read(Se),ke)}return ie.read}storeValue(ie,ge){if(!(!ie||ie.computed)&&f(ie.read))return this.storeReader(ie)(ge)}storeSchema(){const ie=[];for(const ge of this.all()){if(ge.computed&&ge.value.pure===!1||!ge.computed&&!ge.field)continue;const ke=this.storeReader(ge);let Se=null;!ge.computed&&!this.#P(ge)&&typeof ge.field=="string"&&!ge.lookup&&(Se=ge.field);const Ae={id:ge.id,kind:ge.storeKind,nullable:ge.nullable,read:ke};Se!==null&&(Ae.field=Se),ge.lookup&&(Ae.dictionary=ge.lookup.dictionary()),ie.push(Ae)}return ie}state(){return this.all().map(ie=>({id:ie.id,width:ie.layout.width,flex:ie.layout.flex||void 0,hidden:!!ie.layout.hidden,headerWrap:ie.header?.wrap===!0?!0:void 0,headerOrientation:ie.header?.orientation==="vertical"?"vertical":void 0,pin:ie.layout.pin??null,sort:ie.sort.direction??null,sortIndex:ie.sort.direction?ie.sort.order??0:null,groupIndex:ie.group.enabled?ie.group.index??0:null,pivotIndex:ie.pivot.enabled?ie.pivot.index??0:null,total:typeof ie.total=="string"?ie.total:null,groupTotal:typeof ie.groupTotal=="string"?ie.groupTotal:void 0,grandTotal:typeof ie.grandTotal=="string"?ie.grandTotal:void 0,decoration:ie.cell&&ie.cell.decoration!=null?pe(ie.cell.decoration):void 0,variant:ie.cell&&ie.cell.variant!=null?pe(ie.cell.variant):void 0}))}applyState(ie,ge={}){const ke={applied:[],skipped:[]},Se=Array.isArray(ie)?ie:ie&&ie.columns||[],Ae=!Array.isArray(ie)&&ie&&ie.columnOrder||null;for(const me of Se){if(!me||!me.id){ke.skipped.push({key:"?",reason:"no id"});continue}let ye=this.#e.get(me.id);if(!ye){ke.skipped.push({key:me.id,reason:"unknown column"});continue}if(Object.hasOwn(me,"decoration")||Object.hasOwn(me,"variant")){const Te=ye.cell?ye.cell.decoration:void 0,Ye=me.decoration??null,Oe=Object.hasOwn(me,"variant"),_e=Oe&&!he(ye.cell?ye.cell.variant:void 0,me.variant);(!he(Te,Ye)||_e)&&(this.redecorate(me.id,Ye,Oe?{variant:me.variant??void 0}:{}),ye=this.#e.get(me.id)||ye)}me.width!=null&&(ye.layout.width=me.width),me.flex!=null&&(ye.layout.flex=me.flex),me.hidden!=null&&(ye.layout.hidden=!!me.hidden),me.headerWrap!==void 0&&(ye.header.wrap=!!me.headerWrap),me.headerOrientation!==void 0&&(ye.header.orientation=me.headerOrientation==="vertical"?"vertical":"horizontal"),me.pin!==void 0&&(ye.layout.pin=me.pin),me.sort!==void 0&&(ye.sort.direction=me.sort),me.sortIndex!=null&&(ye.sort.order=me.sortIndex),me.groupIndex!=null&&(ye.group.enabled=!0,ye.group.index=me.groupIndex),me.pivotIndex!=null&&(ye.pivot.enabled=!0,ye.pivot.index=me.pivotIndex),me.total!==void 0&&(ye.total=me.total),me.groupTotal!==void 0&&(ye.groupTotal=me.groupTotal),me.grandTotal!==void 0&&(ye.grandTotal=me.grandTotal),ke.applied.push(me.id)}const xe=Ae||(ge&&ge.keepOrder?[]:Se.map(me=>me&&me.id).filter(Boolean));if(xe.length){const me=xe.filter(Te=>this.#e.has(Te)),ye=this.#t.filter(Te=>!me.includes(Te));this.#t=[...me,...ye]}return this.#w&&this.#w("state",ke),ke}move(ie,ge){this.#M(ie,ge)&&(this.#$(),this.#w&&this.#w("move",{id:ie,to:ge}))}reorder(ie){const ge={applied:[],skipped:[]},ke=[];let Se=0;for(const Ae of Array.isArray(ie)?ie:[]){const xe=Se++;this.#M(Ae,xe)&&(ge.applied.push(Ae),ke.push({id:Ae,to:xe}))}if(!ke.length)return ge;if(this.#$(),this.#w)for(const Ae of ke)this.#w("move",Ae);return ge}#M(ie,ge){const ke=this.#t.indexOf(ie);if(ke===-1||Math.max(0,Math.min(Number(ge)||0,this.#t.length-1))===ke)return!1;const Ae=this.#e.get(ie);if(Ae.layout.movable===!1||Ae.layout.lockPosition)return K(`move:${ie}`,`column "${ie}" is not movable; the move was ignored`),!1;const xe=this.#R(ie,ge);return xe?(K(`move.married:${xe}`,`band "${xe}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(ke,1),this.#t.splice(Math.max(0,Math.min(ge,this.#t.length)),0,ie),!0)}#R(ie,ge){if(!this.#n||!this.#n.length)return null;const ke=this.#t.filter(me=>me!==ie),Se=Math.max(0,Math.min(ge,ke.length)),Ae=(me,ye)=>{if(Array.isArray(me.columns)){for(const Ye of me.columns)Ae(Ye,ye);return ye}const Te=me.column?me.column.id:me.id;return Te&&ye.push(Te),ye},xe=me=>{for(const ye of me){if(!Array.isArray(ye.columns))continue;if(ye.marryChildren===!0){const Ye=Ae(ye,[]),Oe=Ye.includes(ie),_e=Ye.map(je=>ke.indexOf(je)).filter(je=>je>=0);if(_e.length){const je=Math.min(..._e),we=Math.max(..._e);if(Oe?Se<je||Se>we+1:Se>je&&Se<=we)return ye.id}}const Te=xe(ye.columns);if(Te)return Te}return null};return xe(this.#n)}#$(){const ie=new Map(this.#t.map((Se,Ae)=>[Se,Ae])),ge=Se=>{if(!Array.isArray(Se.columns)){const xe=Se.column?Se.column.id:Se.id;return ie.has(xe)?ie.get(xe):1/0}let Ae=1/0;for(const xe of Se.columns)Ae=Math.min(Ae,ge(xe));return Ae},ke=Se=>{Se.sort((Ae,xe)=>ge(Ae)-ge(xe));for(const Ae of Se)Array.isArray(Ae.columns)&&ke(Ae.columns)};ke(this.#n)}#G(ie){const ge=ke=>{for(let Se=0;Se<ke.length;Se++){const Ae=ke[Se];if(Array.isArray(Ae.columns)){const xe=ge(Ae.columns);if(xe)return xe}else if(Ae.column&&Ae.column.id===ie)return ke.splice(Se,1)[0]}return null};return ge(this.#n)}#V(ie){const ge=[];for(let ke=ie.length-1;ke>=0;ke--){const Se=ie[ke];Array.isArray(Se.columns)&&(ge.push(...this.#V(Se.columns)),Se.columns.length===0&&(ge.push(Se.id),ie.splice(ke,1)))}return ge}#F(){const ie=(ge,ke,Se)=>{for(const Ae of ge)Array.isArray(Ae.columns)?ie(Ae.columns,[...ke,Ae.id]):Ae.column&&(Ae.column.groupPath=ke)};ie(this.#n,[])}#x(ie){const ge=new Set(ie),ke=this.#t.filter(me=>ge.has(me));if(!ke.length)return;const Se=Math.min(...ke.map(me=>this.#t.indexOf(me))),Ae=this.#t.slice(0,Se).filter(me=>!ge.has(me)),xe=this.#t.slice(Se).filter(me=>!ge.has(me));this.#t=[...Ae,...ke,...xe]}#Y(ie){const ge=[],ke=Se=>{if(Array.isArray(Se.columns))for(const Ae of Se.columns)ke(Ae);else Se.column&&ge.push(Se.column.id)};return ke(ie),ge}#D(ie){const ge=ke=>{for(const Se of ke){if(!Array.isArray(Se.columns))continue;if(Se.id===ie)return{node:Se,parent:ke};const Ae=ge(Se.columns);if(Ae)return Ae}return null};return ge(this.#n)}groupColumns(ie,ge={}){const ke=B(ie).filter(ye=>this.#e.has(ye));if(!ke.length)return K("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const ye of ke)if(this.#e.get(ye).layout.lockPosition)return K(`columns.group.locked:${ye}`,`column "${ye}" is position-locked and cannot be grouped.`),null;const Se=ge.groupId?this.#D(ge.groupId):null;if(ge.groupId&&!Se)return K(`columns.group.unknown:${ge.groupId}`,`no band "${ge.groupId}" to add to; nothing was grouped.`),null;let Ae=null;if(!Se&&ge.id!=null&&(Ae=String(ge.id),this.#D(Ae)||this.#e.has(Ae)))return K(`columns.group.idtaken:${Ae}`,`band id "${Ae}" is already in use; nothing was grouped.`),null;const xe=ke.map(ye=>this.#G(ye)).filter(Boolean);if(!xe.length)return null;let me;if(Se)Se.node.columns.push(...xe),me=Se.node.id;else{const ye={id:Ae||t("grp"),title:ge.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:xe},Te=Number.isInteger(ge.at)?Math.max(0,Math.min(ge.at,this.#n.length)):this.#n.length;this.#n.splice(Te,0,ye),me=ye.id}return this.#V(this.#n),this.#x(ke),this.#F(),this.#$(),this.#w&&this.#w("columngroup",{action:"formed",groupId:me,ids:ke}),me}ungroupColumn(ie){const ge=this.#e.get(ie);if(!ge){K(`columns.ungroup.unknown:${ie}`,`no column "${ie}" to ungroup.`);return}const ke=ge.groupPath||[];if(!ke.length)return;const Se=ke[ke.length-1],Ae=this.#D(Se);if(!Ae)return;const xe=this.#G(ie);if(!xe)return;const me=Ae.parent.indexOf(Ae.node);Ae.parent.splice(me+1,0,xe);const ye=this.#V(this.#n),Te=this.#Y(Ae.node);if(Te.length){this.#x(Te);const Ye=Math.max(...Te.map(_e=>this.#t.indexOf(_e))),Oe=this.#t.filter(_e=>_e!==ie);Oe.splice(Ye+1,0,ie),this.#t=Oe}this.#F(),this.#$(),this.#w&&this.#w("columngroup",{action:"removed",id:ie,dissolved:ye})}renameGroup(ie,ge){const ke=this.#D(ie);if(!ke){K(`columns.group.rename:${ie}`,`no band "${ie}" to rename.`);return}ke.node.title=String(ge??""),this.#w&&this.#w("columngroup",{action:"renamed",groupId:ie,title:ke.node.title})}dissolveGroup(ie){const ge=this.#D(ie);if(!ge){K(`columns.group.dissolve:${ie}`,`no band "${ie}" to dissolve.`);return}const ke=ge.parent.indexOf(ge.node);ge.parent.splice(ke,1,...ge.node.columns),this.#F(),this.#$(),this.#w&&this.#w("columngroup",{action:"dissolved",groupId:ie})}moveGroup(ie,ge){const ke=this.#D(ie);if(!ke){K(`columns.group.move:${ie}`,`no band "${ie}" to move.`);return}const Se=ke.parent,Ae=Se.indexOf(ke.node);Ae!==-1&&(Se.splice(Ae,1),Se.splice(Math.max(0,Math.min(ge,Se.length)),0,ke.node),this.#K(),this.#F(),this.#w&&this.#w("columngroup",{action:"moved",groupId:ie,to:ge}))}#K(){const ie=[],ge=Se=>{for(const Ae of Se)Array.isArray(Ae.columns)?ge(Ae.columns):Ae.column&&ie.push(Ae.column.id)};ge(this.#n);const ke=new Set(ie);this.#t=[...ie,...this.#t.filter(Se=>!ke.has(Se))]}groupTree(){const ie=ke=>ke.map(Se=>Array.isArray(Se.columns)?{id:Se.id,title:Se.title||"",collapsible:!!Se.collapsible,openByDefault:Se.openByDefault!==!1,columns:ie(Se.columns)}:Se.column?Se.column.id:null).filter(Se=>Se!==null),ge=ie(this.#n);return ge.some(ke=>ke&&typeof ke=="object")?ge:[]}applyGroupTree(ie){if(!Array.isArray(ie))return;const ge=new Set,ke=Ae=>{const xe=[];for(const me of Ae)if(me&&typeof me=="object"&&Array.isArray(me.columns)){const ye=ke(me.columns);if(!ye.length)continue;xe.push({id:me.id||t("grp"),title:me.title||"",collapsible:me.collapsible===!0,openByDefault:me.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:ye})}else if(typeof me=="string"){const ye=this.#e.get(me);ye&&!ge.has(me)&&(ge.add(me),xe.push({column:ye,path:[]}))}return xe},Se=ke(ie);for(const Ae of this.#t){if(ge.has(Ae))continue;const xe=this.#e.get(Ae);xe&&Se.push({column:xe,path:[]})}this.#n=Se,this.#F(),this.#$(),this.#w&&this.#w("columngroup",{action:"applied"})}show(ie){this.#H(ie,!1)}hide(ie){this.#H(ie,!0)}#H(ie,ge){const ke=[];for(const Se of B(ie)){const Ae=this.#e.get(Se);if(Ae){if(ge&&Ae.layout.lockVisible){K(`lockVisible:${Se}`,`column "${Se}" is \`layout.lockVisible\` and cannot be hidden`);continue}Ae.layout.hidden!==ge&&(Ae.layout.hidden=ge,ke.push(Se))}}ke.length&&this.#w&&this.#w("visible",{ids:ke,hidden:ge})}pin(ie,ge){const ke=this.#e.get(ie);ke&&(ke.layout.pin=ge??null,this.#w&&this.#w("pin",{id:ie,side:ke.layout.pin}))}pinMany(ie){const ge={};for(const[Se,Ae]of ie){const xe=this.#e.get(Se);xe&&(xe.layout.pin=Ae??null,ge[Se]=xe.layout.pin)}const ke=Object.keys(ge);ke.length&&this.#w&&this.#w("pin",{ids:ke,pins:ge})}#B(ie,ge){const ke=ie.layout.min??0,Se=ie.layout.max;let Ae=Math.max(ke,ge);return Se!=null&&(Ae=Math.min(Se,Ae)),ie.layout.width=Ae,ie.layout.flex=0,Ae}resize(ie,ge){const ke=this.#e.get(ie);if(!ke)return;if(ke.layout.resizable===!1){K(`resize:${ie}`,`column "${ie}" is not resizable; the resize was ignored`);return}const Se=this.#B(ke,ge);this.#w&&this.#w("resize",{id:ie,width:Se})}resizeMany(ie){const ge={};for(const[Se,Ae]of ie){const xe=this.#e.get(Se);if(xe){if(xe.layout.resizable===!1){K(`resize:${Se}`,`column "${Se}" is not resizable; the resize was ignored`);continue}ge[Se]=this.#B(xe,Ae)}}const ke=Object.keys(ge);ke.length&&this.#w&&this.#w("resize",{ids:ke,widths:ge})}}function fe(Le){const ie={};return Le.width!=null&&(ie.width=Le.width),Le.hidden!=null&&(ie.hidden=Le.hidden),Le.pin!==void 0&&(ie.pin=Le.pin),ie}function pe(Le){if(Le===null||typeof Le!="object")return Le;try{return structuredClone(Le)}catch{}try{return JSON.parse(JSON.stringify(Le))}catch{return Le}}function he(Le,ie){const ge=Le??null,ke=ie??null;if(ge===ke)return!0;if(ge===null||ke===null)return!1;if(typeof ge!="object"||typeof ke!="object")return ge===ke;try{return JSON.stringify(ge)===JSON.stringify(ke)}catch{return!1}}function Re(Le){const ie=[],ge=(Se,Ae,xe)=>{const me=[];for(const ye of Se){if(!a(ye)){q("a column definition must be an object");continue}if(Array.isArray(ye.columns)){J(ye,_,"columnGroup",ye.title||ye.id||"(unnamed)");const Te={id:ye.id||t("grp"),title:ye.title||"",collapsible:ye.collapsible===!0,openByDefault:ye.openByDefault!==!1,showWhen:ye.showWhen||"always",marryChildren:ye.marryChildren===!0,header:ye.header||{},def:ye,columns:[]};Te.columns=ge(ye.columns,[...Ae,Te.id],ye.facet!==void 0?ye.facet:xe),me.push(Te)}else{const Te={def:ye,path:Ae,facet:xe};ie.push(Te),me.push(Te)}}return me},ke=ge(Le,[],void 0);return{leaves:ie,groups:ke}}function Ue(Le,ie,ge){for(const ke of Le){if(ke.columns){if(Ue(ke.columns,ie,ge))return!0;continue}if(ke.column&&ke.column.id===ie)return ke.column=ge,!0}return!1}}),Ie("packages/core/src/columns/autogroup.js",function(e,U){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return K}});const N=U("packages/core/src/internal/warn.js").warnOnce,X="__lattice_group",B=240,D=.5;function q(x){const{columns:G,groupBy:z}=x,j=z.map(u=>G.get(u)).filter(Boolean),O=j.length?j.map(u=>u.title||u.id).join(" > "):"Group",b=x.config&&x.config.autoGroupColumnWidth||B;return{id:X,field:null,title:O,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!0},groupedIds:z.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:b,min:120,pin:x.config&&x.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(u,f){return f&&f.group?f.groupValue:null},formatValue(u,f){if(!f||!f.group)return"";if(f.grandTotal)return x.config&&x.config.grandTotalLabel||"Total";const a=j[Math.min(f.level||0,j.length-1)];return a&&typeof a.formatValue=="function"?a.formatValue(u,f):u==null?"":String(u)}}}function K(x,G,z){!x.length||z<100||G<z*D||N(`grouping.cardinality:${x.join(",")}`,`grouping by ${x.join(", ")} produced ${G} 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.`)}}),Ie("packages/core/src/columns/selectcolumn.js",function(e,U){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return B}});const te="__lattice_select",N=44;function X(D){const q=D.selection||{},K=D.config&&D.config.selectionColumnWidth||N;return{id:te,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:K,min:K,max:K,pin:D.config&&D.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:q.headerCheckbox===!0,def:{},getValue(x,G){return G?G.selected:!1},formatValue(){return""}}}const B=X}),Ie("packages/core/src/columns/rownumbercolumn.js",function(e,U){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return G}});const N=U("packages/core/src/internal/predicates.js").isFunction,X="__lattice_rownumber",B=40,D=9,q=22;function K(z){const j=String(Math.max(1,Math.trunc(Math.abs(z))||1)).length;return Math.max(B,j*D+q)}function x(z){const j=z.rowNumbers,O=j&&typeof j=="object"?j:{},b=Number.isFinite(O.start)?O.start:1,u=Number.isFinite(O.width)?O.width:K((z.maxNumber||0)+b),f=N(z.rank)?z.rank:()=>null;return{id:X,field:null,title:typeof O.title=="string"?O.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:u,min:u,max:u,pin:"start",hidden:!1,resizable:O.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(a,r){const t=f(r);return t==null?null:t-1+b},formatValue(a){return a==null?"":String(a)}}}const G=x}),Ie("packages/core/src/model/detail.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return G}});const N=U("packages/core/src/internal/predicates.js").isFunction,B=U("packages/core/src/internal/warn.js").warnOnce,D=240,q=10;function K(z){if(!z)return null;const j=z===!0?{}:z;return j.enabled===!1?null:!N(j.rows)&&!j.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:j.render||null,config:j.config||null,rows:N(j.rows)?j.rows:null,height:j.height??D,maxHeight:j.maxHeight??null,cacheLimit:Number.isFinite(j.cacheLimit)?Math.max(0,j.cacheLimit):q,isMaster:N(j.isMaster)?j.isMaster:null,target:j.target||null,onCreate:N(j.onCreate)?j.onCreate:null,path:typeof j.path=="string"?j.path:null}}class x{#e;#t=new Set;#n;#r=0;constructor(j){this.#e=j.config,this.#n=N(j.onChange)?j.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(j){if(!j||j.group||j.detail)return!1;const O=this.#e.isMaster;return O?!!O(j.data,j):!0}isOpen(j){return this.#t.has(j)}keys(){return[...this.#t]}activeKey(){for(const j of this.#t)return j;return null}heightOf(j){const O=this.#e.height;return N(O)?Number(O(j))||D:O==="auto"?D:Number(O)||D}open(j){return this.#t.has(j)?!1:(this.inline||this.#t.clear(),this.#t.add(j),this.#i(),!0)}close(j){return this.#t.delete(j)?(this.#i(),!0):!1}toggle(j){return this.#t.has(j)?(this.close(j),!1):(this.open(j),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#i())}prune(j){if(!this.#t.size||!N(j))return;let O=!1;for(const b of[...this.#t])j(b)||(this.#t.delete(b),O=!0);O&&this.#i()}signature(){return`${this.#r}`}set(j){this.#t.clear();const O=Array.isArray(j)?j:[];for(const b of this.inline?O:O.slice(0,1))this.#t.add(b);this.#i()}#i(){this.#r++,this.#n()}}const G=x}),Ie("packages/core/src/compute/special.js",function(e,U){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return a}});const te=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),N=3e-12,X=1e-300;function B(r){if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-B(1-r);const t=r-1;let s=.9999999999998099;const i=t+7.5;for(let n=0;n<te.length;n++)s+=te[n]/(t+n+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(i)-i+Math.log(s)}function D(r,t,s){const i=r+t,n=r+1,c=r-1;let o=1,l=1-i*s/n;Math.abs(l)<X&&(l=X),l=1/l;let h=l;for(let w=1;w<=300;w++){const g=2*w;let k=w*(t-w)*s/((c+g)*(r+g));l=1+k*l,Math.abs(l)<X&&(l=X),o=1+k/o,Math.abs(o)<X&&(o=X),l=1/l,h*=l*o,k=-(r+w)*(i+w)*s/((r+g)*(n+g)),l=1+k*l,Math.abs(l)<X&&(l=X),o=1+k/o,Math.abs(o)<X&&(o=X),l=1/l;const d=l*o;if(h*=d,Math.abs(d-1)<N)break}return h}function q(r,t,s){if(!(r>0)||!(t>0)||!Number.isFinite(s))return Number.NaN;if(s<=0)return 0;if(s>=1)return 1;const i=Math.exp(B(r+t)-B(r)-B(t)+r*Math.log(s)+t*Math.log(1-s));return s<(r+1)/(r+t+2)?i*D(r,t,s)/r:1-i*D(t,r,1-s)/t}function K(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],s=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],i=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],n=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],c=.02425;let o,l,h;r<c?(o=Math.sqrt(-2*Math.log(r)),h=(((((i[0]*o+i[1])*o+i[2])*o+i[3])*o+i[4])*o+i[5])/((((n[0]*o+n[1])*o+n[2])*o+n[3])*o+1)):r<=1-c?(o=r-.5,l=o*o,h=(((((t[0]*l+t[1])*l+t[2])*l+t[3])*l+t[4])*l+t[5])*o/(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+1)):(o=Math.sqrt(-2*Math.log(1-r)),h=-(((((i[0]*o+i[1])*o+i[2])*o+i[3])*o+i[4])*o+i[5])/((((n[0]*o+n[1])*o+n[2])*o+n[3])*o+1));const g=(.5*x(-h/Math.SQRT2)-r)*Math.sqrt(2*Math.PI)*Math.exp(h*h/2);return h-g/(1+h*g/2)}function x(r){const t=Math.abs(r),s=2/(2+t),i=4*s-2,n=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let c=0,o=0,l;for(let w=n.length-1;w>0;w--)l=o,o=i*o-c+n[w],c=l;const h=s*Math.exp(-t*t+.5*(n[0]+i*o)-c);return r>=0?h:2-h}function G(r){return .5*x(-r/Math.SQRT2)}function z(r,t){if(!(t>0)||!Number.isFinite(r))return Number.NaN;const s=.5*q(t/2,.5,t/(t+r*r));return r>0?1-s:s}function j(r,t){if(!(r>0)||!(r<1)||!(t>0))return Number.NaN;if(t>1e7)return K(r);let s=-1e4,i=1e4,n=K(r);const c=B(t/2)+B(.5)-B((t+1)/2);for(let o=0;o<60;o++){const l=z(n,t);l<r?s=n:i=n;const h=Math.exp(-((t+1)/2)*Math.log(1+n*n/t)-c)/Math.sqrt(t),w=h>0?(l-r)/h:0;if(Math.abs(w)<1e-12)break;const g=n-w;if(n=g>s&&g<i&&Number.isFinite(g)?g:(s+i)/2,i-s<1e-12)break}return n}function O(r,t){let s=r,i=1/r,n=i;for(let c=0;c<300&&(s+=1,n*=t/s,i+=n,!(Math.abs(n)<Math.abs(i)*N));c++);return i*Math.exp(-t+r*Math.log(t)-B(r))}function b(r,t){let s=t+1-r,i=1/X,n=1/s,c=n;for(let o=1;o<=300;o++){const l=-o*(o-r);s+=2,n=l*n+s,Math.abs(n)<X&&(n=X),i=s+l/i,Math.abs(i)<X&&(i=X),n=1/n;const h=n*i;if(c*=h,Math.abs(h-1)<N)break}return Math.exp(-t+r*Math.log(t)-B(r))*c}function u(r,t){return!(r>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<r+1?O(r,t):1-b(r,t)}function f(r,t){return t>0?u(t/2,r/2):Number.NaN}function a(r,t){const s=f(r,t);return Number.isNaN(s)?Number.NaN:Math.min(1,Math.max(0,1-s))}}),Ie("packages/core/src/compute/linalg.js",function(e,U){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return q}});function te(K){const x=K.length,G=Array.from({length:x},()=>new Array(x).fill(0));for(let z=0;z<x;z++)for(let j=0;j<=z;j++){let O=K[z][j];for(let b=0;b<j;b++)O-=G[z][b]*G[j][b];if(z===j){if(!(O>0))return null;G[z][j]=Math.sqrt(O)}else G[z][j]=O/G[j][j]}return G}function N(K,x){const G=K.length,z=new Array(G).fill(0);for(let O=0;O<G;O++){let b=x[O];for(let u=0;u<O;u++)b-=K[O][u]*z[u];z[O]=b/K[O][O]}const j=new Array(G).fill(0);for(let O=G-1;O>=0;O--){let b=z[O];for(let u=O+1;u<G;u++)b-=K[u][O]*j[u];j[O]=b/K[O][O]}return j}function X(K){const x=K.length,G=Array.from({length:x},()=>new Array(x).fill(0));for(let z=0;z<x;z++){const j=new Array(x).fill(0);j[z]=1;const O=N(K,j);for(let b=0;b<x;b++)G[b][z]=O[b]}return G}function B(K,x,G){const z=K.length,j=z?K[0].length:0,O=Array.from({length:j},()=>new Array(j).fill(0)),b=new Array(j).fill(0);for(let u=0;u<z;u++){const f=G?G[u]:1,a=K[u];for(let r=0;r<j;r++){const t=f*a[r];b[r]+=t*x[u];for(let s=r;s<j;s++)O[r][s]+=t*a[s]}}for(let u=0;u<j;u++)for(let f=0;f<u;f++)O[u][f]=O[f][u];return{xtwx:O,xtwy:b}}function D(K,x){return K.map(G=>G.reduce((z,j,O)=>z+j*x[O],0))}function q(K,x){let G=0;for(let z=0;z<K.length;z++){let j=0;for(let O=0;O<K.length;O++)j+=x[z][O]*K[O];G+=K[z]*j}return G}}),Ie("packages/core/src/compute/sketch.js",function(e,U){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});class te{#e=0;#t=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#e}add(u){if(!Number.isFinite(u))return;this.#e++;const f=u-this.#t;this.#t+=f/this.#e,this.#n+=f*(u-this.#t)}merge(u){if(u.#e===0)return;if(this.#e===0){this.#e=u.#e,this.#t=u.#t,this.#n=u.#n;return}const f=this.#e+u.#e,a=u.#t-this.#t;this.#t+=a*(u.#e/f),this.#n+=u.#n+a*a*(this.#e*u.#e/f),this.#e=f}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 u=this.variance();return u===null?null:Math.sqrt(u)}stddevP(){const u=this.varianceP();return u===null?null:Math.sqrt(u)}}class N{#e=[];#t=0;#n;#r;constructor(u,f=Math.random){if(!(u>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(u),this.#r=f}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(u){if(!Number.isFinite(u))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(u);return}const f=Math.floor(this.#r()*this.#t);f<this.#n&&(this.#e[f]=u)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let u=0;for(const f of this.#e)u+=f;return u/this.#e.length}quantile(u){const f=this.#e.length;if(!f)return null;const a=this.#e.slice().sort((i,n)=>i-n);if(f===1)return a[0];const r=(f-1)*Math.min(1,Math.max(0,u)),t=Math.floor(r),s=Math.ceil(r);return t===s?a[t]:a[t]+(r-t)*(a[s]-a[t])}}function X(b){return b^=b>>>16,b=Math.imul(b,2246822507),b^=b>>>13,b=Math.imul(b,3266489909),b^=b>>>15,b>>>0}function B(b){if(typeof b=="number"){const a=new DataView(new ArrayBuffer(8));return a.setFloat64(0,b===0?0:b),X(a.getUint32(0)^a.getUint32(4))}const u=typeof b=="string"?b:String(b);let f=2166136261;for(let a=0;a<u.length;a++)f^=u.charCodeAt(a),f=Math.imul(f,16777619);return X(f)}class D{#e;#t;#n;constructor(u=14){const f=Math.floor(u);if(f<4||f>16)throw new RangeError("HLL precision must be 4..16");this.#e=f,this.#t=1<<f,this.#n=new Uint8Array(this.#t)}static errorBoundFor(u=14){const f=1<<Math.floor(u),a=1.04/Math.sqrt(f);return Object.freeze({kind:"probabilistic",metric:"relative",value:a,statement:`distinct count within ~${(a*100).toFixed(2)}% relative standard error (m=${f} buckets)`})}errorBound(){return D.errorBoundFor(this.#e)}add(u){const f=B(u),a=f&this.#t-1,r=f>>>this.#e|1<<32-this.#e;let t=1,s=r;for(;(s&1)===0;)t++,s>>>=1;t>this.#n[a]&&(this.#n[a]=t)}count(){const u=this.#t,f=32-this.#e,a=new Float64Array(f+2);for(let s=0;s<u;s++)a[this.#n[s]]++;let r=u*x(1-a[f+1]/u);for(let s=f;s>=1;s--)r=.5*(r+a[s]);r+=u*K(a[0]/u);const t=q*u*u/r;return Math.round(t)}}const q=.5/Math.log(2);function K(b){if(b===1)return 1/0;let u=1,f=b,a;do b*=b,a=f,f+=b*u,u+=u;while(f!==a);return f}function x(b){if(b===0||b===1)return 0;let u=1,f=1-b,a;do b=Math.sqrt(b),a=f,u*=.5,f-=(1-b)**2*u;while(f!==a);return f/3}class G{#e=new Map;#t;#n=0;constructor(u){if(!(u>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(u)}errorBoundFor(u){const f=u/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:f,statement:`each count overestimates the truth by at most N/m = ${f.toFixed(2)} (N=${u}, m=${this.#t})`})}get seen(){return this.#n}add(u){this.#n++;const f=this.#e.get(u);if(f){f.count++;return}if(this.#e.size<this.#t){this.#e.set(u,{count:1,error:0});return}let a,r=1/0;for(const[t,s]of this.#e)s.count<r&&(r=s.count,a=t);this.#e.delete(a),this.#e.set(u,{count:r+1,error:r})}top(u=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(u)))}}class z{#e;#t=[[]];#n=0;#r;#i;constructor(u=200,f=Math.random){this.#e=Math.max(8,Math.floor(u)),this.#r=f,this.#i=2/3}static errorBoundFor(u=200){const f=1/Math.max(8,Math.floor(u));return Object.freeze({kind:"probabilistic",metric:"rank",value:f,statement:`queried quantile's true rank within ~${(f*100).toFixed(2)}% of N of the requested rank (k=${u})`})}errorBound(){return z.errorBoundFor(this.#e)}get count(){return this.#n}#s(u){const a=this.#t.length-1-u,r=Math.ceil(this.#e*this.#i**a);return Math.max(2,r)}add(u){Number.isFinite(u)&&(this.#n++,this.#t[0].push(u),this.#t[0].length>=this.#s(0)&&this.#o(0))}#o(u){const f=this.#t[u];f.sort((t,s)=>t-s),u+1>=this.#t.length&&this.#t.push([]);const a=this.#t[u+1],r=this.#r()<.5?0:1;for(let t=r;t<f.length;t+=2)a.push(f[t]);this.#t[u]=[];for(let t=0;t<this.#t.length;t++)if(this.#t[t].length>=this.#s(t)){this.#o(t);return}}#l(){const u=[];for(let f=0;f<this.#t.length;f++){const a=1<<f;for(const r of this.#t[f])u.push({v:r,w:a})}return u}quantile(u){const f=this.#l();if(!f.length)return null;f.sort((s,i)=>s.v-i.v);let a=0;for(const s of f)a+=s.w;const r=Math.min(1,Math.max(0,u))*a;let t=0;for(const s of f)if(t+=s.w,t>=r)return s.v;return f[f.length-1].v}rank(u){let f=0;for(let a=0;a<this.#t.length;a++){const r=1<<a;for(const t of this.#t[a])t<=u&&(f+=r)}return f}}const j=Object.freeze({distinct:D.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"})}),O={Welford:te,Reservoir:N,HyperLogLog:D,SpaceSaving:G,KLL:z,hash32:B,SKETCH_BOUNDS:j}}),Ie("packages/core/src/compute/statistics.js",function(e,U){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return at}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return Pe}});const te=U("packages/core/src/compute/handle.js"),N=te.presenceReader,X=te.valueReader,B=U("packages/core/src/compute/special.js"),D=B.studentTQuantile,q=B.studentT,K=B.normalQuantile,x=B.normalCdf,G=B.chiSquareUpperTail,z=U("packages/core/src/compute/linalg.js"),j=z.cholesky,O=z.choleskySolve,b=z.choleskyInverse,u=z.normalEquations,f=z.quadForm,r=U("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,t=5e3,s=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 n(le){const be=le==="sum"||le==="avg"||le==="countValues"||le==="min"||le==="max"?"maintained":Object.prototype.hasOwnProperty.call(s,le)?s[le]:null,ue=Object.prototype.hasOwnProperty.call(i,le)?i[le]:null;return{stat:le,exact:be,approximate:ue}}function c(le,be){const ue=be.length,ve=new Float64Array(ue);let Ce=0;if(le&&(le.kind==="float64"||le.kind==="int32")){const Be=le.values,Ve=N(le);for(let Je=0;Je<ue;Je++){const $e=be[Je];if(Ve&&Ve($e)!==1)continue;const ze=Be[$e];Number.isNaN(ze)||(ve[Ce++]=ze)}return ve.subarray(0,Ce)}const Fe=X(le);for(let Be=0;Be<ue;Be++){const Ve=Fe(be[Be]);if(Ve==null||Ve==="")continue;const Je=typeof Ve=="number"?Ve:Number(Ve);Number.isFinite(Je)&&(ve[Ce++]=Je)}return ve.subarray(0,Ce)}function o(le,be){const ue=new Map,ve=X(le);let Ce=0;for(let Fe=0;Fe<be.length;Fe++){const Be=ve(be[Fe]);if(Be==null||Be===""||typeof Be=="number"&&Number.isNaN(Be))continue;const Ve=typeof Be=="object"?String(Be):Be;ue.set(Ve,(ue.get(Ve)||0)+1),Ce++}const Ee=[...ue.values()].sort((Fe,Be)=>Be-Fe);return{counts:Ee,total:Ce,distinct:Ee.length}}function l(le){return le.total>0?le.counts.map(be=>be/le.total):[]}function h(le,be){const ue=o(le,be);if(!ue.total)return null;let ve=0;for(const Ce of l(ue))ve+=Ce*Ce;return ve}function w(le,be){const ue=o(le,be);if(!ue.total)return null;let ve=0;for(const Ce of l(ue))Ce>0&&(ve-=Ce*Math.log2(Ce));return ve}function g(le,be){const ue=o(le,be);if(!ue.total||ue.distinct<2)return ue.total?1:null;let ve=0;for(const Ce of l(ue))Ce>0&&(ve-=Ce*Math.log2(Ce));return ve/Math.log2(ue.distinct)}function k(le,be,ue=3){const ve=o(le,be);if(!ve.total)return null;const Ce=Math.max(1,Math.floor(ue));let Ee=0;for(let Fe=0;Fe<Math.min(Ce,ve.counts.length);Fe++)Ee+=ve.counts[Fe];return Ee/ve.total}function d(le,be){const ue=c(le,be),ve=ue.length;if(!ve)return null;const Ce=ue.slice().sort();if(Ce[0]<0)return null;let Ee=0,Fe=0;for(let Be=0;Be<ve;Be++)Ee+=Ce[Be],Fe+=(Be+1)*Ce[Be];return Ee===0?0:2*Fe/(ve*Ee)-(ve+1)/ve}function p(le){let be=0,ue=0,ve=0;for(let Ce=0;Ce<le.length;Ce++){const Ee=le[Ce];be++;const Fe=Ee-ue;ue+=Fe/be,ve+=Fe*(Ee-ue)}return{n:be,mean:ue,m2:ve}}function m(le,be){const ue=le.length;if(!ue)return NaN;if(ue===1)return le[0];const ve=(ue-1)*Math.min(1,Math.max(0,be)),Ce=Math.floor(ve),Ee=Math.ceil(ve);return Ce===Ee?le[Ce]:le[Ce]+(ve-Ce)*(le[Ee]-le[Ce])}function v(le,be){if(!le.length)return NaN;const ue=le.slice().sort();return m(ue,be)}function y(le,be){const ue=X(le);let ve=0,Ce=0,Ee=0;for(let Fe=0;Fe<be.length;Fe++){const Be=ue(be[Fe]);if(Be==null||Be==="")continue;const Ve=String(Be).toUpperCase();Ve==="PASS"?ve++:Ve==="FAIL"?Ce++:Ve==="WARN"&&Ee++}return{pass:ve+Ee,fail:Ce,warn:Ee,judged:ve+Ee+Ce}}const E=Object.freeze({hhi:(le,be)=>h(le,be),entropy:(le,be)=>w(le,be),evenness:(le,be)=>g(le,be),top3Share:(le,be)=>k(le,be,3),top10Share:(le,be)=>k(le,be,10),gini:(le,be)=>d(le,be),trimmedMean:(le,be)=>$(c(le,be),.1),winsorizedMean:(le,be)=>S(c(le,be),.1),robustOutliers:(le,be)=>R(c(le,be),3.5),jarqueBera:(le,be)=>L(c(le,be)),variance:(le,be)=>{const{n:ue,m2:ve}=p(c(le,be));return ue>1?ve/(ue-1):null},varianceP:(le,be)=>{const{n:ue,m2:ve}=p(c(le,be));return ue>0?ve/ue:null},stddev:(le,be)=>{const{n:ue,m2:ve}=p(c(le,be));return ue>1?Math.sqrt(ve/(ue-1)):null},stddevP:(le,be)=>{const{n:ue,m2:ve}=p(c(le,be));return ue>0?Math.sqrt(ve/ue):null},median:(le,be)=>{const ue=c(le,be);return ue.length?v(ue,.5):null},p25:(le,be)=>{const ue=c(le,be);return ue.length?v(ue,.25):null},p75:(le,be)=>{const ue=c(le,be);return ue.length?v(ue,.75):null},p90:(le,be)=>{const ue=c(le,be);return ue.length?v(ue,.9):null},p95:(le,be)=>{const ue=c(le,be);return ue.length?v(ue,.95):null},p99:(le,be)=>{const ue=c(le,be);return ue.length?v(ue,.99):null},iqr:(le,be)=>{const ue=c(le,be);if(!ue.length)return null;const ve=ue.slice().sort();return m(ve,.75)-m(ve,.25)},mad:(le,be)=>{const ue=c(le,be);if(!ue.length)return null;const ve=v(ue,.5),Ce=new Float64Array(ue.length);for(let Ee=0;Ee<ue.length;Ee++)Ce[Ee]=Math.abs(ue[Ee]-ve);return v(Ce,.5)},range:(le,be)=>{const ue=c(le,be);if(!ue.length)return null;let ve=1/0,Ce=-1/0;for(let Ee=0;Ee<ue.length;Ee++)ue[Ee]<ve&&(ve=ue[Ee]),ue[Ee]>Ce&&(Ce=ue[Ee]);return Ce-ve},distinct:(le,be)=>{const ue=X(le),ve=new Set;for(let Ce=0;Ce<be.length;Ce++){const Ee=ue(be[Ce]);Ee==null||Ee===""||ve.add(Ee instanceof Date?Ee.getTime():Ee)}return ve.size},mode:(le,be)=>{const ue=X(le),ve=new Map;for(let Fe=0;Fe<be.length;Fe++){const Be=ue(be[Fe]);if(Be==null||Be==="")continue;const Ve=Be instanceof Date?Be.getTime():Be;ve.set(Ve,(ve.get(Ve)||0)+1)}let Ce=null,Ee=1;for(const[Fe,Be]of ve)Be>Ee&&(Ee=Be,Ce=Fe);return Ce},skewness:(le,be)=>{const ue=c(le,be),{n:ve,mean:Ce,m2:Ee}=p(ue);if(ve<3||Ee<=0)return null;const Fe=Math.sqrt(Ee/(ve-1));let Be=0;for(let Ve=0;Ve<ue.length;Ve++)Be+=((ue[Ve]-Ce)/Fe)**3;return ve/((ve-1)*(ve-2))*Be},kurtosis:(le,be)=>{const ue=c(le,be),{n:ve,mean:Ce,m2:Ee}=p(ue);if(ve<4||Ee<=0)return null;const Fe=Math.sqrt(Ee/(ve-1));let Be=0;for(let $e=0;$e<ue.length;$e++)Be+=((ue[$e]-Ce)/Fe)**4;const Ve=ve*(ve+1)/((ve-1)*(ve-2)*(ve-3)),Je=3*(ve-1)**2/((ve-2)*(ve-3));return Ve*Be-Je},geomean:(le,be)=>{const ue=c(le,be);if(!ue.length)return null;let ve=0;for(let Ce=0;Ce<ue.length;Ce++){if(ue[Ce]<=0)return null;ve+=Math.log(ue[Ce])}return Math.exp(ve/ue.length)},harmean:(le,be)=>{const ue=c(le,be);if(!ue.length)return null;let ve=0;for(let Ce=0;Ce<ue.length;Ce++){if(ue[Ce]===0)return null;ve+=1/ue[Ce]}return ue.length/ve},sumSquares:(le,be)=>{const ue=c(le,be);let ve=0;for(let Ce=0;Ce<ue.length;Ce++)ve+=ue[Ce]*ue[Ce];return ve},passRate:(le,be)=>{const{pass:ue,judged:ve}=y(le,be);return ve?ue/ve:null},failureCount:(le,be)=>y(le,be).fail}),M=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(le,be,ue){const ve=X(le),Ce=X(be);let Ee=0,Fe=0;for(let Be=0;Be<ue.length;Be++){const Ve=ue[Be],Je=Number(ve(Ve)),$e=Number(Ce(Ve));!Number.isFinite(Je)||!Number.isFinite($e)||(Ee+=Je*$e,Fe+=$e)}return Fe===0?null:Ee/Fe}function V(le,be,ue){const ve=X(le);let Ce=null,Ee=ue?-1/0:1/0;for(let Fe=0;Fe<be.length;Fe++){const Be=be[Fe],Ve=Number(ve(Be));Number.isFinite(Ve)&&(ue?Ve>Ee:Ve<Ee)&&(Ee=Ve,Ce=Be)}return Ce}function I(le,be,ue){const ve=X(le),Ce=X(be);let Ee=0,Fe=0,Be=0,Ve=0,Je=0,$e=0;for(let et=0;et<ue.length;et++){const dt=ue[et],ft=Number(ve(dt)),lt=Number(Ce(dt));!Number.isFinite(ft)||!Number.isFinite(lt)||(Ee++,Fe+=ft,Be+=lt,Ve+=ft*ft,Je+=lt*lt,$e+=ft*lt)}if(Ee<2)return null;const ze=Ee*$e-Fe*Be,Qe=Math.sqrt((Ee*Ve-Fe*Fe)*(Ee*Je-Be*Be));if(Qe===0)return null;const tt=ze/Qe;return Math.max(-1,Math.min(1,tt))}function $(le,be=.1){const ue=le.length;if(!ue)return null;const ve=Array.from(le).sort((Be,Ve)=>Be-Ve),Ce=Math.floor(ue*Math.min(.49,Math.max(0,be))),Ee=ve.slice(Ce,ue-Ce);if(!Ee.length)return m(ve,.5);let Fe=0;for(const Be of Ee)Fe+=Be;return Fe/Ee.length}function S(le,be=.1){const ue=le.length;if(!ue)return null;const ve=Array.from(le).sort((Ve,Je)=>Ve-Je),Ce=Math.floor(ue*Math.min(.49,Math.max(0,be))),Ee=ve[Ce],Fe=ve[ue-1-Ce];let Be=0;for(const Ve of ve)Be+=Math.min(Fe,Math.max(Ee,Ve));return Be/ue}function R(le,be=3.5){if(!le.length)return null;const ve=Array.from(le).sort((Ve,Je)=>Ve-Je),Ce=m(ve,.5),Ee=ve.map(Ve=>Math.abs(Ve-Ce)).sort((Ve,Je)=>Ve-Je),Fe=m(Ee,.5);if(Fe===0)return null;let Be=0;for(const Ve of ve)Math.abs(.6745*(Ve-Ce)/Fe)>be&&Be++;return Be}function L(le){const be=le.length;if(be<8)return null;let ue=0;for(const Ve of le)ue+=Ve;ue/=be;let ve=0,Ce=0,Ee=0;for(const Ve of le){const Je=Ve-ue;ve+=Je*Je,Ce+=Je*Je*Je,Ee+=Je*Je*Je*Je}if(ve/=be,Ce/=be,Ee/=be,ve===0)return null;const Fe=Ce/ve**1.5,Be=Ee/(ve*ve)-3;return be/6*(Fe*Fe+Be*Be/4)}function T(le,be,ue){const ve=[];let Ce=0;for(let Ve=0;Ve<le.length;Ve++){const Je=Number(le[Ve]),$e=Number(be[Ve]);!Number.isFinite(Je)||!Number.isFinite($e)||$e<=0||(ve.push([Je,$e]),Ce+=$e)}if(!ve.length||Ce<=0)return null;if(ve.sort((Ve,Je)=>Ve[0]-Je[0]),ve.length===1)return ve[0][0];const Ee=[];let Fe=0;for(const[,Ve]of ve)Ee.push((Fe+Ve/2)/Ce),Fe+=Ve;const Be=Math.max(0,Math.min(1,ue));if(Be<=Ee[0])return ve[0][0];if(Be>=Ee[Ee.length-1])return ve[ve.length-1][0];for(let Ve=1;Ve<Ee.length;Ve++){if(Be>Ee[Ve])continue;const Je=Ee[Ve]-Ee[Ve-1],$e=Je>0?(Be-Ee[Ve-1])/Je:0;return ve[Ve-1][0]+(ve[Ve][0]-ve[Ve-1][0])*$e}return ve[ve.length-1][0]}function A(le,be,ue){const ve=X(le),Ce=X(be),Ee=new Float64Array(ue.length),Fe=new Float64Array(ue.length);let Be=0;for(let Ve=0;Ve<ue.length;Ve++){const Je=ue[Ve],$e=Number(ve(Je)),ze=Number(Ce(Je));!Number.isFinite($e)||!Number.isFinite(ze)||(Ee[Be]=$e,Fe[Be]=ze,Be++)}return{xs:Ee.subarray(0,Be),ys:Fe.subarray(0,Be),n:Be}}function C(le,be,ue,ve=!1){const{xs:Ce,ys:Ee,n:Fe}=A(le,be,ue);if(Fe<2)return null;let Be=0,Ve=0;for(let $e=0;$e<Fe;$e++)Be+=Ce[$e],Ve+=Ee[$e];Be/=Fe,Ve/=Fe;let Je=0;for(let $e=0;$e<Fe;$e++)Je+=(Ce[$e]-Be)*(Ee[$e]-Ve);return Je/(ve?Fe:Fe-1)}function H(le,be,ue){const{xs:ve,ys:Ce,n:Ee}=A(le,be,ue);if(Ee<2)return null;let Fe=0,Be=0;for(let ft=0;ft<Ee;ft++)Fe+=ve[ft],Be+=Ce[ft];Fe/=Ee,Be/=Ee;let Ve=0,Je=0,$e=0;for(let ft=0;ft<Ee;ft++){const lt=ve[ft]-Fe,jt=Ce[ft]-Be;Ve+=lt*lt,Je+=lt*jt,$e+=jt*jt}if(Ve===0)return null;const ze=Je/Ve,Qe=Be-ze*Fe,tt=$e===0?1:Math.max(0,Math.min(1,Je*Je/(Ve*$e))),et=Math.max(0,$e-ze*Je),dt=Ee>2?Math.sqrt(et/(Ee-2)/Ve):0;return{slope:ze,intercept:Qe,r2:tt,stdError:dt,n:Ee}}const Y=new Set(["ols","wls","robust"]),Z=new Set(["quantile"]),_=new Set(["ridge","lasso","elasticnet","mixed","gls"]),J=1.345;function ee(le,be,ue){const{xtwx:ve,xtwy:Ce}=u(le,be,ue),Ee=j(ve);if(!Ee)return null;const Fe=O(Ee,Ce),Be=b(Ee),Ve=ne(le,Fe),Je=be.map(($e,ze)=>$e-Ve[ze]);return{beta:Fe,cov:Be,fitted:Ve,residuals:Je}}function ne(le,be){return le.map(ue=>ue.reduce((ve,Ce,Ee)=>ve+Ce*be[Ee],0))}function se(le,be){const ue=le.length,ve=le.map(Je=>Je[be]),Ce=le.map(Je=>[1,...Je.filter(($e,ze)=>ze!==be)]),Ee=ee(Ce,ve,null);if(!Ee)return 1;const Fe=ve.reduce((Je,$e)=>Je+$e,0)/ue;let Be=0,Ve=0;for(let Je=0;Je<ue;Je++)Be+=Ee.residuals[Je]**2,Ve+=(ve[Je]-Fe)**2;return Ve===0?1:Math.max(0,Math.min(1,1-Be/Ve))}function oe(le){const be=[...le].sort((Ce,Ee)=>Ce-Ee),ue=fe(be),ve=le.map(Ce=>Math.abs(Ce-ue)).sort((Ce,Ee)=>Ce-Ee);return fe(ve)/.6745}function fe(le){const be=le.length;if(!be)return 0;const ue=Math.floor(be/2);return be%2?le[ue]:(le[ue-1]+le[ue])/2}function pe(le,be,ue={}){const ve=ue.method||"ols";if(_.has(ve))throw new Error(`[lattice] regression method "${ve}" is out of scope; use ols, wls or robust.`);if(Z.has(ve))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!Y.has(ve))throw new Error(`[lattice] unknown regression method "${ve}"; use ols, wls or robust.`);const Ce=Array.isArray(be)?be.length:0,Ee=Ce&&Array.isArray(le[0])?le[0].length:0,Fe=Ee+1;if(!(Ce>Fe))return null;for(let Lt=0;Lt<Ce;Lt++){if(!Number.isFinite(be[Lt])||!Array.isArray(le[Lt])||le[Lt].length!==Ee)return null;for(let Dt=0;Dt<Ee;Dt++)if(!Number.isFinite(le[Lt][Dt]))return null}let Be=null;if(ve==="wls"){if(Be=ue.weights,!Array.isArray(Be)||Be.length!==Ce)return null;for(let Lt=0;Lt<Ce;Lt++)if(!(Be[Lt]>0)||!Number.isFinite(Be[Lt]))return null}const Ve=le.map(Lt=>[1,...Lt]);let Je,$e=null;if(ve==="robust"){if(Je=ee(Ve,be,null),!Je)return null;for(let Lt=0;Lt<50;Lt++){const Dt=oe(Je.residuals);if(!(Dt>0))break;const zt=Je.residuals.map(Qt=>{const Xt=Math.abs(Qt/Dt);return Xt<=J?1:J/Xt}),Kt=ee(Ve,be,zt);if(!Kt)return null;const qt=Kt.beta.reduce((Qt,Xt,nn)=>Math.max(Qt,Math.abs(Xt-Je.beta[nn])),0);if(Je=Kt,$e=zt,qt<1e-10)break}}else if(Je=ee(Ve,be,Be),!Je)return null;const ze=ve==="robust"?$e:Be,{beta:Qe,cov:tt,fitted:et,residuals:dt}=Je;let ft=0,lt=0,jt=0;for(let Lt=0;Lt<Ce;Lt++){const Dt=ze?ze[Lt]:1;ft+=Dt*dt[Lt]**2,lt+=Dt,jt+=Dt*be[Lt]}const Tt=jt/lt;let xt=0;for(let Lt=0;Lt<Ce;Lt++){const Dt=ze?ze[Lt]:1;xt+=Dt*(be[Lt]-Tt)**2}const Ge=Ce-Fe,vt=ft/Ge,ht=xt===0?1:Math.max(0,Math.min(1,1-ft/xt)),kt=1-(1-ht)*(Ce-1)/Ge,Nt=Array.isArray(ue.names)&&ue.names.length===Ee?ue.names:le[0].map((Lt,Dt)=>`x${Dt+1}`),bt=it(ue.confidence),mt=Ge>0?D(1-(1-bt)/2,Ge):1/0,$t=Qe.map((Lt,Dt)=>{const zt=Math.sqrt(Math.max(0,vt*tt[Dt][Dt])),Kt=zt>0?Lt/zt:Lt===0?0:1/0,qt=Number.isFinite(Kt)?2*(1-q(Math.abs(Kt),Ge)):0,Qt=Number.isFinite(mt)?mt*zt:null;return{name:Dt===0?"(intercept)":Nt[Dt-1],estimate:Lt,stdError:zt,t:Kt,p:Math.max(0,Math.min(1,qt)),lower:Qt===null?null:Lt-Qt,upper:Qt===null?null:Lt+Qt}}),Ht=new Array(Ce),Yt=new Array(Ce);for(let Lt=0;Lt<Ce;Lt++){const Dt=ze?ze[Lt]:1,zt=Math.max(0,Math.min(1,Dt*f(Ve[Lt],tt)));Ht[Lt]=zt;const Kt=(1-zt)**2;Yt[Lt]=Kt>0&&vt>0?dt[Lt]**2/(Fe*vt)*(zt/Kt):null}const pn=le[0].map((Lt,Dt)=>{if(Ee<2)return 1;const zt=se(le,Dt);return zt>=1?1/0:1/(1-zt)});let un=null;{const Lt=dt.map(zt=>zt*zt),Dt=ee(Ve,Lt,null);if(Dt){const zt=Lt.reduce((Jt,mn)=>Jt+mn,0)/Ce;let Kt=0,qt=0;for(let Jt=0;Jt<Ce;Jt++)Kt+=Dt.residuals[Jt]**2,qt+=(Lt[Jt]-zt)**2;const Qt=qt===0?0:Math.max(0,Math.min(1,1-Kt/qt)),Xt=Ce*Qt,nn=G(Xt,Ee);un={statistic:Xt,df:Ee,p:nn,heteroscedastic:nn<.05}}}let on=null;if(Ee===1){const Lt=le.map((Dt,zt)=>zt).sort((Dt,zt)=>le[Dt][0]-le[zt][0]);on={confidence:bt,points:Lt.map(Dt=>{const zt=Ve[Dt],Kt=Math.sqrt(Math.max(0,vt*f(zt,tt)));return{x:le[Dt][0],yhat:et[Dt],lower:et[Dt]-mt*Kt,upper:et[Dt]+mt*Kt}})}}return{method:ve,coefficients:$t,r2:ht,adjR2:kt,n:Ce,df:Ge,sigma2:vt,fitted:et,residuals:dt,leverage:Ht,cooksD:Yt,vif:pn,heteroscedasticity:un,band:on,weights:ze?[...ze]:null}}function he(le){const be=le.length,ue=Array.from({length:be},(Ee,Fe)=>Fe).sort((Ee,Fe)=>le[Ee]-le[Fe]),ve=new Float64Array(be);let Ce=0;for(;Ce<be;){let Ee=Ce;for(;Ee+1<be&&le[ue[Ee+1]]===le[ue[Ce]];)Ee++;const Fe=(Ce+Ee)/2+1;for(let Be=Ce;Be<=Ee;Be++)ve[ue[Be]]=Fe;Ce=Ee+1}return ve}const Re=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function Ue(le){const be=[.01,.05,.1],ue=[Re["1%"],Re["5%"],Re["10%"]];if(le<=ue[0]){const Ee=(Math.log(be[1])-Math.log(be[0]))/(ue[1]-ue[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(be[0])+Ee*(le-ue[0]))))}if(le>=ue[2]){const Ee=(Math.log(be[2])-Math.log(be[1]))/(ue[2]-ue[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(be[2])+Ee*(le-ue[2]))))}const ve=le<ue[1]?0:1,Ce=(le-ue[ve])/(ue[ve+1]-ue[ve]);return Math.exp(Math.log(be[ve])+Ce*(Math.log(be[ve+1])-Math.log(be[ve])))}function Le(le,be,ue,ve){const Ce=ue-ve,Ee=ve+3,Fe=new Array(Ce),Be=new Array(Ce);let Ve=!0,Je=ve;for(let et=0;et<Ce;et++){const dt=ve+et,ft=new Float64Array(Ee);ft[0]=1,ft[1]=et+1,ft[2]=le[dt];for(let lt=1;lt<=ve;lt++)ft[2+lt]=be[dt-lt];for(let lt=1;lt<Ee;lt++)Number.isFinite(ft[lt])||(Je=Math.min(Je,lt-3));Fe[et]=ft,Be[et]=be[dt],Number.isFinite(Be[et])||(Ve=!1)}if(!Ve)return 0;const{xtwx:$e,xtwy:ze}=u(Fe,Be,null);let Qe=0,tt=1/0;for(let et=0;et<=Je;et++){const dt=et+3;if(!(Ce>dt))continue;const ft=new Array(dt);for(let ht=0;ht<dt;ht++)ft[ht]=$e[ht].slice(0,dt);const lt=j(ft);if(!lt)continue;const jt=O(lt,ze.slice(0,dt));let Tt=0;for(let ht=0;ht<Ce;ht++){const kt=Fe[ht];let Nt=0;for(let bt=0;bt<dt;bt++)Nt+=kt[bt]*jt[bt];Tt+=(Be[ht]-Nt)**2}const Ge=Tt/(Ce-dt)*(Ce-dt);if(!(Ge>0))continue;const vt=Ce*Math.log(Ge/Ce)+2*dt;vt<tt&&(tt=vt,Qe=et)}return Qe}function ie(le,be={}){const ue=[];for(let tt=0;tt<le.length;tt++){const et=Number(le[tt]);Number.isFinite(et)&&ue.push(et)}const ve=ue.length,Ce=ve-1;if(ve<8||Ce<6)return null;const Ee=new Array(Ce);for(let tt=0;tt<Ce;tt++)Ee[tt]=ue[tt+1]-ue[tt];let Fe=Number.isFinite(be.maxlag)?Math.floor(be.maxlag):Math.ceil(12*(ve/100)**.25);Fe=Math.max(0,Math.min(Fe,Math.floor((Ce-5)/2)));const Be=(tt,et)=>{const dt=[],ft=[];for(let lt=et;lt<Ce;lt++){const jt=[lt-et+1,ue[lt]];for(let Tt=1;Tt<=tt;Tt++)jt.push(Ee[lt-Tt]);dt.push(jt),ft.push(Ee[lt])}return pe(dt,ft,{method:"ols"})},Ve=Le(ue,Ee,Ce,Fe),Je=Be(Ve,Ve);if(!Je||!Je.coefficients[2])return null;const $e=Je.coefficients[2].t,ze=Ue($e),Qe=$e<Re["5%"];return{statistic:$e,usedLag:Ve,nobs:Ce-Ve,criticalValues:{...Re},pValue:ze,pApproximate:!0,stationary:Qe,verdict:Qe?"stationary":"non-stationary",regression:"ct"}}function ge(le,be={}){const ue=[];for(let Qe=0;Qe<le.length;Qe++){const tt=Number(le[Qe]);Number.isFinite(tt)&&ue.push(tt)}const ve=ue.length;if(ve<3)return null;let Ce=Number.isFinite(be.maxlag)?Math.floor(be.maxlag):Math.min(10,ve-1);Ce=Math.max(1,Math.min(Ce,ve-1));let Ee=0;for(const Qe of ue)Ee+=Qe;Ee/=ve;const Fe=ue.map(Qe=>Qe-Ee);let Be=0;for(const Qe of Fe)Be+=Qe*Qe;Be/=ve;const Ve=new Array(Ce+1).fill(0);Ve[0]=1;for(let Qe=1;Qe<=Ce;Qe++){let tt=0;for(let et=Qe;et<ve;et++)tt+=Fe[et]*Fe[et-Qe];Ve[Qe]=Be>0?tt/ve/Be:0}const Je=new Array(Ce+1).fill(0);Je[0]=1;let $e=[];for(let Qe=1;Qe<=Ce;Qe++){let tt=Ve[Qe];for(let lt=1;lt<Qe;lt++)tt-=$e[lt-1]*Ve[Qe-lt];let et=1;for(let lt=1;lt<Qe;lt++)et-=$e[lt-1]*Ve[lt];const dt=et!==0?tt/et:0,ft=new Array(Qe);for(let lt=1;lt<Qe;lt++)ft[lt-1]=$e[lt-1]-dt*$e[Qe-1-lt];ft[Qe-1]=dt,Je[Qe]=dt,$e=ft}const ze=1.96/Math.sqrt(ve);return{acf:Ve,pacf:Je,bounds:{upper:ze,lower:-ze},n:ve,nlags:Ce,approximate:!0}}function ke(le,be,ue){const{xs:ve,ys:Ce,n:Ee}=A(le,be,ue);if(Ee<2)return null;const Fe=he(ve),Be=he(Ce);let Ve=0,Je=0;for(let tt=0;tt<Ee;tt++)Ve+=Fe[tt],Je+=Be[tt];Ve/=Ee,Je/=Ee;let $e=0,ze=0,Qe=0;for(let tt=0;tt<Ee;tt++){const et=Fe[tt]-Ve,dt=Be[tt]-Je;$e+=et*dt,ze+=et*et,Qe+=dt*dt}return ze===0||Qe===0?null:Math.max(-1,Math.min(1,$e/Math.sqrt(ze*Qe)))}function Se(le,be,ue){const{xs:ve,ys:Ce,n:Ee}=A(le,be,ue);if(Ee<2||Ee>t)return null;let Fe=0,Be=0,Ve=0,Je=0;for(let Qe=0;Qe<Ee;Qe++)for(let tt=Qe+1;tt<Ee;tt++){const et=Math.sign(ve[Qe]-ve[tt]),dt=Math.sign(Ce[Qe]-Ce[tt]),ft=et*dt;ft>0?Fe++:ft<0?Be++:et===0&&dt===0||(et===0?Ve++:Je++)}const $e=Fe+Be+Je,ze=Fe+Be+Ve;return $e===0||ze===0?null:(Fe-Be)/Math.sqrt($e*ze)}function Ae(le,be={}){const ue=le.length;if(ue<2)return null;const ve=le[0],Ce=le[ue-1],Ee=[];for(let lt=1;lt<ue;lt++){const jt=le[lt-1];jt!==0&&Ee.push((le[lt]-jt)/Math.abs(jt))}let Fe=null;if(Ee.length>1){let lt=0;for(const Tt of Ee)lt+=Tt;lt/=Ee.length;let jt=0;for(const Tt of Ee)jt+=(Tt-lt)**2;Fe=Math.sqrt(jt/(Ee.length-1))}const Be=Number(be.periodsPerYear)>0?Number(be.periodsPerYear):null;let Ve=le[0],Je=0,$e=0,ze=0,Qe=0;for(let lt=1;lt<ue;lt++){if(le[lt]>Ve){Ve=le[lt],Je=lt;continue}if(Ve<=0)continue;const jt=(Ve-le[lt])/Ve;jt>$e&&($e=jt,ze=Je,Qe=lt)}let tt=null;if(ue>2){let lt=0;for(let xt=0;xt<ue;xt++)lt+=le[xt];lt/=ue;let jt=0,Tt=0;for(let xt=0;xt<ue;xt++){const Ge=le[xt]-lt;Tt+=Ge*Ge,xt>0&&(jt+=Ge*(le[xt-1]-lt))}tt=Tt>0?jt/Tt:null}let et=0,dt=0;for(const lt of Ee)lt>0?et++:lt<0&&dt++;let ft=null;if(ve>0&&Ce>0){const lt=(Ce/ve)**(1/(ue-1))-1;ft=Be?(1+lt)**Be-1:lt}return{n:ue,first:ve,last:Ce,change:Ce-ve,changePercent:ve===0?null:(Ce-ve)/Math.abs(ve)*100,volatility:Fe,annualisedVolatility:Fe!==null&&Be?Fe*Math.sqrt(Be):null,growth:ft,maxDrawdown:$e,maxDrawdownFrom:ze,maxDrawdownTo:Qe,autocorrelation:tt,upDays:et,downDays:dt}}const xe=1.128,me=3.267;function ye(le){const be=le.length;if(be<2)return null;const ue=[];for(let Ce=1;Ce<be;Ce++)ue.push(Math.abs(le[Ce]-le[Ce-1]));const ve=ue.reduce((Ce,Ee)=>Ce+Ee,0)/ue.length;return{ranges:ue,centre:ve,upper:me*ve,lower:0}}function Te(le){const be=le.length;if(be<2)return null;let ue=0;for(let Ce=1;Ce<be;Ce++)ue+=Math.abs(le[Ce]-le[Ce-1]);const ve=ue/(be-1);return{sigma:ve/xe,meanRange:ve}}function Ye(le,be){const ue=le.length;if(ue<2||!be)return null;const ve=Number.isFinite(Number(be.lower))?Number(be.lower):null,Ce=Number.isFinite(Number(be.upper))?Number(be.upper):null;if(ve===null&&Ce===null)return null;let Ee=0;for(let et=0;et<ue;et++)Ee+=le[et];Ee/=ue;let Fe=0;for(let et=0;et<ue;et++)Fe+=(le[et]-Ee)**2;const Be=Math.sqrt(Fe/(ue-1)),Ve=Te(le),Je=Ve?Ve.sigma:null,$e=et=>{if(!et||et<=0)return{index:null,k:null};const ft=ve!==null&&Ce!==null?(Ce-ve)/(6*et):null,lt=Ce!==null?(Ce-Ee)/(3*et):1/0,jt=ve!==null?(Ee-ve)/(3*et):1/0;return{index:ft,k:Math.min(lt,jt)}},ze=$e(Je),Qe=$e(Be);let tt=0;for(let et=0;et<ue;et++){if(ve!==null&&le[et]<ve){tt++;continue}Ce!==null&&le[et]>Ce&&tt++}return{n:ue,mean:Ee,lower:ve,upper:Ce,target:Number.isFinite(Number(be.target))?Number(be.target):null,sigmaWithin:Je,sigmaOverall:Be,cp:ze.index,cpk:ze.k,pp:Qe.index,ppk:Qe.k,outOfSpec:tt,defectRate:ue?tt/ue:null}}function Oe(le){const be=le.length;if(be<2)return null;const ue=Te(le);if(!ue||!(ue.sigma>0))return null;let ve=0;for(let Ce=0;Ce<be;Ce++)ve+=le[Ce];return ve/=be,{centre:ve,sigma:ue.sigma,upper:ve+3*ue.sigma,lower:ve-3*ue.sigma}}function _e(le,be){if(!be||!(be.sigma>0))return[];const ue=le.length,{centre:ve,sigma:Ce}=be,Ee=Be=>(le[Be]-ve)/Ce,Fe=[];for(let Be=0;Be<ue;Be++){if(Math.abs(Ee(Be))>3&&Fe.push({index:Be,rule:1,description:"beyond three sigma"}),Be>=2)for(const Ve of[1,-1]){let Je=0;for(let $e=Be-2;$e<=Be;$e++)Ee($e)*Ve>2&&Je++;if(Je>=2){Fe.push({index:Be,rule:2,description:"two of three past two sigma"});break}}if(Be>=4)for(const Ve of[1,-1]){let Je=0;for(let $e=Be-4;$e<=Be;$e++)Ee($e)*Ve>1&&Je++;if(Je>=4){Fe.push({index:Be,rule:3,description:"four of five past one sigma"});break}}if(Be>=7)for(const Ve of[1,-1]){let Je=!0;for(let $e=Be-7;$e<=Be;$e++)if(Ee($e)*Ve<=0){Je=!1;break}if(Je){Fe.push({index:Be,rule:4,description:"eight in a row on one side"});break}}}return Fe}function je(le,be){if(!be||!(be.sigma>0))return[];const ue=le.length,{centre:ve,sigma:Ce}=be,Ee=Ve=>(le[Ve]-ve)/Ce,Fe=(Ve,Je,$e,ze)=>{for(const Qe of[1,-1]){let tt=0;for(let et=Ve;et<=Je;et++)Ee(et)*Qe>$e&&tt++;if(tt>=ze)return!0}return!1},Be=[];for(let Ve=0;Ve<ue;Ve++){if(Math.abs(Ee(Ve))>3&&Be.push({index:Ve,rule:1,description:"beyond three sigma"}),Ve>=8)for(const Je of[1,-1]){let $e=!0;for(let ze=Ve-8;ze<=Ve;ze++)if(Ee(ze)*Je<=0){$e=!1;break}if($e){Be.push({index:Ve,rule:2,description:"nine in a row on one side"});break}}if(Ve>=5)for(const Je of[1,-1]){let $e=!0;for(let ze=Ve-4;ze<=Ve;ze++)if((le[ze]-le[ze-1])*Je<=0){$e=!1;break}if($e){Be.push({index:Ve,rule:3,description:Je>0?"six rising":"six falling"});break}}if(Ve>=13){let Je=!0;for(let $e=Ve-12;$e<=Ve;$e++){const ze=le[$e]-le[$e-1],Qe=le[$e+1<=Ve?$e+1:$e]-le[$e];if($e+1>Ve)break;if(ze===0||Qe===0||ze>0==Qe>0){Je=!1;break}}Je&&Be.push({index:Ve,rule:4,description:"fourteen alternating"})}if(Ve>=2&&Fe(Ve-2,Ve,2,2)&&Be.push({index:Ve,rule:5,description:"two of three past two sigma"}),Ve>=4&&Fe(Ve-4,Ve,1,4)&&Be.push({index:Ve,rule:6,description:"four of five past one sigma"}),Ve>=14){let Je=!0;for(let $e=Ve-14;$e<=Ve;$e++)if(Math.abs(Ee($e))>=1){Je=!1;break}Je&&Be.push({index:Ve,rule:7,description:"fifteen within one sigma"})}if(Ve>=7){let Je=!0;for(let $e=Ve-7;$e<=Ve;$e++)if(Math.abs(Ee($e))<=1){Je=!1;break}Je&&Be.push({index:Ve,rule:8,description:"eight beyond one sigma"})}}return Be}const we=Object.freeze(["westernElectric","nelson"]);function He(le,be,ue="westernElectric"){return String(ue)==="nelson"?je(le,be):_e(le,be)}function Ke(le,be,ue){let ve=0;for(let Ce=0;Ce<le.length;Ce++)(le[Ce]<be||le[Ce]>ue)&&ve++;return ve}function Xe(le,be,ue,ve=20){const Ce=le.length;if(!Ce)return[];const Ee=le[0],Fe=le[Ce-1];if(Fe===Ee)return[{from:Ee,to:Fe,count:Ce}];const Be=ue-be,Ve=1.5*Be;let Je=Be>0?Math.max(Ee,be-Ve):Ee,$e=Be>0?Math.min(Fe,ue+Ve):Fe;$e>Je||(Je=Ee,$e=Fe);const ze=Be>0?2*Be/Math.cbrt(Ce):($e-Je)/(Math.ceil(Math.log2(Ce))+1),Qe=ze>0?Math.min(ve,Math.max(1,Math.ceil(($e-Je)/ze))):1,tt=($e-Je)/Qe,et=[];for(let dt=0;dt<Qe;dt++)et.push({from:Je+dt*tt,to:Je+(dt+1)*tt,count:0});for(let dt=0;dt<Ce;dt++){const ft=Math.min(Qe-1,Math.max(0,Math.floor((le[dt]-Je)/tt)));et[ft].count++}return et[0].from=Ee,et[Qe-1].to=Fe,et}const nt=.95;function it(le){const be=Number(le);return Number.isFinite(be)&&be>0&&be<1?be:nt}function wt(le,be=nt){const ue=le.length;if(ue<2)return null;let ve=0;for(let $e=0;$e<ue;$e++)ve+=le[$e];const Ce=ve/ue;let Ee=0;for(let $e=0;$e<ue;$e++){const ze=le[$e]-Ce;Ee+=ze*ze}const Fe=Math.sqrt(Ee/(ue-1)),Be=it(be),Je=D(1-(1-Be)/2,ue-1)*Fe/Math.sqrt(ue);return{mean:Ce,lower:Ce-Je,upper:Ce+Je,margin:Je,n:ue,confidence:Be}}function pt(le,be,ue=nt){const ve=Number(le),Ce=Number(be);if(!(Ce>0)||!(ve>=0)||ve>Ce)return null;const Ee=it(ue),Fe=K(1-(1-Ee)/2),Be=ve/Ce,Ve=Fe*Fe,Je=1+Ve/Ce,$e=(Be+Ve/(2*Ce))/Je,ze=Fe/Je*Math.sqrt(Be*(1-Be)/Ce+Ve/(4*Ce*Ce));return{proportion:Be,lower:Math.max(0,$e-ze),upper:Math.min(1,$e+ze),n:Ce,confidence:Ee}}function St(le,be=nt){if(!le||!(le.n>2)||!Number.isFinite(le.stdError))return null;const ue=it(be),Ce=D(1-(1-ue)/2,le.n-2)*le.stdError;return{slope:le.slope,lower:le.slope-Ce,upper:le.slope+Ce,margin:Ce,confidence:ue}}function Ct(le,be,ue=nt){const ve=Number(le),Ce=Number(be);if(!Number.isFinite(ve)||!(Ce>1))return null;const Ee=it(ue),Be=K(1-(1-Ee)/2)*Math.sqrt(1/(9*Ce)+ve*ve/(2*(Ce-1)));return{index:ve,lower:ve-Be,upper:ve+Be,margin:Be,n:Ce,confidence:Ee}}function Mt(le,be){return!le||!(le.sd>0)||!Number.isFinite(be)||!Number.isFinite(le.mean)?null:(be-le.mean)/le.sd}function at(le){return Number.isFinite(le)?Math.min(1,Math.max(0,2*x(Math.abs(le)/2)-1)):0}function ot(le,be){const ue=new Map,ve=X(le);let Ce=0;for(let Ee=0;Ee<be.length;Ee++){const Fe=ve(be[Ee]);if(Fe==null||Fe===""||typeof Fe=="number"&&Number.isNaN(Fe))continue;const Be=Fe instanceof Date?Fe.getTime():typeof Fe=="object"?String(Fe):Fe;ue.set(Be,(ue.get(Be)||0)+1),Ce++}return{map:ue,total:Ce}}function gt(le,be,ue,ve){if(!(be>0)||!(ve>0))return null;let Ce=0;const Ee=new Set(le.keys());for(const Fe of ue.keys())Ee.add(Fe);for(const Fe of Ee){const Be=(le.get(Fe)||0)/be,Ve=(ue.get(Fe)||0)/ve;Ce+=Math.abs(Be-Ve)}return Ce/2}const Et=10;function ut(le,be,ue){if(ue&&ue.numeric){const Be=c(le,be),{n:Ve,mean:Je}=p(Be),$e=Ve>0?Mt({mean:ue.mean,sd:ue.sd},Je):null;return{measure:"standardizedMeanDifference",magnitude:$e,distance:$e===null?0:at($e),direction:$e===null?0:Math.sign($e),subsetN:Ve,populationN:ue.n||0,reliable:Ve>=Et}}const{map:Ce,total:Ee}=ot(le,be),Fe=gt(Ce,Ee,ue.map,ue.total);return{measure:"categoricalTotalVariation",magnitude:Fe,distance:Fe===null?0:Fe,direction:0,subsetN:Ee,populationN:ue.total||0,reliable:Ee>=Et}}function de(le,be){if(le&&(le.kind==="float64"||le.kind==="int32"))return!0;const ue=X(le);let ve=0,Ce=0;for(let Ee=0;Ee<be.length&&ve<200;Ee++){const Fe=ue(be[Ee]);if(Fe==null||Fe==="")continue;if(Fe instanceof Date)return!1;ve++;const Be=typeof Fe=="number"?Fe:Number(Fe);Number.isFinite(Be)&&Ce++}return ve===0?!1:Ce/ve>=.9}function Pe(le,be){if(de(le,be)){const Ce=c(le,be),{n:Ee,mean:Fe,m2:Be}=p(Ce);return{numeric:!0,mean:Fe,sd:Ee>0?Math.sqrt(Be/Ee):0,n:Ee}}const{map:ue,total:ve}=ot(le,be);return{numeric:!1,map:ue,total:ve}}}),Ie("packages/core/src/compute/total.js",function(e,U){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return p}});const N=U("packages/core/src/internal/predicates.js").isFunction,B=U("packages/core/src/internal/warn.js").warnOnce,D=U("packages/core/src/compute/handle.js"),q=D.presenceReader,K=D.valueComparator,x=D.valueReader,G=U("packages/core/src/compute/statistics.js"),z=G.STAT_FNS,j=G.STAT_LABELS;function O(m){return!!m&&(m.kind==="float64"||m.kind==="int32")}function b(m,v){const y=v.length;let E=0;if(O(m)){const F=m.values,V=q(m);if(!V){for(let I=0;I<y;I++){const $=F[v[I]];Number.isNaN($)||(E+=$)}return E}for(let I=0;I<y;I++){const $=v[I];if(V($)===1){const S=F[$];Number.isNaN(S)||(E+=S)}}return E}const M=x(m);for(let F=0;F<y;F++){const V=c(M(v[F]));V!==null&&(E+=V)}return E}b.kernel=!0;function u(m,v){const y=v.length;let E=0;if(O(m)){const F=m.values,V=q(m);if(!V){for(let I=0;I<y;I++)Number.isNaN(F[v[I]])||E++;return E}for(let I=0;I<y;I++){const $=v[I];V($)===1&&!Number.isNaN(F[$])&&E++}return E}const M=x(m);for(let F=0;F<y;F++){const V=M(v[F]);V!=null&&!(typeof V=="number"&&Number.isNaN(V))&&E++}return E}u.kernel=!0;function f(m,v){return v.length}f.kernel=!0;function a(m,v){const y=u(m,v);return y===0?null:b(m,v)/y}a.kernel=!0;function r(m,v,y,E){const M=v.length;if(O(m)){const $=m.values,S=q(m);let R=null;if(!S){for(let L=0;L<M;L++){const T=$[v[L]];Number.isNaN(T)||(R===null||(y<0?T<R:T>R))&&(R=T)}return R}for(let L=0;L<M;L++){const T=v[L];if(S(T)===0)continue;const A=$[T];Number.isNaN(A)||(R===null||(y<0?A<R:A>R))&&(R=A)}return R}const F=x(m),V=K(E);let I=null;for(let $=0;$<M;$++){const S=F(v[$]);S==null||typeof S=="number"&&Number.isNaN(S)||(I===null||(y<0?V(S,I)<0:V(S,I)>0))&&(I=S)}return I}function t(m,v,y){return r(m,v,-1,y&&y.locale)}t.kernel=!0;function s(m,v,y){return r(m,v,1,y&&y.locale)}s.kernel=!0;function i(m,v){return v.length===0?null:x(m)(v[0])}i.kernel=!0;function n(m,v){return v.length===0?null:x(m)(v[v.length-1])}n.kernel=!0;function c(m){if(typeof m=="number")return Number.isNaN(m)?null:m;if(m==null||m===""||typeof m=="boolean")return null;if(m instanceof Date)return m.getTime();const v=Number(m);return Number.isNaN(v)?null:v}const o={sum:b,min:t,max:s,avg:a,count:f,first:i,last:n,countValues:u,...z},l=Object.freeze({...j,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function h(m){return m?typeof m=="string"?l[m]||m:"Total":""}const w=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function g(m){const v=m&&m.dataType&&m.dataType.totals&&m.dataType.totals.supported;if(Array.isArray(v))return v.slice();const y=w.filter(E=>E in o);for(const E of Object.keys(o))y.includes(E)||y.push(E);return y}function k(m,v){return typeof v!="string"?!0:g(m).includes(v)}function d(m,v){const y=x(m),E=[];for(let M=0;M<v.length;M++){const F=y(v[M]);F!=null&&E.push(F)}return E}function p(m,v,y,E){const M=v||[];if(typeof y=="string"){const F=o[y];return F?F(m,M,E):(B(`total:${y}`,`unknown total function "${y}"; register it in config.totalFns`),null)}return N(y)?y.kernel===!0?y(m,M,E):y(d(m,M),E||{}):null}}),Ie("packages/core/src/compute/windowed.js",function(e,U){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return q}});const N=U("packages/core/src/compute/sketch.js").Welford;class X{#e;#t;#n=[];#r;#i;constructor(x,G=0,z=Date.now){if(x!=="count"&&x!=="time"&&x!=="session")throw new RangeError(`unknown window kind: ${x}`);if((x==="count"||x==="time")&&!(G>0))throw new RangeError(`a ${x} window needs a positive span`);this.#e=x,this.#t=Math.floor(G),this.#r=z,this.#i=z()}get size(){return this.#n.length}push(x,G=this.#r()){Number.isFinite(x)&&(this.#n.push({t:G,v:x}),this.#s(G))}#s(x){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const G=x-this.#t;for(;this.#n.length&&this.#n[0].t<G;)this.#n.shift()}}spec(){const x=this.#e==="session"?this.#r()-this.#i:this.#t;return{kind:this.#e,span:x,size:this.#n.length}}values(){return this.#n.map(x=>x.v)}aggregate(){const x=this.spec();if(!this.#n.length)return{over:x,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const G=new N;let z=0,j=1/0,O=-1/0;for(const{v:b}of this.#n)z+=b,b<j&&(j=b),b>O&&(O=b),G.add(b);return{over:x,count:this.#n.length,sum:z,mean:G.mean(),min:j,max:O,variance:G.variance(),stddev:G.stddev()}}reduce(x){const G=this.aggregate(),z={sum:G.sum,avg:G.mean,mean:G.mean,min:G.min,max:G.max,count:G.count,variance:G.variance,stddev:G.stddev};if(!(x in z))throw new RangeError(`unknown windowed aggregate: ${x}`);return{value:z[x],over:G.over}}}const B=Object.freeze(["count","time","session"]);function D(K,x=Date.now){const G=K.kind==="time"&&K.minutes!=null?K.minutes*6e4:K.span??0;return new X(K.kind,G,x)}const q={Window:X,WINDOW_KINDS:B,openWindow:D}}),Ie("packages/core/src/compute/rolling.js",function(e,U){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const N=U("packages/core/src/compute/windowed.js").openWindow,B=U("packages/core/src/compute/sketch.js").KLL,D=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function q(o,l,h,w){if(o.kind==="count"){const g=Math.max(1,Math.floor(o.span||0));return{coverage:Math.min(1,l/g),partial:l<g}}if(o.kind==="time"){const g=o.minutes!=null?o.minutes*6e4:o.span||0;if(!(g>0))return{coverage:1,partial:!1};const k=h-w;return{coverage:Math.min(1,k/g),partial:k<g}}return{coverage:null,partial:!1}}function K(o,l){const h=N(l),w=new Map,g=o.length?o[0].at:0;for(let k=0;k<o.length;k++){const{key:d,at:p,value:m}=o[k];Number.isFinite(m)&&h.push(m,p);const v=h.aggregate(),y=q(l,v.count,p,g);d!=null&&w.set(String(d),{sum:v.sum,avg:v.mean,min:v.min,max:v.max,count:v.count,coverage:y.coverage,partial:y.partial})}return w}function x(o){const l=new Map;let h=0;for(const{key:w,value:g}of o)Number.isFinite(g)&&(h+=g),w!=null&&l.set(String(w),h);return l}function G(o,l=1){const h=new Map,w=Math.max(1,Math.floor(l));for(let g=0;g<o.length;g++){const{key:k,value:d}=o[g];if(k==null)continue;const p=g>=w?o[g-w].value:null,m=Number.isFinite(d)?d:null,v=Number.isFinite(p)?p:null;h.set(String(k),m!==null&&v!==null?m-v:null)}return h}const z=4096;function j(o){let l=o>>>0;return()=>{l+=1831565813;let h=l;return h=Math.imul(h^h>>>15,h|1),h^=h+Math.imul(h^h>>>7,h|61),((h^h>>>14)>>>0)/4294967296}}function O(o,l){const h=o.length;if(h===1)return o[0];const w=(h-1)*l,g=Math.floor(w),k=Math.ceil(w);return g===k?o[g]:o[g]+(w-g)*(o[k]-o[g])}function b(o,l,h={}){const w=Math.min(1,Math.max(0,h.q==null?.5:h.q)),g=Math.max(1,Math.floor(h.cap==null?z:h.cap)),k=j(h.seed==null?2654435769:h.seed),d=new Map,p=o.length?o[0].at:0;if(l.kind==="session"){const v=new B(200,k);let y=0;for(const{key:E,value:M}of o)Number.isFinite(M)&&(v.add(M),y++),E!=null&&d.set(String(E),{value:y?v.quantile(w):null,approx:y>0,count:y,coverage:null,partial:!1});return d}const m=N(l);for(const{key:v,at:y,value:E}of o){Number.isFinite(E)&&m.push(E,y);const M=m.values(),F=M.length;let V=null,I=!1;if(F)if(F<=g)V=O([...M].sort((S,R)=>S-R),w);else{const S=new B(200,k);for(const R of M)S.add(R);V=S.quantile(w),I=!0}const $=q(l,F,y,p);v!=null&&d.set(String(v),{value:V,approx:I,count:F,coverage:$.coverage,partial:$.partial})}return d}function u(o,l){const h=o.length,w=new Array(h).fill(null),g=Math.floor(l/2),k=l%2===0;for(let d=0;d<h;d++){if(d-g<0||d+g>=h)continue;let p=0,m=!0;if(k)for(let v=-g;v<=g;v++){const y=o[d+v];if(!Number.isFinite(y)){m=!1;break}p+=v===-g||v===g?y*.5:y}else for(let v=-g;v<=g;v++){const y=o[d+v];if(!Number.isFinite(y)){m=!1;break}p+=y}m&&(w[d]=p/l)}return w}function f(o,l){const h=new Map,w=Math.floor(Number(l&&l.period));if(!(w>=2))return h;const g=l&&l.model==="multiplicative",k=o.length,d=o.map(I=>Number.isFinite(I.value)?I.value:null),p=u(d,w),m=new Array(k).fill(null);for(let I=0;I<k;I++){const $=p[I],S=d[I];$===null||S===null||(g?$!==0&&(m[I]=S/$):m[I]=S-$)}const v=new Array(w).fill(0),y=new Array(w).fill(0);for(let I=0;I<k;I++){if(m[I]===null)continue;const $=I%w;v[$]+=m[I],y[$]+=1}const E=g?1:0,M=v.map((I,$)=>y[$]?I/y[$]:E),F=M.reduce((I,$)=>I+$,0)/w,V=g?M.map(I=>F!==0?I/F:1):M.map(I=>I-F);for(let I=0;I<k;I++){const{key:$}=o[I];if($==null)continue;const S=p[I],R=V[I%w],L=d[I];let T=null;S!==null&&L!==null&&(T=g?S*R!==0?L/(S*R):null:L-S-R),h.set(String($),{trend:S,seasonal:L===null?null:R,residual:T,coverage:S===null?0:1,partial:S===null})}return h}function a(o,l,h,w=80){const g=(Math.sqrt(5)-1)/2;let k=l,d=h,p=d-g*(d-k),m=k+g*(d-k),v=o(p),y=o(m);for(let E=0;E<w;E++)v<y?(d=m,m=p,y=v,p=d-g*(d-k),v=o(p)):(k=p,p=m,v=y,m=k+g*(d-k),y=o(m));return(k+d)/2}const r=1e-4,t=1-1e-4;function s(o,l){const h=o.length,w=new Array(h).fill(null),g=new Array(h).fill(null);let k=null,d=0;for(let p=0;p<h;p++){const m=o[p];if(!Number.isFinite(m)){k!==null&&(g[p]=k,w[p]=k);continue}if(k===null){k=m,g[p]=m,w[p]=m;continue}g[p]=k,d+=(m-k)**2,k=l*m+(1-l)*k,w[p]=k}return{smoothed:w,fitted:g,sse:d}}function i(o,l,h){const w=o.length,g=new Array(w).fill(null),k=new Array(w).fill(null);let d=null,p=null,m=0;for(let v=0;v<w;v++){const y=o[v];if(!Number.isFinite(y)){d!==null&&(d+=p,g[v]=d);continue}if(d===null){d=y,g[v]=y;continue}if(p===null){p=y-d;const F=d+p;k[v]=F,m+=(y-F)**2;const V=d;d=l*y+(1-l)*(V+p),p=h*(d-V)+(1-h)*p,g[v]=d;continue}const E=d+p;k[v]=E,m+=(y-E)**2;const M=d;d=l*y+(1-l)*(M+p),p=h*(d-M)+(1-h)*p,g[v]=d}return{smoothed:g,fitted:k,sse:m}}function n(o,l={}){const h=new Map,w=l.method==="holt",g=o.map(E=>Number.isFinite(E.value)?E.value:null),k=g.filter(E=>E!==null).length,d=E=>Math.min(t,Math.max(r,E)),p=()=>{for(const{key:E}of o)E!=null&&h.set(String(E),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return h};if(k<(w?2:1))return p();let m=Number.isFinite(l.alpha)?d(l.alpha):null,v=w&&Number.isFinite(l.beta)?d(l.beta):null;if(w){if(m===null||v===null){let E=m===null?.5:m,M=v===null?.5:v;for(let F=0;F<6;F++)m===null&&(E=a(V=>i(g,V,M).sse,r,t)),v===null&&(M=a(V=>i(g,E,V).sse,r,t));m=m===null?E:m,v=v===null?M:v}}else m===null&&(m=a(E=>s(g,E).sse,r,t));const y=w?i(g,m,v):s(g,m);for(let E=0;E<o.length;E++){const{key:M}=o[E];M!=null&&h.set(String(M),{smoothed:y.smoothed[E],fitted:y.fitted[E],alpha:m,beta:w?v:null,sse:y.sse})}return h}const c={ROLLING_WINDOW_FIELDS:D,QUANTILE_SPAN_CAP:z,rollingWindow:K,rollingQuantile:b,cumulativeToDate:x,periodOverPeriod:G,seasonalDecompose:f,exponentialSmoothing:n}}),Ie("packages/core/src/compute/compare.js",function(e,U){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return u}});const te=U("packages/core/src/compute/statistics.js"),N=te.numbers,X=te.moments,B=te.frequencyMap,D=te.categoricalDistance,q=te.normalTotalVariation,K=te.isNumericColumn,x=te.SUBSET_RELIABILITY_FLOOR,G=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function z(f,a){if(!f||!a||!(f.n>0)||!(a.n>0)||!Number.isFinite(f.mean)||!Number.isFinite(a.mean))return null;const r=(f.n*f.sd*f.sd+a.n*a.sd*a.sd)/(f.n+a.n);return r>0?(f.mean-a.mean)/Math.sqrt(r):null}function j(f,a){const r=N(f,a),{n:t,mean:s,m2:i}=X(r),n=t>0?Math.sqrt(i/t):0;return{mean:s,sd:n,n:t}}function O(f,a,r,t){return K(f,a)&&K(r,t)}function b(f,a,r,t){if(O(f,a,r,t)){const c=j(f,a),o=j(r,t),l=z(c,o);return{measure:G.numeric,magnitude:l,distance:l===null?0:q(l),direction:l===null?0:Math.sign(l),nA:c.n,nB:o.n,reliable:c.n>=x&&o.n>=x}}const s=B(f,a),i=B(r,t),n=D(s.map,s.total,i.map,i.total);return{measure:G.categorical,magnitude:n,distance:n===null?0:n,direction:0,nA:s.total,nB:i.total,reliable:s.total>=x&&i.total>=x}}function u(f,a,r={}){const t=new Set(f.columns),s=new Set(a.columns),i=f.columns.filter(h=>s.has(h)),n=Array.isArray(r.columns)&&r.columns.length?i.filter(h=>r.columns.includes(h)):i,c=f.indices(),o=a.indices(),l=[];for(const h of n){const w=f.handle(h),g=a.handle(h);if(!w||!g)continue;const k=b(w,c,g,o);l.push({column:h,name:f.name&&f.name(h)||a.name&&a.name(h)||h,measure:k.measure,magnitude:k.magnitude,distance:k.distance,direction:k.direction,nA:k.nA,nB:k.nB,reliable:k.reliable})}return l.sort((h,w)=>w.distance-h.distance||Math.abs(w.magnitude||0)-Math.abs(h.magnitude||0)),{ranked:l,nA:c.length,nB:o.length,unmatched:{onlyA:f.columns.filter(h=>!s.has(h)),onlyB:a.columns.filter(h=>!t.has(h))},measures:G}}}),Ie("packages/core/src/compute/anomaly.js",function(e,U){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return c}});const N=U("packages/core/src/compute/statistics.js").quantileSorted,B=U("packages/core/src/compute/special.js").logGamma,D=.6745,q=3.5,K=1.5,x=.975,G=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function z(o){if(!o.length)return null;const h=Array.from(o,Number).sort((d,p)=>d-p),w=N(h,.5),g=h.map(d=>Math.abs(d-w)).sort((d,p)=>d-p),k=N(g,.5);return{median:w,mad:k}}function j(o,l={}){const h=Number.isFinite(l.threshold)?l.threshold:q,w=o.length,g=new Array(w).fill(null),k=new Array(w).fill(!1),d=[];for(let v=0;v<w;v++){const y=Number(o[v]);Number.isFinite(y)&&d.push(y)}if(!d.length)return{median:null,mad:null,threshold:h,scores:g,flags:k,flagged:0};const p=z(d);if(p.mad===0)return{median:p.median,mad:0,threshold:h,scores:g,flags:k,flagged:0};let m=0;for(let v=0;v<w;v++){const y=Number(o[v]);if(!Number.isFinite(y))continue;const E=D*(y-p.median)/p.mad;g[v]=E,Math.abs(E)>h&&(k[v]=!0,m++)}return{median:p.median,mad:p.mad,threshold:h,scores:g,flags:k,flagged:m}}function O(o,l={}){const h=Number.isFinite(l.k)?l.k:K,w=[];for(let m=0;m<o.length;m++){const v=Number(o[m]);Number.isFinite(v)&&w.push(v)}if(!w.length)return null;const g=w.sort((m,v)=>m-v),k=N(g,.25),d=N(g,.75),p=d-k;return{q1:k,q3:d,iqr:p,lower:k-h*p,upper:d+h*p,k:h}}function b(o,l){if(l<=0)return 0;const h=B(o);if(l<o+1){let v=o,y=1/o,E=y;for(let M=0;M<1e3&&(v+=1,E*=l/v,y+=E,!(Math.abs(E)<Math.abs(y)*1e-15));M++);return y*Math.exp(-l+o*Math.log(l)-h)}const w=1e-300;let g=l+1-o,k=1/w,d=1/g,p=d;for(let v=1;v<1e3;v++){const y=-v*(v-o);g+=2,d=y*d+g,Math.abs(d)<w&&(d=w),k=g+y/k,Math.abs(k)<w&&(k=w),d=1/d;const E=d*k;if(p*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-l+o*Math.log(l)-h)*p}function u(o,l){return o<=0?0:b(l/2,o/2)}function f(o,l=x){if(!(l>0)||!(l<1))return NaN;let h=0,w=Math.max(1,o);for(;u(w,o)<l;)w*=2;for(let g=0;g<200;g++){const k=(h+w)/2;if(u(k,o)<l?h=k:w=k,w-h<1e-10)break}return(h+w)/2}function a(o){const l=o.length,h=o.map((w,g)=>{const k=w.slice();for(let d=0;d<l;d++)k.push(g===d?1:0);return k});for(let w=0;w<l;w++){let g=w;for(let d=w+1;d<l;d++)Math.abs(h[d][w])>Math.abs(h[g][w])&&(g=d);if(Math.abs(h[g][w])<1e-12)return null;if(g!==w){const d=h[g];h[g]=h[w],h[w]=d}const k=h[w][w];for(let d=0;d<2*l;d++)h[w][d]/=k;for(let d=0;d<l;d++){if(d===w)continue;const p=h[d][w];if(p!==0)for(let m=0;m<2*l;m++)h[d][m]-=p*h[w][m]}}return h.map(w=>w.slice(l))}function r(o,l){const h=o.length,w=new Array(l).fill(0);for(const d of o)for(let p=0;p<l;p++)w[p]+=d[p];for(let d=0;d<l;d++)w[d]/=h;const g=Array.from({length:l},()=>new Array(l).fill(0));for(const d of o)for(let p=0;p<l;p++){const m=d[p]-w[p];for(let v=p;v<l;v++)g[p][v]+=m*(d[v]-w[v])}const k=h>1?h-1:1;for(let d=0;d<l;d++)for(let p=d;p<l;p++)g[d][p]/=k,g[p][d]=g[d][p];return{mean:w,cov:g}}function t(o,l={}){const h=Number.isFinite(l.p)?l.p:x,w=Number.isFinite(l.ridge)?l.ridge:1e-6,g=o.length;if(!g)return null;const k=o[0].length;if(!k)return null;const d=new Array(g).fill(null),p=new Array(g).fill(null),m=new Array(g).fill(!1),v=[],y=[];for(let R=0;R<g;R++){const L=o[R];let T=L.length===k;const A=new Array(k);for(let C=0;T&&C<k;C++){const H=Number(L[C]);Number.isFinite(H)?A[C]=H:T=!1}T&&(v.push(R),y.push(A))}const E=k,M=f(E,h);if(y.length<=k)return{center:[],df:E,cutoff:M,singular:!0,used:y.length,distances:d,squared:p,flags:m,flagged:0};const{mean:F,cov:V}=r(y,k);let I=a(V),$=!1;if(!I){$=!0;let R=0;for(let A=0;A<k;A++)R+=V[A][A];const L=R/k*w||w,T=V.map((A,C)=>A.map((H,Y)=>C===Y?H+L:H));if(I=a(T),!I)return{center:F,df:E,cutoff:M,singular:!0,used:y.length,distances:d,squared:p,flags:m,flagged:0}}let S=0;for(let R=0;R<y.length;R++){const L=y[R],T=new Array(k);for(let H=0;H<k;H++)T[H]=L[H]-F[H];let A=0;for(let H=0;H<k;H++){let Y=0;for(let Z=0;Z<k;Z++)Y+=I[H][Z]*T[Z];A+=T[H]*Y}A<0&&(A=0);const C=v[R];p[C]=A,d[C]=Math.sqrt(A),A>M&&(m[C]=!0,S++)}return{center:F,df:E,cutoff:M,singular:$,used:y.length,distances:d,squared:p,flags:m,flagged:S}}const s=20,i=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function n(o,l={}){const h=l.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",w=Number.isFinite(l.windowLen)&&l.windowLen>=1?Math.floor(l.windowLen):s,g=Number.isFinite(l.threshold)?l.threshold:q,k=Number.isFinite(l.k)?l.k:K,d=Number.isFinite(l.minPeriods)&&l.minPeriods>=1?Math.floor(l.minPeriods):w,p=o.length,m=new Array(p).fill(null),v=new Array(p).fill(!1);let y=0;for(let E=0;E<p;E++){const M=Number(o[E]);if(!Number.isFinite(M))continue;const F=Math.max(0,E-w+1),V=[];for(let I=F;I<=E;I++){const $=Number(o[I]);Number.isFinite($)&&V.push($)}if(!(V.length<d))if(h==="rollingIqr"){const I=O(V,{k});if(!I)continue;(M<I.lower||M>I.upper)&&(v[E]=!0,y++)}else{const I=z(V);if(!I||I.mad===0)continue;const $=D*(M-I.median)/I.mad;m[E]=$,Math.abs($)>g&&(v[E]=!0,y++)}}return{method:h,windowLen:w,minPeriods:d,threshold:g,k,scores:m,flags:v,flagged:y}}function c(o={}){const l=o||{},h=l.field;if(typeof h!="string"||!h)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const w=l.method||"modifiedZScore";if(!(G.includes(w)||i.includes(w))||w==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${w}'`);const k=typeof l.orderBy=="string"?l.orderBy:null,d=l.latest===!0,p=i.includes(w),m=v=>Number(v==null?NaN:v[h]);return v=>{const y=Array.isArray(v)?v.slice():[...v];k&&y.sort((I,$)=>{const S=I?.[k],R=$?.[k];return S===R?0:S==null?-1:R==null?1:S<R?-1:1});const E=y.map(m);let M,F;if(p)({flags:M,scores:F}=n(E,{method:w,windowLen:l.windowLen,threshold:l.threshold,k:l.k,minPeriods:l.minPeriods}));else if(w==="iqr"){const I=O(E,{k:l.k});M=E.map($=>I?Number.isFinite($)&&($<I.lower||$>I.upper):!1),F=E.map(()=>null)}else({flags:M,scores:F}=j(E,{threshold:l.threshold}));if(d){const I=M.length-1;return I<0||!M[I]?!1:{method:w,field:h,flagged:[{row:y[I],score:F[I]}]}}const V=[];for(let I=0;I<M.length;I++)M[I]&&V.push({row:y[I],score:F[I]});return V.length?{method:w,field:h,flagged:V}:!1}}}),Ie("packages/core/src/compute/forecast.js",function(e,U){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const te=U("packages/core/src/compute/special.js"),N=te.normalQuantile,X=te.studentTQuantile,D=U("packages/core/src/internal/warn.js").warnOnce,q=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),K=1e-4,x=1-1e-4;function G(l){const h=[];for(let w=0;w<l.length;w++){const g=l[w];if(g!==null&&typeof g=="object"){const k=Number.isFinite(g.at)?g.at:w,d=Number.isFinite(g.value)?g.value:null;h.push({at:k,value:d})}else h.push({at:w,value:Number.isFinite(g)?Number(g):null})}return h}function z(l){const h=l.filter(p=>p.value!==null),w=h[0],g=h[h.length-1],k=g.at-w.at,d=h.length>1&&k>0?k/(h.length-1):1;return{lastAt:g.at,step:d}}function j(l){return Math.min(x,Math.max(K,l))}function O(l,h=K,w=x,g=80){const k=(Math.sqrt(5)-1)/2;let d=h,p=w,m=p-k*(p-d),v=d+k*(p-d),y=l(m),E=l(v);for(let M=0;M<g;M++)y<E?(p=v,v=m,E=y,m=p-k*(p-d),y=l(m)):(d=m,m=v,y=E,v=d+k*(p-d),E=l(v));return(d+p)/2}function b(l,h){let w=null,g=0,k=0;for(let d=0;d<l.length;d++){const p=l[d];if(p!==null){if(w===null){w=p;continue}g+=(p-w)**2,k+=1,w=h*p+(1-h)*w}}return{level:w,sse:g,m:k}}function u(l,h,w){let g=null,k=null,d=0,p=0;for(let m=0;m<l.length;m++){const v=l[m];if(v===null){g!==null&&k!==null&&(g+=k);continue}if(g===null){g=v;continue}k===null&&(k=v-g);const y=g+k;d+=(v-y)**2,p+=1;const E=g;g=h*v+(1-h)*(E+k),k=w*(g-E)+(1-w)*k}return{level:g,trend:k,sse:d,m:p}}function f(l,h,w,g,k){const d=l.length;if(d<2*h)return null;const p=$=>{let S=0,R=0;for(let L=$;L<$+h&&L<d;L++)l[L]!==null&&(S+=l[L],R+=1);return R?S/R:null},m=p(0),v=p(h);if(m===null||v===null)return null;let y=m,E=(v-m)/h;const M=new Array(h).fill(0);for(let $=0;$<h;$++)M[$]=l[$]===null?0:l[$]-y;const F=M.reduce(($,S)=>$+S,0)/h;for(let $=0;$<h;$++)M[$]-=F;let V=0,I=0;for(let $=h;$<d;$++){const S=$%h,R=M[S],L=l[$];if(L===null){y+=E;continue}const T=y+E+R;V+=(L-T)**2,I+=1;const A=y;y=w*(L-R)+(1-w)*(y+E),E=g*(y-A)+(1-g)*E,M[S]=k*(L-y)+(1-k)*R}return{level:y,trend:E,season:M,phase:(d-1)%h,sse:V,count:I}}function a(l,h,w){let g=1;for(const d of h)g+=d*d;const k=Math.sqrt(l*g);return{se:k,margin:w*k}}function r(l,h={}){if(!l||typeof l.length!="number"||l.length===0)return null;const w=q.includes(h.method)?h.method:"linear",g=Math.max(1,Math.floor(Number(h.horizon)||1)),k=Number.isFinite(h.confidence)&&h.confidence>0&&h.confidence<1?h.confidence:.95,d=1-(1-k)/2,p=G(l),m=p.map(V=>V.value),v=m.filter(V=>V!==null),y=v.length,{lastAt:E,step:M}=y?z(p):{lastAt:0,step:1},F=V=>E+V*M;return w==="linear"?t(p,y,g,k,d,F):w==="movingAverage"?s(v,y,g,k,d,h,F):w==="ses"?i(m,y,g,k,d,h,F):w==="holt"?n(m,y,g,k,d,h,F):c(m,y,g,k,d,h,F)}function t(l,h,w,g,k,d){if(h<2)return null;let p=0,m=0;for(const L of l)L.value!==null&&(p+=L.at,m+=L.value);p/=h,m/=h;let v=0,y=0,E=0;for(const L of l){if(L.value===null)continue;const T=L.at-p,A=L.value-m;v+=T*T,y+=T*A,E+=A*A}if(v===0)return null;const M=y/v,F=m-M*p,V=E===0?1:Math.max(0,Math.min(1,y*y/(v*E))),I=Math.max(0,E-M*y),$=h>2?Math.sqrt(I/(h-2)):null,S=h>2?X(k,h-2):null,R=[];for(let L=1;L<=w;L++){const T=d(L),A=F+M*T;let C=null,H=null,Y=null,Z=null,_=null;if($!==null){const J=1/h+(T-p)**2/v,ee=$*Math.sqrt(1+J),ne=$*Math.sqrt(J);_=ee,C=A-S*ee,H=A+S*ee,Y=A-S*ne,Z=A+S*ne}R.push({step:L,at:T,mean:A,lower:C,upper:H,lowerMean:Y,upperMean:Z,se:_})}return{method:"linear",horizon:w,confidence:g,n:h,sigma:$,r2:V,params:{slope:M,intercept:F},points:R}}function s(l,h,w,g,k,d,p){if(h<1)return null;const m=Math.max(1,Math.min(h,Math.floor(Number(d.windowLen)||h))),v=l.slice(h-m);let y=0;for(const $ of v)y+=$;const E=y/m;let M=null,F=null;if(m>1){let $=0;for(const R of v)$+=(R-E)**2;M=Math.sqrt($/(m-1))*Math.sqrt(1+1/m),F=X(k,m-1)}const V=M===null?null:F*M,I=[];for(let $=1;$<=w;$++)I.push({step:$,at:p($),mean:E,lower:V===null?null:E-V,upper:V===null?null:E+V,se:M});return{method:"movingAverage",horizon:w,confidence:g,n:h,sigma:M===null?null:M,params:{windowLen:m},points:I}}function i(l,h,w,g,k,d,p){if(h<1)return null;let m=Number.isFinite(d.alpha)?j(d.alpha):null;m===null&&(m=O(F=>b(l,F).sse));const v=b(l,m),y=N(k),E=v.m>0?v.sse/v.m:null,M=[];for(let F=1;F<=w;F++){const V=v.level;let I=null,$=null,S=null;if(E!==null){const R=[];for(let T=1;T<F;T++)R.push(m);const L=a(E,R,y);S=L.se,I=V-L.margin,$=V+L.margin}M.push({step:F,at:p(F),mean:V,lower:I,upper:$,se:S})}return{method:"ses",horizon:w,confidence:g,n:h,sigma:E===null?null:Math.sqrt(E),params:{alpha:m},points:M}}function n(l,h,w,g,k,d,p){if(h<2)return null;let m=Number.isFinite(d.alpha)?j(d.alpha):null,v=Number.isFinite(d.beta)?j(d.beta):null;if(m===null||v===null){let I=m===null?.5:m,$=v===null?.5:v;for(let S=0;S<6;S++)m===null&&(I=O(R=>u(l,R,$).sse)),v===null&&($=O(R=>u(l,I,R).sse));m=m===null?I:m,v=v===null?$:v}const y=u(l,m,v),E=N(k),M=y.m>0?y.sse/y.m:null,F=m*v,V=[];for(let I=1;I<=w;I++){const $=y.level+I*y.trend;let S=null,R=null,L=null;if(M!==null){const T=[];for(let C=1;C<I;C++)T.push(m+C*F);const A=a(M,T,E);L=A.se,S=$-A.margin,R=$+A.margin}V.push({step:I,at:p(I),mean:$,lower:S,upper:R,se:L})}return{method:"holt",horizon:w,confidence:g,n:h,sigma:M===null?null:Math.sqrt(M),params:{alpha:m,beta:v},points:V}}function c(l,h,w,g,k,d,p){const m=Math.floor(Number(d.period));if(!(m>=2))return D("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(h<2*m)return null;let v=Number.isFinite(d.alpha)?j(d.alpha):null,y=Number.isFinite(d.beta)?j(d.beta):null,E=Number.isFinite(d.gamma)?j(d.gamma):null;const M=(L,T,A)=>{const C=f(l,m,L,T,A);return C?C.sse:1/0};if(v===null||y===null||E===null){let L=v===null?.5:v,T=y===null?.5:y,A=E===null?.5:E;for(let C=0;C<8;C++)v===null&&(L=O(H=>M(H,T,A))),y===null&&(T=O(H=>M(L,H,A))),E===null&&(A=O(H=>M(L,T,H)));v=v===null?L:v,y=y===null?T:y,E=E===null?A:E}const F=f(l,m,v,y,E);if(!F)return null;const V=N(k),I=F.count>0?F.sse/F.count:null,$=v*y,S=E*(1-v),R=[];for(let L=1;L<=w;L++){const T=F.season[(F.phase+L)%m],A=F.level+L*F.trend+T;let C=null,H=null,Y=null;if(I!==null){const Z=[];for(let J=1;J<L;J++)Z.push(v+J*$+(J%m===0?S:0));const _=a(I,Z,V);Y=_.se,C=A-_.margin,H=A+_.margin}R.push({step:L,at:p(L),mean:A,lower:C,upper:H,se:Y})}return{method:"holtWinters",horizon:w,confidence:g,n:h,sigma:I===null?null:Math.sqrt(I),params:{alpha:v,beta:y,gamma:E,period:m},points:R}}const o={FORECAST_METHODS:q,forecast:r}}),Ie("packages/core/src/compute/hypothesis.js",function(e,U){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return V}});const N=U("packages/core/src/internal/warn.js").warnOnce,B=U("packages/core/src/compute/handle.js").valueReader,D=U("packages/core/src/compute/statistics.js"),q=D.numbers,K=D.moments,x=D.frequencyMap,G=D.categoricalDistance,z=D.isNumericColumn,j=D.jarqueBera,O=D.proportionInterval,b=D.SUBSET_RELIABILITY_FLOOR,f=U("packages/core/src/compute/compare.js").pooledStandardMeanDifference,a=U("packages/core/src/compute/special.js"),r=a.studentT,t=a.studentTQuantile,s=a.normalCdf,i=a.normalQuantile,n=a.chiSquareUpperTail,c=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),o=.05,l=2e6;function h(I){const $=Number(I);return Number.isFinite($)&&$>0&&$<1?$:.95}function w(I){const{n:$,mean:S,m2:R}=K(I);return{mean:S,sd:$>0?Math.sqrt(R/$):0,n:$}}function g(I,$){const S=I.length;if(S<2)return 0;let R=0;for(let L=0;L<S;L++){const T=I[L]-$;R+=T*T}return R/(S-1)}function k(I,$){return{name:"pooledStandardMeanDifference",value:f(w(I),w($))}}function d(I,$,S){const R=I.length,L=$.length;if(R<2||L<2)return null;const T=h(S),{mean:A}=K(I),{mean:C}=K($),H=g(I,A),Y=g($,C),Z=H/R+Y/L;if(!(Z>0))return null;const _=Math.sqrt(Z),J=(A-C)/_,ee=H/R*(H/R)/(R-1),ne=Y/L*(Y/L)/(L-1),se=Z*Z/(ee+ne),oe=Math.min(1,Math.max(0,2*(1-r(Math.abs(J),se)))),fe=A-C,pe=t(1-(1-T)/2,se)*_;return{test:c.WELCH,statistic:J,statisticName:"t",df:se,pValue:oe,interval:{estimate:fe,lower:fe-pe,upper:fe+pe,confidence:T,method:"welch-t (difference of means)"},effectSize:k(I,$),nA:R,nB:L,reliable:R>=b&&L>=b,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function p(I){const $=I.length;if($===0)return Number.NaN;const S=$>>1;return $%2?I[S]:(I[S-1]+I[S])/2}function m(I,$,S){const R=I.length,L=$.length,T=R*L;if(T===0||T>l)return null;const A=new Float64Array(T);let C=0;for(let ee=0;ee<R;ee++)for(let ne=0;ne<L;ne++)A[C++]=I[ee]-$[ne];A.sort();const H=p(A),Y=Math.sqrt(R*L*(R+L+1)/12),Z=i(1-(1-S)/2);let _=Math.round(T/2-Z*Y);_>=0||(_=0);const J=Math.floor((T-1)/2);return _>J&&(_=J),{estimate:H,lower:A[_],upper:A[T-1-_],confidence:S,method:"hodges-lehmann (normal approximation)"}}function v(I,$,S){const R=I.length,L=$.length;if(R<1||L<1)return null;const T=h(S),A=R+L,C=new Array(A);for(let oe=0;oe<R;oe++)C[oe]={v:I[oe],g:0};for(let oe=0;oe<L;oe++)C[R+oe]={v:$[oe],g:1};C.sort((oe,fe)=>oe.v-fe.v);let H=0,Y=0,Z=0;for(;Z<A;){let oe=Z;for(;oe<A&&C[oe].v===C[Z].v;)oe++;const fe=oe-Z,pe=(Z+1+oe)/2;for(let he=Z;he<oe;he++)C[he].g===0&&(H+=pe);Y+=fe*fe*fe-fe,Z=oe}const _=H-R*(R+1)/2,J=R*L/2,ee=R*L/12*(A+1-Y/(A*(A-1)));let ne=1;if(ee>0){const oe=Math.max(0,Math.abs(_-J)-.5);ne=Math.min(1,2*s(-oe/Math.sqrt(ee)))}const se=m(I,$,T);return{test:c.MANN_WHITNEY,statistic:_,statisticName:"U",df:null,pValue:ne,interval:se,effectSize:k(I,$),nA:R,nB:L,reliable:R>=b&&L>=b,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function y(I,$,S,R,L){const T=O(I,$,L),A=O(S,R,L);if(!T||!A)return null;const C=T.proportion-A.proportion,H=C-Math.sqrt((T.proportion-T.lower)**2+(A.upper-A.proportion)**2),Y=C+Math.sqrt((T.upper-T.proportion)**2+(A.proportion-A.lower)**2);return{lower:H,upper:Y}}function E(I,$,S,R,L,T={}){if(!($>0)||!(R>0))return null;const A=new Set([...I.keys(),...S.keys()]),C=A.size;if(C<2)return null;const H=$+R;let Y=0;for(const ne of A){const se=I.get(ne)||0,oe=S.get(ne)||0,fe=se+oe,pe=$*fe/H,he=R*fe/H;pe>0&&(Y+=(se-pe)*(se-pe)/pe),he>0&&(Y+=(oe-he)*(oe-he)/he)}const Z=C-1,_=n(Y,Z);let J=null;T.category!==void 0&&A.has(T.category)?J=T.category:C===2&&([J]=[...A]);let ee=null;if(J!==null){const ne=y(I.get(J)||0,$,S.get(J)||0,R,h(L));ne&&(ee={estimate:(I.get(J)||0)/$-(S.get(J)||0)/R,lower:ne.lower,upper:ne.upper,confidence:h(L),method:"newcombe (difference in this category's share)",category:J})}return{test:c.CHI_SQUARE,statistic:Y,statisticName:"chiSquare",df:Z,pValue:_,interval:ee,effectSize:{name:"categoricalTotalVariation",value:G(I,$,S,R)},nA:$,nB:R,reliable:$>=b&&R>=b,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function M(I){return I==null||I===""||typeof I=="number"&&Number.isNaN(I)?null:I instanceof Date?I.getTime():typeof I=="object"?String(I):I}function F(I,$,S){if(S===c.WELCH||S===c.MANN_WHITNEY)return{test:S,chosenBy:"override",reason:`caller override: ${S}`};const R=j(I),L=j($),T=R===null?null:Math.exp(-R/2),A=L===null?null:Math.exp(-L/2);return T!==null&&T<o||A!==null&&A<o?{test:c.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${o})`}:{test:c.WELCH,chosenBy:"auto",reason:T!==null||A!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function V(I,$,S,R={}){if(!I||!$)return null;const L=h(R.confidence),T=B($);let A;if(Array.isArray(R.groups)&&R.groups.length===2)A=[M(R.groups[0]),M(R.groups[1])];else{const{map:oe}=x($,S),fe=[...oe.entries()].sort((pe,he)=>he[1]-pe[1]).slice(0,2).map(pe=>pe[0]);if(fe.length<2)return N("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;A=fe}const[C,H]=A;if(C===null||H===null||C===H)return N("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const Y=[],Z=[];for(let oe=0;oe<S.length;oe++){const fe=M(T(S[oe]));fe===C?Y.push(S[oe]):fe===H&&Z.push(S[oe])}if(Y.length===0||Z.length===0)return N("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const _=R.test&&R.test!=="auto"?String(R.test):null,J=z(I,Y.concat(Z));let ee,ne,se;if(_===c.CHI_SQUARE||!_&&!J){ne=_?"override":"auto",se=_?"caller override: chiSquare":"column family: categorical";const oe=x(I,Y),fe=x(I,Z);ee=E(oe.map,oe.total,fe.map,fe.total,L,{category:R.category})}else{if((_===c.WELCH||_===c.MANN_WHITNEY)&&!J)return N("compareGroups:numeric-override",`[lattice] compareGroups: ${_} needs a numeric column, but the column is not numeric.`),null;const oe=q(I,Y),fe=q(I,Z),pe=F(oe,fe,_);ne=pe.chosenBy,se=pe.reason,ee=pe.test===c.MANN_WHITNEY?v(oe,fe,L):d(oe,fe,L)}return ee?{...ee,chosenBy:ne,reason:se,groups:[C,H]}:(N("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Ie("packages/core/src/columns/detailcolumn.js",function(e,U){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return B}});const te="__lattice_detail",N=36;function X(D){const q=D.config&&D.config.detailColumnWidth||N;return{id:te,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:q,min:q,max:q,pin:D.config&&D.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(K,x){return!!(x&&x.expanded)},formatValue(){return""}}}const B=X}),Ie("packages/core/src/columns/treecolumn.js",function(e,U){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return q}});const N=U("packages/core/src/internal/predicates.js").isFunction,X="__lattice_tree",B=260;function D(K){const x=K.tree||{},G=K.config&&K.config.treeColumnWidth||B,z=()=>(K.columns&&N(K.columns.visible)?K.columns.visible():[]).find(u=>!u.generated)||null,j=(b,u)=>{if(u&&u.group)return u.groupValue;if(N(x.label))return x.label(b,u);if(typeof x.label=="string")return b==null?null:b[x.label];const f=z();return f&&N(f.getValue)?f.getValue(b,u):null},O=()=>{if(x.title)return x.title;const b=typeof x.label=="string"?K.columns&&N(K.columns.get)?K.columns.get(x.label):null:z();return b&&(b.title||b.id)||"Hierarchy"};return{id:X,get title(){return O()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:G,min:140,pin:K.config&&K.config.treeColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(b,u){return j(b,u)},formatValue(b,u){if(u&&u.grandTotal)return K.config&&K.config.grandTotalLabel||"Total";if(b==null)return"";if(!x.label){const f=z();if(f&&N(f.formatValue))return f.formatValue(b,u)}return String(b)}}}const q=D}),Ie("packages/core/src/columns/pivotcolumns.js",function(e,U){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return D}});const N=U("packages/core/src/internal/warn.js").warnOnce,X="__lattice_pivot",B=500;function D(G){const{pivot:z,valueColumns:j,config:O}=G,b=z&&z.paths||[],u=G.separator||O&&O.pivot&&O.pivot.separator||" | ",f=O&&O.pivot&&O.pivot.maxColumns||B;if(!b.length||!j.length)return{tree:[],leaves:[],error:null};const a=q(O),r=b.length*j.length+(a?j.length:0);if(r>f){const i=`pivot would generate ${r} columns, above the limit of ${f}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return N(`pivot.maxColumns:${r}`,i),{tree:[],leaves:[],error:i}}const t=[],s=[];for(const i of b){const n=[];for(const c of j){const o=x(i,c,u);n.push(o),s.push(o)}n.length===1?(n[0].title=String(i),t.push(n[0])):t.push({id:`${X}:group:${i}`,title:String(i),columns:n,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(a){const i=j.map(c=>K(c,O));s.push(...i);const n=O&&O.pivot&&O.pivot.totalsLabel||"Total";if(i.length===1)i[0].title=n,a==="before"?t.unshift(i[0]):t.push(i[0]);else{const c={id:`${X}:group:__totals`,title:n,columns:i,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};a==="before"?t.unshift(c):t.push(c)}}return{tree:t,leaves:s,error:null}}function q(G){const z=G&&G.pivot&&G.pivot.groupTotals;return z==="before"||z==="after"?z:null}function K(G,z){return{id:`${X}:__total${z&&z.pivot&&z.pivot.separator||" | "}${G.id}`,field:null,title:G.title||G.id,type:G.type,dataType:G.dataType,nullable:!0,align:G.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:G.id,total:!0},value:{pure:!0},cell:{align:G.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:G.total,lookup:null,layout:{width:G.layout&&G.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(j,O){const b=O&&O.totals;return b&&Object.hasOwn(b,G.id)?b[G.id]:null},formatValue(j,O){return j==null?"":G.formatValue?G.formatValue(j,O):String(j)}}}function x(G,z,j){return{id:`${X}:${G}${j}${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:G,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(O,b){return O==null?"":z.formatValue?z.formatValue(O,b):String(O)}}}}),Ie("packages/core/src/compute/group.js",function(e,U){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return O}});const te=U("packages/core/src/compute/handle.js"),N=te.dictSize,X=te.identity,B=te.presenceReader,D=te.rowCount,q=te.valueReader,K="",x="\0",G=1<<20;function z(b,u,f,a){const r=b.length,t=b.map(l=>q(l)),s=Array.isArray(a)&&a.some(Boolean),i=s?t.map((l,h)=>a[h]?w=>a[h](l(w)):l):t;if(!s&&r>0&&b.every(l=>l&&l.kind==="dictionary"&&l.dict)){const l=b.map(w=>N(w.dict)+1);let h=1;for(let w=0;w<r;w++)h*=l[w];if(h<=Number.MAX_SAFE_INTEGER){const w=b.map(p=>p.values),g=b.map(p=>B(p)),k=p=>{let m=0;for(let v=0;v<r;v++){const y=g[v],E=y&&y(p)===0?l[v]-1:w[v][p];m=m*l[v]+E}return m},d=new Float64Array(f);for(let p=0;p<f;p++)d[p]=k(u[p]);return{packed:d,strings:null,product:h,readers:i,keyOf:k}}}const c=l=>{let h="";for(let w=0;w<r;w++){const g=i[w](l);h+=(w===0?"":K)+(g==null?x:String(g))}return h},o=new Array(f);for(let l=0;l<f;l++)o[l]=c(u[l]);return{packed:null,strings:o,product:1/0,readers:i,keyOf:c}}function j(b,u,f,a){const r=new Uint32Array(a+1);for(let n=0;n<f;n++)r[u[n]+1]++;for(let n=0;n<a;n++)r[n+1]+=r[n];const t=new Uint32Array(f),s=r.slice(0,a);for(let n=0;n<f;n++)t[s[u[n]]++]=b[n];const i=new Array(a);for(let n=0;n<a;n++)i[n]=t.subarray(r[n],r[n+1]);return i}function O(b,u,f={}){const a=b||[],r=u||X(D(a[0],f)),t=r.length;if(a.length===0||t===0)return{keys:[],buckets:[]};const{packed:s,strings:i,product:n,readers:c}=z(a,r,t,f.project),o=new Uint32Array(t);let l=0,h=null;if(s&&n<=Math.max(1024,Math.min(G,t*4))){const d=n,p=new Int32Array(d).fill(-1);for(let m=0;m<t;m++)p[s[m]]=0;for(let m=0;m<d;m++)p[m]===0&&(p[m]=l++);for(let m=0;m<t;m++)o[m]=p[s[m]];h=new Float64Array(l);for(let m=0;m<d;m++)p[m]>=0&&(h[p[m]]=m)}else if(s){const d=new Map;for(let p=0;p<t;p++){const m=s[p];let v=d.get(m);v===void 0&&(v=l++,d.set(m,v)),o[p]=v}h=new Float64Array(l);for(const[p,m]of d)h[m]=p}else{const d=new Map;for(let p=0;p<t;p++){const m=i[p];let v=d.get(m);v===void 0&&(v=l++,d.set(m,v)),o[p]=v}}const w=j(r,o,t,l),g=new Array(l);for(let d=0;d<l;d++){const p=w[d][0],m=new Array(c.length);for(let v=0;v<c.length;v++)m[v]=c[v](p);g[d]=m}const k={keys:g,buckets:w};return h&&(k.packed=h),k}}),Ie("packages/core/src/compute/pivot.js",function(e,U){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return t}});const N=U("packages/core/src/internal/warn.js").warnOnce,B=U("packages/core/src/compute/handle.js").valueComparator,q=U("packages/core/src/compute/group.js").packKeys,x=U("packages/core/src/compute/total.js").total,G="|",z="/",j=2e3;function O(n,c,o){return`${n}${G}${c}${G}${o}`}function b(n,c){let o="";for(let l=0;l<n.length;l++){const h=n[l];o+=(l===0?"":c)+(h==null?"":String(h))}return o}function u(n,c,o={}){const l=o.separator||z,h=c.length,{keyOf:w,readers:g}=q(n,c,0),k=new Map,d=[],p=[];for(let V=0;V<h;V++){const I=c[V],$=w(I);if(k.has($))continue;k.set($,d.length),p.push($);const S=new Array(g.length);for(let R=0;R<g.length;R++)S[R]=g[R](I);d.push(S)}const m=B(o.locale),v=d.map((V,I)=>I);v.sort((V,I)=>{const $=d[V],S=d[I];for(let R=0;R<$.length;R++){const L=f($[R],S[R],m);if(L!==0)return L}return V-I});const y=new Array(v.length),E=new Array(v.length),M=new Map;for(let V=0;V<v.length;V++){const I=v[V];y[V]=d[I],E[V]=b(d[I],l),M.set(p[I],V)}return{keys:y,paths:E,idOf:V=>{const I=M.get(w(V));return I===void 0?-1:I}}}function f(n,c,o){const l=n==null,h=c==null;return l||h?l&&h?0:l?1:-1:o(n,c)}function a(n){const c=n.values||n.totals||[];if(c.length&&typeof c[0]=="object"&&c[0]!==null)return c.filter(w=>w&&w.handle);const o=typeof n.handle=="function"?n.handle:null;if(!o)return c.length&&N("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 l=typeof n.totalOf=="function"?n.totalOf:null,h=[];for(const w of c){const g=o(w);g&&h.push({colId:w,handle:g,fn:l?l(w):"sum"})}return h}function r(n,c,o){if(Array.isArray(n)){const l=o||{};return{...l,pivotHandles:n,order:c||null,groups:l.groups||null}}return n||{}}function t(n,c,o){const l=r(n,c,o),h=l.separator||z,w=a(l),g=l.maxColumns===void 0?j:l.maxColumns,k=l.groups&&l.groups.buckets?l.groups:null,d=k?k.buckets:[l.order||new Uint32Array(0)],p=l.groupPaths||(k?k.keys.map($=>b($,h)):[""]),m=i(d),{keys:v,paths:y,idOf:E}=u(l.pivotHandles||[],m,l),M=y.length*Math.max(1,w.length),F=s(y,w,h);if(g&&M>g){const $=new Map;return{keys:v,paths:y,fields:F,groupPaths:p,columns:M,values:$,cells:$,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${M} columns, above pivot.maxColumns of ${g}. Narrow the pivot columns or raise the limit.`,columns:M,maxColumns:g}}}const V=new Map,I=y.length;for(let $=0;$<d.length;$++){const S=d[$],R=p[$]===void 0?"":p[$],L=S.length;if(L===0)continue;const T=new Int32Array(L),A=new Uint32Array(I+1);for(let Y=0;Y<L;Y++){const Z=E(S[Y]);T[Y]=Z,Z>=0&&A[Z+1]++}for(let Y=0;Y<I;Y++)A[Y+1]+=A[Y];const C=new Uint32Array(L),H=A.slice(0,I);for(let Y=0;Y<L;Y++){const Z=T[Y];Z>=0&&(C[H[Z]++]=S[Y])}for(let Y=0;Y<I;Y++){const Z=A[Y],_=A[Y+1];if(_===Z)continue;const J=C.subarray(Z,_);for(let ee=0;ee<w.length;ee++){const ne=w[ee],se=x(ne.handle,J,ne.fn,l.totalContext||{locale:l.locale});V.set(O(R,y[Y],ne.colId),se)}}}return{keys:v,paths:y,fields:F,groupPaths:p,columns:M,values:V,cells:V,error:null}}function s(n,c,o){if(c.length===0)return n.slice();const l=[];for(const h of n)for(const w of c)l.push(`${h}${o}${w.colId}`);return l}function i(n){if(n.length===1)return n[0]||new Uint32Array(0);let c=0;for(const h of n)c+=h?h.length:0;const o=new Uint32Array(c);let l=0;for(const h of n)!h||h.length===0||(o.set(h,l),l+=h.length);return o}}),Ie("packages/core/src/store/bitset.js",function(e,U){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return N}});const te=8;class N{static#e=new Uint8Array(256);static{for(let B=1;B<256;B++)N.#e[B]=N.#e[B>>1]+(B&1)}#t;#n;constructor(B=0){const D=Math.max(0,B|0);this.#n=D,this.#t=new Uint8Array(Math.ceil(D/te))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(B){return B<0||B>=this.#n?0:this.#t[B>>3]>>(B&7)&1}set(B){return B>=0&&B<this.#n&&(this.#t[B>>3]|=1<<(B&7)),this}clear(B){return B>=0&&B<this.#n&&(this.#t[B>>3]&=~(1<<(B&7))),this}assign(B,D){return D?this.set(B):this.clear(B)}fill(B=!1){return this.#t.fill(B?255:0),B&&this.#r(),this}grow(B){const D=Math.max(0,B|0);if(D<=this.#n)return this;const q=Math.ceil(D/te);if(q>this.#t.length){const K=new Uint8Array(q);K.set(this.#t),this.#t=K}return this.#n=D,this}count(){const B=this.#t,D=N.#e;let q=0;for(let K=0;K<B.length;K++)q+=D[B[K]];return q}and(B){const D=B instanceof N?B.words:B,q=this.#t,K=Math.min(q.length,D.length);for(let x=0;x<K;x++)q[x]&=D[x];for(let x=K;x<q.length;x++)q[x]=0;return this}or(B){const D=B instanceof N?B.words:B,q=this.#t,K=Math.min(q.length,D.length);for(let x=0;x<K;x++)q[x]|=D[x];return this}not(){const B=this.#t;for(let D=0;D<B.length;D++)B[D]=~B[D]&255;return this.#r(),this}clone(){const B=new N(this.#n);return B.words.set(this.#t.subarray(0,B.words.length)),B}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const B=this.#n&7;if(B===0)return;const D=this.#n>>3;D<this.#t.length&&(this.#t[D]&=(1<<B)-1)}static from(B){const D=Array.isArray(B)?B:Array.from(B),q=new N(D.length);for(let K=0;K<D.length;K++)D[K]&&q.set(K);return q}}}),Ie("packages/core/src/store/dictionary.js",function(e,U){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return B}});const te=U("packages/core/src/internal/compare.js"),N=te.collator,X=te.defaultCompare;class B{#e;#t=new Map;#n=0;#r=null;#i=-1;#s="\0";constructor(q=[]){this.#e=[];for(let K=0;K<q.length;K++){const x=q[K];this.#t.has(x)||(this.#t.set(x,this.#e.length),this.#e.push(x))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let q=this.#e.length*8;for(let K=0;K<this.#e.length;K++){const x=this.#e[K];typeof x=="string"&&(q+=x.length*2),q+=16}return q}codeOf(q){const K=this.#t.get(q);if(K!==void 0)return K;const x=this.#e.length;return this.#e.push(q),this.#t.set(q,x),this.#n++,x}lookup(q){const K=this.#t.get(q);return K===void 0?-1:K}has(q){return this.#t.has(q)}valueOf(q){return this.#e[q]}values(){return this.#e}ranks(q){const K=q||"";if(this.#r&&this.#i===this.#n&&this.#s===K)return this.#r;const x=this.#e.length,G=new Array(x);for(let b=0;b<x;b++)G[b]=b;const z=N(q).compare,j=this.#e;G.sort((b,u)=>this.#o(j[b],j[u],z));const O=new Uint32Array(x);for(let b=0;b<x;b++)O[G[b]]=b;return this.#r=O,this.#i=this.#n,this.#s=K,O}#o(q,K,x){return typeof q=="string"&&typeof K=="string"?x(q,K):X(q,K)}}}),Ie("packages/core/src/store/multivalue.js",function(e,U){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return te}});class te{#e;#t;#n=0;#r=0;constructor(X={}){const B=Math.max(1,X.rows??16),D=Math.max(1,X.values??B);this.#e=new Int32Array(D),this.#t=new Uint32Array(B+1)}get values(){return this.#e}get offsets(){return this.#t}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#e.byteLength+this.#t.byteLength}count(X){return X<0||X>=this.#n?0:this.#t[X+1]-this.#t[X]}at(X){return X<0||X>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[X],this.#t[X+1])}has(X,B){if(X<0||X>=this.#n)return!1;const D=this.#e,q=this.#t[X+1];for(let K=this.#t[X];K<q;K++)if(D[K]===B)return!0;return!1}hasAny(X,B){for(let D=0;D<B.length;D++)if(this.has(X,B[D]))return!0;return!1}hasAll(X,B){for(let D=0;D<B.length;D++)if(!this.has(X,B[D]))return!1;return!0}hasNone(X,B){return!this.hasAny(X,B)}push(X){const B=this.#n,D=X.length;this.#i(B+1),this.#s(this.#r+D);const q=this.#r;for(let K=0;K<D;K++)this.#e[q+K]=X[K]|0;return this.#r+=D,this.#n=B+1,this.#t[B]=q,this.#t[B+1]=this.#r,B}write(X,B){if(X===this.#n){this.push(B);return}if(X<0||X>this.#n)return;const D=this.#t[X],q=this.#t[X+1],K=B.length;if(q-D===K){for(let x=0;x<K;x++)this.#e[D+x]=B[x]|0;return}this.#o(X,B)}compact(X,B,D){const q=this.#e,K=this.#t,x=this.#n,G=new Int32Array(Math.max(1,this.#r)),z=new Uint32Array(B+1);let j=0;for(let O=0;O<x;O++){if(X[O]===D)continue;const b=K[O],u=K[O+1];z[X[O]]=j;for(let f=b;f<u;f++)G[j++]=q[f];z[X[O]+1]=j}this.#e=G,this.#t=z,this.#n=B,this.#r=j}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#i(X){if(X+1<=this.#t.length)return;let B=this.#t.length-1;for(;B<X;)B=B*2||16;const D=new Uint32Array(B+1);D.set(this.#t),this.#t=D}#s(X){if(X<=this.#e.length)return;let B=this.#e.length;for(;B<X;)B=B*2||16;const D=new Int32Array(B);D.set(this.#e),this.#e=D}#o(X,B){const D=this.#e,q=this.#t,K=this.#n,x=B.length-(q[X+1]-q[X]),G=new Int32Array(Math.max(1,this.#r+x)),z=new Uint32Array(q.length);let j=0;for(let O=0;O<K;O++){if(z[O]=j,O===X)for(let b=0;b<B.length;b++)G[j++]=B[b]|0;else for(let b=q[O];b<q[O+1];b++)G[j++]=D[b];z[O+1]=j}this.#e=G,this.#t=z,this.#r=j}}}),Ie("packages/core/src/compute/sort.js",function(e,U){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return I}});const te=U("packages/core/src/compute/handle.js"),N=te.bitReader,X=te.dictRanks,B=te.dictSize,D=te.identity,q=te.isMissing,K=te.presenceReader,x=te.rowCount,G=te.valueComparator,z=te.valueReader,j=new Uint32Array(0),O=new ArrayBuffer(8),b=new Float64Array(O),u=new Uint32Array(O),f=(b[0]=-1,(u[1]&2147483648)!==0?1:0),a=f===1?0:1;function r(S,R){b[0]=S;let L=u[f],T=u[a];(L&2147483648)!==0?(L=~L>>>0,T=~T>>>0):L=(L^2147483648)>>>0,R[0]=T,R[1]=L}function t(S,R,L,T){if(T<2)return S;const A=new Uint32Array(256*8);for(let ne=0;ne<T;ne++){const se=R[ne],oe=L[ne];A[se&255]++,A[256+(se>>>8&255)]++,A[512+(se>>>16&255)]++,A[768+(se>>>24&255)]++,A[1024+(oe&255)]++,A[1280+(oe>>>8&255)]++,A[1536+(oe>>>16&255)]++,A[1792+(oe>>>24&255)]++}let C=S,H=R,Y=L,Z=new Uint32Array(T),_=new Uint32Array(T),J=new Uint32Array(T);const ee=new Uint32Array(256);for(let ne=0;ne<8;ne++){const se=ne<<8,oe=(ne&3)<<3,fe=ne>=4;let pe=!1;for(let Ue=0;Ue<256;Ue++)if(A[se+Ue]===T){pe=!0;break}if(pe)continue;let he=0;for(let Ue=0;Ue<256;Ue++)ee[Ue]=he,he+=A[se+Ue];for(let Ue=0;Ue<T;Ue++){const Le=H[Ue],ie=Y[Ue],ge=(fe?ie:Le)>>>oe&255,ke=ee[ge]++;Z[ke]=C[Ue],_[ke]=Le,J[ke]=ie}let Re=C;C=Z,Z=Re,Re=H,H=_,_=Re,Re=Y,Y=J,J=Re}return C}function s(S,R,L){if(L<2)return S;const T=new Uint32Array(256*4);for(let _=0;_<L;_++){const J=R[_];T[J&255]++,T[256+(J>>>8&255)]++,T[512+(J>>>16&255)]++,T[768+(J>>>24&255)]++}let A=S,C=R,H=new Uint32Array(L),Y=new Uint32Array(L);const Z=new Uint32Array(256);for(let _=0;_<4;_++){const J=_<<8,ee=_<<3;let ne=!1;for(let fe=0;fe<256;fe++)if(T[J+fe]===L){ne=!0;break}if(ne)continue;let se=0;for(let fe=0;fe<256;fe++)Z[fe]=se,se+=T[J+fe];for(let fe=0;fe<L;fe++){const pe=C[fe],he=Z[pe>>>ee&255]++;H[he]=A[fe],Y[he]=pe}let oe=A;A=H,H=oe,oe=C,C=Y,Y=oe}return A}function i(S,R,L,T){const A=new Uint32Array(T+1);for(let Y=0;Y<L;Y++)A[R[Y]]++;let C=0;for(let Y=0;Y<=T;Y++){const Z=A[Y];A[Y]=C,C+=Z}const H=new Uint32Array(L);for(let Y=0;Y<L;Y++)H[A[R[Y]]++]=S[Y];return H}function n(S,R,L,T){return L<2?S:T<=65536||T<=L*2?i(S,R,L,T):s(S,R,L)}function c(S,R){return S.length===R&&S.byteOffset===0?S:Uint32Array.prototype.slice.call(S,0,R)}function o(S,R,L=!1){const T=R||D(S.length),A=T.length;if(A<2)return Uint32Array.from(T);const C=new Uint32Array(A),H=new Uint32Array(A),Y=new Uint32Array(A),Z=new Uint32Array(A),_=new Uint32Array(2);let J=0,ee=0;for(let oe=0;oe<A;oe++){const fe=T[oe],pe=S[fe];if(Number.isNaN(pe)){Z[ee++]=fe;continue}r(pe,_),L?(H[J]=~_[0]>>>0,Y[J]=~_[1]>>>0):(H[J]=_[0],Y[J]=_[1]),C[J++]=fe}const ne=t(C.subarray(0,J),H.subarray(0,J),Y.subarray(0,J),J);if(ee===0)return c(ne,J);const se=new Uint32Array(A);return se.set(ne.subarray(0,J),0),se.set(Z.subarray(0,ee),J),se}function l(S,R,L=!1){const T=R||D(S.length),A=T.length;if(A<2)return Uint32Array.from(T);const C=Uint32Array.from(T),H=new Uint32Array(A);for(let Y=0;Y<A;Y++){const Z=(S[C[Y]]^2147483648)>>>0;H[Y]=L?~Z>>>0:Z}return c(s(C,H,A),A)}function h(S,R,L={}){const T=R||D(x(S,L)),A=T.length;if(A<2)return Uint32Array.from(T);const C=X(S.dict,L.locale),H=S.values,Y=K(S),Z=Math.max(B(S.dict),C.length),_=Z,J=Uint32Array.from(T),ee=new Uint32Array(A),ne=!!L.descending;for(let se=0;se<A;se++){const oe=J[se];let fe=Y&&Y(oe)===0?_:C[H[oe]];fe===void 0&&(fe=_),ee[se]=ne?_-fe:fe}return c(n(J,ee,A,Z+1),A)}function w(S,R,L){const T=R.length;let A=Uint32Array.from(R);if(T<2)return A;let C=new Uint32Array(T);for(let H=1;H<T;H<<=1){for(let Z=0;Z<T;Z+=H<<1){const _=Math.min(Z+H,T),J=Math.min(Z+(H<<1),T);let ee=Z,ne=_,se=Z;for(;ee<_&&ne<J;)C[se++]=L(S[A[ee]],S[A[ne]])<=0?A[ee++]:A[ne++];for(;ee<_;)C[se++]=A[ee++];for(;ne<J;)C[se++]=A[ne++]}const Y=A;A=C,C=Y}return A}function g(S,R,L){const T=N(S.values),A=R.length,C=new Uint32Array(A),H=L?1:0;let Y=0;for(let Z=0;Z<A;Z++)T(R[Z])===H&&(C[Y++]=R[Z]);for(let Z=0;Z<A;Z++)T(R[Z])!==H&&(C[Y++]=R[Z]);return C}function k(S,R){const L=S.values,T=S.kind;if((T==="object"||T===void 0)&&(Array.isArray(L)||ArrayBuffer.isView(L))&&!S.presence)return L;const C=z(S),H=new Array(x(S)||0);for(let Y=0;Y<R.length;Y++){const Z=R[Y];H[Z]=C(Z)}return H}function d(S,R){for(let L=0;L<R.length;L++)if(typeof S[R[L]]!="string")return!1;return!0}function p(S,R,L,T,A){const C=S.length,H=Uint32Array.from(S);if(C<2||T<1)return H;const Y=new Uint32Array(C),Z=T-1;for(let _=0;_<C;_++){const J=L[R[_]];Y[_]=A?Z-J:J}return c(n(H,Y,C,T),C)}function m(S,R,L){const T=G(L),A=new Array(R);for(let H=0;H<R;H++)A[H]=H;A.sort((H,Y)=>T(S[H],S[Y])||H-Y);const C=new Uint32Array(R);for(let H=0;H<R;H++)C[A[H]]=H;return C}function v(S,R,L){const T=R.length,A=new Map,C=[],H=new Uint32Array(T);for(let _=0;_<T;_++){const J=S[R[_]];let ee=A.get(J);ee===void 0&&(ee=C.length,A.set(J,ee),C.push(J)),H[_]=ee}const Y=C.length,Z=m(C,Y,L.locale);return p(R,H,Z,Y,!!L.descending)}function y(S,R,L){const T=k(S,R);if(R.length>=2&&d(T,R)){const H=S.stringRank;return H&&H.version===S.version&&H.usable(R,T,L.locale)?H.sort(R,L):v(T,R,L)}const A=G(L.locale),C=L.descending?(H,Y)=>A(Y,H):A;return w(T,R,C)}function E(S,R,L){const T=k(S,R),A=L.compare,H=!!L.descending?(Y,Z)=>-A(Y,Z,void 0,void 0,!0):(Y,Z)=>A(Y,Z,void 0,void 0,!1);return w(T,R,H)}function M(S,R){const L=R.length,T=K(S),A=S.values,C=S.kind==="float64"&&!!A,H=S.kind==="object"||S.kind==="multi"||S.kind===void 0;if(!T&&!C&&!H)return{present:R,absent:j};const Y=new Uint32Array(L),Z=new Uint32Array(L);let _=0,J=0;if(T&&C)for(let ee=0;ee<L;ee++){const ne=R[ee];T(ne)===1&&!Number.isNaN(A[ne])?Y[_++]=ne:Z[J++]=ne}else if(C&&!T)for(let ee=0;ee<L;ee++){const ne=R[ee];Number.isNaN(A[ne])?Z[J++]=ne:Y[_++]=ne}else if(T&&!H)for(let ee=0;ee<L;ee++){const ne=R[ee];T(ne)===1?Y[_++]=ne:Z[J++]=ne}else{const ee=z(S);for(let ne=0;ne<L;ne++){const se=R[ne];q(ee(se))?Z[J++]=se:Y[_++]=se}}return J===0?{present:R,absent:j}:{present:Y.subarray(0,_),absent:Z.subarray(0,J)}}function F(S,R,L){if(R.length===0)return S;const T=new Uint32Array(S.length+R.length);return L?(T.set(R,0),T.set(S,R.length)):(T.set(S,0),T.set(R,S.length)),T}function V(S,R,L={}){const T=R||D(x(S,L));if(!S||T.length<2)return Uint32Array.from(T);const{present:A,absent:C}=M(S,T);if(A.length===0)return Uint32Array.from(T);const H=!!L.descending;let Y;if(typeof L.compare=="function")Y=E(S,A,L);else switch(S.kind){case"float64":Y=o(S.values,A,H);break;case"int32":Y=l(S.values,A,H);break;case"dictionary":Y=h(S,A,L);break;case"bitset":Y=g(S,A,H);break;default:Y=y(S,A,L);break}return F(Y,C,!!L.nullsFirst)}function I(S,R,L,T={}){const A=R||[],C=A.length&&(A[0].handle||$(S,A[0].col))||S&&S[0];let H=L||D(x(C,T));for(let Y=A.length-1;Y>=0;Y--){const Z=A[Y],_=Z.handle||$(S,Z.col)||S&&S[Y];_&&(H=V(_,H,{descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,locale:Z.locale!==void 0?Z.locale:T.locale,compare:Z.compare}))}return H instanceof Uint32Array?H:Uint32Array.from(H)}function $(S,R){if(!(!S||R===void 0)){for(let L=0;L<S.length;L++)if(S[L]&&S[L].id===R)return S[L]}}}),Ie("packages/core/src/store/stringrank.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return D}});const te=U("packages/core/src/compute/sort.js"),N=te.collateStringRanks,X=te.rankSortStrings,B=1e5;class D{#e=[];#t=new Map;#n;#r=0;#i=0;#s=-1;#o;#l=!1;#a=null;#c=-1;#u="\0";constructor(K=B){this.#o=K>0?K:B,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(K){this.#s=K}get generation(){return this.#i}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let K=this.#n.byteLength;const x=this.#e;for(let G=0;G<x.length;G++)K+=x[G].length*2+24;return K}#f(K,x){const G=this.#t.get(K);if(G!==void 0)return G;if(this.#l)return-1;if(x&&this.#e.length>=this.#o)return this.#l=!0,-1;const z=this.#e.length;return this.#e.push(K),this.#t.set(K,z),this.#i++,z}build(K,x){const G=x|0;this.#e=[],this.#t=new Map,this.#i=0,this.#l=!1,this.#a=null,this.#c=-1,this.#n=new Uint32Array(G);for(let z=0;z<G;z++){const j=K[z],O=typeof j=="string"?this.#f(j,!1):-1;this.#n[z]=O<0?0:O}this.#r=G}append(K,x,G){const z=(x|0)+(G|0);if(z>this.#n.length){const j=new Uint32Array(z);j.set(this.#n.subarray(0,this.#r)),this.#n=j}for(let j=x|0;j<z;j++){const O=K[j],b=typeof O=="string"?this.#f(O,!0):-1;this.#n[j]=b<0?0:b}this.#r=Math.max(this.#r,z)}ranks(K){const x=K||"";if(this.#a&&this.#c===this.#i&&this.#u===x)return this.#a;const G=N(this.#e,this.#e.length,K);return this.#a=G,this.#c=this.#i,this.#u=x,G}usable(K,x,G){if(this.#l||this.#e.length===0)return!1;const z=this.#n,j=this.#e,O=this.#r;for(let b=0;b<K.length;b++){const u=K[b];if(u>=O||j[z[u]]!==x[u])return!1}return!0}sort(K,x){const G=this.ranks(x.locale),z=this.#e.length,j=K.length,O=new Uint32Array(j),b=this.#n;for(let u=0;u<j;u++)O[u]=b[K[u]];return X(K,O,G,z,!!x.descending)}}}),Ie("packages/core/src/store/columnstore.js",function(e,U){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return g}});const N=U("packages/core/src/internal/warn.js").warnOnce,B=U("packages/core/src/internal/predicates.js").isFunction,q=U("packages/core/src/internal/paths.js").pathGetter,x=U("packages/core/src/store/bitset.js").Bitset,z=U("packages/core/src/store/dictionary.js").Dictionary,O=U("packages/core/src/store/multivalue.js").MultiValue,u=U("packages/core/src/store/stringrank.js").StringRankIndex,f=4294967295,a=1024,r=5e3,t=.2,s=new Set(["float64","int32","bitset","dictionary","object","multi"]);function i(k){return k==null}function n(k){if(typeof k=="number")return k;if(k instanceof Date)return k.getTime();if(typeof k=="boolean")return k?1:0;const d=Number(k);return Number.isNaN(d)&&typeof k=="string"?Date.parse(k):d}function c(k){const d=n(k);return Number.isFinite(d)?d|0:0}function o(k){return i(k)?[]:Array.isArray(k)?k:[k]}function l(k,d){switch(k.kind){case"float64":case"int32":return k.buf[d];case"bitset":return k.bits.get(d)===1;case"dictionary":return k.dict.valueOf(k.buf[d]);case"multi":{const p=k.mv.at(d),m=new Array(p.length);for(let v=0;v<p.length;v++)m[v]=k.dict.valueOf(p[v]);return m}default:return k.buf[d]}}function h(k,d){switch(k.kind){case"float64":case"int32":return k.values[d];case"bitset":return(k.values[d>>3]&1<<(d&7))!==0;case"dictionary":return(k.table||[])[k.values[d]];case"multi":{const p=k.offsets[d],m=k.offsets[d+1],v=k.table||[],y=new Array(m-p);for(let E=p;E<m;E++)y[E-p]=v[k.values[E]];return y}default:return k.values[d]}}class w{#e;#t;#n;#r;#i;#s;#o;#l=!1;#a=null;#c=null;#u=null;#f=null;#d=null;#h;#p;#m=-1;#g=null;#b=0;#y=0;#A=null;#w=null;#O=!1;constructor(d,p){this.#e=d.id;const m=s.has(d.kind)?d.kind:"object";d.kind&&!s.has(d.kind)&&N(`store.kind.${d.id}`,`column "${d.id}" declares unknown storage kind "${d.kind}"; falling back to object`),this.#n=m,this.#t=m,this.#r=d.nullable!==!1,this.#o=d.dictionary??null,this.#s=p,this.#i=B(d.read)?d.read:q(d.field||d.id),this.#h=d.stringRankIndex!=="off",this.#p=typeof d.stringRankMaxDistinct=="number"?d.stringRankMaxDistinct:0,this.#A=new Map}get id(){return this.#e}get kind(){return this.#l?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#O?null:this.#l?this.#t==="bitset"?this.#c.words:this.#t==="multi"?this.#u.values:this.#a:this.#P().values}get presence(){return this.#O||!this.#r?null:this.#l?this.#g:this.#P().presence}get dict(){return this.#O||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#f:null}get stringRank(){if(this.#O||!this.#h||this.kind!=="object")return null;const d=this.values,p=this.#s.physical();if(!d||p===0)return null;if(this.#d===null){if(typeof d[0]!="string")return null;const m=new u(this.#v());return m.build(d,p),m.version=this.#y,this.#d=m,this.#m=this.#y,m.capped?null:m}return this.#d.length<p&&this.#d.append(d,this.#d.length,p-this.#d.length),this.#d.version=this.#y,this.#m=this.#y,this.#d.capped?null:this.#d}#v(){return this.#p}#T(){this.#d=null,this.#m=-1}get offsets(){return this.#O||!this.#l||this.#t!=="multi"?null:this.#u.offsets}get version(){return this.#y}get bytes(){let d=0;return this.#a&&(d+=this.#a.byteLength??this.#a.length*8),this.#c&&(d+=this.#c.bytes),this.#u&&(d+=this.#u.bytes),this.#g&&(d+=this.#g.bytes),this.#f&&(d+=this.#f.bytes),this.#A&&(d+=this.#A.size*24),d}get(d){if(!this.#O&&!(d<0||d>=this.#s.physical())){if(!this.#l)return this.#N(d);if(this.#r&&this.#g.get(d)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[d];case"bitset":return this.#c.get(d)===1;case"dictionary":return this.#f.valueOf(this.#a[d]);case"multi":{const p=this.#u.at(d),m=new Array(p.length);for(let v=0;v<p.length;v++)m[v]=this.#f.valueOf(p[v]);return m}default:return this.#a[d]}}}set(d,p){this.#O||(this.#l?this.#E(d,p):this.#A.set(d,p===void 0?null:p),this.#d&&this.#T(),this.#y++)}read(d){return this.#i(d)}appendColumn(d,p,m){if(this.#O||m<=0)return;if(!this.#l){this.#y++;return}const v=this.#i,y=this.#r,E=this.#g;let M=!1;switch(this.#t){case"float64":{const F=this.#a;for(let V=0;V<m;V++){const I=v(d[V]);if(typeof I=="number"){y&&E.set(p+V),F[p+V]=I;continue}const $=I==null;y?E.assign(p+V,!$):$&&(M=!0),F[p+V]=$?NaN:n(I)}break}case"int32":{const F=this.#a;for(let V=0;V<m;V++){const I=v(d[V]),$=I==null;y?E.assign(p+V,!$):$&&(M=!0),F[p+V]=$?0:c(I)}break}case"bitset":{const F=this.#c;for(let V=0;V<m;V++){const I=v(d[V]),$=I==null;y?E.assign(p+V,!$):$&&(M=!0),F.assign(p+V,!$&&!!I)}break}case"dictionary":{const F=this.#a,V=this.#f;for(let I=0;I<m;I++){const $=v(d[I]),S=$==null;y?E.assign(p+I,!S):S&&(M=!0),F[p+I]=S?0:V.codeOf($)}break}case"multi":{const F=this.#u,V=this.#f;for(let I=0;I<m;I++){const $=v(d[I]),S=$==null;y?E.assign(p+I,!S):S&&(M=!0);const R=o($),L=new Array(R.length);for(let T=0;T<R.length;T++)L[T]=V.codeOf(R[T]);F.write(p+I,L)}break}default:{const F=this.#a;for(let V=0;V<m;V++){const I=v(d[V]),$=I==null;y?E.assign(p+V,!$):$&&(M=!0),F[p+V]=$?null:I}break}}M&&N(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#t==="object"&&(this.#d.append(this.#a,p,m),this.#d.version=this.#y+1,this.#m=this.#y+1),this.#y++}appendPacked(d,p,m){if(this.#O||m<=0||!d)return;if(!this.#l){this.#y++;return}const v=this.#g,y=d.presence;if(v)if(y)for(let M=0;M<m;M++)v.assign(p+M,(y[M>>3]&1<<(M&7))!==0);else for(let M=0;M<m;M++)v.set(p+M);const E=d.kind===this.#t;if(E&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(d.values,p),this.#y++;return}if(E&&this.#t==="bitset"){const M=d.values;for(let F=0;F<m;F++)this.#c.assign(p+F,(M[F>>3]&1<<(F&7))!==0);this.#y++;return}if(E&&this.#t==="dictionary"){const M=d.table||[],F=new Uint32Array(M.length);for(let S=0;S<M.length;S++)F[S]=this.#f.codeOf(M[S]);const V=d.values,I=this.#a,$=v;for(let S=0;S<m;S++){if($&&(y&&(y[S>>3]&1<<(S&7))===0)){I[p+S]=0;continue}I[p+S]=F[V[S]]??0}this.#y++;return}if(E&&this.#t==="multi"){const M=d.table||[],F=new Uint32Array(M.length);for(let $=0;$<M.length;$++)F[$]=this.#f.codeOf(M[$]);const V=d.values,I=d.offsets;for(let $=0;$<m;$++){const S=I[$],R=I[$+1],L=new Array(R-S);for(let T=S;T<R;T++)L[T-S]=F[V[T]]??0;this.#u.write(p+$,L)}this.#y++;return}for(let M=0;M<m;M++){const F=y?(y[M>>3]&1<<(M&7))===0:d.kind==="object"?d.values[M]===null:!1;this.#E(p+M,F?null:h(d,M))}this.#y++}touch(){this.#y++}columnarise(d,p){if(this.#l||this.#O)return;const m=new Array(p);for(let v=0;v<p;v++)m[v]=this.#N(v);this.#t=this.#n,this.#l=!0,this.#S(d);for(let v=0;v<p;v++)this.#E(v,m[v]);this.#A.clear(),this.#w=null,this.#T(),this.#y++}grow(d){if(!(!this.#l||this.#O||d<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const p=new this.#a.constructor(d);p.set(this.#a),this.#a=p;break}case"bitset":this.#c.grow(d);break;case"multi":break;default:this.#a.length=d;break}this.#g&&this.#g.grow(d),this.#b=d,this.#y++}}convert(d){if(this.#O||!s.has(d)||(this.#n=d,!this.#l||d===this.#t))return!1;const p={kind:this.#t,buf:this.#a,bits:this.#c,mv:this.#u,dict:this.#f},m=this.#s.physical(),v=this.#g;this.#t=d,this.#S(this.#b);for(let y=0;y<m;y++){const E=v!==null&&v.get(y)===0;E&&d!=="multi"||this.#E(y,E?null:l(p,y))}return this.#T(),this.#y++,!0}compact(d,p,m){if(!this.#O){if(this.#T(),!this.#l){const v=this.#A;if(v.size){const y=new Map;for(const[E,M]of v)d[E]!==f&&y.set(d[E],M);this.#A=y}this.#w=null,this.#y++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const v=this.#a;for(let y=0;y<p;y++)d[y]!==f&&(v[d[y]]=v[y]);if(this.#t==="object")for(let y=m;y<p;y++)v[y]=void 0;break}case"bitset":{const v=this.#c;for(let y=0;y<p;y++)d[y]!==f&&v.assign(d[y],v.get(y)===1);for(let y=m;y<p;y++)v.clear(y);break}case"multi":this.#u.compact(d,m,f);break;default:break}if(this.#g){const v=this.#g;for(let y=0;y<p;y++)d[y]!==f&&v.assign(d[y],v.get(y)===1);for(let y=m;y<p;y++)v.clear(y)}this.#y++}}release(){this.#O||(this.#O=!0,this.#a=null,this.#c&&this.#c.release(),this.#c=null,this.#u&&this.#u.release(),this.#u=null,this.#g&&this.#g.release(),this.#g=null,this.#f=null,this.#d=null,this.#A=new Map,this.#w=null,this.#b=0,this.#y++)}#S(d){const p=Math.max(1,d);switch(this.#a=null,this.#c=null,this.#u=null,this.#t){case"float64":this.#a=new Float64Array(p);break;case"int32":this.#a=new Int32Array(p);break;case"bitset":this.#c=new x(p);break;case"dictionary":this.#a=new Uint32Array(p),this.#f=this.#f??new z(this.#o??[]);break;case"multi":this.#u=new O({rows:p,values:p}),this.#f=this.#f??new z(this.#o??[]);break;default:this.#a=new Array(p);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#f=null),this.#r&&(this.#g?this.#g.grow(p):this.#g=new x(p)),this.#b=p}#E(d,p){const m=i(p);switch(this.#r?this.#g.assign(d,!m):m&&N(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[d]=m?NaN:n(p);break;case"int32":this.#a[d]=m?0:c(p);break;case"bitset":this.#c.assign(d,!m&&!!p);break;case"dictionary":this.#a[d]=m?0:this.#f.codeOf(p);break;case"multi":{const v=o(p),y=new Array(v.length);for(let E=0;E<v.length;E++)y[E]=this.#f.codeOf(v[E]);this.#u.write(d,y);break}default:this.#a[d]=m?null:p;break}}#N(d){if(this.#A.has(d))return this.#A.get(d);const p=this.#i(this.#s.rowAt(d));return p===void 0?null:p}#P(){if(this.#w&&this.#w.version===this.#y)return this.#w;const d=this.#s.physical(),p=new Array(d),m=this.#r?new x(d):null;for(let v=0;v<d;v++){const y=this.#N(v);p[v]=y,m&&!i(y)&&m.set(v)}return this.#w={version:this.#y,values:p,presence:m},this.#w}}class g{#e;#t=new Map;#n=[];#r=[];#i=0;#s=0;#o=0;#l=0;#a=new x(0);#c=!1;#u=!0;#f;#d;#h;#p=!1;constructor(d,p={}){this.#e=Array.isArray(d)?d:[],this.#d=Math.max(1,p.initialCapacity??a),this.#u=p.retainSource!==!1,this.#f=this.#u?p.columnarBelow??r:0,this.#h=p.compactRatio??t;const m={rowAt:v=>this.#r[v],physical:()=>this.#i};for(const v of this.#e){if(!v||!v.id)continue;if(this.#t.has(v.id)){N(`store.dup.${v.id}`,`duplicate column id "${v.id}" in the store schema; ignoring the second`);continue}const y=new w(v,m);this.#t.set(v.id,y),this.#n.push(y)}this.#f<=0&&this.#b()}get count(){return this.#o}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#c}get destroyed(){return this.#p}get bytes(){let d=this.#a.bytes+this.#r.length*8;for(const p of this.#n)d+=p.bytes;return d}append(d){const p=this.#i;if(this.#p||!d)return{from:p,to:p};const m=d.length|0;if(m===0)return{from:p,to:p};if(this.#u)for(let y=0;y<m;y++)this.#r[p+y]=d[y];if(this.#i=p+m,this.#o+=m,this.#a.grow(this.#i),!this.#c){if(this.#i>=this.#f)this.#b();else for(const y of this.#n)y.touch();return{from:p,to:this.#i}}this.#m(this.#i);const v=this.#n;for(let y=0;y<v.length;y++)v[y].appendColumn(d,p,m);return{from:p,to:this.#i}}appendPacked(d,p){const m=this.#i;if(this.#p||!d)return{from:m,to:m};const v=d.count|0;if(v===0)return{from:m,to:m};if(this.#u&&p)for(let E=0;E<v;E++)this.#r[m+E]=p[E];this.#i=m+v,this.#o+=v,this.#a.grow(this.#i),this.#c||this.#b(),this.#m(this.#i);const y=new Map;for(const E of d.columns)y.set(E.id,E);for(const E of this.#n){const M=y.get(E.id);M?E.appendPacked(M,m,v):E.grow(this.#s)}return{from:m,to:this.#i}}source(d){if(this.#u)return this.#r[d];if(!(d<0||d>=this.#i))return this.#g(d)}setSource(d,p){this.#p||d<0||d>=this.#i||this.#u&&(this.#r[d]=p)}get(d,p){const m=this.#t.get(d);return m?m.get(p):void 0}set(d,p,m){if(this.#p||p<0||p>=this.#i)return;const v=this.#t.get(d);if(!v){N(`store.set.${d}`,`set() on unknown column "${d}"`);return}v.set(p,m)}remove(d){return this.#p||d<0||d>=this.#i||this.#a.get(d)===1?!1:(this.#a.set(d),this.#l++,this.#o--,!0)}live(d){return d<0||d>=this.#i?!1:this.#a.get(d)===0}compact(d={}){if(this.#p||this.#l===0||!d.force&&this.#l/this.#i<this.#h)return null;const p=this.#i,m=new Uint32Array(p);let v=0;for(let y=0;y<p;y++)m[y]=this.#a.get(y)===1?f:v++;for(const y of this.#n)y.compact(m,p,v);if(this.#u){const y=this.#r;for(let E=0;E<p;E++)m[E]!==f&&(y[m[E]]=y[E]);y.length=v}return this.#i=v,this.#o=v,this.#l=0,this.#a=new x(Math.max(this.#s,v)),m}column(d){return this.#t.get(d)}columns(){return this.#n.slice()}liveIndices(){const d=new Uint32Array(this.#o);if(this.#l===0){for(let m=0;m<this.#i;m++)d[m]=m;return d}let p=0;for(let m=0;m<this.#i;m++)this.#a.get(m)===0&&(d[p++]=m);return d}convert(d,p){const m=this.#t.get(d);return m?m.convert(p):!1}destroy(){if(!this.#p){this.#p=!0;for(const d of this.#n)d.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#i=0,this.#o=0,this.#l=0,this.#s=0}}#m(d){if(d<=this.#s)return;let p=this.#s||this.#d;for(;p<d;)p*=2;for(const m of this.#n)m.grow(p);this.#a.grow(p),this.#s=p}#g(d){const p={};for(const m of this.#n)p[m.id]=m.get(d);return p}#b(){if(this.#c)return;let d=this.#d;for(;d<this.#i;)d*=2;this.#c=!0,this.#s=d,this.#a.grow(d);for(const p of this.#n)p.columnarise(d,this.#i)}}}),Ie("packages/core/src/store/pool.js",function(e,U){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return D}});const te=64,N=8;function X(K){let x=te;for(;x<K;)x*=2;return x}class B{#e=new Map;#t=new WeakSet;#n;#r=0;#i={acquired:0,reused:0,released:0};constructor(x={}){this.#n=x.limit??N}get bytes(){return this.#r}mask(x){const G=new Uint8Array(this.#s(x),0,x);return G.fill(0),G}indices(x){return new Uint32Array(this.#s(x*4),0,x)}release(x){if(!x||!x.buffer)return!1;const G=x.buffer;if(!this.#t.has(G))return!1;this.#t.delete(G),this.#i.released++;const z=G.byteLength;let j=this.#e.get(z);return j||this.#e.set(z,j=[]),j.length>=this.#n||(j.push(G),this.#r+=z),!0}releaseAll(x){for(const G of x)this.release(G)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#i,retained:this.#r}}#s(x){const G=X(x),z=this.#e.get(G);this.#i.acquired++;let j;return z&&z.length?(j=z.pop(),this.#r-=G,this.#i.reused++):j=new ArrayBuffer(G),this.#t.add(j),j}}function D(){return q??=new B,q}let q=null}),Ie("packages/core/src/compute/sortspec.js",function(e,U){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return D}});function te(q){return{locale:q===void 0?void 0:String(q),numeric:!0,sensitivity:"variant"}}function N(q){return!!q&&typeof q.compare!="function"}function X(q){if(!q)return!0;for(let K=0;K<q.length;K++)if(!N(q[K]))return!1;return!0}function B(q,K){const x=q.col!==void 0?q.col:q.handle&&q.handle.id,G=q.locale!==void 0?q.locale:K;return{col:x,descending:q.descending!==void 0?!!q.descending:q.dir==="desc",nullsFirst:!!q.nullsFirst,collation:te(G)}}function D(q,K){const x=q||[],G=new Array(x.length);for(let z=0;z<x.length;z++)G[z]=B(x[z],K);return G}}),Ie("packages/core/src/compute/facet.js",function(e,U){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return u}}),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 s}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const te=U("packages/core/src/compute/handle.js"),N=te.presenceReader,X=te.valueReader,B=te.dictSize,D=te.dictValue,q=Object.freeze(["equal","quantile","log"]),K=Object.freeze(["hour","day","week","month","quarter","year"]),x=20,G=50,z=1e4;function j(m,v){if(!m)return"none";const y=v;if(y&&(y.multi===!0||typeof y.items=="function"))return"category";const E=v&&v.base;if(E==="date"||E==="datetime"||E==="time"||E==="dateString")return"date";switch(m.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return E==="number"?"numeric":E==="boolean"?"boolean":E==="text"?"category":"none"}}function O(m){const v=m.values,y=m.kind;if((y==="float64"||y==="int32")&&v)return M=>v[M];const E=X(m);return M=>b(E(M))}function b(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(m==null||m==="")return NaN;if(typeof m=="boolean")return m?1:0;if(typeof m=="string"){const v=Number(m);if(Number.isFinite(v))return v;const y=Date.parse(m);return Number.isFinite(y)?y:NaN}return NaN}function u(m,v,y,E=G){if(!m)return{cardinality:0,exact:!0};if(m.dict)return{cardinality:B(m.dict),exact:!0};if(m.kind==="bitset")return{cardinality:2,exact:!0};const M=X(m),F=v?v.length:y,V=new Set;for(let I=0;I<F;I++){const $=M(v?v[I]:I);if($!=null&&(V.add($),V.size>E))return{cardinality:V.size,exact:!1}}return{cardinality:V.size,exact:!0}}const f=36e5,a=864e5;function r(m,v=x){const y=Number.isFinite(m)&&m>0?m:0,E=Math.max(1,v)*2;return y/f<=E?"hour":y/a<=E?"day":y/(7*a)<=E?"week":y/(30*a)<=E?"month":y/(91*a)<=E?"quarter":"year"}function t(m,v){if(!Number.isFinite(m))return NaN;const y=new Date(m);switch(v){case"hour":return y.setMinutes(0,0,0),y.getTime();case"day":return y.setHours(0,0,0,0),y.getTime();case"week":{y.setHours(0,0,0,0);const E=(y.getDay()+6)%7;return y.setDate(y.getDate()-E),y.getTime()}case"month":return y.setDate(1),y.setHours(0,0,0,0),y.getTime();case"quarter":return y.setMonth(Math.floor(y.getMonth()/3)*3,1),y.setHours(0,0,0,0),y.getTime();default:return y.setMonth(0,1),y.setHours(0,0,0,0),y.getTime()}}function s(m,v){const y=new Date(m);switch(v){case"hour":y.setHours(y.getHours()+1);break;case"day":y.setDate(y.getDate()+1);break;case"week":y.setDate(y.getDate()+7);break;case"month":y.setMonth(y.getMonth()+1);break;case"quarter":y.setMonth(y.getMonth()+3);break;default:y.setFullYear(y.getFullYear()+1);break}return y.getTime()}function i(m,v,y){const E=O(m),M=N(m),F=v?v.length:y;let V=1/0,I=-1/0,$=0,S=0;for(let R=0;R<F;R++){const L=v?v[R]:R;if(M&&!M(L)){$++;continue}const T=E(L);if(!Number.isFinite(T)){$++;continue}T<V&&(V=T),T>I&&(I=T),S++}return{min:V,max:I,nulls:$,finite:S}}function n(m,v,y,E){const M=O(m),F=N(m),V=v?v.length:y,I=V>E?V/E:1,$=[];for(let R=0;R<V;R+=I){const L=v?v[Math.floor(R)]:Math.floor(R);if(F&&!F(L))continue;const T=M(L);Number.isFinite(T)&&$.push(T)}const S=Float64Array.from($);return S.sort(),S}function c(m,v,y,E={}){const M=E.kind||j(m,E.type);return M==="none"||!m?{kind:"none",buckets:[],suppressed:"type"}:M==="boolean"?o(m,v,y):M==="category"?l(m,v,y,E):h(m,v,y,M,E)}function o(m,v,y){const E=N(m);let M=0;if(E){const V=v?v.length:y;for(let I=0;I<V;I++)E(v?v[I]:I)||M++}const F=[{value:!1,label:"false"},{value:!0,label:"true"}];return M>0&&F.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:F}}function l(m,v,y,E){const M=E.cardinalityLimit??G,{cardinality:F}=u(m,v,y,M);if(F>M&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:F};const V=X(m),I=v?v.length:y,$=new Map;let S=0;for(let C=0;C<I;C++){const H=V(v?v[C]:C);if(H==null||H===""){S++;continue}if(Array.isArray(H)){if(!H.length){S++;continue}for(const Y of H)$.set(Y,($.get(Y)||0)+1);continue}$.set(H,($.get(H)||0)+1)}let R=[...$.entries()];E.order==="alpha"?R.sort((C,H)=>String(C[0]).localeCompare(String(H[0]))):R.sort((C,H)=>H[1]-C[1]);let L=0,T=0;if(R.length>M){T=R.length-M;for(let C=M;C<R.length;C++)L+=R[C][1];R=R.slice(0,M)}const A=R.map(([C])=>({value:C,label:String(C)}));return L>0&&A.push({remainder:!0,label:`Other (${T} values)`}),S>0&&A.push({null:!0,label:"Empty"}),{kind:"category",buckets:A,cardinality:F}}function h(m,v,y,E,M){const{min:F,max:V,nulls:I,finite:$}=i(m,v,y);if(!$)return{kind:E,buckets:I?[{null:!0,label:"Empty"}]:[],empty:!0};const S=Math.max(1,Math.floor(M.buckets||x));let R=[];if(E==="date"){const T=K.includes(M.granularity)?M.granularity:r(V-F,S);let A=t(F,T);for(;A<=V&&R.length<4096;){const C=s(A,T);if(!(C>A))break;R.push({from:A,to:C}),A=C}return{kind:E,buckets:w(R,I),granularity:T}}const L=q.includes(M.strategy)?M.strategy:"equal";if(L==="quantile"){const T=n(m,v,y,z);if(T.length){const A=[T[0]];for(let C=1;C<S;C++){const H=T[Math.min(T.length-1,Math.floor(C/S*T.length))];H>A[A.length-1]&&A.push(H)}A.push(V);for(let C=0;C<A.length-1;C++)R.push({from:A[C],to:A[C+1]})}}else if(L==="log"&&F>0){const T=Math.log10(F),C=(Math.log10(V)-T)/S||1;for(let H=0;H<S;H++)R.push({from:10**(T+H*C),to:10**(T+(H+1)*C)})}if(!R.length){const T=(V-F)/S||1;for(let A=0;A<S;A++)R.push({from:F+A*T,to:F+(A+1)*T})}return R[R.length-1].to=V,{kind:E,buckets:w(R,I),strategy:L,min:F,max:V}}function w(m,v){return v>0?[...m,{null:!0,label:"Empty"}]:m}function g(m,v,y,E,M){const F=E&&E.buckets||[],V=M&&M.length>=F.length?M.subarray(0,F.length):new Uint32Array(F.length);if(V.fill(0),!m||!F.length)return V;const I=F.length-1,$=!!F[I]&&F[I].null===!0,S=v?v.length:y;if(E.kind==="boolean"){const C=X(m);for(let H=0;H<S;H++){const Y=C(v?v[H]:H);if(Y==null){$&&V[I]++;continue}V[Y?1:0]++}return V}if(E.kind==="category"){const C=new Map;for(let Z=0;Z<F.length;Z++)!F[Z].null&&!F[Z].remainder&&C.set(F[Z].value,Z);const H=F.findIndex(Z=>Z.remainder),Y=X(m);for(let Z=0;Z<S;Z++){const _=Y(v?v[Z]:Z);if(_==null||_===""){$&&V[I]++;continue}if(Array.isArray(_)){if(!_.length){$&&V[I]++;continue}for(const ee of _){const ne=C.get(ee);ne!==void 0?V[ne]++:H>=0&&V[H]++}continue}const J=C.get(_);J!==void 0?V[J]++:H>=0&&V[H]++}return V}const R=$?F.length-1:F.length,L=new Float64Array(R+1);for(let C=0;C<R;C++)L[C]=F[C].from;L[R]=R?F[R-1].to:0;const T=O(m),A=N(m);for(let C=0;C<S;C++){const H=v?v[C]:C;if(A&&!A(H)){$&&V[I]++;continue}const Y=T(H);if(!Number.isFinite(Y)){$&&V[I]++;continue}const Z=k(L,R,Y);Z>=0&&V[Z]++}return V}function k(m,v,y){if(!v||y<m[0])return-1;if(y>=m[v])return y===m[v]?v-1:-1;let E=0,M=v-1;for(;E<M;){const F=E+M+1>>>1;y>=m[F]?E=F:M=F-1}return E}function d(m,v,y,E={}){const M=E.bounds||c(m,E.boundsIndices??v,y,E);return{bounds:M,counts:g(m,v,y,M)}}const p=d}),Ie("packages/core/src/compute/pivotmatrix.js",function(e,U){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return O}}),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 N=U("packages/core/src/compute/handle.js").valueComparator,B=U("packages/core/src/compute/total.js").total,q=U("packages/core/src/compute/group.js").packKeys,K=U("packages/core/src/compute/pivot.js"),x=K.joinPath,G=K.DEFAULT_PATH_SEPARATOR,z=K.DEFAULT_MAX_COLUMNS,j="";function O(s,i,n={}){const c=n.separator||G,o=s||[],l=i instanceof Uint32Array?i:Uint32Array.from(i||[]),h=l.length;if(o.length===0)return{tuples:[[]],paths:[j],buckets:[l]};const{keyOf:w,readers:g}=q(o,l,0),k=new Map,d=[],p=[],m=[];for(let V=0;V<h;V++){const I=l[V],$=w(I);let S=k.get($);if(S===void 0){S=d.length,k.set($,S),p.push($);const R=new Array(g.length);for(let L=0;L<g.length;L++)R[L]=g[L](I);d.push(R),m.push([])}m[S].push(I)}const v=N(n.locale),y=d.map((V,I)=>I);y.sort((V,I)=>{const $=d[V],S=d[I];for(let R=0;R<$.length;R++){const L=b($[R],S[R],v);if(L!==0)return L}return V-I});const E=new Array(y.length),M=new Array(y.length),F=new Array(y.length);for(let V=0;V<y.length;V++){const I=y[V];E[V]=d[I],M[V]=x(d[I],c),F[V]=Uint32Array.from(m[I])}return{tuples:E,paths:M,buckets:F}}function b(s,i,n){const c=s==null,o=i==null;return c||o?c&&o?0:c?1:-1:n(s,i)}function u(s,i,n){const c=[];for(let o=0;o<s.length;o++)n.has(s[o])&&c.push(s[o]);return Uint32Array.from(c)}function f(s,i,n,c){return{value:i.length?B(s,i,n,c):null,leaves:i,count:i.length}}function a(s){const i=s&&s.opts||{},n=i.separator||G,c=i.totalContext||{locale:i.locale},o=(s.measures||[]).filter(M=>M&&M.handle),l=s.leaves instanceof Uint32Array?s.leaves:Uint32Array.from(s.leaves||[]),h=O(s.rowHandles||[],l,{...i,separator:n}),w=O(s.columnHandles||[],l,{...i,separator:n}),g=i.maxColumns===void 0?z:i.maxColumns,k=w.paths.length*Math.max(1,o.length),d=new Map;if(g&&k>g)return{rowAxis:h,columnAxis:w,measures:o.map(M=>({colId:M.colId,fn:M.fn})),body:d,rowMargin:d,columnMargin:d,grand:d,columns:k,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${k} columns, above pivot.maxColumns of ${g}. Narrow the pivot columns or raise the limit.`,columns:k,maxColumns:g}};const p=new Map,m=new Map,v=new Map,y=new Map,E=w.buckets.map(M=>new Set(M));for(let M=0;M<w.paths.length;M++){const F=w.buckets[M],V=w.paths[M];for(const I of o)v.set(t(V,I.colId),f(I.handle,F,I.fn,c))}for(let M=0;M<h.paths.length;M++){const F=h.buckets[M],V=h.paths[M];for(const I of o)m.set(t(V,I.colId),f(I.handle,F,I.fn,c));for(let I=0;I<w.paths.length;I++){const $=u(F,w.buckets[I],E[I]);if($.length===0)continue;const S=w.paths[I];for(const R of o)p.set(r(V,S,R.colId),f(R.handle,$,R.fn,c))}}for(const M of o)y.set(M.colId,f(M.handle,l,M.fn,c));return{rowAxis:h,columnAxis:w,measures:o.map(M=>({colId:M.colId,fn:M.fn})),body:p,rowMargin:m,columnMargin:v,grand:y,columns:k,error:null}}function r(s,i,n){return`${s}\0${i}\0${n}`}function t(s,i){return`${s}\0${i}`}}),Ie("packages/core/src/compute/reference.js",function(e,U){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return a}});const N=U("packages/core/src/internal/paths.js").getPath,X=U("packages/core/src/compute/handle.js"),B=X.isMissing,D=X.valueComparator,K=U("packages/core/src/compute/filter.js").testValue,x="",G="\0";function z(s,i){const n=i.includes(".")?N(s,i):s?.[i];return n===void 0?null:n}function j(s,i,n={}){const c=i||[];let o=s.map((l,h)=>h);if(c.length===0)return o;for(let l=c.length-1;l>=0;l--)o=O(s,o,c[l],n);return o}function O(s,i,n,c){const o=n.locale!==void 0?n.locale:c.locale,l=D(o),h=n.descending!==void 0?!!n.descending:n.dir==="desc",w=[],g=[];for(const p of i){const m=z(s[p],n.col);B(m)?g.push(p):w.push(p)}const k=new Map;for(let p=0;p<w.length;p++)k.set(w[p],p);const d=(p,m)=>{const v=z(s[p],n.col),y=z(s[m],n.col);let E;return typeof n.compare=="function"?(E=n.compare(v,y,s[p],s[m],h),h&&(E=-E)):E=h?l(y,v):l(v,y),E!==0?E:k.get(p)-k.get(m)};return w.sort(d),n.nullsFirst?g.concat(w):w.concat(g)}function b(s,i,n={}){const c=[];for(let o=0;o<s.length;o++)u(s[o],i,n,o)&&c.push(o);return c}function u(s,i,n,c){if(!i)return!0;if(Array.isArray(i.conditions)){const o=i.conditions.filter(h=>h!=null);if(o.length===0)return!0;if(i.op==="or")return o.some(h=>u(s,h,n,c));const l=o.every(h=>u(s,h,n,c));return i.op==="not"?!l:l}return i.col===void 0&&typeof n.custom=="function"?!!n.custom(i,s,c):K(z(s,i.col),i,n.locale)}function f(s,i,n,c){const o=n||s.map((g,k)=>k),l=new Map,h=[],w=[];for(const g of o){const k=i.map((m,v)=>{const y=z(s[g],m);return c&&c[v]?c[v](y):y}),d=k.map(m=>m==null?G:String(m)).join(x);let p=l.get(d);p===void 0&&(p=h.length,l.set(d,p),h.push(k),w.push([])),w[p].push(g)}return{keys:h,buckets:w}}function a(s,i,n={}){const c=D(n.locale),o=s.filter(h=>!B(h)),l=o.map(r).filter(h=>h!==null);switch(i){case"count":return s.length;case"countValues":return o.length;case"sum":return l.reduce((h,w)=>h+w,0);case"avg":return o.length===0?null:l.reduce((h,w)=>h+w,0)/o.length;case"min":return o.length===0?null:o.reduce((h,w)=>c(w,h)<0?w:h);case"max":return o.length===0?null:o.reduce((h,w)=>c(w,h)>0?w:h);case"first":return s.length===0?null:t(s[0]);case"last":return s.length===0?null:t(s[s.length-1]);default:return null}}function r(s){if(typeof s=="number")return Number.isNaN(s)?null:s;if(s==null||s===""||typeof s=="boolean")return null;if(s instanceof Date)return s.getTime();const i=Number(s);return Number.isNaN(i)?null:i}function t(s){return s===void 0?null:s}}),Ie("packages/core/src/compute/index.js",function(e,U){"use strict";const te=U("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return te.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return te.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return te.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return te.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return te.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return te.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return te.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return te.rankSortStrings}});const N=U("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return N.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return N.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return N.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return N.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return N.describeSort}});const X=U("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return X.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return X.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return X.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return X.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return X.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return X.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return X.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return X.mentionsColumn}});const B=U("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return B.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return B.packKeys}});const D=U("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return D.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return D.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return D.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return D.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return D.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return D.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return D.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return D.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return D.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return D.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return D.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return D.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return D.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return D.QUANTILE_SAMPLE}});const q=U("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return q.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return q.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return q.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return q.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return q.collectValues}});const K=U("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return K.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return K.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return K.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return K.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return K.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return K.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return K.DEFAULT_MAX_COLUMNS}});const x=U("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return x.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return x.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return x.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return x.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return x.GRAND_PATH}});const G=U("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return G.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return G.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return G.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return G.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return G.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return G.referenceValue}});const z=U("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 j=U("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return j.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return j.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return j.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return j.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return j.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return j.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return j.SKETCH_BOUNDS}});const O=U("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return O.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return O.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return O.openWindow}});const b=U("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return b.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return b.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return b.maintenanceOf}});const u=U("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return u.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return u.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return u.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return u.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u.anomalyCondition}});const f=U("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return f.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return f.forecast}})}),Ie("packages/core/src/source/rows.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return f}});const N=U("packages/core/src/internal/warn.js").warnOnce,B=U("packages/core/src/internal/predicates.js").isFunction,D=32,q="\0";function K(a){return new x(a)}class x{#e;#t;constructor(r){this.#e=B(r&&r.rowKey)?r.rowKey:null;const t=r&&r.config?r.config.rowHeight:void 0;this.#t=typeof t=="number"||B(t)?t:D}get keyed(){return this.#e!==null}keyOf(r,t){if(this.#e){const s=this.#e(r);if(s!=null)return String(s)}else N("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${t}`}heightOf(r){return B(this.#t)?Number(this.#t(r))||D:this.#t}leaf(r,t,s=0,i=null){const n={key:this.keyOf(r,t),data:r,level:s,parent:i,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:t};return n.height=this.heightOf(n),n}group(r){const t={key:u(r.keyPath||r.path),data:null,level:r.level,parent:r.parent||null,children:[],group:!0,expanded:r.expanded!==!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.column,groupValue:r.value,groupPath:r.path,hasChildren:r.hasChildren!==!1};return r.totals&&(t.totals=r.totals),t.height=this.heightOf(t),t}footer(r){const t={key:`${r.key}${q}footer`,data:null,level:r.level,parent:r,group:!0,footer:!0,expanded:!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.groupColumn,groupValue:r.groupValue,groupPath:r.groupPath,hasChildren:!1,totals:r.totals};return t.height=this.heightOf(t),t}detail(r,t){return{key:`${r.key}${q}detail`,data:r.data,level:r.level+1,parent:r,group:!1,detail:!0,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:r.key}}grandTotal(r,t){const s={key:`${q}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:t,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:r};return s.height=this.heightOf(s),s}skeleton(r,t=0,s=!1){const i={key:`${q}pending${q}${r}`,data:null,level:t,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:r,selected:!1,physical:null,pending:!0};return s&&(i.loadError=!0),i.height=this.heightOf(i),i}}function G(a,r,t,s){return{key:`${q}pinned${q}${t}${q}${r}`,data:a,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:s,index:null,selected:!1,physical:null,hasChildren:!1,pinned:t}}function z(a,r){return new Proxy([],{get(t,s,i){if(s==="length")return a();if(typeof s=="string"){const n=Number(s);if(Number.isInteger(n)&&n>=0)return r(n)}return Reflect.get(t,s,i)},has(t,s){if(typeof s=="string"){const i=Number(s);if(Number.isInteger(i)&&i>=0)return i<a()}return Reflect.has(t,s)}})}function j(a){return a==null?"":String(a)}const O="";function b(a){if(a==null)return O;const r=String(a);return r.startsWith(O)?O+r:r}function u(a){const r=a||[];let t="g";for(let s=0;s<r.length;s++)t+=q+b(r[s]);return t}function f(a){const r=new Array(a.length),t=[];for(let s=0;s<a.length;s++)t.push(a[s]),r[s]=u(t);return r}}),Ie("packages/core/src/source/handles.js",function(e,U){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return q}});const N=U("packages/core/src/internal/predicates.js").isFunction,B=U("packages/core/src/internal/warn.js").warnOnce;class D{#e;#t;#n;#r=new Map;#i=0;constructor(x,G,z){this.#e=x,this.#t=G,this.#n=N(z)?z:()=>!1}get store(){const x=this.#e.store;return x&&N(x.column)?x:null}invalidate(){this.#i++}handle(x){const G=this.store;if(G){const b=G.column(x);if(b)return b}const z=this.#r.get(x);if(z&&z.builtAt===this.#i)return z.handle;const j=this.#s(x);if(!j)return;if(G&&this.#n()){B(`source.dropped.${x}`,`column "${x}" cannot be served under ingest.dropSourceRows: it is an impure computed column (a shadow or a positional/rank column) that is never stored, so it can only be read from the caller's row objects — which dropSourceRows has released. Do not sort, filter, group or total on such a column with dropSourceRows enabled.`);return}const O=this.#o(j);return this.#r.set(x,{handle:O,builtAt:this.#i}),O}#s(x){const G=this.#e.columns;return G&&N(G.get)?G.get(x):void 0}#o(x){const G=this.#t()||[],z=G.length,j=new Array(z),O=N(x.getValue)?u=>x.getValue(u):u=>u?.[x.field||x.id];for(let u=0;u<z;u++)j[u]=G[u]===void 0?void 0:O(G[u]);const b=this.#i;return{id:x.id,kind:"object",nullable:!1,values:j,presence:null,dict:null,offsets:null,get(u){return j[u]},version:b}}}function q(K,x,G){return new D(K,x,G)}}),Ie("packages/core/src/compute/incremental.js",function(e,U){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return G}});const N=U("packages/core/src/store/columnstore.js").toFloat,X=Object.freeze(["sum","avg","countValues","min","max"]),B=Object.freeze(["float64"]),D=1e15;function q(z,j){return typeof z!="string"||!X.includes(z)?!1:!!j&&B.includes(j.kind)}function K(z){if(z==null)return null;const j=N(z);return Number.isNaN(j)?null:j}class x{#e;#t=0;#n=0;#r=0;#i=1/0;#s=-1/0;#o=!1;#l=!1;constructor(j){this.#e=j}get valid(){return this.#o&&!this.#l}get fn(){return this.#e}seed(j){this.#a();for(let O=0;O<j.length;O++){const b=K(j[O]);b!==null&&this.#c(b)}this.#o=!0}seedColumn(j,O,b){this.#a();for(let u=0;u<b.length;u++){const f=b[u];if(O&&O(f)===0)continue;const a=j[f];Number.isNaN(a)||this.#c(a)}this.#o=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#i=1/0,this.#s=-1/0,this.#l=!1}#c(j){if(!Number.isFinite(j)){this.#l=!0;return}const O=this.#t+j;this.#n+=Math.abs(this.#t)>=Math.abs(j)?this.#t-O+j:j-O+this.#t,this.#t=O,this.#r++,j<this.#i&&(this.#i=j),j>this.#s&&(this.#s=j)}#u(j){const O=this.#t-j;this.#n+=Math.abs(this.#t)>=Math.abs(j)?this.#t-O-j:-j-O+this.#t,this.#t=O,this.#r--}update(j,O){if(!this.#o)return!1;const b=K(j),u=K(O);return b===null&&u===null?!0:b!==null&&!Number.isFinite(b)||u!==null&&!Number.isFinite(u)?!1:this.#e==="min"||this.#e==="max"?b===null||u===null?!1:this.#e==="min"?u<this.#i?(this.#i=u,!0):b>this.#i:u>this.#s?(this.#s=u,!0):b<this.#s:Math.abs(this.#t)>D?!1:(b!==null&&this.#u(b),u!==null&&this.#c(u),!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.#i:null;case"max":return this.#r?this.#s:null;default:return this.#t+this.#n}}invalidate(){this.#o=!1}}const G=x}),Ie("packages/core/src/source/filterwire.js",function(e,U){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return G}}),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 s}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return v}});const N=U("packages/core/src/internal/warn.js").warnOnce,X="source.remote.hostFilter",B="source.where.pageRelative";function D(M,F){!Array.isArray(M)||!M.length||N(B,`filters.where (${M.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 q(M){const F=(M||{}).config;!F||!F.hostFilter||N(X,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const K="source.where.notApplied";function x(M,F){N(`${K}:${M}`,`filters.where("${M}") 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 G="source.where.overThreshold";function z(M,F,V,I){!Array.isArray(M)||!M.length||N(`${G}:${F}`,`filters.where (${M.join(", ")}) is not applied to the ${F} pushdown source:`,V===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${V.toLocaleString()} rows, at or past the whereRowLimit of ${I.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 j=new Map;function O(M){let F=j.get(M);return F||(F=new Intl.DateTimeFormat("en-US",{timeZone:M,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),j.set(M,F)),F}function b(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function u(M,F){const V=O(F).formatToParts(new Date(M)),I={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const $ of V)$.type==="year"?I.y=+$.value:$.type==="month"?I.m=+$.value:$.type==="day"?I.d=+$.value:$.type==="hour"?I.h=+$.value%24:$.type==="minute"?I.mi=+$.value:$.type==="second"&&(I.s=+$.value);return I}function f(M,F){const V=u(M,F);return Date.UTC(V.y,V.m-1,V.d,V.h,V.mi,V.s)-Math.floor(M/1e3)*1e3}function a(M,F,V,I){const $=Date.UTC(M,F-1,V),S=$-f($,I);return $-f(S,I)}function r(M,F,V){const I=new Date(Date.UTC(M.y,M.m-1,M.d+F));return a(I.getUTCFullYear(),I.getUTCMonth()+1,I.getUTCDate(),V)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function s(M,F){if(typeof M!="string")return null;const V=M.trim().toLowerCase().replace(/[\s_-]+/g,""),I=/^last(\d*|n)days?$/.exec(V);if(I){const $=I[1]==="n"?"":I[1],S=Number($||F);return!Number.isFinite(S)||S<=0?null:{kind:"lastNDays",n:Math.floor(S)}}switch(V){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(M,F={}){const V=s(M,F.n);if(!V)return null;const I=F.tz||b(),$=F.now instanceof Date?F.now.getTime():typeof F.now=="number"?F.now:Date.now(),S=u($,I),R=a(S.y,S.m,S.d,I),L=r(S,1,I);let T=R,A=L;switch(V.kind){case"today":break;case"yesterday":T=r(S,-1,I),A=R;break;case"lastNDays":A=F.includeToday?L:R,T=r(S,F.includeToday?-(V.n-1):-V.n,I);break;case"thisWeek":{const C=Number.isFinite(F.weekStartsOn)?Number(F.weekStartsOn):1,Y=(new Date(Date.UTC(S.y,S.m-1,S.d)).getUTCDay()-C+7)%7;T=r(S,-Y,I),A=r(S,-Y+7,I);break}case"thisMonth":T=a(S.y,S.m,1,I),A=a(S.m===12?S.y+1:S.y,S.m===12?1:S.m+1,1,I);break;case"thisQuarter":case"quarterToDate":{const C=Math.floor((S.m-1)/3)*3+1;T=a(S.y,C,1,I),A=V.kind==="quarterToDate"?L:C===10?a(S.y+1,1,1,I):a(S.y,C+3,1,I);break}case"thisYear":case"yearToDate":T=a(S.y,1,1,I),A=V.kind==="yearToDate"?L:a(S.y+1,1,1,I);break;default:return null}return{from:new Date(T).toISOString(),to:new Date(A).toISOString(),bounds:"[)",tz:I,relative:V.kind==="lastNDays"?`last${V.n}Days`:V.kind,n:V.n}}function n(M){if(!M||typeof M!="object")return null;const F=M.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(M.op==="relative"&&typeof M.value=="string")return{token:M.value,n:void 0};const V=M.meta;return V&&typeof V.relative=="string"&&M.value===void 0?{token:V.relative,n:typeof V.n=="number"?V.n:void 0}:null}function c(){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(M){const F=n(M);return F?s(F.token,F.n)!==null:!1}function l(M,F={}){const V=n(M);if(!V)return M;const I=i(V.token,{...F,n:V.n});return I?{...M,type:M.type||"date",op:"between",value:[I.from,I.to],bounds:M.bounds||I.bounds,meta:{...M.meta||{},relative:I.relative,tz:I.tz}}:(N(`source.relative.${V.token}`,`unknown relative date token "${V.token}"; sending the condition unresolved.`,c()),M)}function h(M){return!!M&&typeof M=="object"&&Array.isArray(M.conditions)}function w(M,F){if(M){if(h(M)){for(const V of M.conditions)w(V,F);return}F(M)}}function g(M,F){if(!M)return null;if(!h(M))return F(M);const V=M;let I=!1;const $=[];for(const S of V.conditions){const R=g(S,F);R!==S&&(I=!0),R&&$.push(R)}return!I&&$.length===V.conditions.length?M:$.length?{...V,conditions:$}:null}function k(M){if(!M)return null;if(!h(M))return M;const F=M,V=[];for(const I of F.conditions){const $=k(I);$&&V.push($)}return V.length?{op:F.op,conditions:V}:null}function d(M){const F=k(M);return F?h(F)&&F.op==="and"?F:{op:"and",conditions:[F]}:null}function p(M){const F=(M||[]).filter(Boolean);return F.length?{op:"and",conditions:F}:null}function m(M,F={}){const V=g(M,I=>l(I,F));return d(V)}function v(M){const F=y(M.filters??null);return JSON.stringify([F,M.sort??null,M.quick??"",M.groupBy??null,M.pivotBy??null,E(M.context)])}function y(M){if(!M)return null;if(h(M)){const I=M;return{op:I.op,conditions:I.conditions.map(y)}}const F=M,V=F.meta&&typeof F.meta.relative=="string"?F.meta.relative:n(F)?.token;return{col:F.col,op:F.op,bounds:F.bounds??null,caseSensitive:F.caseSensitive??!1,value:V?`rel:${V}`:F.value??null}}function E(M){if(M==null)return null;try{return JSON.parse(JSON.stringify(M))}catch{return N("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Ie("packages/core/src/source/tree.js",function(e,U){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return u}});const N=U("packages/core/src/internal/predicates.js").isFunction,B=U("packages/core/src/internal/warn.js").warnOnce,D="",q="\0tree:";function K(f,a){return{physical:f,key:a,level:0,children:[],value:void 0}}function x(f,a){const r=[],t=new Map;for(let s=0;s<f.length;s++){const i=f[s],n=a.pathOf(i),c=Array.isArray(n)?n.map(l=>String(l)):[];if(!c.length){const l=K(i,a.keyOf(i));r.push(l);continue}let o=null;for(let l=0;l<c.length;l++){const h=c.slice(0,l+1).join(D),w=l===c.length-1;let g=t.get(h);g&&w&&g.physical===-1&&(g.physical=i,g.key=a.keyOf(i)),g||(g=K(w?i:-1,w?a.keyOf(i):q+h),g.level=l,g.value=c[l],t.set(h,g),o?o.children.push(g):r.push(g)),o=g}}return{roots:r,nodes:t}}function G(f,a){const r=new Map,t=[];for(let c=0;c<f.length;c++){const o=f[c],l=a.keyOf(o),h=K(o,l);r.set(l,h);const w=a.parentOf(o);w!=null&&w!==""&&t.push({node:h,parent:String(w)})}let s=null;const i=new Map;for(const{node:c,parent:o}of t){const l=r.get(o);if(l){i.set(c.key,l);continue}a.orphans&&a.orphans!=="root"&&(s||(s=K(-1,`${q}orphans`),s.value=a.orphans),i.set(c.key,s))}const n=[];for(const c of r.values()){const o=i.get(c.key);o?o.children.push(c):n.push(c)}return s&&s.children.length&&n.push(s),{roots:z(n,r,a.orphans,s),nodes:r}}function z(f,a,r,t){const s=new Set,i=[...f];for(;i.length;){const h=i.pop();if(!s.has(h.key)){s.add(h.key);for(const w of h.children)i.push(w)}}const n=[];for(const h of a.values())s.has(h.key)||n.push(h);if(!n.length)return f;const c=!!r&&r!=="root";B("tree.cycle",`tree.parentKey produced ${n.length} row(s) inside a parent cycle; `+(c?`they are shown under "${r}".`:"they are shown at the root."));for(const h of n)h.children=h.children.filter(w=>s.has(w.key));if(!c)return[...f,...n];let o=t;const l=[...f];return o||(o=K(-1,`${q}orphans`),o.value=r,l.push(o)),o.children.push(...n),l}function j(f){let a=0;const r=(t,s)=>{for(const i of t)i.level=s,s>a&&(a=s),i.children.length&&r(i.children,s+1)};return r(f,0),a}function O(f,a){if(!f||typeof f!="object")return null;const r=f.path,t=f.parentKey,s=N(f.hasChildren)?i=>!!f.hasChildren(a.dataAt(i)):null;if(N(r))return{mode:"path",pathOf:i=>r(a.dataAt(i)),keyOf:a.keyOf,declaresChildren:s};if(t!=null){const i=N(t)?t:n=>n?.[t];return{mode:"parentKey",parentOf:n=>i(a.dataAt(n)),keyOf:a.keyOf,orphans:f.orphans||"root",declaresChildren:s}}return B("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function b(f,a){const r=a.mode==="path"?x(f,a):G(f,a),t=j(r.roots);return{...r,depth:t}}function u(f,a){const r=new Map,t=s=>{for(let i=0;i<s.length;i++){const n=s[i];if(n.physical>=0){const c=a?a(n.physical):!1,o=c&&n.children.length===0;r.set(n.physical,{level:n.level,posinset:i+1,setsize:s.length,hasChildren:n.children.length>0||c,lazy:o})}n.children.length&&t(n.children)}};return t(f),r}}),Ie("packages/core/src/source/settle.js",function(e,U){"use strict";Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return N}});const te=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function N(X){const B=X&&typeof X=="object"?X.reason:null;return typeof B=="string"&&te.includes(B)}}),Ie("packages/core/src/source/memory.js",function(e,U){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return Y}});const N=U("packages/core/src/internal/lru.js").Lru,X=U("packages/core/src/internal/warn.js"),B=X.warnOnce,D=X.fail,K=U("packages/core/src/internal/predicates.js").isFunction,G=U("packages/core/src/internal/compare.js").defaultCompare,j=U("packages/core/src/internal/merge.js").mergeRow,O=U("packages/core/src/source/rows.js"),b=O.createRowFactory,u=O.groupKey,f=O.groupPathElement,a=O.groupPrefixKeys,r=O.lazyRowView,s=U("packages/core/src/source/handles.js").createHandleProvider,i=U("packages/core/src/compute/incremental.js"),n=i.RunningTotal,c=i.isIncremental,l=U("packages/core/src/compute/handle.js").presenceReader,h=U("packages/core/src/source/filterwire.js"),w=h.querySignature,g=h.mapConditions,k=h.resolveRelativeCondition,d=U("packages/core/src/source/tree.js"),p=d.buildTree,m=d.resolveTree,v=d.indexTree,y=U("packages/core/src/source/settle.js"),E=y.PIPELINE_SETTLE_REASONS,M=y.isPipelineSettle,F=Object.freeze(["filter","sort","group","total","pivot","flatten"]),V=Object.freeze([]);function I(Z,_){if(!Z)return null;const J=_==="grand"?Z.grandTotal:Z.groupTotal;return J??Z.total}function $(Z){return!!Z&&!Z.running}function S(Z){if(Z)return Z.value&&K(Z.value.compare)?Z.value.compare:K(Z.compare)?Z.compare:void 0}function R(Z){const _=Z&&Z.dataType;return!_||!K(_.items)?null:{items:_.items,type:Z.itemType&&Z.itemType.name||"text"}}function L(Z){return!!Z&&(typeof Z=="object"||typeof Z=="function")&&K(Z.then)}const T=new Uint32Array(0),A=4096;function C(Z,_){return new Y(Z,_)}function H(Z,_){if(_==="regex")try{const J=new RegExp(Z,"iu");return ee=>J.test(ee)}catch{return J=>J.includes(Z)}if(_==="fuzzy"){const J=[...Z].filter(ee=>ee!==" ");return J.length?ee=>{let ne=0;for(let se=0;se<ee.length&&ne<J.length;se++)ee[se]===J[ne]&&ne++;return ne===J.length}:()=>!0}if(_==="words"){const J=Z.split(/\s+/).filter(Boolean);return J.length?ee=>J.every(ne=>ee.includes(ne)):()=>!0}return J=>J.includes(Z)}class Y{mode="memory";#e;#t;#n;#r=!1;#i=null;#s;#o;#l=new Map;#a=!1;#c=0;#u=0;#f=new Map;#d=new Map;#h;#p=null;#m=Y.#g();static#g(){return{slots:[],groupHeadings:V,unnumbered:V,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#b=new Map;#y=null;#A=new Map;#w=-1;#O=[];#v=new Map;#T=-1;#S=[];#E=null;#N=null;#P=null;#M=null;#R=null;#$=null;#G=null;#V=null;#F=Symbol("unset");#x=new Map;#Y=null;get#D(){return this.#m.slots}set#D(_){this.#m.slots=_}get#K(){return this.#m.inlineLeaves}set#K(_){this.#m.inlineLeaves=_}get#H(){return this.#m.groupHeadings}set#H(_){this.#m.groupHeadings=_}get#B(){return this.#m.unnumbered}set#B(_){this.#m.unnumbered=_}get#fe(){return this.#m.pivot}set#fe(_){this.#m.pivot=_}constructor(_,J){this.#t=_||{mode:"memory"},this.#e=J||{};const ee=this.#e.config||{};this.#n=this.#t.rows||ee.rows||[],this.#s=b(this.#e),this.#o=s(this.#e,()=>this.#n,()=>this.#r),this.#h=new N(Number(ee.rowCacheSize)||A);for(const ne of F)this.#l.set(ne,{key:null,result:null,id:0,computed:!1})}count(){this.#I();const _=this.#pe();return _?_.length:this.#D.length}#pe(){const _=Number(this.#z("pageSize",0))||0;if(_<=0)return null;const J=this.#D.length,ee=Math.max(1,Math.ceil(J/_)),se=Math.min(Math.max(0,Number(this.#z("page",0))||0),ee-1)*_;return{offset:se,length:Math.max(0,Math.min(_,J-se))}}pageInfo(){this.#I();const _=Number(this.#z("pageSize",0))||0,J=this.#D.length;if(_<=0)return{page:0,pageSize:0,total:J,pageCount:1};const ee=Math.max(1,Math.ceil(J/_));return{page:Math.min(Math.max(0,Number(this.#z("page",0))||0),ee-1),pageSize:_,total:J,pageCount:ee}}totalCount(){return this.#Ke().length}matchCount(){return this.#I(),this.#m.matchCount}at(_){this.#I();const J=this.#pe();if(J)return _<0||_>=J.length?void 0:this.#Ne(J.offset+_,_);if(!(_<0||_>=this.#D.length))return this.#Ne(_,_)}byKey(_){this.#I(),this.#p||this.#Ce();const J=this.#p.get(_);if(J!==void 0)return this.#ee(J);for(let ee=0;ee<this.#D.length;ee++){const ne=this.#D[ee];if(typeof ne!="number"&&ne&&ne.key===_)return this.#Ne(ee)}}loaded(_){return _>=0&&_<this.count()}hint(_,J){}display(){return this.#I(),this.#Y||(this.#Y=this.#ct()),this.#Y}invalidateQuickText(){this.#x.clear(),this.invalidate("filter")}invalidate(_){const J=F.indexOf(_);J<0&&D(`unknown pipeline stage "${_}"; expected one of ${F.join(", ")}`);for(let ee=J;ee<F.length;ee++){const ne=this.#l.get(F[ee]);ne.key=null,ne.computed=!1}this.#Y=null}apply(_){const J=[],ee={added:[],updated:[],removed:[],rejected:J};if(!_)return ee;let ne=!1;const se=new Set;if(_.remove&&_.remove.length)for(const oe of _.remove){const fe=this.#Pe(oe);if(fe===void 0){J.push({operation:"remove",id:this.#be(oe),reason:"unknown-id"});continue}ee.removed.push(this.#s.keyOf(this.#r?this.#ue(fe):this.#n[fe],fe)),this.#r||(this.#n[fe]=void 0),this.#h.delete(fe),this.#x.delete(fe),ne=!0}if(_.update&&_.update.length){const oe=this.#A.size||this.#qe()?this.#st():null,fe=this.#v.size?this.#lt():null,pe=fe&&fe.length?this.#st():null;for(const he of _.update){const Re=this.#Pe(he);if(Re===void 0){J.push({operation:"update",id:this.#je(he),reason:"unknown-id"});continue}const Ue=this.#r?this.#i&&this.#i.has(Re)?this.#i.get(Re):this.#ue(Re):this.#n[Re],Le=j(Ue,he);for(const ie of this.#re(Ue,Le))se.add(ie);if(this.#r||(this.#n[Re]=Le),oe&&this.#ht(oe,Re,Ue,Le),pe&&this.#wt(fe,pe,Re,Ue,Le),this.#p){const ie=this.#s.keyOf(Ue,Re),ge=this.#s.keyOf(Le,Re);ie!==ge&&(this.#p.delete(ie),this.#p.set(ge,Re))}this.#h.delete(Re),this.#x.delete(Re),ee.updated.push(this.#ee(Re))}}if(_.add&&_.add.length&&this.#r){typeof _.at=="number"&&_.at<this.#Fe()&&(this.#h.clear(),this.#x.clear()),this.#p=null;for(const oe of _.add){const fe=this.#ne(this.#je(oe));fe!==void 0&&ee.added.push(this.#ee(fe))}ne=!0}else if(_.add&&_.add.length){const oe=typeof _.at=="number"?_.at:this.#n.length,fe=this.#n.length;let pe=_.add===this.#n?_.add.slice():_.add;if(this.#s.keyed){const he=[];for(const Re of pe){const Ue=this.#je(Re);if(this.#Pe(Ue)!==void 0){J.push({operation:"add",id:Ue,reason:"duplicate-id"});continue}he.push(Re)}he.length!==pe.length&&(pe=he)}if(!pe.length)return ee;if(oe>=fe)for(let he=0;he<pe.length;he++)this.#n.push(pe[he]);else this.#n.splice(oe,0,...pe),this.#h.clear(),this.#x.clear();for(let he=0;he<pe.length;he++)ee.added.push(this.#ee(oe>=fe?fe+he:oe+he));ne=!0}return this.#c++,ne&&(this.#p=null,this.#We()),this.#o.invalidate(),this.#Y=null,ne||this.#Z(se)?(this.#u++,this.invalidate("filter")):this.invalidate("total"),this.#Je("rows:changed",{companion:!0,added:ee.added.length,updated:ee.updated.length,removed:ee.removed.length}),this.#i=null,ee}groupHeadingsAt(_){this.#I();const J=this.#H;if(!J.length||!Number.isInteger(_)||_<0)return V;let ee=0,ne=J.length-1,se=-1;for(;ee<=ne;){const fe=ee+ne>>1;J[fe].at<=_?(se=fe,ee=fe+1):ne=fe-1}if(se<0)return V;const oe=[];for(let fe=J[se].row;fe;fe=fe.parent)oe.push(fe);return oe.reverse(),oe}unnumberedRowCount(_){this.#I();const J=this.#B;if(!J.length||!Number.isInteger(_)||_<0)return 0;let ee=0,ne=J.length-1,se=-1;for(;ee<=ne;){const oe=ee+ne>>1;J[oe].at<=_?(se=oe,ee=oe+1):ne=oe-1}return se+1}moveRow(_,J){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 ee=this.#n;if(!Number.isInteger(_)||!Number.isInteger(J)||_<0||_>=ee.length)return!1;const ne=Math.max(0,Math.min(ee.length-1,J));if(ne===_)return!1;const[se]=ee.splice(_,1);return ee.splice(ne,0,se),this.#c++,this.#u++,this.#p=null,this.#h.clear(),this.#x.clear(),this.#We(),this.#o.invalidate(),this.#Y=null,this.invalidate("filter"),this.#Je("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(_){this.#se(),this.#c++,this.#u++,this.#p=null,this.#x.clear(),this.#h.clear(),this.#We(),this.#o.invalidate(),this.invalidate("filter"),this.#Je("model:changed",{reason:"reload"})}destroy(){this.#se(),this.#h.clear(),this.#x.clear(),this.#p=null,this.#D=[],this.#K=null,this.#Y=null,this.#We();for(const _ of F)this.#l.set(_,{key:null,result:null,id:0,computed:!1})}#se(){for(const{controller:_}of this.#b.values())try{_.abort()}catch{}this.#b.clear()}setRows(_){this.#n=_||[],this.#r=!1,this.#c++,this.#u++,this.#p=null,this.#x.clear(),this.#h.clear(),this.#We(),this.#o.invalidate(),this.invalidate("filter")}notePriorRows(_){this.#i=_||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#x.clear(),this.#o.invalidate()}data(){if(!this.#r)return this.#n;const _=this.#e.store;if(!_||!K(_.source))return this.#n;const J=_.physical||0,ee=new Array(J);for(let ne=0;ne<J;ne++)ee[ne]=_.live&&!_.live(ne)?void 0:_.source(ne);return ee}#Be(){const _=this.#z("detail",null);return!_||!K(_.isOpen)||_.inline===!1?null:_}#Se(){const _=(this.#e.config||{}).tree;return this.#F!==_&&(this.#F=_,this.#V=m(_,{dataAt:J=>this.#ue(J),keyOf:J=>this.#s.keyOf(this.#ue(J),J)})),this.#V}#ge(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#ge())return null;this.#I();const _=this.#m.grand;return _?this.#s.grandTotal(_,this.#nt(this.#m.grandLeaves)):null}pivot(){return this.#I(),this.#fe}pivotMatrix(){this.#I();const _=this.#m.groupLeaves,J=(this.#e.compute||{}).pivotMatrix;if(!K(J))return null;const ee=this.#z("groupBy",[]),ne=this.#z("pivotBy",[]);if(!ee.length&&!ne.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 se=this.#st().map(fe=>({colId:fe.id,handle:this.#o.handle(fe.id),fn:I(fe,"group")})).filter(fe=>fe.handle&&fe.fn),oe=this.#e.config||{};return J({rowHandles:ee.map(fe=>this.#o.handle(fe)).filter(Boolean),columnHandles:ne.map(fe=>this.#o.handle(fe)).filter(Boolean),measures:se,leaves:_||new Uint32Array(0),opts:{locale:oe.locale,separator:(oe.pivot||{}).separator,maxColumns:(oe.pivot||{}).maxColumns}})}keysForLeaves(_){const J=[];if(!_)return J;for(let ee=0;ee<_.length;ee++){const ne=this.#ee(_[ee]);ne&&ne.key!=null&&J.push(String(ne.key))}return J}leavesOf(_){this.#I();const J=this.#l.get("group"),ee=J&&J.result;if(!ee||!ee.nodes)return[];const ne=ee.nodes.get(_);if(!ne)return[];const se=[],oe=fe=>{const pe=fe.row&&fe.row.children;if(pe&&pe.length){for(const he of pe){const Re=ee.nodes.get(he.key);Re&&oe(Re)}return}if(fe.leaves)for(let he=0;he<fe.leaves.length;he++)se.push(this.#ee(fe.leaves[he]))};return oe(ne),se}#be(_){return typeof _=="string"?_:this.#je(_)}#je(_){try{return this.#s.keyOf(_,-1)}catch{return"(unkeyed)"}}#Pe(_){if(typeof _=="string")return this.#ne(_);if(this.#s.keyed){const ee=this.#s.keyOf(_,-1),ne=this.#ne(ee);if(ne!==void 0)return ne}if(this.#r)return;const J=this.#n.indexOf(_);return J>=0?J:void 0}#ne(_){return this.#p||this.#Ce(),this.#p.get(_)}#Ce(){this.#p=new Map;const _=this.#Fe(),J=this.#e.store,ee=J&&K(J.live)?ne=>J.live(ne):null;for(let ne=0;ne<_;ne++){if(ee&&!ee(ne))continue;const se=this.#ue(ne);se!==void 0&&this.#p.set(this.#s.keyOf(se,ne),ne)}}#re(_,J){const ee=[];for(const ne of this.#_())this.#ze(ne)&&this.#J(ne,_,J,new Set)&&ee.push(ne);return ee}#J(_,J,ee,ne){if(ne.has(_))return!1;ne.add(_);const se=this.#ze(_);if(!se)return!1;const oe=se.value&&se.value.deps;return Array.isArray(oe)&&oe.length?oe.some(fe=>this.#J(String(fe),J,ee,ne)):K(se.getValue)?!Object.is(se.getValue(J),se.getValue(ee)):!1}#_(){const _=new Set;for(const ee of this.#z("sort",[]))_.add(ee.col);for(const ee of this.#z("groupBy",[]))_.add(ee);const J=ee=>{if(ee){if(Array.isArray(ee.conditions)){ee.conditions.forEach(J);return}ee.col&&_.add(ee.col)}};return J(this.#z("filters",null)),[..._]}#Z(_){if(!_.size)return!1;if(this.#z("quick",""))return!0;for(const J of this.#_())if(_.has(J))return!0;return!1}#I(){if(!this.#a){this.#a=!0;try{this.#Te()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#Te(){const _=this.#U("filter",()=>this.#W(),()=>this.#ve()),J=this.#X(_),ee=this.#U("group",()=>this.#de(),()=>this.#at(J)),ne=this.#U("total",()=>this.#he(),()=>this.#Ue(ee));this.#U("pivot",()=>this.#Le(),()=>this.#Rt(ee)),this.#U("flatten",()=>this.#xe(),()=>this.#j(ee)),this.#$e(ee,ne)}#X(_){const J=this.#l.get("sort"),ee=this.#ie();if(J.computed&&J.key===ee&&!this.#b.has("sort"))return J.result;const ne=this.#b.get("sort");return ne&&ne.key===ee?J.result:J.result&&this.#we(_)?(this.#Ee(_,ee),J.result):this.#U("sort",()=>ee,()=>this.#Me(_))}#oe(){if(this.#y===null){const _=this.#e.pipelineWorker,J=K(_)?_():null;this.#y=J||!1}return this.#y||null}#Oe(){const _=this.#z("sort",[]);if(!Array.isArray(_)||!_.length)return null;const J=(this.#e.config||{}).locale,ee=[],ne=[];for(const se of _){const oe=this.#ze(se.col);if(oe&&oe.running)continue;if(oe&&oe.value&&K(oe.value.compare))return null;const fe=this.#o.handle(se.col);if(!fe)return null;ee.push({col:se.col,descending:se.dir==="desc",nullsFirst:!!se.nullsFirst,locale:J}),ne.push(fe)}return ee.length?{entries:ee,handles:ne,locale:J}:null}#we(_){if(this.#me())return!1;const J=this.#oe();if(!J)return!1;const ee=Number(J.threshold);return Number.isFinite(ee)&&_.length<ee?!1:!!this.#Oe()}#Ee(_,J){const ee=this.#oe(),ne=ee&&this.#Oe();if(!ne){this.#U("sort",()=>J,()=>this.#Me(_));return}const se=new AbortController;this.#b.set("sort",{key:J,controller:se});const oe=ne.entries.length===1?ee.sortColumn(ne.handles[0],_,{descending:ne.entries[0].descending,nullsFirst:ne.entries[0].nullsFirst,locale:ne.locale,signal:se.signal,key:"sort"}):ee.sortMulti(ne.handles,ne.entries.map((fe,pe)=>({...fe,handle:ne.handles[pe]})),_,{signal:se.signal,key:"sort"});if(!L(oe)){this.#b.delete("sort"),this.#U("sort",()=>J,()=>oe);return}oe.then(fe=>this.#ae(J,fe),fe=>this.#ce("sort",J,fe))}#ae(_,J){const ee=this.#b.get("sort");if(!(!ee||ee.key!==_)){if(this.#ie()!==_){this.#b.delete("sort");return}this.#b.delete("sort"),this.#U("sort",()=>_,()=>J),this.#Y=null,this.#I(),this.#Je("model:changed",{reason:E[0]})}}#ce(_,J,ee){const ne=this.#b.get(_);if(!(!ne||ne.key!==J)&&(this.#b.delete(_),!(ee&&ee.name==="AbortError")&&_==="sort"&&this.#ie()===J)){const se=this.#U("filter",()=>this.#W(),()=>this.#ve());this.#U("sort",()=>J,()=>this.#Me(se)),this.#Y=null,this.#I(),B("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",ee),this.#Je("model:changed",{reason:E[1]})}}#$e(_,J){const ee=_&&_.leaves?_.leaves.length:this.#m.slots.length;this.#m.matchCount=ee,this.#m.grand=J&&J.grand||null,this.#m.grandLeaves=_&&_.leaves?_.leaves.length:0,this.#m.groupLeaves=_&&_.leaves?_.leaves:null}#U(_,J,ee){const ne=this.#l.get(_),se=J();return ne.computed&&ne.key===se||(ne.result=ee(),ne.key=se,ne.computed=!0,ne.id++,_==="flatten"&&(this.#Y=null)),ne.result}#C(_){return this.#l.get(_).id}#W(){const _=(this.#e.config||{}).hostFilter,J=_&&K(_.active)&&_.active()?1:0,ee=this.#z("where",null),ne=ee?ee.version:0,se=this.#it("filter.sig",`${this.#Qe()}`,()=>w({filters:this.#z("filters",null),quick:this.#z("quick",""),quickMode:this.#z("quickMode","contains")}));return`${this.#u}|${se}|${J}|${ne}`}#ie(){const _=this.#me();return`${this.#C("filter")}|${JSON.stringify(this.#z("sort",[]))}`+(_?`|manual:${_.version}`:"")}#me(){const _=this.#z("rowOrder",null);return _&&Array.isArray(_.keys)?_:null}#le(_,J){this.#p||this.#Ce();const ee=this.#p,ne=this.#Fe(),se=J.keys.length,oe=new Float64Array(ne);for(let fe=0;fe<ne;fe++)oe[fe]=se+fe;for(let fe=0;fe<se;fe++){const pe=ee.get(J.keys[fe]);pe!==void 0&&(oe[pe]=fe)}return Uint32Array.from(_).sort((fe,pe)=>oe[fe]-oe[pe])}orderedKeys(){this.#p||this.#Ce();const _=this.#p,J=new Map;for(const[fe,pe]of _)J.set(pe,fe);const ee=Uint32Array.from([...J.keys()]).sort(),ne=this.#me(),se=ne?this.#le(ee,ne):this.#Me(ee),oe=new Array(se.length);for(let fe=0;fe<se.length;fe++)oe[fe]=J.get(se[fe]);return oe}#de(){const _=this.#z("pivotBy",[]).length>0?"p":"u";return`${this.#C("sort")}|${JSON.stringify(this.#z("groupBy",[]))}|${_}`}#he(){const _=this.#Ge()?"f":"a",J=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#C("group")}|${JSON.stringify(this.#z("totals",[]))}|${_}${J}|${this.#c}`}#Le(){return`${this.#C("group")}|${JSON.stringify(this.#z("pivotBy",[]))}`}#xe(){const J=this.#k()||!this.#ge()?this.#C("total"):"x",ee=`${this.#Qe()}`,ne=this.#it("flatten.keys",ee,()=>{const oe=this.#z("expanded",null);return oe?[...oe].sort().join(""):"*"}),se=this.#it("flatten.detail",ee,()=>{const oe=this.#z("detail",null);return oe&&K(oe.signature)?oe.signature():""});return`${J}|${this.#C("pivot")}|${ne}|${se}`}#k(){const _=this.#z("groupBy",[]);return Array.isArray(_)&&_.length>0}stageState(){const _=[];for(const[J,ee]of this.#l){const ne=ee.result;_.push({stage:J,materialised:!!ee.computed,bytes:ne&&typeof ne.byteLength=="number"?ne.byteLength:null,rows:ne&&typeof ne.length=="number"?ne.length:null,rebuilds:ee.id})}return _}facetIndices(_){return this.#ve(_||null)}facetRows(_){const J=this.facetIndices(_),ee=[];for(let ne=0;ne<J.length;ne++){const se=this.#ee(J[ne]);se&&ee.push(se)}return ee}invalidateRows(){this.#h.clear(),this.#x.clear(),this.#Y=null}invalidateHandles(){this.#o.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Ke()}filteredIndices(){const _=this.#l.get("filter");if(_&&_.computed&&_.key===this.#W())return _.result||this.#Ke();this.#I();const J=this.#l.get("filter");return(J&&J.computed?J.result:null)||this.#Ke()}unfilteredRows(){const _=this.#Ke(),J=[];for(let ee=0;ee<_.length;ee++){const ne=this.#ee(_[ee]);ne&&J.push(ne)}return J}#ve(_=null){const J=this.#Ke(),ee=this.#z("filters",null),ne=_?this.#ot("pruneColumn")(ee,_):ee,se=this.#kt(ne),oe=String(this.#z("quick","")||"").trim().toLowerCase(),fe=oe?H(oe,String(this.#z("quickMode","contains")||"contains")):null,pe=(this.#e.config||{}).hostFilter,he=!!(pe&&K(pe.active)&&pe.active()),Re=this.#z("where",null),Ue=!!(Re&&Re.active);if(!se&&!oe&&!he&&!Ue)return J;let Le=null;se&&(Le=this.#ot("evaluateFilters")(se,{handle:Se=>this.#o.handle(Se),count:this.#Fe(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:Se=>R(this.#ze(Se))}));const ie=new Uint32Array(J.length);let ge=0;for(let ke=0;ke<J.length;ke++){const Se=J[ke];if(!(Le&&!Le[Se])&&!(fe&&!this.#vt(Se,fe))){if(he||Ue){const Ae=this.#ee(Se);if(he&&!pe.passes(Ae)||Ue&&!Re.passes(Ae.data,Ae.key))continue}ie[ge++]=Se}}if(Le){const ke=(this.#e.compute||{}).releaseMask;K(ke)&&ke({pool:this.#e.pool},Le)}return ie.subarray(0,ge)}handleFor(_){return this.#o.handle(_)}#Me(_){const J=this.#me();if(J)return this.#le(_,J);const ee=this.#z("sort",[]).filter(oe=>{const fe=this.#ze(oe.col);return!fe||!fe.running?!0:(B(`source.sort.running.${oe.col}`,`sort ignores "${oe.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!ee.length)return _;const ne=(this.#e.config||{}).locale;if(ee.length===1){const oe=ee[0],fe=this.#o.handle(oe.col);if(!fe)return B(`source.sort.${oe.col}`,`sort ignores unknown column "${oe.col}".`),_;const pe=this.#ze(oe.col);return this.#ot("sortColumn")(fe,_,{descending:oe.dir==="desc",nullsFirst:oe.nullsFirst,locale:ne,compare:S(pe)})}const se=[];for(const oe of ee){const fe=this.#o.handle(oe.col);if(!fe){B(`source.sort.${oe.col}`,`sort ignores unknown column "${oe.col}".`);continue}se.push({handle:fe,descending:oe.dir==="desc",nullsFirst:oe.nullsFirst,locale:ne,compare:S(this.#ze(oe.col))})}return se.length?this.#ot("sortMulti")(se.map(oe=>oe.handle),se,_):_}#at(_){const J=this.#z("groupBy",[]),ee=this.#Se();if(ee&&!J.length){const ke=p(_,ee);return this.#$=v(ke.roots,ee.declaresChildren),{roots:null,leaves:_,nodes:new Map,tree:ke}}if(this.#$=null,ee&&J.length&&B("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!J.length)return{roots:null,leaves:_,nodes:new Map};const ne=(this.#e.config||{}).timeZone,se=[],oe=[];let fe=!1;for(const ke of J){const Se=this.#o.handle(ke);if(!Se){B(`source.group.${ke}`,`grouping ignores unknown column "${ke}".`);continue}se.push(Se);const Ae=this.#ze(ke),xe=Ae&&Ae.dataType;if(xe&&K(xe.groupProjector)){const me=Ae.typeOptions&&Ae.typeOptions.timeZone||ne||void 0,ye=xe.groupProjector(Ae,me);oe.push(ye||null),ye&&(fe=!0)}else oe.push(null)}if(!se.length)return{roots:null,leaves:_,nodes:new Map};const{keys:pe,buckets:he}=this.#ot("groupByColumns")(se,_,{locale:(this.#e.config||{}).locale,project:fe?oe:void 0}),Re=this.#z("pivotBy",[]).length>0,Ue=[],Le=new Map;for(let ke=0;ke<he.length;ke++){const Se=pe[ke];let Ae=null;const xe=[];for(let me=0;me<Se.length;me++){xe.push(f(Se[me]));const ye=u(xe),Te=me===Se.length-1;let Ye=Le.get(ye);if(!Ye){const Oe=this.#s.group({path:[...xe],column:J[me],value:Se[me],level:me,parent:Ae,expanded:Re&&Te?!1:this.#ut(ye,{key:ye,column:J[me],value:Se[me],level:me,path:[...xe]}),hasChildren:!(Re&&Te)});Ye={row:Oe,leaves:null},Le.set(ye,Ye),Ae?Ae.children.push(Oe):Ue.push(Oe)}Ye.row.leafCount+=he[ke].length,me===Se.length-1&&(Ye.leaves=he[ke]),Ae=Ye.row}}const ie=this.#z("sort",[])||[],ge=(ke,Se)=>{if(!ke||ke.length<2){if(ke)for(const ye of ke)ge(ye.children,Se+1);return}const Ae=J[Se],xe=ie.find(ye=>ye.col===Ae),me=xe&&xe.dir==="desc"?-1:1;ke.sort((ye,Te)=>me*G(ye.groupValue,Te.groupValue));for(const ye of ke)ge(ye.children,Se+1)};return ge(Ue,0),{roots:Ue,leaves:_,nodes:Le,keys:pe,buckets:he}}#_e(_,J){const ee=new Map,ne=new Map,se=oe=>{const fe=oe.physical>=0?[oe.physical]:[];for(const pe of oe.children)fe.push(...se(pe));if(oe.children.length){const pe=this.#Ye(J,Uint32Array.from(fe),null);oe.physical>=0?ee.set(oe.physical,pe):ne.set(oe.key,pe)}return fe};for(const oe of _.roots)se(oe);return{byPhysical:ee,byKey:ne}}#Ue(_){const J=this.#st();if(!J.length)return this.#N=null,this.#P=null,{grand:null};const ee={id:this.#C("group"),columns:J.map(ie=>ie.id).join("")},ne=this.#N&&this.#N.id===ee.id&&this.#N.columns===ee.columns,se=this.#qe()&&ne?this.#E:null,oe=se?J.filter(ie=>se.has(ie.id)):J,fe=ne?this.#P:null,pe=this.#Ge()?null:this.#Mt(),he=this.#ye(J),Re=ie=>{const ge=_.nodes.get(ie.key);let ke=ge&&ge.leaves?ge.leaves:null;if(ie.children&&ie.children.length){const xe=ie.children.map(Re);let me=0;for(const Ye of xe)me+=Ye.length;const ye=new Uint32Array(me);let Te=0;for(const Ye of xe)ye.set(Ye,Te),Te+=Ye.length;ke=ye}ke=ke||new Uint32Array(0);const Se=pe?pe.get(ie.key)||T:ke,Ae=this.#bt(ie,se?oe:J,Se,he);return ie.totals=se?{...ie.totals,...Ae}:Ae,ke};if(_.roots&&oe.length)for(const ie of _.roots)Re(ie);if(this.#G=_.tree?this.#_e(_.tree,J):null,this.#N=ee,this.#E=this.#qe()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#O.length=0,this.#P=null,{grand:null};const Le=pe?this.#rt():_.leaves;return this.#P=this.#Xe(J,Le,se,fe),{grand:this.#P}}#Xe(_,J,ee,ne){const se={},oe=this.#C("group");oe!==this.#w&&(this.#Ze(),this.#w=oe);const fe=this.#O;this.#O=[];for(const pe of _){if(!$(pe))continue;const he=this.#o.handle(pe.id);if(!he)continue;const Re=I(pe,"grand");if(!c(Re,he)){if(ee&&!ee.has(pe.id)&&ne&&pe.id in ne){se[pe.id]=ne[pe.id];continue}se[pe.id]=this.#Ye([pe],J,null,"grand")[pe.id];continue}let Ue=this.#A.get(pe.id);if((!Ue||Ue.fn!==Re)&&(Ue=new n(Re),this.#A.set(pe.id,Ue)),Ue.valid){let Le=!0;for(const ie of fe)if(ie.colId===pe.id&&!Ue.update(ie.before,ie.after)){Le=!1;break}if(Le){se[pe.id]=Ue.value();continue}Ue.invalidate()}Ue.seedColumn(he.values,l(he),J),se[pe.id]=Ue.valid?Ue.value():this.#Ye([pe],J,null,"grand")[pe.id]}return se}#ye(_){const J=this.#C("group");J!==this.#T&&(this.#v.clear(),this.#T=J);const ee=new Map;for(const se of _){if(!$(se))continue;const oe=this.#o.handle(se.id),fe=I(se,"group");c(fe,oe)&&ee.set(se.id,{fn:fe})}if(!ee.size)return this.#S.length=0,ee;const ne=this.#S;this.#S=[];for(const se of ne){const{beforeKeys:oe,afterKeys:fe,colDeltas:pe}=se,he=oe.length?new Set(oe):null,Re=fe.length?new Set(fe):null;for(const{colId:Ue,before:Le,after:ie}of pe)if(ee.has(Ue)){for(const ge of oe)Re&&Re.has(ge)||this.#ke(ge,Ue,Le,null);for(const ge of fe)he&&he.has(ge)||this.#ke(ge,Ue,null,ie);for(const ge of oe)Re&&!Re.has(ge)||this.#ke(ge,Ue,Le,ie)}}return ee}#ke(_,J,ee,ne){const se=this.#v.get(_),oe=se&&se.get(J);!oe||!oe.valid||oe.update(ee,ne)||oe.invalidate()}#bt(_,J,ee,ne){if(!ne||!ne.size)return this.#Ye(J,ee,_);const se={};let oe=null,fe=this.#v.get(_.key);for(const pe of J){const he=ne.get(pe.id);if(!he){(oe||(oe=[])).push(pe);continue}const Re=this.#o.handle(pe.id);if(!Re)continue;fe||(fe=new Map,this.#v.set(_.key,fe));let Ue=fe.get(pe.id);if((!Ue||Ue.fn!==he.fn)&&(Ue=new n(he.fn),fe.set(pe.id,Ue)),Ue.valid||Ue.seedColumn(Re.values,l(Re),ee),Ue.valid){se[pe.id]=Ue.value();continue}(oe||(oe=[])).push(pe)}return oe&&Object.assign(se,this.#Ye(oe,ee,_)),se}#ht(_,J,ee,ne){const se=!this.#Ge()||this.#te(J);for(const oe of _){const fe=oe.getValue;if(!K(fe))continue;const pe=fe(ee),he=fe(ne);Object.is(pe,he)||(this.#E&&this.#E.add(oe.id),se&&this.#A.has(oe.id)&&this.#O.push({colId:oe.id,before:pe,after:he}))}}#lt(){const _=this.#z("groupBy",[]),J=[];for(const ee of _){const ne=this.#ze(ee);ne&&J.push(ne)}return J}#yt(_,J){const ee=new Array(_.length);for(let ne=0;ne<_.length;ne++){const se=_[ne].getValue;ee[ne]=f(K(se)?se(J):void 0)}return ee}#wt(_,J,ee,ne,se){if(this.#Ge()&&!this.#te(ee))return;const oe=a(this.#yt(_,ne)),fe=a(this.#yt(_,se)),pe=oe.length!==fe.length||oe.some((Re,Ue)=>Re!==fe[Ue]),he=[];for(const Re of J){const Ue=Re.getValue;if(!K(Ue))continue;const Le=Ue(ne),ie=Ue(se);!pe&&Object.is(Le,ie)||he.push({colId:Re.id,before:Le,after:ie})}!he.length&&!pe||this.#S.push({beforeKeys:oe,afterKeys:fe,colDeltas:he})}#te(_){const J=this.#l.get("filter"),ee=J&&J.computed?J.result:null;if(!ee)return!0;let ne=0,se=ee.length-1;for(;ne<=se;){const oe=ne+se>>1,fe=ee[oe];if(fe===_)return!0;fe<_?ne=oe+1:se=oe-1}return!1}#Ge(){return(this.#e.config||{}).totalFilteredOnly!==!1}#nt(_){return this.#Ge()?_:this.#rt().length}#rt(){return(!this.#M||this.#M.version!==this.#u)&&(this.#M={version:this.#u,indices:this.#Ke()}),this.#M.indices}#Mt(){const _=this.#z("groupBy",[]),J=`${this.#u}|${JSON.stringify(_)}`;if(this.#R&&this.#R.key===J)return this.#R.map;const ee=new Map,ne=[];for(const se of _){const oe=this.#o.handle(se);oe&&ne.push(oe)}if(ne.length){const se=this.#rt(),{keys:oe,buckets:fe}=this.#ot("groupByColumns")(ne,se,{locale:(this.#e.config||{}).locale}),pe=new Map;for(let he=0;he<fe.length;he++){const Re=oe[he],Ue=[];for(let Le=0;Le<Re.length;Le++){Ue.push(f(Re[Le]));const ie=u(Ue);let ge=pe.get(ie);ge||(ge=[],pe.set(ie,ge));for(let ke=0;ke<fe[he].length;ke++)ge.push(fe[he][ke])}}for(const[he,Re]of pe)ee.set(he,Uint32Array.from(Re))}return this.#R={key:J,map:ee},ee}#qe(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#We(){this.#Ze(),this.#Nt(),this.#E=null,this.#N=null,this.#P=null}#Ze(){this.#A.clear(),this.#O.length=0,this.#w=-1}#Nt(){this.#v.clear(),this.#S.length=0,this.#T=-1}#Rt(_){const J=this.#z("pivotBy",[]);if(!J.length)return this.#fe=null,null;const ee=(this.#e.compute||{}).pivot;if(!K(ee))return B("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#fe=null,null;const ne=J.map(oe=>this.#o.handle(oe)).filter(Boolean),se=this.#st();return this.#fe=ee(ne,_.leaves,{groups:_.keys&&_.buckets?{keys:_.keys,buckets:_.buckets}:null,totals:se.map(oe=>oe.id),handle:oe=>this.#o.handle(oe),totalOf:oe=>I(se.find(fe=>fe.id===oe),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#fe}#j(_){const J=this.#l.get("total").result,ee=!!(this.#e.config||{}).groupFooter,ne=this.#Be();if(_.tree)return this.#He(_,J,ne);if(!_.roots&&!ne){if(J&&J.grand&&!this.#ge()){const Re=this.#s.grandTotal(J.grand,this.#nt(_.leaves.length));if(this.#K===_.leaves&&Array.isArray(this.#D))this.#D[this.#D.length-1]=Re;else{const Ue=Array.from(_.leaves);Ue.push(Re),this.#D=Ue,this.#K=_.leaves}this.#B=[{at:this.#D.length-1}]}else this.#K=null,this.#D=_.leaves,this.#B=V;return this.#H=V,this.#D}const se=[],oe=[],fe=[],pe=Re=>{if(se.push(Re),!ne)return;const Ue=this.#ee(Re);!Ue||!ne.isOpen(Ue.key)||(Ue.master=!0,Ue.expanded=!0,fe.push({at:se.length}),se.push(this.#s.detail(Ue,ne.heightOf(Ue))))};if(!_.roots){for(let Re=0;Re<_.leaves.length;Re++)pe(_.leaves[Re]);return J&&J.grand&&!this.#ge()&&(fe.push({at:se.length}),se.push(this.#s.grandTotal(J.grand,this.#nt(_.leaves.length)))),this.#K=null,this.#H=V,this.#B=fe.length?fe:V,this.#D=se,se}const he=(Re,Ue,Le)=>{if(Re.expanded=Re.hasChildren===!1?!1:this.#ut(Re.key,{key:Re.key,column:Re.groupColumn,value:Re.groupValue,level:Re.level,path:Re.groupPath}),Re.posinset=Ue+1,Re.setsize=Le,oe.push({at:se.length,row:Re}),fe.push({at:se.length}),se.push(Re),!!Re.expanded){if(Re.children&&Re.children.length)for(let ie=0;ie<Re.children.length;ie++)he(Re.children[ie],ie,Re.children.length);else{const ie=_.nodes.get(Re.key),ge=ie&&ie.leaves?ie.leaves:null;if(ge)for(let ke=0;ke<ge.length;ke++)pe(ge[ke])}ee&&Re.totals&&(fe.push({at:se.length}),se.push(this.#s.footer(Re)))}};for(let Re=0;Re<_.roots.length;Re++)he(_.roots[Re],Re,_.roots.length);return J&&J.grand&&!this.#ge()&&(fe.push({at:se.length}),se.push(this.#s.grandTotal(J.grand,this.#nt(_.leaves.length)))),this.#H=oe,this.#B=fe,this.#D=se,se}#Ke(){const _=this.#e.store;if(_&&K(_.liveIndices))return _.liveIndices();const J=new Uint32Array(this.#n.length);let ee=0;for(let ne=0;ne<this.#n.length;ne++)this.#n[ne]!==void 0&&(J[ee++]=ne);return J.subarray(0,ee)}#Fe(){const _=this.#e.store;return _&&typeof _.physical=="number"?_.physical:this.#n.length}#ue(_){const J=this.#e.store;return J&&K(J.source)?J.source(_):this.#n[_]}#Ne(_,J=_){const ee=this.#D[_];if(typeof ee!="number")return ee.index=J,ee;const ne=this.#ee(ee);return ne.index=J,ne}#ee(_){let J=this.#h.get(_);J||(J=this.#s.leaf(this.#ue(_),_),this.#h.set(_,J));const ee=this.#$?this.#$.get(_):null;if(ee){J.level=ee.level,J.posinset=ee.posinset,J.setsize=ee.setsize,J.hasChildren=ee.hasChildren,J.expanded=ee.hasChildren&&!ee.lazy&&this.#ut(J.key);const ne=this.#G?this.#G.byPhysical.get(_):void 0;ne?J.totals=ne:J.totals&&(J.totals=null)}else J.hasChildren&&(J.level=0,J.hasChildren=!1,J.expanded=!1,J.posinset=void 0,J.setsize=void 0);return J}#He(_,J,ee){const ne=[],se=[],oe=pe=>{if(pe.leafCount!==void 0)return pe.leafCount;let he=pe.physical>=0?1:0;for(const Re of pe.children)he+=oe(Re);return pe.leafCount=he,he},fe=pe=>{const he=this.#ut(pe.key);if(pe.physical>=0){if(ne.push(pe.physical),ee&&ee.isOpen(this.#ee(pe.physical).key)){const Re=this.#ee(pe.physical);se.push({at:ne.length}),ne.push(this.#s.detail(Re,ee.heightOf(Re)))}}else ne.push(this.#s.group({path:[pe.key],column:null,value:pe.value,level:pe.level,parent:null,expanded:he,hasChildren:pe.children.length>0,leafCount:oe(pe),totals:this.#G?this.#G.byKey.get(pe.key):void 0}));if(he)for(const Re of pe.children)fe(Re)};for(const pe of _.tree.roots)fe(pe);return J&&J.grand&&!this.#ge()&&(se.push({at:ne.length}),ne.push(this.#s.grandTotal(J.grand,this.#nt(_.leaves.length)))),this.#K=null,this.#H=V,this.#B=se.length?se:V,this.#D=ne,ne}#ct(){return r(()=>this.count(),_=>this.at(_))}#vt(_,J){let ee=this.#x.get(_);if(ee===void 0){const ne=this.#ue(_),se=this.#St(),oe=[],fe=this.#e.columnHidden;for(const pe of se){if(pe.quickFilter===!1||K(fe)&&fe(pe.id))continue;const he=pe.value&&K(pe.value.quickFilterText)?pe.value.quickFilterText({value:void 0,data:ne,row:null,column:pe,colId:pe.id,grid:null,context:this.#z("context",null)}):null,Re=he??(K(pe.formatValue)?pe.formatValue(K(pe.getValue)?pe.getValue(ne):void 0):"");Re!=null&&Re!==""&&oe.push(String(Re))}ee=oe.join(" ").toLowerCase(),this.#x.set(_,ee)}return J(ee)}#st(){const _=this.#z("totals",[]),J=_&&_.length?new Set(_):null;return this.#St().filter(ee=>J?J.has(ee.id):!!(ee.total||ee.groupTotal||ee.grandTotal))}#Ye(_,J,ee,ne="group"){const se={},oe=(this.#e.compute||{}).total;for(const fe of _){if(!$(fe))continue;const pe=this.#o.handle(fe.id);if(!pe)continue;const he=I(fe,ne);if(he)if(K(he)){const Re=new Array(J.length);for(let Ue=0;Ue<J.length;Ue++)Re[Ue]=pe.get(J[Ue]);se[fe.id]=he(Re,{row:ee,column:fe,grid:this.#e.grid||null,context:this.#z("context",null),valueAt:(Ue,Le)=>{const ie=this.#o.handle(Ue);return ie&&Le>=0&&Le<J.length?ie.get(J[Le]):null}})}else K(oe)&&(se[fe.id]=oe(pe,J,he))}return se}#kt(_){if(!_)return _;const J=this.#e.config||{},ee={tz:J.timeZone,weekStartsOn:J.weekStartsOn};return g(_,ne=>{const se=k(ne,ee),oe=this.#ze(se&&se.col),fe=oe&&oe.type==="datetime";if(se&&se.type)return se.type==="datetime"&&!se.timeZone&&oe?{...se,timeZone:J.timeZone||void 0}:se;if(fe)return{...se,type:"datetime",timeZone:J.timeZone||void 0};const pe=oe&&(oe.dataType?.base||oe.type);return pe?{...se,type:pe}:se})}#ut(_,J){const ee=this.#z("expanded",null);return ee?K(ee.has)?ee.has(_,J):Array.prototype.includes.call(ee,_):!0}#z(_,J){if(_==="context"||!K(this.#e.stateVersion))return this.#$t(_,J);const ee=this.#Ot(_),ne=this.#f.get(_);if(ne&&ne.version===ee)return ne.value;const se=this.#$t(_,J);return this.#f.set(_,{version:ee,value:se}),se}#$t(_,J){const ee=this.#e.state;if(ee&&K(ee[_])){const ne=ee[_]();return ne??J}return J}#Qe(){const _=this.#e.stateVersion;return K(_)?_():0}#It(){const _=this.#e.columnsVersion,J=this.#e.permissionsVersion;return`${K(_)?_():0}|${K(J)?J():0}`}#Ot(_){return _==="totals"?this.#It():`${this.#Qe()}`}#it(_,J,ee){if(!K(this.#e.stateVersion))return ee();const ne=this.#d.get(_);if(ne&&ne.version===J)return ne.key;const se=ee();return this.#d.set(_,{version:J,key:se}),se}#ot(_){const J=(this.#e.compute||{})[_];return K(J)||D(`ctx.compute.${_} is required by the memory source pipeline`),J}#St(){const _=this.#e.columns;return _&&K(_.all)?_.all():[]}#ze(_){const J=this.#e.columns;return J&&K(J.get)?J.get(_):void 0}#Je(_,J){const ee=this.#e.emit;K(ee)&&ee(_,J)}}}),Ie("packages/core/src/source/abort.js",function(e,U){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return D}});class te extends Error{constructor(K,x="superseded"){super(`[lattice] request ${K?`"${K}" `:""}${x}`),this.name="SupersededError",this.superseded=!0,this.key=K}}class N{#e;constructor(K,x,G,z){this.#e=K,this.key=x,this.controller=G,this.signal=G.signal,this.seq=z}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(K){this.signal.aborted||this.controller.abort(new te(this.key,K)),this.#e.settle(this)}}class X{#e=new Map;#t=0;begin(K="",x="superseded"){const G=this.#e.get(K);G&&!G.signal.aborted&&G.controller.abort(new te(K,x));const z=new N(this,K,new AbortController,++this.#t);return this.#e.set(K,z),z}tokenFor(K){return this.#e.get(K)}pending(K=""){const x=this.#e.get(K);return!!x&&!x.signal.aborted}get size(){return this.#e.size}settle(K){this.#e.get(K.key)===K&&this.#e.delete(K.key)}abort(K="",x="superseded"){const G=this.#e.get(K);G&&G.abort(x)}abortAll(K="superseded"){for(const x of[...this.#e.values()])x.abort(K);this.#e.clear()}}function B(){return new X}function D(q){if(!q||typeof q!="object")return!1;const K=q;return K.superseded===!0||K.name==="AbortError"||K.name==="SupersededError"}}),Ie("packages/core/src/source/blockcache.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return B}});const te=100,N=32;class X{constructor(q){this.id=q,this.rows=null,this.state="pending",this.token=null,this.error=null}}class B{#e=new Map;#t;#n;#r=0;#i=-1;constructor(q={}){this.#t=Math.max(1,Math.floor(Number(q.pageSize)||te)),this.#n=Math.max(1,Math.floor(Number(q.maxCachedPages)||N))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(q){return Math.floor(q/this.#t)}rangeOf(q){return{start:q*this.#t,end:(q+1)*this.#t}}has(q){return this.#e.has(q)}pending(q){const K=this.#e.get(q);return!!K&&K.state==="pending"}loaded(q){const K=this.#e.get(q);return!!K&&K.state==="loaded"}begin(q,K){let x=this.#e.get(q);return x||(x=new X(q)),x.state="pending",x.token=K,x.error=null,this.#s(q,x),x}fill(q,K){const x=this.#e.get(q)||new X(q);x.rows=K,x.state="loaded",x.token=null,this.#s(q,x)}failed(q,K){const x=this.#e.get(q)||new X(q);x.state="error",x.error=K,x.token=null,this.#s(q,x)}delete(q){return this.#e.delete(q)}rowAt(q){const K=this.blockOf(q),x=this.#e.get(K);if(!(!x||x.state!=="loaded"||!x.rows))return this.#s(K,x),x.rows[q-K*this.#t]}rowLoaded(q){const K=this.blockOf(q),x=this.#e.get(K);return!!x&&x.state==="loaded"&&!!x.rows&&q-K*this.#t<x.rows.length}erroredAt(q){const K=this.#e.get(this.blockOf(q));return!!K&&K.state==="error"}loadedExtent(){let q=0;for(const K of this.#e.values()){if(K.state!=="loaded"||!K.rows)continue;const x=K.id*this.#t+K.rows.length;x>q&&(q=x)}return q}fillOf(q){const K=this.#e.get(q);return K&&K.state==="loaded"&&K.rows?K.rows.length:null}protect(q,K){this.#r=this.blockOf(Math.max(0,q)),this.#i=this.blockOf(Math.max(0,K))}evict(){const q=[];if(this.#e.size<=this.#n)return q;for(const[K,x]of this.#e){if(this.#e.size-q.length<=this.#n)break;K>=this.#r&&K<=this.#i||x.state!=="pending"&&q.push(K)}for(const K of q)this.#e.delete(K);return q}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#s(q,K){this.#e.delete(q),this.#e.set(q,K)}}}),Ie("packages/core/src/source/pagewindow.js",function(e,U){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return te}});function te(N,X,B,D){const q=Math.floor(Number(N)||0);if(q<=0)return null;const K=Math.max(0,Math.floor(Number(X)||0)),x=Math.max(0,Math.floor(Number(B)||0));if(D){const G=Math.max(1,Math.ceil(x/q)),z=Math.min(K,G-1),j=z*q;return{page:z,pageSize:q,offset:j,length:Math.max(0,Math.min(q,x-j)),pageCount:G,total:x}}return{page:K,pageSize:q,offset:K*q,length:q,pageCount:Math.max(K+2,Math.ceil(x/q)),total:null}}}),Ie("packages/core/src/source/paged.js",function(e,U){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return w}});const N=U("packages/core/src/internal/lru.js").Lru,B=U("packages/core/src/internal/predicates.js").isFunction,q=U("packages/core/src/internal/warn.js").warnOnce,x=U("packages/core/src/internal/schedule.js").settleDebounce,G=U("packages/core/src/source/abort.js"),z=G.createAbortScope,j=G.isAbortError,O=U("packages/core/src/source/blockcache.js"),b=O.BlockCache,u=O.DEFAULT_PAGE_SIZE,f=O.DEFAULT_MAX_CACHED_PAGES,r=U("packages/core/src/source/rows.js").createRowFactory,t=U("packages/core/src/source/filterwire.js"),s=t.wireFilters,i=t.querySignature,n=t.warnHostFilterNotApplied,o=U("packages/core/src/source/pagewindow.js").pageWindow,l=120;function h(g,k){return new w(g,k)}class w{mode="paged";#e;#t;#n;#r=z();#i;#s;#o=new Map;#l=null;#a=null;#c=!1;#u=0;#f="";#d={start:0,end:0};#h;#p=!1;#m=0;#g="";constructor(k,d){this.#e=k||{mode:"paged"},this.#t=d||{},this.#n=new b({pageSize:this.#e.pageSize||u,maxCachedPages:this.#e.maxCachedPages||f}),this.#i=r(this.#t),this.#s=new N(this.#n.pageSize*4),this.#h=x((p,m)=>this.#w(p,m),l),this.#f=this.#E(),B(this.#e.fetch)||q("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),n(this.#t)}count(){const k=this.#y();return k?k.length:this.#b()}#b(){if(this.#T(),this.#l!==null)return this.#l;const k=Math.max(this.#u,this.#n.loadedExtent());return this.#c?k:k+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const k=this.#y();if(!k){const d=this.#b();return{page:0,pageSize:0,total:this.exact()?d:null,pageCount:1,counting:!1}}return{page:k.page,pageSize:k.pageSize,total:k.total,pageCount:k.pageCount,counting:k.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const k=this.#b(),d=o(this.#P("pageSize",0),this.#P("page",0),k,this.exact());if(!d)return this.#g="",null;const p=`${this.#m}:${d.offset}:${d.length}`;if(p!==this.#g&&!this.#p&&(this.#g=p,d.length>0)){const m=d.offset+d.length-1;this.#d={start:d.offset,end:m},this.#w(d.offset,m)}return d}at(k){const d=this.#y();if(d){if(k<0||k>=d.length)return;const p=this.#A(d.offset+k);return p&&(p.index=k),p}return this.#A(k)}#A(k){if(k<0||k>=this.#b())return;const d=this.#s.get(k);if(d&&(d.data!==null||!this.#n.rowLoaded(k)))return d;const p=this.#n.rowAt(k);if(p===void 0){const v=this.#i.skeleton(k,0,this.#n.erroredAt(k));return this.#s.set(k,v),v}const m=this.#i.leaf(p,k);return m.index=k,this.#s.set(k,m),this.#o.set(m.key,k),m}byKey(k){const d=this.#o.get(k);return d===void 0?void 0:this.#A(d)}loaded(k){const d=this.#y();return d?k>=0&&k<d.length&&this.#n.rowLoaded(d.offset+k):this.#n.rowLoaded(k)}loadedCount(){this.#T();let k=0;for(const d of this.#n.ids()){if(!this.#n.loaded(d))continue;const p=this.#n.fillOf(d);typeof p=="number"&&(k+=p)}return k}residentRows(){this.#T();const k=this.#y(),d=k?k.offset:0,p=k?k.offset+k.length:1/0,m=[],v=this.#n.ids().sort((y,E)=>y-E);for(const y of v){if(!this.#n.loaded(y))continue;const{start:E}=this.#n.rangeOf(y),M=this.#n.fillOf(y)||0;for(let F=E;F<E+M;F++){if(F<d||F>=p)continue;const V=this.#s.peek(F);if(V&&V.data!==null&&V.data!==void 0){m.push(V);continue}const I=this.#n.rowAt(F);if(I===void 0)continue;const $=this.#i.leaf(I,F);$.index=F,this.#s.set(F,$),this.#o.set($.key,F),m.push($)}}return m}hint(k,d){if(this.#p)return;const p=this.#T();let m=Math.max(0,Math.floor(k)),v=Math.max(m,Math.floor(d));const y=this.#y();if(y){if(y.length===0)return;m=y.offset,v=y.offset+y.length-1}this.#d={start:m,end:v},this.#n.protect(m,v);for(const E of this.#n.evict())this.#v(E);this.#h(m,v),p&&this.#h.flush()}#w(k,d){if(this.#p)return;this.#n.protect(k,d);const p=this.#n.blockOf(k),m=this.#n.blockOf(d);for(let v=p;v<=m&&!(this.#l!==null&&v*this.#n.pageSize>=this.#l);v++)this.#n.has(v)||this.#O(v)}apply(k){const d={added:[],updated:[],removed:[]};if(!k)return d;if(k.update)for(const p of k.update){const m=this.#i.keyOf(p,-1),v=this.#o.get(m);if(v===void 0)continue;const y=this.#i.leaf(p,v);y.index=v,this.#s.set(v,y),d.updated.push(y)}return(k.add&&k.add.length||k.remove&&k.remove.length)&&this.reload(),d}reload(k){this.#S("reload"),this.#h.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#p=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#s.clear(),this.#o.clear()}exact(){return this.#l!==null||this.#c}pending(){return this.#r.size}async#O(k){if(!B(this.#e.fetch))return;const d=this.#r.begin(`block:${k}`);this.#n.begin(k,d);const{start:p,end:m}=this.#n.rangeOf(k),v=this.#f;try{const y=await this.#e.fetch({range:{start:p,end:m},sort:this.#P("sort",[]),filters:s(this.#P("filters",null),this.#N()),quick:this.#P("quick","")||void 0,context:this.#P("context",null),signal:d.signal});if(!d.current||v!==this.#f||this.#p)return;d.settle();const E=y&&y.rows||[];this.#n.fill(k,E);for(let F=0;F<E.length;F++)this.#s.delete(p+F);const M=y&&typeof y.total=="number"?y.total:y&&typeof y.count=="number"?y.count:null;M!==null?(this.#l=M,this.#c=!0):E.length<this.#n.pageSize?(this.#c=!0,this.#l=p+E.length):this.#u=Math.max(this.#u,p+E.length),this.#M("model:changed",{reason:"page",block:k,from:p,to:p+E.length}),this.#M("rows:changed",{companion:!0,reason:"page",block:k,from:p,to:p+E.length}),this.#l!==null&&this.#l!==this.#a&&(this.#a=this.#l,this.#M("source:total",{total:this.#l,groupPath:[]}))}catch(y){if(d.settle(),j(y))return;this.#n.failed(k,y);for(let E=p;E<m;E++)this.#s.delete(E);this.#M("model:changed",{reason:"page-error",block:k,range:{start:p,end:m}}),this.#M("source:error",{error:y,block:k,range:{start:p,end:m}})}}#v(k){const{start:d,end:p}=this.#n.rangeOf(k);for(let m=d;m<p;m++){const v=this.#s.peek(m);v&&this.#o.delete(v.key),this.#s.delete(m)}}#T(){const k=this.#E();return k===this.#f?!1:(this.#f=k,this.#S("query"),!0)}#S(k){this.#r.abortAll(k),this.#n.clear(),this.#s.clear(),this.#o.clear(),this.#l=null,this.#a=null,this.#c=!1,this.#u=0,this.#m++,this.#M("model:changed",{reason:k})}#E(){return i({filters:this.#P("filters",null),sort:this.#P("sort",[]),quick:this.#P("quick",""),context:this.#P("context",null)})}#N(){const k=this.#t.config||{};return{tz:k.timeZone,weekStartsOn:k.weekStartsOn}}#P(k,d){const p=this.#t.state;if(p&&B(p[k])){const m=p[k]();return m??d}return d}#M(k,d){const p=this.#t.emit;B(p)&&p(k,d)}}}),Ie("packages/core/src/source/aggregates.js",function(e,U){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return G}});const te=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function N(){const z=new Set;for(const[j,O]of Object.entries(te))O.pushable&&z.add(j);return z}function X(z,j,O){let b=z.split("%c").join(j);return O!==void 0&&(b=b.split("%w").join(O)),b}function B(z){const j=z||{},O=j.default==="engine"||j.default==="engine-if-identical"?j.default:"client",b={};if(j.overrides&&typeof j.overrides=="object")for(const[u,f]of Object.entries(j.overrides))(f==="engine"||f==="client")&&(b[u]=f);return{default:O,overrides:b}}function D(z,j){const O=te[z];if(!O||!O.pushable)return"client";const b=j.overrides[z];return b==="engine"||b==="client"?b:j.default==="client"?"client":j.default==="engine-if-identical"?O.class==="identical"?"engine":"client":"engine"}function q(z,j){const O=B(j),b=[],u=[];for(const f of z||[]){const a=te[f.fn],r=D(f.fn,O),t={id:f.id,col:f.col,fn:f.fn,class:a?a.class:"fallback"};f.weight!==void 0&&(t.weight=f.weight),f.params!==void 0&&(t.params=f.params),r==="engine"?b.push(t):(t.reason=a&&!a.pushable?a.note||"the engine cannot express this stat":"client by config",u.push(t))}return{engine:b,client:u,config:O}}const K=/^[A-Za-z_][A-Za-z0-9_$]*$/;function x(z,j=[]){return(z||[]).every(b=>{if(typeof b=="string")return K.test(b);if(!b||typeof b!="object")return!1;const u=b;return Array.isArray(j)&&j.includes(u.bucket)&&typeof u.col=="string"&&K.test(u.col)&&typeof u.size=="number"&&Number.isFinite(u.size)&&u.size>0})}function G(){return Object.entries(te).map(([z,j])=>({stat:z,class:j.class,sql:j.sql?X(j.sql,"col",j.twoColumn?"weight":void 0):"",note:j.note||(j.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Ie("packages/core/src/source/pushdown.js",function(e,U){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return Z}});const N=U("packages/core/src/internal/compare.js").defaultCompare,B=U("packages/core/src/internal/predicates.js").isFunction,q=U("packages/core/src/internal/merge.js").toArray,x=U("packages/core/src/internal/warn.js").warnOnce,G=U("packages/core/src/source/filterwire.js"),z=G.isGroup,j=G.warnWherePageRelative,O=G.warnWhereOverThreshold,b=G.wireFilters,u=U("packages/core/src/source/aggregates.js"),f=u.resolveAggregatePlan,a=u.groupKeysPushable,r=u.STAT_PUSHDOWN,s=U("packages/core/src/source/abort.js").SupersededError,i=1e3;function n(_){const J=_&&_.signal;if(!J||!J.aborted)return;const ee=J.reason;throw ee instanceof Error?ee:new s("","superseded before it was sent")}const c=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function o(_){if(!_||typeof _!="object")return!1;const J=_.returning==="row"||_.returning==="key"?_.returning:"none";return{append:_.append===!0,update:_.update===!0,delete:_.delete===!0,returning:J}}function l(_,J){if(!_||typeof J!="string")return;if(!J.includes("."))return _[J];let ee=_;for(const ne of J.split(".")){if(ee===null||typeof ee!="object")return;ee=ee[ne]}return ee}function h(_){if(_===!0)return!0;if(!_||typeof _!="object")return!1;const J=_;return J.enabled===!1?!1:J.enabled===!0||B(J.commit)}function w(_){const J={...c,..._||{}};return J.operators=new Set(J.operators||[]),J.mutate=o(J.mutate),J}function g(_,J){return!_||!_.op||!J.operators.size?!1:J.operators.has(_.op)}function k(_,J){if(!_)return{pushed:null,residual:null};if(!J.filter)return{pushed:null,residual:_};if(J.filter==="term"){if(z(_)){const oe=_.conditions||[];if(String(_.op)!=="and")return{pushed:null,residual:_};const fe=oe.findIndex(he=>!z(he)&&g(he,J));if(fe<0)return{pushed:null,residual:_};const pe=oe.filter((he,Re)=>Re!==fe);return{pushed:oe[fe],residual:pe.length?{op:"and",conditions:pe}:null}}return g(_,J)?{pushed:_,residual:null}:{pushed:null,residual:_}}if(!z(_))return g(_,J)?{pushed:_,residual:null}:{pushed:null,residual:_};if(String(_.op)!=="and")return(_.conditions||[]).every(fe=>z(fe)?k(fe,J).residual===null:g(fe,J))?{pushed:_,residual:null}:{pushed:null,residual:_};const ee=[],ne=[];for(const oe of _.conditions||[]){if(z(oe)){if(J.filter==="flat"){ne.push(oe);continue}const fe=k(oe,J);fe.pushed&&ee.push(fe.pushed),fe.residual&&ne.push(fe.residual);continue}(g(oe,J)?ee:ne).push(oe)}const se=oe=>oe.length===0?null:oe.length===1?oe[0]:{op:"and",conditions:oe};return{pushed:se(ee),residual:se(ne)}}const d="__lattice_leaves";function p(_){return _.aggregates?_.aggregates instanceof Set?_.aggregates:new Set(q(_.aggregates)):new Set}function m(_){const J=p(_);return J.size?J.has("count")?_.filter!=="tree"||!_.operators||!_.operators.has("eq")?"the adapter does not declare the `group` capability, and cannot narrow a group's rows by its key (that needs a `tree` filter with the `eq` operator)":"":"the adapter does not declare the `group` capability, and its declared aggregates have no `count` to give each group its row count":"the adapter does not declare the `group` capability"}function v(_,J,ee,ne,se,oe,fe){const pe=Array.isArray(_.groupBy)?_.groupBy:[],he=Array.isArray(_.groupPath)?_.groupPath:[],Re=Array.isArray(_.groupValues)?_.groupValues:null;if(!J.group){const Ue=m(J);if(Ue)return Ue}return a(pe)?ee.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":ne?se?oe?"a host `where` predicate can only run in the browser, over rows the engine grouped":fe?"fullDataset holds the whole matching set, so the grid groups it itself":!Re||Re.length!==he.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",E="pushdown:group-unsupported",M=Symbol("lattice.remote.ungroupedLevel");function F(_,J,ee,ne,se,oe){const fe=Array.isArray(_.pivotBy)?_.pivotBy:[],pe=Array.isArray(_.groupBy)?_.groupBy:[],he=Array.isArray(_.groupPath)?_.groupPath:[],Re=Array.isArray(_.groupValues)?_.groupValues:null;return J.pivot?a(fe)?pe.length&&!a(pe)?"a grouping key is not a plain column the engine can name in a GROUP BY":ee.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":ne?se?oe?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!Re||Re.length!==he.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(_,J,ee=!1){const ne=k(_.filters||null,J),se=[];ne.residual&&se.push("filter");const oe=_.sort||[],fe=oe.length===0||J.sort==="multi"&&oe.length>=1||J.sort==="single"&&oe.length===1;!fe&&oe.length&&se.push("sort");const pe=_.quick?String(_.quick):"",he=!pe||!!J.quick;he||se.push("quick");const Re=_.where&&_.where.active?_.where:null;Re&&se.push("where");const Ue={filters:ne.residual,sort:fe?null:oe,quick:he?"":pe,where:Re},Le=!!ee,ie=Array.isArray(_.groupBy)&&_.groupBy.length>0,ge=ie?v(_,J,ne,fe,he,Re,Le):"",ke=_.pivotMode!==!1&&Array.isArray(_.pivotBy)&&_.pivotBy.length>0,Se=ke?F(_,J,ne,fe,he,Re):"",Ae=ke&&Se==="";ke&&!Ae&&se.push("pivot");const xe=ke?Ae&&ie:ie&&ge==="";ie&&!ke&&!xe&&se.push("group");const me=(xe||Ae)&&Array.isArray(_.groupValues)?_.groupValues.length:0,ye=xe||ke?!1:Le||!!(Ue.filters||Ue.sort||Ue.quick||Ue.where)||!J.range;return{pushed:{..._,filters:ne.pushed,sort:fe?oe:[],quick:he?pe:"",range:ye?null:_.range},residual:Ue,needsAll:ye,unpushed:se,full:Le,grouped:xe,groupLevel:me,groupReason:ke?"":ge,pivoted:Ae,pivotReason:Se}}function I(_){const J=Array.isArray(_.totals)?_.totals:[],ee=_.totalFns&&typeof _.totalFns=="object"?_.totalFns:{},ne=[],se=[];for(const oe of J){const fe=String(oe),pe=typeof ee[fe]=="string"?ee[fe]:null,he=pe?r[pe]:null;pe?!he||!he.pushable||!he.sql?se.push({id:fe,fn:pe,class:he?he.class:"fallback",reason:he&&he.note?he.note:`the pushdown map cannot express "${pe}"`}):he.twoColumn?se.push({id:fe,fn:pe,class:he.class,reason:`"${pe}" reduces two columns, and a grouped request carries no weight column`}):ne.push({id:fe,col:fe,fn:pe,class:he.class}):se.push({id:fe,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:ne,client:se}}const $=Object.freeze({items:_=>_==null?[]:Array.isArray(_)?_:[_]});function S(_,J,ee){if(!J)return _;let ne=_;if(J.filters&&B(ee.evaluateFilters)){const se=ne,oe={count:ne.length,handle:he=>({id:he,get:Re=>l(se[Re],he)}),itemwise:he=>se.some(Re=>Array.isArray(l(Re,he)))?$:null},fe=ee.evaluateFilters(J.filters,oe),pe=[];for(let he=0;he<ne.length;he++)fe[he]&&pe.push(ne[he]);ne=pe}if(J.where&&J.where.active&&(J.whole||j(J.where.names,"pushdown"),ne=ne.filter(se=>J.where.passes(se))),J.quick){const se=J.quick.toLowerCase();ne=ne.filter(oe=>{if(!oe||typeof oe!="object")return!1;for(const fe of Object.values(oe))if(fe!=null&&String(fe).toLowerCase().includes(se))return!0;return!1})}if(J.sort&&J.sort.length&&B(ee.sortMulti)){const se=[...new Set(J.sort.map(he=>he.col))],oe=ne,fe=se.map(he=>({id:he,get:Re=>l(oe[Re],he)})),pe=ee.sortMulti(fe,J.sort.map(he=>({col:he.col,dir:he.dir})),Uint32Array.from({length:ne.length},(he,Re)=>Re),{});ne=Array.from(pe,he=>oe[he])}return ne}function R(_){return JSON.stringify({filters:_.filters||null,sort:_.sort||[],quick:_.quick||"",groupBy:_.groupBy||[],groupPath:_.groupPath||[],context:_.context??null})}function L(_){if(!_||typeof _!="object")return 16;let J="";try{J=JSON.stringify(_)}catch{return 200}return J.length*2+64}function T(_){const J=_||{};return{enabled:!!J.enabled,maxRows:Number.isFinite(J.maxRows)?J.maxRows:1e6,maxBytesEstimate:Number.isFinite(J.maxBytesEstimate)?J.maxBytesEstimate:512*1024*1024}}const A=5e4;function C(_){return Number.isFinite(_)&&_>=0?_:A}function H(_){return!!_&&B(_.then)}async function Y(_){if(!_||_.total!==void 0||!H(_.pendingTotal))return _;const J=await _.pendingTotal,{pendingTotal:ee,...ne}=_;return typeof J=="number"?{...ne,total:J}:ne}function Z(_={}){const J=_.adapter;if(!J||!B(J.execute))return x("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{..._,mode:"remote",fetch:async()=>({rows:[],total:0})};const ee=w(J.capabilities),ne=J.capabilities&&Object.getOwnPropertyDescriptor(J.capabilities,"operators");ne&&B(ne.get)&&Object.defineProperty(ee,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(J.capabilities.operators||[]),set:()=>{}});const se=J.name||"adapter";let oe=null;const fe=()=>B(J.ready)?(oe||(oe=Promise.resolve(J.ready()).then(()=>{Object.assign(ee,w(J.capabilities))},ue=>{throw oe=null,ue})),oe):null,pe=T(_.fullDataset),he=!!_.allowPartialResults,Re=C(_.whereRowLimit);let Ue=null;const Le=_.aggregates;let ie=null,ge=null,ke=null,Se=null,Ae=null,xe,me=null,ye=0,Te=null;const Ye=()=>!pe.enabled||!ie?null:(Te!==ie.key&&(ye++,Te=ie.key),{rows:ie.rows,version:ye}),Oe=async ue=>{const ve=ue.where&&ue.where.active?ue.where:null;if(!ve)return{request:ue,probe:null};const{where:Ce,...Ee}=ue,Fe=V(Ee,ee,pe.enabled);if(Fe.needsAll)return{request:ue,probe:null};const Be=R(Fe.pushed);let Ve=null;return(!Ue||Ue.key!==Be)&&(ee.total?(n(ue),Ve=await Y(await J.execute(Fe.pushed,ue)),Ue={key:Be,size:Ve&&typeof Ve.total=="number"?Ve.total:null}):Ue={key:Be,size:null}),Ue.size!==null&&Ue.size<Re?{request:ue,probe:null}:(O(ve.names,se,Ue.size,Re),{request:Ee,probe:Ve})},_e=async(ue,ve)=>{me=null;const Ce=I(ue.pushed);ke={engine:Ce.engine,client:Ce.client,groupBy:ue.pushed.groupBy},Ce.client.length&&x(`source.pushdown.group.totals.${se}.${Ce.client.map(Be=>Be.id).join(".")}`,`the ${se} adapter cannot compute the group subtotal for ${Ce.client.map(Be=>`"${Be.id}" (${Be.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 Ee=await J.executeGroupLevel(ue.pushed,Ce.engine,ve)||{};let Fe=Ee.rows||[];return!ee.range&&ve.range&&(Fe=Fe.slice(ve.range.start,ve.range.end)),Ke(Ee),Ee.total===void 0?{rows:Fe}:{rows:Fe,total:Ee.total}},je=new Map,we=64,He=async(ue,ve)=>{me=null;const Ce=ue.pushed,Ee=Ce.groupBy,Fe=Array.isArray(Ce.groupValues)?Ce.groupValues:[],Be=Fe.length,Ve=[...Ce.filters?[Ce.filters]:[],...Ee.slice(0,Be).map((bt,mt)=>({col:bt,op:"eq",value:Fe[mt]===void 0?null:Fe[mt],caseSensitive:!0}))],Je=Ve.length===0?null:Ve.length===1?Ve[0]:{op:"and",conditions:Ve},$e=ve.range?ve.range.start:0;if(Be>=Ee.length){const bt={...Ce,filters:Je,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},mt=await Y(await J.execute(bt,ve))||{};let $t=mt.rows||[];return!ee.range&&ve.range&&($t=$t.slice(ve.range.start,ve.range.end)),typeof mt.total=="number"?{rows:$t,total:mt.total}:{rows:$t}}const ze=Ee[Be],Qe=I(Ce),tt=p(ee),et=Qe.engine.filter(bt=>tt.has(bt.fn)),dt=[...Qe.engine.filter(bt=>!tt.has(bt.fn)).map(bt=>({id:bt.id,fn:bt.fn,class:bt.class,reason:`the ${se} adapter does not compute "${bt.fn}"`})),...Qe.client];ke={engine:et,client:dt,groupBy:Ee},dt.length&&x(`source.pushdown.group.totals.${se}.${dt.map(bt=>bt.id).join(".")}`,`the ${se} adapter cannot compute the group subtotal for ${dt.map(bt=>`"${bt.id}" (${bt.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 ft=[...et.map(bt=>({id:bt.id,col:bt.col,fn:bt.fn})),{id:d,col:ze,fn:"count"}],lt={...Ce,filters:Je,range:null},jt=JSON.stringify([R(lt),Fe,ze,ft]);let Tt=$e>0?je.get(jt):void 0;if(!Tt){for(Tt=Promise.resolve(J.executeGroupedAggregates(lt,[ze],ft)),je.delete(jt),je.set(jt,Tt);je.size>we;)je.delete(je.keys().next().value);Tt.catch(()=>{je.get(jt)===Tt&&je.delete(jt)})}const xt=await Tt||[];n(ve);const Ge=bt=>{const mt={};for(const $t of et)mt[$t.id]=bt?bt[$t.id]:void 0;return mt},vt=(Ce.sort||[]).find(bt=>bt&&bt.col===ze),ht=vt&&vt.dir==="desc"?-1:1,kt=xt.filter(bt=>bt&&bt.level===1).map(bt=>({[ze]:bt.keys[0]===void 0?null:bt.keys[0],leafCount:Number(bt.values&&bt.values[d])||0,totals:Ge(bt.values)})).sort((bt,mt)=>ht*N(bt[ze],mt[ze]));if(Be===0){const bt=xt.find($t=>$t&&$t.level===0),mt=bt?Number(bt.values&&bt.values[d]):NaN;Ke({matchCount:Number.isFinite(mt)?mt:kt.reduce(($t,Ht)=>$t+Ht.leafCount,0),...bt?{grand:Ge(bt.values)}:{}})}const Nt=ve.range?ve.range.end:kt.length;return{rows:kt.slice($e,Nt),total:kt.length}},Ke=ue=>{typeof ue.matchCount=="number"&&(Se=ue.matchCount,Ae=ue.grand?{totals:ue.grand,leafCount:ue.matchCount}:null,xe===void 0&&B(J.unfilteredCount)&&(xe=null,Promise.resolve(J.unfilteredCount()).then(ve=>{xe=typeof ve=="number"?ve:null}).catch(ve=>{x(`source.pushdown.group.unfiltered.${se}`,`the ${se} adapter could not count the unfiltered set (${ve&&ve.message?ve.message:ve}), so "N of M" falls back to the display count for its denominator.`)})))},Xe=async(ue,ve)=>{me=null;const Ce=I(ue.pushed);ke={engine:Ce.engine,client:Ce.client,groupBy:ue.pushed.groupBy,pivotBy:ue.pushed.pivotBy},Ce.client.length&&x(`source.pushdown.pivot.totals.${se}.${Ce.client.map(Je=>Je.id).join(".")}`,`the ${se} adapter cannot compute the pivot cells for ${Ce.client.map(Je=>`"${Je.id}" (${Je.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 Ee=await J.executePivotLevel(ue.pushed,Ce.engine,ve)||{};let Fe=Ee.rows||[];!ee.range&&ve.range&&(Fe=Fe.slice(ve.range.start,ve.range.end)),Ke(Ee);const Be=Ee.pivot&&typeof Ee.pivot=="object"?Ee.pivot:{},Ve={cells:Array.isArray(Be.cells)?Be.cells:[],...Array.isArray(Be.axis)?{axis:Be.axis}:{}};return Ee.total===void 0?{rows:Fe,pivot:Ve}:{rows:Fe,total:Ee.total,pivot:Ve}},nt=ue=>{x(`source.pushdown.pivot.${se}.${ue}`,`pushdown:pivot-unsupported: the ${se} adapter cannot pivot this query because ${ue}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const ve=new Error(`[lattice] ${y}: the ${se} adapter cannot pivot this query because ${ue}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw ve.code=y,ve.reason=ue,ve},it=(ue,ve)=>{const Ce={key:ve,state:"pending",value:null};return me=Ce,ue.then(Ee=>(me===Ce&&(me={key:ve,state:"settled",value:typeof Ee=="number"?Ee:null}),Ee),Ee=>{throw me===Ce&&(me={key:ve,state:"failed",value:null}),Ee})};let wt=0,pt=[];const St=()=>wt===0?null:new Promise(ue=>{const ve=setTimeout(ue,i);pt.push(()=>{clearTimeout(ve),ue()})});let Ct;const Mt=async ue=>{const ve=fe();ve&&await ve;const Ee=ue&&ue.pivotMode!==!1&&Array.isArray(ue.pivotBy)&&ue.pivotBy.length>0?{request:ue,probe:null}:await Oe(ue);n(ue);let Fe=V(Ee.request,ee,pe.enabled);if(ee.group&&Fe.grouped&&!Fe.pivoted&&!B(J.executeGroupLevel)&&(x(`source.pushdown.group.method.${se}`,`the ${se} 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.`),Fe=V(Ee.request,{...ee,group:!1,aggregates:null},pe.enabled)),Fe.pivoted&&!B(J.executePivotLevel)&&(Fe=V(Ee.request,{...ee,pivot:!1},pe.enabled),Fe.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),Fe.grouped&&!Fe.pivoted&&!ee.group&&!B(J.executeGroupedAggregates)&&(x(`source.pushdown.group.aggregates.method.${se}`,`the ${se} 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\`.`),Fe=V(Ee.request,{...ee,aggregates:null},pe.enabled)),ge=Fe,Fe.pivoted)return Xe(Fe,ue);if(Fe.pivotReason&&nt(Fe.pivotReason),Fe.grouped)return ee.group?_e(Fe,ue):He(Fe,ue);const Ve=!!Fe.groupReason&&!Fe.full;Ve?x(`source.pushdown.group-unsupported.${se}.${Fe.groupReason}`,`pushdown:group-unsupported: the ${se} adapter was not asked to group this query because ${Fe.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.`):Fe.groupReason&&x(`source.pushdown.group.${se}.${Fe.groupReason}`,`the ${se} adapter was not asked to group this query because ${Fe.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 Je=ft=>Ve?{...ft,[M]:!0}:ft;if(!Fe.needsAll){const ft=Ee.probe||await J.execute(Fe.pushed,ue),lt=ft.rows||[];return H(ft.pendingTotal)&&ft.total===void 0?Je({rows:lt,pendingTotal:it(ft.pendingTotal,R(Fe.pushed))}):(me=null,!ee.total&&ft.total===void 0?Je({rows:lt}):Je({rows:lt,total:ft.total??lt.length}))}Fe.unpushed.length&&x(`source.pushdown.residual.${se}.${Fe.unpushed.join(".")}`,`the ${se} adapter cannot push ${Fe.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=R(Fe.pushed);if(!ie||ie.key!==$e){const ft=await Y(await J.execute(Fe.pushed,ue));me=null;const lt=ft.rows||[];if(Fe.full){const jt=typeof ft.total=="number"?Math.max(ft.total,lt.length):lt.length;if(jt>pe.maxRows)throw new Error(`[lattice] fullDataset refused: the ${se} adapter's matching set is ${jt.toLocaleString()} rows, past the configured maxRows of ${pe.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 Tt=lt.length*L(lt[0]);if(Tt>pe.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${se} adapter's matching set is an estimated ${Math.round(Tt/(1024*1024)).toLocaleString()} MB across ${lt.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(pe.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 ft.total=="number"&<.length<ft.total){const jt=!!(Fe.residual.filters||Fe.residual.quick||Fe.residual.sort&&Fe.residual.sort.length);if(jt&&!he)throw new Error(`[lattice] the ${se} adapter returned ${lt.length} of ${ft.total} matching rows when asked for the whole result, and the query has residual ${Fe.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.`);jt?x(`source.pushdown.partial.residual.${se}`,`the ${se} adapter returned ${lt.length} of ${ft.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.`):x(`source.pushdown.partial.${se}`,`the ${se} adapter returned ${lt.length} of ${ft.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}ie={key:$e,rows:lt,total:typeof ft.total=="number"?ft.total:null}}let ze=Fe;if(Fe.residual.where){const ft=ie.total??ie.rows.length;if(ft>=Re){O(Fe.residual.where.names,se,ft,Re);const{where:lt,...jt}=Ee.request;ze=V(jt,ee,pe.enabled),ge=ze}}const Qe=ie.total!==null&&ie.rows.length>=ie.total,tt=S(ie.rows,{...ze.residual,whole:Qe},_.compute||{}),et=ue.range?ue.range.start:0,dt=ue.range?ue.range.end:tt.length;return Je({rows:tt.slice(et,dt),total:tt.length})},at=async(ue,ve,Ce)=>{const Fe=Ce&&Ce.waitForPage&&Ct&&B(Ct.pageForegroundIdle)?Ct.pageForegroundIdle():St();Fe&&await Fe;const Be=fe();Be&&await Be;const Ve=V(ue,ee,pe.enabled);ge=Ve;const Je=f(ve,Le),$e=Array.isArray(ue.groupBy)?ue.groupBy:[],ze=$e.length>0,Qe=!Ve.residual.filters&&!Ve.residual.quick,tt=!ze||a($e,ee.buckets);let et=Je.engine,dt=Je.client;if(ee.aggregates&&et.length){const Tt=ee.aggregates instanceof Set?ee.aggregates:new Set(q(ee.aggregates)),xt=et.filter(Ge=>!Tt.has(Ge.fn));xt.length&&(et=et.filter(Ge=>Tt.has(Ge.fn)),dt=[...xt.map(Ge=>({...Ge,reason:`the ${se} adapter does not compute "${Ge.fn}"`})),...dt])}const ft=Tt=>{dt=[...et.map(xt=>({...xt,reason:Tt})),...dt],et=[]};et.length&&!Qe?ft(Ve.residual.quick&&!Ve.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):et.length&&!tt&&ft("a grouping key the engine cannot form forces all-client (no mixed provenance)");let lt={},jt;return et.length&&(B(ze?J.executeGroupedAggregates:J.executeAggregates)?ze?jt=await J.executeGroupedAggregates(Ve.pushed,$e,et)||[]:lt=await J.executeAggregates(Ve.pushed,et)||{}:(x(`source.pushdown.aggregates.${se}${ze?".grouped":""}`,`the ${se} adapter cannot compute ${ze?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),ft(`adapter cannot compute ${ze?"grouped ":""}aggregates`))),ke={engine:et,client:dt,...ze?{groupBy:$e}:{}},{values:lt,engine:et,client:dt,...jt!==void 0?{groups:jt}:{}}},ot=async ue=>{wt++;try{return await Mt(ue)}finally{if(wt--,wt===0&&pt.length){const ve=pt;pt=[];for(const Ce of ve)Ce()}}},gt=h(_.edit),Et=_.edit&&typeof _.edit=="object"&&B(_.edit.commit);let ut=_.edit;if(gt&&!Et)if(ee.mutate&&ee.mutate.update){const ue=ve=>{if(!ee.mutate||!ee.mutate.update)throw new Error(`[lattice] the ${se} adapter cannot update rows (mutate.update is not declared), so this edit cannot be persisted. The cell is reverted rather than left looking saved.`);const Ce={kind:"update",key:String(ve.key),patch:{[ve.colId]:ve.value}};return J.mutate(Ce,ve.request||{})};ut={..._.edit===!0?{}:_.edit,commit:ue}}else x(`source.pushdown.readonly.${se}`,`edit is enabled but the ${se} adapter declares mutate: ${ee.mutate?"without update":"false"} (read-only by declaration), so no commit is synthesised and the grid stays read-only. Declare \`mutate: { update: true }\` on the adapter to allow cell edits.`);const de=gt&&ee.mutate&&(ee.mutate.append||ee.mutate.delete)?{append:ee.mutate.append===!0,remove:ee.mutate.delete===!0,returning:ee.mutate.returning,mutate:(ue,ve)=>J.mutate(ue,ve||{})}:null,Pe=async ue=>{const ve=fe();ve&&await ve;const{range:Ce,signal:Ee,export:Fe,...Be}=ue||{},Ve={...Be,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:V(Ve,ee,pe.enabled),signal:Ee}};async function*le(ue,ve={}){const{plan:Ce,signal:Ee}=await Pe(ue),Fe=Math.max(1,Math.floor(Number(ve.pageSize))||5e3),Be={signal:Ee,stream:!0};if(!Ce.needsAll)for(let $e=0;;$e+=Fe){n(Be);const ze=await J.execute({...Ce.pushed,range:{start:$e,end:$e+Fe}},Be);ze&&H(ze.pendingTotal)&&ze.pendingTotal.then(null,()=>{});const Qe=ze&&ze.rows||[];if(Qe.length&&(yield Qe),Qe.length<Fe)return}n(Be);const Ve=await Y(await J.execute({...Ce.pushed,range:void 0},Be)),Je=S(Ve&&Ve.rows||[],{...Ce.residual,whole:!0},_.compute||{});for(let $e=0;$e<Je.length;$e+=Fe)yield Je.slice($e,$e+Fe)}return Ct={..._,edit:ut,rowMutate:de,mode:"remote",fetch:ot,foregroundIdle:St,aggregate:at,countMatching:async ue=>{const{plan:ve,signal:Ce}=await Pe(ue);if(!ve.needsAll&&ee.total){n({signal:Ce});const Fe=await Y(await J.execute({...ve.pushed,range:{start:0,end:0}},{signal:Ce}));if(Fe&&typeof Fe.total=="number")return Fe.total}let Ee=0;for await(const Fe of le(ue))Ee+=Fe.length;return Ee},streamMatching:le,capabilitiesOf:w,planQuery:V,wireFilters:b,resolveAggregatePlan:ue=>f(ue,Le),STAT_PUSHDOWN:r,lastPlan:()=>ge?{...ge,...ke?{aggregates:ke}:{},...me?{total:{deferred:!0,state:me.state,value:me.value}}:{}}:null,fullFrame:Ye,counts:()=>({match:Se,total:xe??null,pending:!!me&&me.state==="pending"}),grandTotals:()=>Ae},Ct}}),Ie("packages/core/src/source/remote.js",function(e,U){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return R}});const N=U("packages/core/src/internal/lru.js").Lru,B=U("packages/core/src/internal/predicates.js").isFunction,q=U("packages/core/src/internal/warn.js").warnOnce,x=U("packages/core/src/internal/schedule.js").settleDebounce,G=U("packages/core/src/source/abort.js"),z=G.createAbortScope,j=G.isAbortError,O=U("packages/core/src/source/blockcache.js"),b=O.BlockCache,u=O.DEFAULT_PAGE_SIZE,f=O.DEFAULT_MAX_CACHED_PAGES,a=U("packages/core/src/source/rows.js"),r=a.createRowFactory,t=a.groupKey,s=U("packages/core/src/source/filterwire.js"),i=s.wireFilters,n=s.querySignature,c=s.warnHostFilterNotApplied,l=U("packages/core/src/source/pagewindow.js").pageWindow,w=U("packages/core/src/source/memory.js").MemorySource,k=U("packages/core/src/compute/handle.js").valueComparator,d=U("packages/core/src/compute/pivot.js"),p=d.pivotKey,m=d.joinPath,v=d.DEFAULT_PATH_SEPARATOR,E=U("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,M=1,F=120,V=1e3;function I(L,T,A){for(let C=0;C<Math.max(L.length,T.length);C++){const H=L[C],Y=T[C],Z=H==null,_=Y==null;if(Z||_){if(Z&&_)continue;return Z?1:-1}const J=A(H,Y);if(J!==0)return J}return 0}function $(L,T){return new R(L,T)}class S{constructor(T,A,C,H){this.path=T,this.keyPath=H||T,this.values=[],this.level=A,this.key=t(this.keyPath),this.cache=new b(C),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 R{mode="remote";#e;#t;#n;#r;#i=new Map;#s=new Set;#o=z();#l;#a;#c=new Map;#u=[];#f=null;#d="";#h;#p=!1;#m=!1;#g=[];#b=!1;#y=0;#A="";#w=null;#O=-1;constructor(T,A){this.#e=T||{mode:"remote"},this.#t=A||{},B(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#G(),this.unfilteredIndices=()=>this.#V(),this.handleFor=_=>this.#F(_),this.display=()=>this.#x(),this.grandTotalRow=()=>this.#D(),this.unfilteredRows=()=>this.#B(),this.facetIndices=_=>this.#Y(_));const C=this.#e.counts;B(C)&&(this.matchCount=()=>this.#K("match"),this.totalCount=()=>this.#K("total"));const H=this.#e.grandTotals;B(H)&&(this.grandTotalRow=()=>this.#H());const Y=this.#e.foregroundIdle;B(Y)&&(this.foregroundIdle=()=>this.#be(Y),this.#e.pageForegroundIdle=()=>this.#b?this.#be(Y):null);const Z=this.#e;B(Z.countMatching)&&B(Z.streamMatching)&&(this.selectionQuery=()=>this.#fe(),this.countMatching=_=>Z.countMatching(_),this.streamMatching=(_,J)=>Z.streamMatching(_,J),this.loadedRows=()=>this.#pe(),this.resident=()=>this.#R()!==null),this.#n={pageSize:this.#e.pageSize||u,maxCachedPages:this.#e.maxCachedPages||f},this.#l=r(this.#t),this.#a=new N(this.#n.pageSize*4),this.#h=x((_,J)=>this.#P(_,J),F),this.#r=new S([],0,this.#n),this.#i.set(this.#r.key,this.#r),this.#d=this.#Oe(),B(this.#e.fetch)||q("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#$e()}count(){const T=this.#S();return T?T.length:this.#v()}#v(){const T=this.#R();return T?T.count():(this.#X(),this.#re(this.#r))}#T(){if(this.#R())return!0;const T=A=>{if(A.count===null&&!A.complete)return!1;for(const C of A.children.values())if(this.#we(C.key)&&!T(C))return!1;return!0};return T(this.#r)}pageInfo(){const T=this.#S(),A=this.totalPending();if(!T){const C=this.#v();return{page:0,pageSize:0,total:this.#T()?C:null,pageCount:1,counting:A}}return{page:T.page,pageSize:T.pageSize,total:T.total,pageCount:T.pageCount,counting:A||T.total===null&&this.#o.size>0&&this.#r.cache.loadedExtent()===0}}#S(){const T=this.#v(),A=l(this.#C("pageSize",0),this.#C("page",0),T,this.#T());if(!A)return this.#A="",null;const C=`${this.#y}:${A.offset}:${A.length}`;return C!==this.#A&&!this.#p&&(this.#A=C,A.length>0&&!this.#R()&&this.#P(A.offset,A.offset+A.length-1)),A}at(T){const A=this.#S();if(A){if(T<0||T>=A.length)return;const C=this.#E(A.offset+T);return C&&(C.index=T),C}return this.#E(T)}#E(T){const A=this.#R();if(A)return A.at(T);if(this.#X(),T<0||T>=this.#v())return;const C=this.#_(this.#r,T);if(!C)return;const H=this.#Z(C.node,C.local);return H&&(H.index=T),H||this.#l.skeleton(T,C.node.level,C.node.cache.erroredAt(C.local))}byKey(T){const A=this.#R();if(A)return A.byKey(T);const C=this.#c.get(T);if(!C)return;const H=C.lastIndexOf(":"),Y=this.#i.get(C.slice(0,H));return Y&&this.#Z(Y,Number(C.slice(H+1)))||void 0}loaded(T){const A=this.#S();if(A){if(T<0||T>=A.length)return!1;T+=A.offset}const C=this.#R();if(C)return C.loaded(T);if(T<0||T>=this.#v())return!1;const H=this.#_(this.#r,T);return!!H&&H.node.cache.rowLoaded(H.local)}hint(T,A){if(this.#p)return;this.#b=!0;const C=this.#X();let H=Math.max(0,Math.floor(T)),Y=Math.max(H,Math.floor(A));const Z=this.#S();if(Z){if(Z.length===0)return;H=Z.offset,Y=Z.offset+Z.length-1}for(const[_,J]of this.#N(H,Y)){_.cache.protect(J.min,J.max);for(const ee of _.cache.evict())this.#Te(_,ee)}this.#h(H,Y),C&&this.#h.flush()}#N(T,A){const C=this.#v(),H=new Map;for(let Y=T;Y<=A&&Y<C;Y++){const Z=this.#_(this.#r,Y);if(!Z)continue;const _=H.get(Z.node);_?(_.min=Math.min(_.min,Z.local),_.max=Math.max(_.max,Z.local)):H.set(Z.node,{min:Z.local,max:Z.local})}return H.size||H.set(this.#r,{min:T,max:T}),H}#P(T,A){if(!this.#p)for(const[C,H]of this.#N(T,A)){C.cache.protect(H.min,H.max);const Y=C.cache.blockOf(H.min),Z=C.cache.blockOf(H.max);for(let _=Y;_<=Z&&!(C.count!==null&&_*C.cache.pageSize>=C.count);_++)C.cache.has(_)||this.#Be(C,_)}}apply(T){const A={added:[],updated:[],removed:[]};if(!T)return A;if(T.update)for(const C of T.update){const H=this.#c.get(this.#l.keyOf(C,-1));if(!H)continue;this.#a.delete(H);const Y=H.lastIndexOf(":"),Z=this.#i.get(H.slice(0,Y));if(!Z)continue;const _=Number(H.slice(Y+1)),J=Z.cache.blockOf(_);if(!Z.cache.loaded(J))continue;const{start:ee}=Z.cache.rangeOf(J),ne=[];for(let oe=ee;oe<ee+Z.cache.pageSize;oe++){const fe=Z.cache.rowAt(oe);if(fe===void 0)break;ne.push(oe===_?C:fe)}Z.cache.fill(J,ne);const se=this.#Z(Z,_);se&&A.updated.push(se)}return(T.add&&T.add.length||T.remove&&T.remove.length)&&this.reload({keepExpanded:!0}),A}reload(T){this.#o.abortAll("reload"),this.#h.cancel(),T&&T.keepExpanded===!1&&this.#s.clear(),this.#oe(),this.#W("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#o.abortAll("destroyed"),this.#oe(),this.#i.clear(),this.#s.clear(),this.#w&&B(this.#w.destroy)&&this.#w.destroy(),this.#w=null}expand(T){this.#s.has(T)||(this.#s.add(T),this.#W("group:toggled",{key:T,expanded:!0}),this.#W("model:changed",{reason:"expand",key:T}))}collapse(T){this.#s.delete(T)&&(this.#W("group:toggled",{key:T,expanded:!1}),this.#W("model:changed",{reason:"collapse",key:T}))}expandedKeys(){return[...this.#s]}pivotFields(){return this.#u}pivot(){this.#X();const T=this.#f;if(!T||!T.keys.size||!this.#C("pivotBy",[]).length)return null;if(!T.result){const A=k((this.#t.config||{}).locale),C=[...T.keys.entries()].sort((Y,Z)=>I(Y[1],Z[1],A)),H=C.map(([Y])=>Y);T.result={keys:C.map(([,Y])=>Y),paths:H,fields:this.#ne(H),groupPaths:[],columns:H.length*Math.max(1,this.#Ee().length),values:T.cells,cells:T.cells,error:null}}return T.result}invalidateHandles(){this.#w&&(B(this.#w.invalidateHandles)&&this.#w.invalidateHandles(),B(this.#w.invalidate)&&this.#w.invalidate("filter"))}#M(){const T=this.#e.fullFrame;return B(T)?T():null}#R(){const T=this.#M();return T?(this.#w||(this.#w=new w({mode:"memory"},this.#$())),T.version!==this.#O&&(this.#w.setRows(T.rows),this.#O=T.version),this.#w):null}#$(){const T=this.#t,A=T.state||{};return{...T,state:{...A,page:()=>0,pageSize:()=>0}}}#G(){const T=this.#R();return T?T.filteredIndices():new Uint32Array(0)}#V(){const T=this.#R();return T?T.unfilteredIndices():new Uint32Array(0)}#F(T){const A=this.#R();return A?A.handleFor(T):void 0}#x(){const T=this.#R();return T?T.display():[]}#Y(T){const A=this.#R();return A&&B(A.facetIndices)?A.facetIndices(T):new Uint32Array(0)}#D(){const T=this.#R();return T&&B(T.grandTotalRow)?T.grandTotalRow():null}#K(T){const A=this.#R();if(A){const Z=T==="match"?A.matchCount:A.totalCount;if(B(Z))return Z.call(A)}const C=this.#e.counts,H=B(C)?C():null,Y=H?H[T]:null;return typeof Y=="number"?Y:this.#v()}#H(){const T=this.#R();if(T&&B(T.grandTotalRow))return T.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const C=this.#e.grandTotals,H=B(C)?C():null;return!H||!H.totals?null:this.#l.grandTotal(H.totals,H.leafCount||0)}#B(){const T=this.#R();if(T&&B(T.unfilteredRows))return T.unfilteredRows();const A=[],C=this.count();for(let H=0;H<C;H++){const Y=this.at(H);Y&&A.push(Y)}return A}#fe(){const T=this.#C("quick",""),A={protocol:M,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:i(this.#C("filters",null),this.#U()),sort:this.#C("sort",[]),context:this.#C("context",null)};T&&(A.quick=T);const C=this.#C("where",null);return C&&C.active&&(A.where=C),A}#pe(){const T=this.#C("groupBy",[]).length,A=[];for(const C of this.#i.values())if(!(C.level!==T&&!C.flat))for(const H of C.cache.ids()){if(!C.cache.loaded(H))continue;const{start:Y,end:Z}=C.cache.rangeOf(H);for(let _=Y;_<Z&&C.cache.rowLoaded(_);_++){const J=this.#Z(C,_);J&&!J.group&&A.push(J)}}return A}loadedCount(){const T=this.#R();if(T){const H=T.matchCount();return typeof H=="number"?H:T.count()}this.#X();const A=this.#C("groupBy",[]).length;let C=0;for(const H of this.#i.values())if(!(H.level!==A&&!H.flat))for(const Y of H.cache.ids()){if(!H.cache.loaded(Y))continue;const Z=H.cache.fillOf(Y);typeof Z=="number"&&(C+=Z)}return C}residentRows(){const T=this.#R();return T?T.display():this.#C("groupBy",[]).length>0?null:(this.#X(),this.#pe())}#se(T,A,C){const{start:H,end:Y}=T.cache.rangeOf(A),Z=this.#C("groupBy",[]),_=this.#C("pivotBy",[]),J=this.#C("quick",""),ee=this.#Ee(),ne={protocol:M,range:{start:H,end:Y},groupPath:T.path,groupValues:T.values,groupBy:Z,totals:ee,totalFns:this.#ae(ee),pivotBy:_,pivotMode:_.length>0,filters:i(this.#C("filters",null),this.#U()),sort:this.#C("sort",[]),context:this.#C("context",null),signal:C};J&&(ne.quick=J);const se=this.#C("where",null);return se&&se.active&&(ne.where=se),ne}async#Be(T,A){if(!B(this.#e.fetch))return;if(!this.#m){this.#m=!0;const Z=this.#g;this.#g=[],queueMicrotask(()=>{for(const _ of Z)_()})}const C=this.#o.begin(`${T.key}:${A}`);T.cache.begin(A,C);const H=this.#d,{start:Y}=T.cache.rangeOf(A);try{const Z=await this.#e.fetch(this.#se(T,A,C.signal));if(!C.current||H!==this.#d||this.#p)return;C.settle();const _=Z&&Z.rows||[];if(!!(Z&&Z[E])&&!T.flat){T.flat=!0,T.children.clear();for(const[se,oe]of[...this.#c])oe.startsWith(`${T.key}:`)&&(this.#a.delete(oe),this.#c.delete(se))}T.cache.fill(A,_),T.failed=!1;for(let se=0;se<_.length;se++)this.#a.delete(`${T.key}:${Y+se}`);const ee=Z&&typeof Z.count=="number"?Z.count:Z&&typeof Z.total=="number"?Z.total:null,ne=Z&&B(Z.pendingTotal?.then)?Z.pendingTotal:null;ee!==null?(T.count=ee,T.complete=!0):_.length<T.cache.pageSize?(T.count=Y+_.length,T.complete=!0):ne&&(T.counting=!0,T.announced=null),Z&&Array.isArray(Z.pivotFields)&&this.#je(Z.pivotFields),Z&&Z.pivot&&typeof Z.pivot=="object"&&this.#Ce(Z.pivot),this.#W("model:changed",{reason:"page",groupPath:T.path,block:A}),this.#W("rows:changed",{companion:!0,reason:"page",groupPath:T.path,block:A}),this.#ge(T),ne&&this.#Se(T,ne,H)}catch(Z){if(C.settle(),j(Z))return;T.cache.failed(A,Z),T.failed=!0;const{end:_}=T.cache.rangeOf(A);for(let J=Y;J<_;J++)this.#a.delete(`${T.key}:${J}`);this.#W("model:changed",{reason:"page-error",groupPath:T.path,block:A}),this.#W("source:error",{error:Z,groupPath:T.path,block:A})}}async#Se(T,A,C){let H;try{H=await A}catch(Y){if(C!==this.#d||this.#p)return;T.counting=!1,j(Y)||(T.failed=!0),j(Y)||this.#W("source:error",{error:Y,groupPath:T.path});return}C!==this.#d||this.#p||(T.counting=!1,typeof H=="number"&&(T.count=H,T.complete=!0,this.#ge(T),this.#W("model:changed",{reason:"total",count:H,groupPath:T.path})))}#ge(T){typeof T.count!="number"||!T.complete||T.announced!==T.count&&(T.announced=T.count,this.#W("source:total",{total:T.count,groupPath:T.path}))}#be(T){if(this.#p)return null;this.#X();const A=this.#m?null:new Promise(_=>{this.#g.push(_),setTimeout(_,V)}),C=T();if(!A&&!C)return null;const H=(async()=>{A&&await A;for(let _=T();_;_=T())await _})();let Y;const Z=new Promise(_=>{Y=setTimeout(_,V)});return Promise.race([H,Z]).then(()=>clearTimeout(Y))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#R())return!1;this.#X();const T=this.#r;return T.count===null&&!T.complete&&T.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#je(T){T.length===this.#u.length&&T.every((A,C)=>A===this.#u[C])||(this.#u=T,this.#W("column:pivoted",{pivotFields:T,remote:!0}))}#Pe(){const T=this.#t.config||{};return T.pivot&&T.pivot.separator||v}#ne(T){const A=this.#Pe(),C=this.#Ee();if(!C.length)return T.slice();const H=[];for(const Y of T)for(const Z of C)H.push(`${Y}${A}${Z}`);return H}#Ce(T){const A=this.#Pe();this.#f||(this.#f={keys:new Map,cells:new Map,result:null});const C=this.#f;let H=!1;const Y=_=>{const J=Array.isArray(_)?_:[_],ee=m(J,A);return C.keys.has(ee)||(C.keys.set(ee,J),H=!0),ee},Z=this.#C("groupBy",[]).length>0;for(const _ of Array.isArray(T.axis)?T.axis:[])Y(_);for(const _ of Array.isArray(T.cells)?T.cells:[]){if(!_||typeof _!="object")continue;const J=Y(_.pivot);if(Z&&!(Array.isArray(_.group)&&_.group.length))continue;const ee=m(Array.isArray(_.group)?_.group:[],A);for(const[ne,se]of Object.entries(_.values||{}))C.cells.set(p(ee,J,ne),se)}C.result=null,H&&this.#je((this.pivot()||{fields:[]}).fields)}#re(T){let A=this.#J(T);for(const C of T.children.values())this.#we(C.key)&&(A+=this.#re(C));return A}#J(T){if(T.count!==null)return T.count;const A=T.cache.loadedExtent();return T.complete?A:T.row&&T.row.leafCount>0?T.level>=this.#C("groupBy",[]).length?Math.max(A,T.row.leafCount):A===0?1:Math.min(A+T.cache.pageSize,Math.max(A,T.row.leafCount)):A+T.cache.pageSize}#_(T,A){let C=A,H=0;const Y=[...T.children.entries()].filter(([,_])=>this.#we(_.key)).sort((_,J)=>_[0]-J[0]);for(const[_,J]of Y){const ee=_-H+1;if(C<ee)return{node:T,local:H+C};C-=ee,H=_+1;const ne=this.#re(J);if(C<ne)return this.#_(J,C);C-=ne}const Z=this.#J(T);return H+C<Z?{node:T,local:H+C}:null}#Z(T,A){const C=`${T.key}:${A}`,H=this.#a.get(C);if(H)return H;const Y=T.cache.rowAt(A);if(Y===void 0)return null;const Z=this.#C("groupBy",[]);let _;if(T.level<Z.length&&!T.flat){const J=Z[T.level],ee=this.#f!==null&&T.level===Z.length-1&&this.#C("pivotBy",[]).length>0,ne=this.#ce(Y,J),se=ne==null,oe=[...T.path,se?"":String(ne)],fe=[...T.keyPath,se?null:String(ne)];if(_=this.#l.group({path:oe,keyPath:fe,column:J,value:ne,level:T.level,parent:T.row,leafCount:Number(Y.leafCount)||0,expanded:ee?!1:this.#we(t(fe)),...ee?{hasChildren:!1}:{}}),_.totals=this.#I(Y),_.data=Y,!ee){let pe=this.#i.get(_.key);pe?pe.row=_:(pe=new S(oe,T.level+1,this.#n,fe),pe.row=_,this.#i.set(pe.key,pe)),pe.values=[...T.values,ne],T.children.set(A,pe)}}else _=this.#l.leaf(Y,A,T.level,T.row);return this.#a.set(C,_),this.#c.set(_.key,C),_}#I(T){const A=T||{};if(A.totals&&typeof A.totals=="object")return A.totals;const C={};for(const H of this.#Ee())Object.hasOwn(A,H)&&(C[H]=A[H]);return C}#Te(T,A){const{start:C,end:H}=T.cache.rangeOf(A);for(let Y=C;Y<H;Y++){const Z=`${T.key}:${Y}`,_=this.#a.peek(Z);_&&this.#c.delete(_.key),this.#a.delete(Z)}}#X(){const T=this.#Oe();return T===this.#d?!1:(this.#d=T,this.#o.abortAll("query"),this.#oe(),this.#m=!1,this.#W("model:changed",{reason:"query"}),!0)}#oe(){for(const T of this.#i.values())T.cache.clear(),T.count=null,T.complete=!1,T.announced=null,T.counting=!1,T.failed=!1,T.children.clear(),T.flat=!1;this.#a.clear(),this.#c.clear(),this.#y++,this.#f=null}#Oe(){const T=this.#C("where",null);return`${n({filters:this.#C("filters",null),sort:this.#C("sort",[]),quick:this.#C("quick",""),groupBy:this.#C("groupBy",[]),pivotBy:this.#C("pivotBy",[]),context:this.#C("context",null)})}|${T?T.version:0}`}#we(T){const A=this.#C("expanded",null);return A?B(A.has)?A.has(T):Array.prototype.includes.call(A,T):this.#s.has(T)}#Ee(){const T=this.#C("totals",[]);if(T&&T.length)return[...T];const A=this.#t.columns;return!A||!B(A.all)?[]:A.all().filter(C=>!!C.total).map(C=>C.id)}#ae(T){const A=this.#t.columns,C={};if(!A||!B(A.get))return C;for(const H of T){const Y=A.get(H);if(!Y)continue;const Z=Y.groupTotal!=null?Y.groupTotal:Y.total;typeof Z=="string"&&(C[H]=Z)}return C}#ce(T,A){const C=this.#t.columns,H=C&&B(C.get)?C.get(A):void 0;return H&&B(H.getValue)?H.getValue(T):T?.[A]}#$e(){c(this.#t)}#U(){const T=this.#t.config||{};return{tz:T.timeZone,weekStartsOn:T.weekStartsOn}}#C(T,A){const C=this.#t.state;if(C&&B(C[T])){const H=C[T]();return H??A}return A}#W(T,A){const C=this.#t.emit;B(C)&&C(T,A)}}}),Ie("packages/core/src/source/gapbuffer.js",function(e,U){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return N}});const te=64;class N{#e;#t=0;#n=0;constructor(B=te){this.#e=new Uint32Array(Math.max(1,B)),this.#n=this.#e.length}static from(B,D=te){const q=new N(B.length+Math.max(1,D));return q.#e.set(B,0),q.#t=B.length,q.#n=q.#e.length,q}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(B){return B<0||B>=this.length?0:B<this.#t?this.#e[B]:this.#e[B+(this.#n-this.#t)]}insert(B,D){const q=B<0?0:B>this.length?this.length:B;this.#r(q),this.#t===this.#n&&this.#i(),this.#e[this.#t++]=D}push(B){this.insert(this.length,B)}removeAt(B){return!Number.isInteger(B)||B<0||B>=this.length?!1:(this.#r(B),this.#n++,!0)}toArray(){const B=new Uint32Array(this.length);return B.set(this.#e.subarray(0,this.#t),0),B.set(this.#e.subarray(this.#n),this.#t),B}clear(){this.#t=0,this.#n=this.#e.length}#r(B){if(B!==this.#t)if(B<this.#t){const D=this.#t-B;this.#e.copyWithin(this.#n-D,B,this.#t),this.#t=B,this.#n-=D}else{const D=B-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+D),this.#t=B,this.#n+=D}}#i(){const B=this.#e.length-this.#n,D=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+te));D.set(this.#e.subarray(0,this.#t),0),D.set(this.#e.subarray(this.#n),D.length-B),this.#e=D,this.#n=D.length-B}}}),Ie("packages/core/src/store/ingest.js",function(e,U){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return i}});const te=U("packages/core/src/internal/schedule.js"),N=te.now,X=te.nextFrame,B=U("packages/core/src/internal/warn.js"),D=B.infoOnce,q=B.warnOnce,x=U("packages/core/src/internal/predicates.js").isFunction,z=U("packages/core/src/internal/paths.js").pathGetter,O=U("packages/core/src/store/columnstore.js").ColumnStore,b=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function u(n,c={}){if(c.multi)return"multi";if(n.length===0)return"object";let o=0,l=0,h=0,w=0,g=0;for(let d=0;d<n.length;d++){const p=n[d];typeof p=="number"?o++:typeof p=="boolean"?l++:typeof p=="string"?h++:p instanceof Date?w++:Array.isArray(p)&&g++}const k=n.length;return o===k?"float64":l===k?"bitset":w===k?"float64":h===k?"text":g===k?"multi":"object"}function f(n,c,o){return c<=0||n<o*c?"dictionary":"object"}function a(n,c,o){const l=new Map,h=new Map;for(const M of n){if(M.computed)continue;const F=x(M.read)?M.read:z(M.field||M.id);h.set(M.id,F),l.set(M.id,F)}const w=c?.order??[],g=c?.fns??{},k=c?.deps??{},d=c?.wrapDeps??null,p=w.filter(M=>x(g[M])),m=p.some(M=>k[M]==="*");let v=new WeakMap;const y=M=>{const F={};if(m)for(const[V,I]of h)F[V]=I(M);for(const V of p){const I=k[V];let $;if(I==="*")$=F;else{$={};const S=I||[];for(let R=0;R<S.length;R++){const L=S[R];$[L]=L in F?F[L]:h.get(L)?.(M)}}F[V]=g[V](d?d($,V):$,{data:M,row:null,column:null,grid:null,context:o})}return F},E=M=>{if(M===null||typeof M!="object"&&typeof M!="function")return y(M);let F=v.get(M);return F===void 0&&(F=y(M),v.set(M,F)),F};for(const M of p)l.set(M,F=>E(F)[M]);return{readers:l,reset(){v=new WeakMap}}}class r{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(c,o){this.spec=c,this.read=o,this.kind="object",this.inferred=!1,this.nullable=c.nullable!==!1}}class t{#e;#t=[];#n=null;#r;#i=0;#s;#o=!1;#l=!1;#a=0;#c;constructor(c,o={},l={}){this.#e=Array.isArray(c)?c:Array.from(c||[]),this.#s={...b,...l};const h=o.columns??[];this.#r=a(h,o.computed??null,o.context),this.#c=this.#e.length>=this.#s.columnarBelow,this.#u(h,o.computed??null),this.#n=new O(this.#t.map(w=>({id:w.spec.id,kind:w.kind,nullable:w.nullable,read:w.read,dictionary:w.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#o||this.#l}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#l=!0,!1;const c=N(),{chunkMs:o,chunkRows:l}=this.#s,h=this.#e.length;do{const w=Math.min(this.#i+l,h);this.#n.append(this.#e.slice(this.#i,w)),this.#f(this.#i,w),this.#i=w,this.#r.reset(),this.#h(!1)}while(this.#i<h&&N()-c<o);return this.#a+=N()-c,this.#s.onProgress?.({loaded:this.#i,total:h}),this.#i>=h?(this.#h(!0),this.#o=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(c=>({id:c.spec.id,kind:c.kind,nullable:c.nullable,read:c.read,dictionary:c.spec.dictionary})),decisions:this.#t.map(c=>({id:c.spec.id,kind:c.kind,nullable:c.nullable,inferred:c.inferred,distinct:c.candidate||c.change?this.#d(c):null,change:c.change,reason:c.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#u(c,o){const l=this.#e,h=Math.min(this.#s.sampleSize,l.length),w=this.#s.dictionaryRatio,g=o?.pure instanceof Set?o.pure:new Set(o?.pure??o?.order??[]);for(const k of c){if(!k||!k.id)continue;if(k.computed&&(k.pure===!1||o&&!g.has(k.id))){q(`ingest.impure.${k.id}`,`column "${k.id}" is an impure computed column and is not materialised into the store`);continue}const d=this.#r.readers.get(k.id)??(x(k.read)?k.read:z(k.field||k.id)),p=new r(k,d);if(k.kind)p.kind=k.kind,p.reason="declared by the caller";else if(k.dictionary)p.kind=k.multi?"multi":"dictionary",p.reason="value table supplied (lookup column)";else{const m=[];for(let y=0;y<h&&m.length<this.#s.sampleSize;y++){const E=d(l[y]);E!=null&&m.push(E)}p.inferred=!0;const v=u(m,{multi:k.multi});if(v==="text"){const y=new Set(m).size;p.kind=f(y,m.length,w),p.candidate=this.#c,p.reason=`sampled ${y} distinct in ${m.length}`}else p.kind=v,p.reason=`inferred from ${m.length} sampled values`,v==="object"&&m.length&&D(`ingest.mixed.${k.id}`,`column "${k.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);p.kind==="object"&&p.candidate&&(p.distinct=new Set(m))}this.#t.push(p)}}#f(c,o){const l=this.#e;for(const h of this.#t){if(!h.candidate||!h.distinct)continue;const w=h.distinct;for(let g=c;g<o;g++){const k=h.read(l[g]);k!=null&&w.add(k)}}}#d(c){if(c.distinct)return c.distinct.size;const o=this.#n.column(c.spec.id);return o?.dict?o.dict.size:0}#h(c){const o=this.#s.dictionaryRatio,l=this.#e.length;for(const h of this.#t){if(!h.candidate)continue;const w=this.#d(h);if(h.kind==="dictionary"&&w>=o*l){const g=this.#n.column(h.spec.id);h.distinct=new Set(g?.dict?g.dict.values():[]),this.#n.convert(h.spec.id,"object"),h.kind="object",h.change="demoted",h.reason=`${w} distinct values is at or above ${o*100}% of ${l} rows`;continue}if(h.kind==="object"&&w>=o*l){h.candidate=!1,h.distinct=null,h.reason=`${w} distinct values is at or above ${o*100}% of ${l} rows`;continue}c&&h.kind==="object"&&w<o*l&&(this.#n.convert(h.spec.id,"dictionary"),h.kind="dictionary",h.change=h.change==="demoted"?null:"promoted",h.reason=`${w} distinct values is below ${o*100}% of ${l} rows`,h.distinct=null),c&&(h.candidate=!1)}}}async function s(n,c={},o={}){const l=new t(n,c,o),h=o.scheduler?.frame??X;for(;l.slice();)await new Promise(w=>{h(w)});return l.result()}function i(n,c={},o={}){const l=new t(n,c,{...o,chunkMs:1/0});for(;l.slice(););return l.result()}}),Ie("packages/core/src/store/columnpack.js",function(e,U){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return f}});const N=U("packages/core/src/internal/paths.js").pathGetter,X=U("packages/core/src/store/ingest.js"),B=X.inferKind,D=X.decideText,q=X.INGEST_DEFAULTS,x=U("packages/core/src/store/columnstore.js").toFloat,G=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&&!G.has(r.kind))return!1;return!0}function j(a){const r=x(a);return Number.isFinite(r)?r|0:0}function O(a){return a==null?[]:Array.isArray(a)?a:[a]}function b(a,r,t,s){if(a.kind)return a.kind;const i=[];for(let o=0;o<r.length&&i.length<q.sampleSize;o++){const l=r[o];l!=null&&i.push(l)}const n=B(i,{multi:a.multi});if(n!=="text")return n;const c=new Set(i).size;return D(c,i.length,s)}function u(a,r,t={}){const s=r.length|0,i=t.dictionaryRatio??q.dictionaryRatio,n=[];for(const c of a){const o=N(c.field||c.id),l=c.nullable!==!1,h=new Array(s);for(let p=0;p<s;p++){const m=o(r[p]);h[p]=m===void 0?null:m}const w=b(c,h,s,i),g=l?new Uint8Array(s+7>>3):null,k=p=>{g&&(g[p>>3]|=1<<(p&7))};let d;switch(w){case"float64":{const p=new Float64Array(s);for(let m=0;m<s;m++){const v=h[m],y=v===null;y||k(m),p[m]=y?NaN:x(v)}d={id:c.id,kind:w,nullable:l,values:p,presence:g,offsets:null,table:null};break}case"int32":{const p=new Int32Array(s);for(let m=0;m<s;m++){const v=h[m],y=v===null;y||k(m),p[m]=y?0:j(v)}d={id:c.id,kind:w,nullable:l,values:p,presence:g,offsets:null,table:null};break}case"bitset":{const p=new Uint8Array(s+7>>3);for(let m=0;m<s;m++){const v=h[m],y=v===null;y||k(m),!y&&v&&(p[m>>3]|=1<<(m&7))}d={id:c.id,kind:w,nullable:l,values:p,presence:g,offsets:null,table:null};break}case"dictionary":{const p=new Uint32Array(s),m=[],v=new Map;for(let y=0;y<s;y++){const E=h[y];if(E===null){p[y]=0;continue}k(y);let M=v.get(E);M===void 0&&(M=m.length,m.push(E),v.set(E,M)),p[y]=M}d={id:c.id,kind:w,nullable:l,values:p,presence:g,offsets:null,table:m};break}case"multi":{const p=[],m=new Map,v=new Uint32Array(s+1),y=[];for(let E=0;E<s;E++){const M=h[E];v[E]=y.length,M===null||k(E);const V=O(M);for(let I=0;I<V.length;I++){const $=V[I];let S=m.get($);S===void 0&&(S=p.length,p.push($),m.set($,S)),y.push(S)}}v[s]=y.length,d={id:c.id,kind:w,nullable:l,values:Int32Array.from(y),presence:g,offsets:v,table:p};break}default:{const p=new Array(s);for(let m=0;m<s;m++){const v=h[m];v!==null&&k(m),p[m]=v}d={id:c.id,kind:"object",nullable:l,values:p,presence:g,offsets:null,table:null};break}}n.push(d)}return{count:s,columns:n}}function f(a){const r=[];if(!a||!Array.isArray(a.columns))return r;const t=s=>{ArrayBuffer.isView(s)&&s.buffer&&!r.includes(s.buffer)&&r.push(s.buffer)};for(const s of a.columns)t(s.values),t(s.presence),t(s.offsets);return r}}),Ie("packages/core/src/source/stream.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return S}});const N=U("packages/core/src/internal/lru.js").Lru,B=U("packages/core/src/internal/predicates.js").isFunction,D=U("packages/core/src/internal/schedule.js"),q=D.now,K=D.nextFrame,x=D.cancelFrame,G=D.whenIdle,j=U("packages/core/src/internal/compare.js").defaultCompare,O=U("packages/core/src/internal/warn.js"),b=O.warnOnce,u=O.infoOnce,a=U("packages/core/src/internal/paths.js").getPath,r=U("packages/core/src/source/abort.js"),t=r.createAbortScope,s=r.isAbortError,i=U("packages/core/src/source/rows.js"),n=i.createRowFactory,c=i.lazyRowView,l=U("packages/core/src/source/gapbuffer.js").GapBuffer,w=U("packages/core/src/source/memory.js").createMemorySource,k=U("packages/core/src/source/filterwire.js").querySignature,p=U("packages/core/src/store/columnpack.js").isPortableSchema,m=25e4,v=Symbol("lattice.stream.storeBacked"),y=8,E=.1,M=1e3,F=50;function V(R){return Math.min(M,Math.max(F,Math.floor(R/4)))}function I(R){if(R instanceof Date)return R.getTime();if(typeof R=="number")return Number.isFinite(R)?R:NaN;if(typeof R=="string"){const L=R.trim();if(!L)return NaN;const T=Date.parse(L);return Number.isNaN(T)?Number(L):T}return NaN}function $(R,L){return new S(R,L)}class S{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#i=[];#s=null;#o;#l;#a=new Map;#c=t();#u={loaded:0,estimated:void 0};#f=null;#d=0;#h=0;#p=0;#m=0;#g=null;#b=null;#y=null;#A=!1;#w=!1;#O=!1;#v=!1;#T="";#S=0;#E=0;#N=0;#P=null;#M=1/0;#R=!1;#$=null;#G=null;#V=null;#F=null;#x=!1;#Y=0;#D=0;#K=!1;constructor(L,T){this.#e=L||{mode:"stream"},this.#t=T||{},this.#o=n(this.#t),this.#l=new N(4096),this.#T=this.#Xe();const A=(this.#t.config||{}).ingest;this.#x=!!A&&A.retainSource===!1,B(this.#e.open)||b("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const C=Number(this.#e.poll);Number.isFinite(C)&&C>0&&(this.#F=setInterval(()=>{this.#v||this.reload()},C),this.#F&&B(this.#F.unref)&&this.#F.unref()),this.#B()}#H(){const L=Number(this.#e.maxAge);return Number.isFinite(L)&&L>0?L:0}#B(){const L=this.#H();if(!L)return;const T=this.#e.ageBy;B(T)?this.#G=T:typeof T=="string"&&T?this.#G=A=>a(A,T):this.#G=null,this.#P=[],this.#$=setInterval(()=>{this.#v||this.#fe()&&(this.#X(),this.#me())},V(L)),this.#$&&B(this.#$.unref)&&this.#$.unref()}#fe(){const L=this.#H();return!L||!this.#P?!1:this.#R?!0:this.#M<Date.now()-L*(1+E)}#pe(L,T){if(!this.#P)return;const A=this.#G?I(this.#G(T)):Date.now();this.#P[L]=A,Number.isNaN(A)||(A<this.#M&&(this.#M=A),A<Date.now()-this.#H()&&(this.#R=!0))}#se(){return this.#ye("groupBy",[]).length>0?!0:!!this.#ye("pivotMode",!1)&&this.#ye("pivotBy",[]).length>0}#Be(){if(this.#g||this.#v)return;const L=this.#se();if(L&&!this.#b){this.#b=w({mode:"memory",rows:this.#n},this.#Se()),this.#A=!1;return}!L&&this.#b&&(this.#b.destroy(),this.#b=null)}#Se(){if(this.#y)return this.#y;const L=this,T={liveIndices:()=>L.#ge(),live:A=>L.#n[A]!==void 0,source:A=>L.#xe(A),get physical(){return L.#n.length}};return this.#x&&(T.column=A=>{const C=L.#t.store;return C&&B(C.column)?C.column(A):void 0}),this.#y=Object.create(this.#t,{store:{value:T,enumerable:!0,configurable:!0}}),this.#y}#ge(){const L=new Uint32Array(this.#n.length);let T=0;for(let A=0;A<this.#n.length;A++)this.#n[A]!==void 0&&(L[T++]=A);return L.subarray(0,T)}#be(){return this.#g?this.#g:this.#b?(this.#A&&(this.#A=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(L="filter"){if(this.#g){this.#g.invalidate(L);return}this.#Be(),this.#b&&this.#b.invalidate(L),(L==="filter"||L==="sort")&&this.#Ee()}count(){const L=this.#be();return L?L.count():this.#r?this.#r.length:this.#S}matchCount(){const L=this.#be();return L&&B(L.matchCount)?L.matchCount():this.#r?this.#r.length:this.#S}totalCount(){const L=this.#be();return L&&B(L.totalCount)?L.totalCount():this.#S}unfilteredRows(){const L=this.#be();if(L&&B(L.unfilteredRows))return L.unfilteredRows();const T=[];for(let A=0;A<this.#n.length;A++){if(!this.#n[A])continue;const C=this.#ve(A);C&&T.push(C)}return T}at(L){const T=this.#be();if(T)return T.at(L);if(L<0||L>=this.count())return;const A=this.#r?this.#r.at(L):L,C=this.#ve(A);return C.index=L,C}byKey(L){const T=this.#be();if(T)return T.byKey(L);const A=this.#a.get(L);return A===void 0?void 0:this.#ve(A)}leavesOf(L){const T=this.#be();return T&&B(T.leavesOf)?T.leavesOf(L):[]}loaded(L){return L>=0&&L<this.count()}hint(L,T){if(this.#g){this.#g.hint(L,T);return}this.#je(),this.#p=Math.max(0,Math.floor(L))}#je(){this.#v||this.#Xe()===this.#T||this.reload()}display(){const L=this.#be();return L?L.display():c(()=>this.count(),T=>this.at(T))}apply(L){if(this.#g)return this.#g.apply(L);const T={added:[],updated:[],removed:[]};if(!L)return T;if(L.update){let A=!1;for(const C of L.update){const H=this.#a.get(this.#o.keyOf(C,-1));if(H===void 0)continue;const Y=this.#$e(H);this.#x?this.#k(H,C):this.#n[H]=C,this.#l.delete(H),this.#U(H,Y),this.#P&&(this.#pe(H,C),A=!0),this.#A=!0,T.updated.push(this.#ve(H))}A&&this.#X()}if(L.add&&L.add.length){const A=this.#I(L.add);for(const C of A)T.added.push(this.#ve(C))}return L.remove&&L.remove.length&&b("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#me(),T}reload(L){this.#c.abortAll("reload"),this.#Ue(),this.#b&&(this.#b.destroy(),this.#b=null),this.#A=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#S=0,this.#E=0,this.#N=0,this.#P&&(this.#P=[]),this.#M=1/0,this.#R=!1,this.#w=!1,this.#O=!1,this.#u={loaded:0,estimated:void 0},this.#T=this.#Xe(),this.#ke("model:changed",{reason:"reload"}),this.start()}destroy(){this.#v=!0,this.#F!==null&&(clearInterval(this.#F),this.#F=null),this.#$!==null&&(clearInterval(this.#$),this.#$=null),this.#P=null,this.#c.abortAll("destroyed"),this.#Ue(),this.#f!==null&&(this.#Le(this.#f),this.#f=null),this.#b&&(this.#b.destroy(),this.#b=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#O||this.#v||!B(this.#e.open))return;this.#O=!0;const L=this.#c.begin("stream");this.#Ee(),this.#Be();let T;try{T=this.#e.open({sort:this.#ye("sort",[]),filters:this.#ye("filters",null),quick:this.#ye("quick","")||void 0,context:this.#ye("context",null),signal:L.signal})}catch(C){this.#ke("source:error",{error:C});return}const A=B(T[Symbol.asyncIterator])?T[Symbol.asyncIterator]():T[Symbol.iterator]();this.#V=A;try{for(;;){const C=await A.next();if(!L.current||this.#v)return;if(C.done){this.#ie();return}if(await this.#Pe(C.value,L),!L.current||this.#v)return;if(C.value&&C.value.done){this.#ie();return}if(await this.#le(),!L.current||this.#v)return}}catch(C){if(s(C))return;this.#ke("source:error",{error:C})}finally{L.settle()}}progress(){return{loaded:this.#u.loaded,estimated:this.#u.estimated,done:this.#w,live:this.#S,evicted:this.#E}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const L=this.#be();L&&(B(L.invalidateHandles)&&L.invalidateHandles(),B(L.invalidate)&&L.invalidate("sort"))}renderCount(){return this.#d}ingestStats(){return{worker:this.#Y,inline:this.#D,storeBacked:this.#x}}#Pe(L,T){if(!L)return;const A=L.rows;if(A&&A.length&&this.#Ce(A))return this.#J(L,T);const C=q();A&&A.length&&(this.#I(A),this.#D++),this.#ne(L),this.#h+=q()-C,this.#me()}#ne(L){this.#u.loaded=L.progress&&typeof L.progress.loaded=="number"?L.progress.loaded:this.#n.length,L.progress&&typeof L.progress.estimated=="number"&&(this.#u.estimated=L.progress.estimated)}#Ce(L){if(this.#K||this.#g)return!1;const T=this.#_();if(!T)return!1;const A=this.#t.store;if(!A||!B(A.appendPacked))return!1;const C=this.#Z();return!C||!p(C)?(this.#K=!0,u("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):L.length<T.threshold?!1:!this.#re(L)}#re(L){if(!this.#o.keyed)return!1;const T=new Set;for(let A=0;A<L.length;A++){const C=this.#o.keyOf(L[A],this.#n.length+A);if(C!=null){if(T.has(C)||this.#a.has(C))return!0;T.add(C)}}return!1}async#J(L,T){const A=L.rows,C=this.#_(),H=this.#Z();let Y;try{Y=await C.columnize(H,A,{key:"ingest:stream",signal:T&&T.signal})}catch(ne){if(s(ne)||(b("source.stream.columnize","worker columnization failed; columnizing on the main thread",ne),this.#K=!0,T&&(!T.current||this.#v)))return;this.#I(A),this.#D++,this.#ne(L),this.#me();return}if(T&&(!T.current||this.#v))return;const Z=this.#t.store,_=this.#x?void 0:A,{from:J}=Z.appendPacked(Y,_),ee=Y.count|0;for(let ne=0;ne<ee;ne++){const se=J+ne,oe=A[ne],fe=this.#o.keyed?this.#o.keyOf(oe,se):null;if(this.#n[se]=this.#x?v:oe,this.#S++,this.#pe(se,oe),fe!==null&&this.#a.set(fe,se),!this.#r||!this.#ae(se))continue;const pe=this.#C(se);this.#r.insert(pe,se),pe<=this.#p&&this.#m++}this.#A=!0,this.#X(),this.#Y++,this.#ne(L),this.#me()}#_(){const L=this.#t.ingestWorker;return B(L)?L():null}#Z(){const L=this.#t.storeSchema;return B(L)?L():null}#I(L){const T=[],A=this.#t.store,C=new Array(L.length),H=[],Y=new Set;for(let _=0;_<L.length;_++){const J=this.#o.keyed?this.#o.keyOf(L[_],this.#n.length+H.length):null;C[_]=J,!(J!==null&&(this.#a.has(J)||Y.has(J)))&&(J!==null&&Y.add(J),H.push(L[_]))}let Z=H.length&&A&&B(A.append)?A.append(H).from:this.#n.length;for(let _=0;_<L.length;_++){const J=L[_],ee=C[_];if(ee!==null&&this.#a.has(ee)){const oe=this.#a.get(ee),fe=this.#$e(oe);this.#x||(this.#n[oe]=J,A&&B(A.setSource)&&A.setSource(oe,J)),this.#k(oe,J),this.#l.delete(oe),this.#pe(oe,J),this.#U(oe,fe);continue}const ne=Z++;if(this.#n[ne]=this.#x?v:J,this.#S++,this.#pe(ne,J),ee!==null&&this.#a.set(ee,ne),T.push(ne),!this.#r||!this.#ae(ne))continue;const se=this.#C(ne);this.#r.insert(se,ne),se<=this.#p&&this.#m++}return this.#A=!0,this.#X(),T}#Te(L){const T=this.#n[L];let A=!1;if(this.#r){const Z=this.#we(L);Z>=0&&Z<=this.#p&&(A=!0)}else L<=this.#p&&(A=!0);const C=T===v?this.#xe(L):T,H=this.#o.keyed?this.#o.keyOf(C,L):null;H!==null&&this.#a.get(H)===L&&this.#a.delete(H),this.#n[L]=void 0,this.#P&&(this.#P[L]=NaN),this.#l.delete(L);const Y=this.#t.store;return Y&&B(Y.remove)&&Y.remove(L),this.#S--,A}#X(){let L=0,T=0;const A=this.#Oe();L+=A.dropped,T+=A.aboveAnchor;const C=this.#oe();L+=C.dropped,T+=C.aboveAnchor,L&&(this.#A=!0,this.#E+=L,this.#Ee(),this.#m-=T,this.#ke("stream:evicted",{evicted:L,total:this.#E,live:this.#S}))}#oe(){const L=this.#e.maxRows;if(!Number.isFinite(L)||L<=0||this.#S<=L)return{dropped:0,aboveAnchor:0};const T=Math.max(1,Math.floor(L*(1-E)));let A=0,C=0;for(;this.#S>T&&this.#N<this.#n.length;){const H=this.#N++;this.#n[H]!==void 0&&(this.#Te(H)&&C++,A++)}return{dropped:A,aboveAnchor:C}}#Oe(){const L=this.#H();if(!L||!this.#P||!this.#fe())return{dropped:0,aboveAnchor:0};const T=Date.now()-L;let A=0,C=0,H=1/0;for(let Y=this.#N;Y<this.#n.length;Y++){if(this.#n[Y]===void 0)continue;const Z=this.#P[Y];if(!(Number.isNaN(Z)||Z===void 0)){if(Z>=T){Z<H&&(H=Z);continue}this.#Te(Y)&&C++,A++}}for(this.#M=H,this.#R=!1;this.#N<this.#n.length&&this.#n[this.#N]===void 0;)this.#N++;return{dropped:A,aboveAnchor:C}}#we(L){if(!this.#r)return L;for(let T=0;T<this.#r.length;T++)if(this.#r.at(T)===L)return T;return-1}#Ee(){this.#i=this.#ye("sort",[]),this.#s=this.#ye("filters",null);const L=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#H()>0,T=this.#ye("where",null),A=(this.#t.config||{}).hostFilter,C=!!(T&&T.active)||!!(A&&B(A.active)&&A.active());if(!(L||this.#i.length>0||!!this.#s||!!this.#ye("quick","")||C)){this.#r=null;return}this.#r=new l(Math.max(64,this.#n.length+64));for(let Y=0;Y<this.#n.length;Y++)this.#n[Y]!==void 0&&this.#ae(Y)&&this.#r.insert(this.#C(Y),Y)}#ae(L){const T=this.#xe(L);if(this.#s&&!this.#ce(this.#s,T))return!1;const A=String(this.#ye("quick","")||"").toLowerCase();if(A&&!this.#at(T).includes(A))return!1;const C=(this.#t.config||{}).hostFilter;if(C&&B(C.active)&&C.active()&&!C.passes(this.#ve(L)))return!1;const H=this.#ye("where",null);if(H&&H.active){const Y=this.#ve(L);if(!H.passes(Y.data,Y.key))return!1}return!0}#ce(L,T){if(!L)return!0;const A=L;if(Array.isArray(A.conditions))return A.op==="or"?A.conditions.some(Y=>this.#ce(Y,T)):A.op==="not"?!A.conditions.some(Y=>this.#ce(Y,T)):A.conditions.every(Y=>this.#ce(Y,T));const C=L,H=(this.#t.compute||{}).testValue;return B(H)?!!H(this.#Me(T,C.col),C,(this.#t.config||{}).locale):(b("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#$e(L){if(!this.#r)return-1;if(!this.#i.length)return this.#we(L);let T=0,A=this.#r.length;for(;T<A;){const C=T+A>>>1;this.#W(this.#r.at(C),L)<0?T=C+1:A=C}for(let C=T;C<this.#r.length;C++){const H=this.#r.at(C);if(H===L)return C;if(this.#W(H,L)>0)break}return this.#we(L)}#U(L,T){if(!this.#r||!this.#i.length)return;const A=this.#ae(L);if(T>=0&&this.#r.at(T)===L)this.#r.removeAt(T),T<=this.#p&&this.#m--;else if(T>=0)return;if(!A)return;const C=this.#C(L);this.#r.insert(C,L),C<=this.#p&&this.#m++}#C(L){if(!this.#r||!this.#i.length)return this.#r?this.#r.length:0;let T=0,A=this.#r.length;for(;T<A;){const C=T+A>>>1;this.#W(L,this.#r.at(C))<0?A=C:T=C+1}return T}#W(L,T){const A=this.#xe(L),C=this.#xe(T);for(const H of this.#i){const Y=this.#_e(H.col),Z=this.#Me(A,H.col),_=this.#Me(C,H.col),ee=(Y&&Y.value&&B(Y.value.compare)?Y.value.compare:j)(Z,_);if(ee!==0)return H.dir==="desc"?-ee:ee}return 0}#ie(){this.#w=!0,this.#u.loaded=this.#u.loaded||this.#n.length;const L=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:m;!this.#x&&this.#n.length<L&&(this.#g=w({mode:"memory",rows:this.#n},this.#t),this.#$!==null&&(clearInterval(this.#$),this.#$=null),this.#b&&(this.#b.destroy(),this.#b=null)),this.#me(),this.#ke("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:L})}#me(){this.#f!==null||this.#v||(this.#f=this.#he(()=>{this.#f=null,this.#d++;const L=this.#m;this.#m=0,this.#h=0,this.#ke("stream:chunk",{loaded:this.#u.loaded,estimated:this.#u.estimated,count:this.count(),renders:this.#d}),this.#ke("model:changed",{reason:"stream",shiftAboveViewport:L,anchor:this.#p}),this.#ke("rows:changed",{companion:!0,reason:"stream"})}))}#le(){return this.#d===0||this.#h<this.#de()?Promise.resolve():(this.#h=0,new Promise(L=>{const T=(this.#t.scheduler||{}).idle;B(T)?T(()=>L()):G(()=>L())}))}#de(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:y}#he(L){const T=this.#t.scheduler||{};return B(T.frame)?T.frame(L):K(L)}#Le(L){const T=this.#t.scheduler||{};B(T.cancel)?T.cancel(L):x(L)}#xe(L){const T=this.#n[L];if(T!==void 0&&T!==v)return T;if(T===void 0)return;const A=this.#t.store;return A&&B(A.source)?A.source(L):void 0}#k(L,T){const A=this.#t.store;if(!A||!B(A.set))return;const C=this.#Z();if(Array.isArray(C))for(const H of C){if(!H||!H.id)continue;const Y=B(H.read)?H.read:Z=>a(Z,H.field||H.id);A.set(H.id,L,Y(T))}}#ve(L){let T=this.#l.get(L);return T||(T=this.#o.leaf(this.#xe(L),L),this.#l.set(L,T)),T}#Me(L,T){const A=this.#_e(T);return A&&B(A.getValue)?A.getValue(L):L?.[T]}#at(L){const T=this.#t.columns,A=T&&B(T.all)?T.all():[],C=[];for(const H of A){const Y=B(H.getValue)?H.getValue(L):void 0;Y!=null&&Y!==""&&C.push(String(Y))}return C.join(" ").toLowerCase()}#_e(L){const T=this.#t.columns;return T&&B(T.get)?T.get(L):void 0}#Ue(){const L=this.#V;if(this.#V=null,L&&B(L.return))try{L.return()}catch{}}#Xe(){return k({context:this.#ye("context",null)})}#ye(L,T){const A=this.#t.state;if(A&&B(A[L])){const C=A[L]();return C??T}return T}#ke(L,T){const A=this.#t.emit;B(A)&&A(L,T)}}}),Ie("packages/core/src/source/url.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return b}});const N=U("packages/core/src/internal/warn.js").warnOnce,X=U("packages/core/src/internal/predicates.js"),B=X.isObject,D=X.isFunction,K=U("packages/core/src/internal/paths.js").getPath,G=U("packages/core/src/source/abort.js").isAbortError,z=500,j=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),O=Symbol("lattice.url.skip");function b(g,k={}){const d=B(k)?k:{},p=D(d.fetch)?d.fetch:typeof globalThis<"u"&&D(globalThis.fetch)?globalThis.fetch:null,m=d.format==="json"||d.format==="ndjson"?d.format:void 0,v=typeof d.rowsPath=="string"&&d.rowsPath?d.rowsPath:void 0,y=D(d.map)?d.map:void 0,E=B(d.headers)?d.headers:void 0,M=Number.isFinite(d.batchSize)&&d.batchSize>0?Math.floor(d.batchSize):z,F=d.lenient===!0,V=Number.isFinite(d.poll)&&d.poll>0?Math.floor(d.poll):void 0,I=typeof g=="string"&&g.length>0;I||N("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*$(R={}){if(!I)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const L=R&&R.signal;let T;try{T=await p(g,E?{signal:L,headers:E}:{signal:L})}catch(H){throw G(H)?H:new Error(`[lattice] createUrlSource: request to ${g} failed — ${H&&H.message||H}`)}if(!T||!T.ok){const H=T?T.status:"no response";throw new Error(`[lattice] createUrlSource: ${H} for ${g}`)}const A=u(g,m,T),C=T.body&&D(T.body.getReader)?T.body.getReader():null;try{if(!C){const Z=await T.text();(A||r(Z,g))==="ndjson"?yield*o(null,null,Z,0,T,g,M,F):yield*c(Z,g,v,y);return}const H=new TextDecoder("utf-8");if(A==="json"){yield*c(await n(C,H,""),g,v,y);return}if(A==="ndjson"){yield*o(C,H,"",0,T,g,M,F);return}const Y=await t(C,H,g);Y.format==="json"?yield*c(await n(C,H,Y.seed),g,v,y):yield*o(C,H,Y.seed,Y.bytes,T,g,M,F)}finally{if(C&&D(C.cancel))try{await C.cancel()}catch{}}}const S={mode:"stream",open:$,autoStart:d.autoStart!==!1};return V!==void 0&&(S.poll=V),Number.isFinite(d.maxRows)&&(S.maxRows=d.maxRows),Number.isFinite(d.maxAge)&&(S.maxAge=d.maxAge),(typeof d.ageBy=="string"||D(d.ageBy))&&(S.ageBy=d.ageBy),Number.isFinite(d.coalesceMs)&&(S.coalesceMs=d.coalesceMs),Number.isFinite(d.promoteToMemoryBelow)&&(S.promoteToMemoryBelow=d.promoteToMemoryBelow),S}function u(g,k,d){if(k)return k;const p=f(g);if(p)return p;const m=d&&d.headers&&D(d.headers.get)?d.headers.get("content-type"):null;return a(m)}function f(g){const k=String(g).split(/[?#]/)[0].toLowerCase();if(k.endsWith(".ndjson")||k.endsWith(".jsonl"))return"ndjson";if(k.endsWith(".json"))return"json"}function a(g){if(!g)return;const k=g.split(";")[0].trim().toLowerCase();if(j.has(k))return"ndjson";if(k==="application/json"||k==="text/json"||k.endsWith("+json"))return"json"}function r(g,k){const d=g.replace(/^\s+/,""),p=s(d);if(p==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${k} — pass opts.format: 'json' | 'ndjson'.`);return p}async function t(g,k,d){let p="",m=0;for(;;){const{value:y,done:E}=await g.read();if(y&&(m+=y.byteLength,p+=k.decode(y,{stream:!0})),E){p+=k.decode();break}const M=p.replace(/^\s+/,"");if(M){if(M[0]==="[")return{format:"json",seed:p,bytes:m};if(M[0]!=="{"||p.indexOf(`
|
|
7
|
+
`||c==="\r"){n++;continue}if(c>="0"&&c<="9"){n=O(s,n,i);continue}if(c==="."&&s[n+1]>="0"&&s[n+1]<="9"){n=O(s,n,i);continue}if(c==='"'||c==="'"){n=b(s,n,i);continue}if(c==="["){const l=s.indexOf("]",n+1);if(l<0)throw new G("a [column reference] was opened and never closed",n);i.push({kind:X,value:s.slice(n+1,l).trim(),at:n}),n=l+1;continue}if(j(c)){n=u(s,n,i);continue}const o=s.slice(n,n+2);if(K.includes(o)){i.push({kind:D,value:o==="!="?"<>":o,at:n}),n+=2;continue}if(x.includes(c)){i.push({kind:D,value:c,at:n}),n++;continue}throw new G(`unexpected character ${JSON.stringify(c)}`,n)}return i.push({kind:q,value:null,at:s.length}),i}function j(s){return/[A-Za-z_À-]/.test(s)}function O(s,i,n){let c=i,o=!1;for(;c<s.length;){const l=s[c];if(l>="0"&&l<="9"){c++;continue}if(l==="."&&!o){o=!0,c++;continue}if((l==="e"||l==="E")&&/[0-9+-]/.test(s[c+1]||"")){for(c+=2;c<s.length&&s[c]>="0"&&s[c]<="9";)c++;break}break}return n.push({kind:te,value:Number(s.slice(i,c)),at:i}),c}function b(s,i,n){const c=s[i];let o=i+1,l="";for(;o<s.length;){if(s[o]===c){if(s[o+1]===c){l+=c,o+=2;continue}return n.push({kind:N,value:l,at:i}),o+1}l+=s[o],o++}throw new G("a string was opened and never closed",i)}function u(s,i,n){let c=i;for(;c<s.length&&/[A-Za-z0-9_.À-]/.test(s[c]);)c++;const o=s.slice(i,c);let l=c;for(;l<s.length&&s[l]===" ";)l++;return n.push({kind:s[l]==="("?B:X,value:o,at:i}),c}const f={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function a(s){const i=String(s??"").replace(/^\s*=/,"");if(!i.trim())throw new G("the formula is empty");const n=z(i);let c=0;const o=()=>n[c],l=()=>n[c++],h=v=>{const y=o();if(y.kind!==D||y.value!==v)throw new G(`expected ${JSON.stringify(v)}`,y.at);c++},w=v=>{let y=g();for(;;){const E=o();if(E.kind!==D)break;const M=f[E.value];if(!M||M<v)break;c++;const F=w(E.value==="^"?M:M+1);y={kind:"bin",op:E.value,left:y,right:F}}return y},g=()=>{const v=o();return v.kind===D&&(v.value==="-"||v.value==="+")?(c++,{kind:"unary",op:v.value,arg:g()}):k()},k=()=>{let v=d();for(;o().kind===D&&o().value==="%";)c++,v={kind:"unary",op:"%",arg:v};return v},d=()=>{const v=l();if(v.kind===te)return{kind:"num",value:v.value};if(v.kind===N)return{kind:"str",value:v.value};if(v.kind===X)return{kind:"ref",name:v.value};if(v.kind===B){h("(");const y=[];if(!(o().kind===D&&o().value===")"))for(;;){if(y.push(w(1)),o().kind===D&&o().value===","){c++;continue}break}return h(")"),{kind:"call",name:String(v.value).toUpperCase(),args:y}}if(v.kind===D&&v.value==="("){const y=w(1);return h(")"),y}throw v.kind===q?new G("the formula ends unexpectedly",v.at):new G(`unexpected ${JSON.stringify(v.value)}`,v.at)},p=w(1),m=o();if(m.kind!==q)throw new G(`unexpected ${JSON.stringify(m.value)}: is an operator missing?`,m.at);return p}function r(s){const i=new Set,n=c=>{if(!(!c||typeof c!="object")){if(c.kind==="ref"){i.add(String(c.name));return}if(c.kind==="bin"){n(c.left),n(c.right);return}if(c.kind==="unary"){n(c.arg);return}if(c.kind==="call")for(const o of c.args)n(o)}};return n(s),[...i]}function t(s){return typeof s=="string"&&/^\s*=/.test(s)&&s.trim()!=="="}}),Ie("packages/core/src/formula/evaluate.js",function(e,U){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return O}});const N=U("packages/core/src/formula/parse.js").FormulaError;function X(b){if(b==null||b==="")return 0;if(typeof b=="boolean")return b?1:0;if(b instanceof Date)return b.getTime();const u=typeof b=="number"?b:Number(String(b).replace(/[,\s]/g,""));if(!Number.isFinite(u))throw new N(`${JSON.stringify(b)} is not a number`);return u}function B(b){return b==null?"":String(b)}function D(b){if(typeof b=="boolean")return b;if(b==null||b==="")return!1;if(typeof b=="number")return b!==0;const u=String(b).trim().toLowerCase();return u==="false"||u==="no"||u==="0"?!1:u!==""}function q(b){const u=[];for(const f of b){if(Array.isArray(f)){for(const a of f)a!=null&&a!==""&&u.push(X(a));continue}f==null||f===""||u.push(X(f))}return u}function K(b,u){const f=10**u,a=b*f;return Math.sign(a)*Math.round(Math.abs(a)+Number.EPSILON*Math.abs(a))/f}function x(b,u){if(!b.length)return 0;const f=b.slice().sort((s,i)=>s-i),a=(f.length-1)*Math.min(1,Math.max(0,u)),r=Math.floor(a),t=Math.ceil(a);return r===t?f[r]:f[r]+(a-r)*(f[t]-f[r])}function G(b,u){let f=0,a=0,r=0;for(const s of b){f++;const i=s-a;a+=i/f,r+=i*(s-a)}const t=u?f-1:f;return t>0?Math.sqrt(r/t):0}const z={SUM:b=>q(b).reduce((u,f)=>u+f,0),AVERAGE:b=>{const u=q(b);return u.length?u.reduce((f,a)=>f+a,0)/u.length:0},MIN:b=>{const u=q(b);return u.length?Math.min(...u):0},MAX:b=>{const u=q(b);return u.length?Math.max(...u):0},COUNT:b=>q(b).length,PRODUCT:b=>q(b).reduce((u,f)=>u*f,1),ROUND:b=>K(X(b[0]),b.length>1?X(b[1]):0),ROUNDDOWN:b=>{const u=10**(b.length>1?X(b[1]):0),f=X(b[0])*u;return(f<0?Math.ceil(f):Math.floor(f))/u},ROUNDUP:b=>{const u=10**(b.length>1?X(b[1]):0),f=X(b[0])*u;return(f<0?Math.floor(f):Math.ceil(f))/u},ABS:b=>Math.abs(X(b[0])),FLOOR:b=>Math.floor(X(b[0])),CEILING:b=>Math.ceil(X(b[0])),SQRT:b=>Math.sqrt(X(b[0])),POWER:b=>X(b[0])**X(b[1]),MOD:b=>{const u=X(b[1]);if(u===0)throw new N("MOD by zero");return(X(b[0])%u+u)%u},IF:b=>D(b[0])?b[1]:b.length>2?b[2]:!1,AND:b=>b.every(D),OR:b=>b.some(D),NOT:b=>!D(b[0]),COALESCE:b=>b.find(u=>u!=null&&u!=="")??null,CONCAT:b=>b.map(B).join(""),LEN:b=>B(b[0]).length,UPPER:b=>B(b[0]).toUpperCase(),LOWER:b=>B(b[0]).toLowerCase(),TRIM:b=>B(b[0]).trim(),LEFT:b=>B(b[0]).slice(0,b.length>1?X(b[1]):1),RIGHT:b=>{const u=b.length>1?X(b[1]):1;return u<=0?"":B(b[0]).slice(-u)},MEDIAN:b=>x(q(b),.5),PERCENTILE:b=>{const u=X(b[b.length-1]);return x(q(b.slice(0,-1)),u>1?u/100:u)},QUARTILE1:b=>x(q(b),.25),QUARTILE3:b=>x(q(b),.75),STDEV:b=>G(q(b),!0),STDEVP:b=>G(q(b),!1),VAR:b=>{const u=G(q(b),!0);return u*u},VARP:b=>{const u=G(q(b),!1);return u*u},COUNTDISTINCT:b=>{const u=new Set;for(const f of b){const a=Array.isArray(f)?f:[f];for(const r of a)r!=null&&r!==""&&u.add(r)}return u.size},IQR:b=>{const u=q(b);return x(u,.75)-x(u,.25)}};z.AVG=z.AVERAGE,z.CEIL=z.CEILING,z.POW=z.POWER,z.STDEVS=z.STDEV,z.PERCENTILEINC=z.PERCENTILE;function j(b,u){const f=Number(b),a=Number(u);if(b!==null&&b!==""&&u!==null&&u!==""&&Number.isFinite(f)&&Number.isFinite(a))return f<a?-1:f>a?1:0;const t=B(b).toLowerCase(),s=B(u).toLowerCase();return t<s?-1:t>s?1:0}function O(b,u={}){const f=typeof u.lookup=="function"?u.lookup:null,a=u.functions?{...z,...u.functions}:z,r=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!f)throw new N(`there is no column called ${JSON.stringify(t.name)} here`);const s=f(String(t.name));if(s===void 0)throw new N(`there is no column called ${JSON.stringify(t.name)}`);return s}case"unary":{if(t.op==="%")return X(r(t.arg))/100;const s=X(r(t.arg));return t.op==="-"?-s:s}case"bin":{const s=t.op;if(s==="=")return j(r(t.left),r(t.right))===0;if(s==="<>")return j(r(t.left),r(t.right))!==0;if(s==="<")return j(r(t.left),r(t.right))<0;if(s==="<=")return j(r(t.left),r(t.right))<=0;if(s===">")return j(r(t.left),r(t.right))>0;if(s===">=")return j(r(t.left),r(t.right))>=0;const i=X(r(t.left)),n=X(r(t.right));if(s==="+")return i+n;if(s==="-")return i-n;if(s==="*")return i*n;if(s==="^")return i**n;if(s==="/"){if(n===0)throw new N("division by zero");return i/n}throw new N(`unknown operator ${JSON.stringify(s)}`)}case"call":{const s=u.lazy&&u.lazy[t.name];if(typeof s=="function")return s(t.args,r,u);const i=a[t.name];if(typeof i!="function")throw new N(`there is no function called ${t.name}`);return i(t.args.map(r),u)}default:throw new N("the formula could not be read")}};return r(b)}}),Ie("packages/core/src/formula/index.js",function(e,U){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return j}});const te=U("packages/core/src/formula/parse.js"),N=te.parseFormula,X=te.referencesOf,B=te.looksLikeFormula,D=te.FormulaError,q=te.tokenise,K=U("packages/core/src/formula/evaluate.js"),x=K.evaluateAst,G=K.FUNCTIONS;function z(O){const{grid:b,row:u,data:f}=O||{},a=n=>String(n).toLowerCase().replace(/[\s_-]/g,""),r=b&&b.columns&&typeof b.columns.all=="function"?b.columns.all():[],t=b&&b.permissions,s=t&&typeof t.isReadable=="function"?n=>t.isReadable(n):()=>!0,i=new Set;for(const n of r)s(n)||(i.add(a(n.id)),n.field&&i.add(a(n.field)),n.title&&i.add(a(n.title)));return n=>{const c=a(n);if(i.has(c))throw new D(`"${n}" cannot be read`);for(const o of r)if(a(o.id)===c||o.field&&a(o.field)===c||o.title&&a(o.title)===c)return u&&b.rows&&typeof b.rows.value=="function"?b.rows.value(u.key,o.id):f?f[o.field||o.id]:void 0;if(f&&typeof f=="object"){for(const o of Object.keys(f))if(a(o)===c){if(!s(o))throw new D(`"${n}" cannot be read`);return f[o]}}}}function j(O,b={}){try{const u=N(O);return{ok:!0,value:x(u,{lookup:z(b),functions:b.formulaFunctions}),references:X(u)}}catch(u){return{ok:!1,error:u instanceof D?u.message:"the formula could not be read",at:u instanceof D?u.at:void 0}}}}),Ie("packages/core/src/internal/version.js",function(e,U){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return X}});const te="1.101.8";async function N(){return te}const X="1.101.8"}),Ie("packages/core/src/internal/merge.js",function(e,U){"use strict";Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return K}});const N=U("packages/core/src/internal/predicates.js").isObject;function X(x,G,z){if(x!==void 0)return x===!0?{enabled:!0,...z}:x===!1?{enabled:!1}:N(x)?x:{[G]:x,enabled:!0}}function B(x){return x==null?[]:Array.isArray(x)?x:[x]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function q(x,G){if(!N(x))return N(G)?{...G}:G;if(!N(G))return G===void 0?x:G;const z={...x};for(const j of Object.keys(G)){if(D.has(j))continue;const O=G[j];O!==void 0&&(z[j]=N(O)&&N(z[j])?q(z[j],O):O)}return z}function K(x,G){if(!N(x)||!N(G)||x===G)return G;const z=Object.create(Object.getPrototypeOf(x));return Object.assign(z,x,G),z}}),Ie("packages/core/src/internal/schedule.js",function(e,U){"use strict";Object.defineProperty(e,"now",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return K}});function te(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const N=typeof requestAnimationFrame=="function";function X(x){return N?requestAnimationFrame(x):setTimeout(()=>x(te()),16)}function B(x){x!=null&&(N?cancelAnimationFrame(x):clearTimeout(x))}function D(x){let G=null,z=null;const j=()=>{G=null;const b=z;z=null,x(...b||[])},O=(...b)=>{z=b,G===null&&(G=X(j))};return O.cancel=()=>{B(G),G=null,z=null},O.flush=()=>{G!==null&&(B(G),j())},O}function q(x,G){let z=null,j=null;const O=()=>{if(z=null,j===null)return;const f=j;j=null,x(...f),b()},b=()=>{z=setTimeout(O,G),typeof z?.unref=="function"&&z.unref()},u=(...f)=>{z===null?(x(...f),b()):(j=f,clearTimeout(z),b())};return u.flush=()=>{if(z!==null&&clearTimeout(z),z=null,j===null)return;const f=j;j=null,x(...f)},u.cancel=()=>{z!==null&&clearTimeout(z),z=null,j=null},u.pending=()=>z!==null||j!==null,u}function K(x,G=50){return typeof requestIdleCallback=="function"?requestIdleCallback(x,{timeout:G}):setTimeout(()=>x({timeRemaining:()=>0,didTimeout:!0}),1)}}),Ie("packages/core/src/internal/paths.js",function(e,U){"use strict";Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return q}});const te=new Map;function N(K){let x=te.get(K);if(x)return x;if(!K.includes("."))x=G=>G?.[K];else{const G=K.split("."),z=G.length;x=j=>{let O=j;for(let b=0;b<z;b++){if(O==null)return;O=O[G[b]]}return O}}return te.set(K,x),x}const X=new Map;function B(K){let x=X.get(K);if(x)return x;if(!K.includes("."))x=(G,z)=>{G!=null&&(G[K]=z)};else{const G=K.split("."),z=G.length-1;x=(j,O)=>{let b=j;for(let u=0;u<z;u++){if(b==null)return;const f=G[u];b[f]==null&&(b[f]={}),b=b[f]}b!=null&&(b[G[z]]=O)}}return X.set(K,x),x}function D(K,x){return N(x)(K)}function q(K,x,G){B(x)(K,G)}}),Ie("packages/core/src/internal/compare.js",function(e,U){"use strict";Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return X}});const te=new Map;function N(B,D){const q=`${B||""}|${D?JSON.stringify(D):""}`;let K=te.get(q);return K||(K=new Intl.Collator(B||void 0,{numeric:!0,sensitivity:"variant",...D}),te.set(q,K)),K}function X(B,D){if(B===D)return 0;if(B==null)return 1;if(D==null)return-1;if(typeof B=="number"&&typeof D=="number")return Number.isNaN(B)?Number.isNaN(D)?0:1:Number.isNaN(D)||B<D?-1:B>D?1:0;const q=String(B),K=String(D);return q<K?-1:q>K?1:0}}),Ie("packages/core/src/defaults.js",function(e,U){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return j}});const N=U("packages/core/src/internal/predicates.js").isObject,B=U("packages/core/src/internal/merge.js").merge,q=U("packages/core/src/internal/warn.js").warnOnce;let K=null;class x extends Error{}function G(O,b=new Set){if(Array.isArray(O)){if(b.has(O))throw new x;b.add(O);const f=O.map(a=>G(a,b));return b.delete(O),f}if(!N(O)||Object.getPrototypeOf(O)!==Object.prototype&&Object.getPrototypeOf(O)!==null)return O;if(b.has(O))throw new x;b.add(O);const u={};for(const[f,a]of Object.entries(O))u[f]=G(a,b);return b.delete(O),u}function z(O){if(O===void 0)return G(K??{});if(O===null)return K=null,{};if(!N(O))return q("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(O)?"an array":typeof O}. The call was ignored and the defaults are unchanged.`),G(K??{});try{K=G(O)}catch(b){if(!(b instanceof x))throw b;return q("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."),G(K??{})}return G(K)}function j(O){return K===null?O:B(G(K),O)}}),Ie("packages/core/src/internal/uid.js",function(e,U){"use strict";Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return N}});let te=0;function N(X="l"){return`${X}${(++te).toString(36)}`}}),Ie("packages/core/src/events/names.js",function(e,U){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return X}});const te=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),N=new Set(te);function X(B){return B==="*"||N.has(B)}}),Ie("packages/core/src/events/bus.js",function(e,U){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return f}});const te=U("packages/core/src/internal/warn.js"),N=te.warnOnce,X=te.DEV,D=U("packages/core/src/internal/uid.js").uid,K=U("packages/core/src/events/names.js").isKnownEvent,x="*";function G(a,r){!X||K(r)||N(`bus.unknown:${r}`,`${a}('${r}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const z=new Set(["api","user","init","ai"]),j=new WeakMap;function O(a){let r=j.get(a);return r||(r=D("h"),j.set(a,r)),r}function b(){return typeof performance=="object"&&performance?performance.now():Date.now()}function u(a){if(!a||typeof a!="object")return{};const r={};for(const[t,s]of Object.entries(a))t!=="grid"&&(s==null?r[t]=String(s):Array.isArray(s)?r[t]=`[${s.length}]`:typeof s=="object"?r[t]=s.key?`row ${s.key}`:"{…}":typeof s=="function"?r[t]="[function]":r[t]=String(s).slice(0,60));return r}class f{#e=new Map;#t=!1;#n=[];#r=200;#i=new Map;#s=null;#o=!1;#l=0;constructor(r=null){this.#s=r}attach(r){this.#s=r}get grid(){return this.#s}get destroyed(){return this.#o}on(r,t){if(typeof t!="function")return N(`bus.handler:${r}`,`on('${r}') needs a function; ignored.`),()=>{};G("on",r);let s=this.#e.get(r);return s||(s=[],this.#e.set(r,s)),s.push(t),()=>this.off(r,t)}once(r,t){if(typeof t!="function")return N(`bus.handler:${r}`,`once('${r}') needs a function; ignored.`),()=>{};G("once",r);const s=i=>{this.off(r,t),t(i)};return this.#i.set(t,s),this.on(r,s)}off(r,t){if(t===void 0){this.#e.delete(r);return}const s=this.#e.get(r);if(!s)return;const i=this.#i.get(t),n=i&&s.includes(i)?i:t,c=s.indexOf(n);c>=0&&s.splice(c,1),i&&n===i&&this.#i.delete(t),s.length===0&&this.#e.delete(r)}count(r){const t=this.#e.get(r),s=r===x?null:this.#e.get(x);return(t?t.length:0)+(s?s.length:0)}#a(r,t,s,i,n){this.#n.push({type:r,origin:t,listeners:(i?i.length:0)+(n?n.length:0),payload:u(s),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(r,t){this.#t=!!r,Number.isFinite(t)&&t>0&&(this.#r=Math.floor(t)),r||(this.#n=[])}eventLog(){return this.#n.map(r=>({...r}))}clearEventLog(){this.#n=[]}counts(){const r={};for(const[t,s]of this.#e)r[t]=s.length;return r}emit(r,t,s){const i=s??(t&&t.origin),n=z.has(i)?i:"api",c={...t||null,type:r,origin:n,grid:this.#s};if(this.#o)return c;const o=this.#e.get(r),l=r===x?void 0:this.#e.get(x);if(this.#t&&this.#a(r,n,t,o,l),!o&&!l)return c;const h=this.#t?b():0;this.#l++;try{o&&this.#c(o.slice(),c,r),l&&this.#c(l.slice(),c,x)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=b()-h)}return c}emitBefore(r,t,s){const i=s??(t&&t.origin),n=z.has(i)?i:"user";let c=!1,o=null;const l=p=>{c=!0,p!=null&&o===null&&(o=String(p))},h={...t||null,type:r,origin:n,grid:this.#s,get defaultPrevented(){return c},get reason(){return o},preventDefault(p){l(p)}};if(this.#o)return!0;const w=this.#e.get(r);this.#t&&this.#a(r,n,t,w,void 0);const g=w?w.slice():[];if(g.length===0)return!0;const k=()=>(c&&o===null&&(o="prevented"),c&&t&&typeof t=="object"&&(t.reason=o),!c),d=[];for(const p of g)try{const m=p(h);m&&typeof m.then=="function"?d.push(m):m===!1&&l("prevented")}catch(m){l("error"),N(`bus.beforeThrow:${r}:${O(p)}`,`a '${r}' before-handler threw; the action was cancelled.`,m)}return d.length===0?k():Promise.allSettled(d).then(p=>{for(const m of p)m.status==="rejected"?(l("error"),N(`bus.beforeReject:${r}`,`a '${r}' before-handler rejected; the action was cancelled.`,m.reason)):m.value===!1&&l("prevented");return k()})}#c(r,t,s){for(let i=0;i<r.length;i++)try{r[i](t)}catch(n){N(`bus.throw:${s}:${O(r[i])}`,`a '${s}' handler threw; other handlers were unaffected.`,n)}}clear(){this.#e.clear(),this.#i.clear()}destroy(){this.clear(),this.#o=!0,this.#s=null}}}),Ie("packages/core/src/registry/free-tier-notice.js",function(e,U){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return te}});const te="Free for non-commercial use: latticegrid.dev/free"}),Ie("packages/core/src/registry/licence.js",function(e,U){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return I}});const N=U("packages/core/src/internal/warn.js").warnOnce,X=U("packages/core/src/registry/free-tier-notice.js"),B=X.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return X.FREE_TIER_NOTICE}});const D="lattice-grid",q=1,K="LG1",x=64,G="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",j=(()=>{const $=new Int16Array(128).fill(-1);for(let S=0;S<z.length;S++)$[z.charCodeAt(S)]=S;return $[43]=62,$[47]=63,$})();function O($){if(typeof $!="string")return null;let S="";for(let H=0;H<$.length;H++){const Y=$.charCodeAt(H);if(Y!==61){if(Y>127||j[Y]<0)return null;S+=$[H]}}const R=S.length;if(R%4===1)return null;const L=new Uint8Array(Math.floor(R*3/4));let T=0,A=0,C=0;for(let H=0;H<R;H++)T=T<<6|j[S.charCodeAt(H)],A+=6,A>=8&&(A-=8,L[C++]=T>>A&255);return C===L.length?L:L.subarray(0,C)}function b($){let S="",R=0;for(;R+2<$.length;R+=3){const T=$[R]<<16|$[R+1]<<8|$[R+2];S+=z[T>>18&63]+z[T>>12&63]+z[T>>6&63]+z[T&63]}const L=$.length-R;if(L===1){const T=$[R]<<16;S+=z[T>>18&63]+z[T>>12&63]}else if(L===2){const T=$[R]<<16|$[R+1]<<8;S+=z[T>>18&63]+z[T>>12&63]+z[T>>6&63]}return S}function u($){const S=new Uint8Array($.length);for(let R=0;R<$.length;R++)S[R]=$.charCodeAt(R)&127;return S}function f($){if(typeof TextDecoder=="function")return new TextDecoder().decode($);let S="";for(let R=0;R<$.length;R++)S+=String.fromCharCode($[R]);return S}function a($){const S={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof $=="string"?$:""};if(typeof $!="string"||$.length===0)return{...S,reason:"missing"};const R=$.trim(),L=R.split(".");if(L.length!==3)return S;const[T,A,C]=L;if(T!==K)return{...S,reason:"prefix"};const H=O(A),Y=O(C);if(!H||!Y)return S;let Z;try{Z=JSON.parse(f(H))}catch{return S}return Z===null||typeof Z!="object"?S:{ok:!0,reason:null,product:typeof Z.p=="string"?Z.p:null,issuedTo:typeof Z.t=="string"?Z.t:null,expires:typeof Z.e=="string"?Z.e:null,terms:typeof Z.terms=="string"?Z.terms:null,features:Array.isArray(Z.f)?Z.f.slice():[],deployments:Array.isArray(Z.d)?Z.d.slice():[],version:typeof Z.v=="number"?Z.v:0,message:u(A),signature:Y,raw:R}}function r($,S){if(!$)return!1;const R=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test($)?`${$}T23:59:59.999Z`:$);return Number.isNaN(R)?!0:S>R}function t($){return $==="non-commercial"?"non-commercial":"commercial"}let s=null,i=null,n=null;function c(){const $=globalThis.crypto;return $&&$.subtle?$.subtle:null}async function o($){if(s&&i===$)return s;const S=c();if(!S)return null;const R=O($);if(!R)return null;try{const L=await S.importKey("raw",R,{name:"Ed25519"},!1,["verify"]);return s=L,i=$,L}catch{return null}}async function l(){return n!==null||(n=await o(G)!==null),n}async function h($,S={}){const R=S.warn!==!1,L=S.product||D,T=S.publicKey||G,A=S.now??Date.now(),C=S.host??g(),H=w(C)?"":` ${B}`,Y=a($);if(!Y.ok){const ne=Y.reason==="missing"?"missing":"malformed";return R&&N(`licence.${ne}`,ne==="missing"?`no licence key supplied. The grid renders in full and carries a trial watermark on any host other than localhost. Get a key at latticegrid.dev.${H}`:`licence key could not be read. The grid will render with a watermark.${H}`),{valid:!1,reason:ne,terms:"commercial"}}const Z={product:Y.product||void 0,issuedTo:Y.issuedTo||void 0,expires:Y.expires||void 0,terms:t(Y.terms)};if(Y.product!==L)return R&&N("licence.product",`licence key is for '${Y.product}', not '${L}'. The grid will render with a watermark.`),{valid:!1,...Z,reason:"product"};if(r(Y.expires,A))return R&&N("licence.expired",`licence expired on ${Y.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...Z,reason:"expired"};const _=Y.deployments||[];if(_.length&&C&&!w(C)&&!k(C,_))return R&&N("licence.domain",`licence key is not valid for ${C}; it covers ${_.join(", ")}. The grid will render with a watermark.`),{valid:!1,...Z,reason:"domain"};const J=await o(T);if(!J){const ne=!!Y.signature&&Y.signature.length===x;return R&&N("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),ne?{valid:!0,...Z,reason:"unverified"}:{valid:!1,...Z,reason:"signature"}}let ee=!1;try{ee=await c().verify({name:"Ed25519"},J,Y.signature,Y.message)}catch{ee=!1}return ee?{valid:!0,...Z}:(R&&N("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...Z,reason:"signature"})}function w($){const S=String($??g()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!S||S==="localhost"||S.endsWith(".localhost")||S==="::1"||S==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(S)}function g(){const $=globalThis.location;return $&&typeof $.hostname=="string"?$.hostname:null}function k($,S){const R=d($);return!R||!Array.isArray(S)?!1:S.some(L=>{const T=d(L);if(!T)return!1;if(T==="*")return!0;if(T.startsWith("*.")){const A=T.slice(2);return R===A||R.endsWith(`.${A}`)}return R===T})}function d($){return String($??"").trim().toLowerCase().replace(/\.$/,"")}class p{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#i;#s=new Set;constructor(S={}){this.#i=S}set(S){this.#e=typeof S=="string"?S.trim():"";const R=a(this.#e);return this.#t=R.ok?{valid:!r(R.expires,Date.now())&&R.product===(this.#i.product||D),product:R.product||void 0,issuedTo:R.issuedTo||void 0,expires:R.expires||void 0,terms:t(R.terms),reason:"pending"}:{valid:!1,reason:R.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const S=this.#e;return this.#n=h(S,this.#i).then(R=>{if(this.#e===S){this.#t=R;for(const L of this.#s)L(R)}return R}),this.#n}onSettled(S){return this.#s.add(S),()=>this.#s.delete(S)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!w(this.#r)}setHost(S){this.#r=S}state(){return this.#t.valid?"licensed":w(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#s.clear()}}const m=Symbol.for("lattice-grid/licence/holder");function v(){const $=globalThis,S=$&&$[m];if(S&&typeof S.set=="function"&&typeof S.watermark=="function")return S;const R=new p;if($)try{$[m]=R}catch{}return R}const y=v();function E($){return y.set($)}function M(){return y.info()}function F(){return y.watermark()}function V(){return y.state()}function I(){return y}}),Ie("packages/core/src/registry/registry.js",function(e,U){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return s}});const te=U("packages/core/src/internal/warn.js"),N=te.warnOnce,X=te.DEV,D=U("packages/core/src/internal/predicates.js").isFunction,q=U("packages/core/src/registry/licence.js"),K=q.LicenceHolder,x=q.sharedLicence,G=["renderer","editor","filter","dataType","totalFn","pipe","component"],z=["all","header","body","totals","panels"];class j{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#i;#s=null;#o=null;#l=new Set;#a=new Map;constructor(n={}){for(const c of G)this.#t.set(c,new Map);this.#i=n.holder||x(),this.#o=n.grid??null,this.#s=this.#i.onSettled(()=>{this.#f({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),n.licence&&this.setLicence(n.licence)}registerModules(n,c={}){c.licence&&this.setLicence(c.licence),c.grid!==void 0&&(this.#o=c.grid);const o=Array.isArray(n)?n:[n],l=[];for(const h of o){if(!h||typeof h!="object"||typeof h.name!="string"||!h.name){N("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(h.name)){X&&this.#u(this.#e.get(h.name),h);continue}if(!D(h.install)){N(`registry.module.install:${h.name}`,`module '${h.name}' has no install() and was ignored.`);continue}const w={registry:this,grid:this.#o};try{h.install(w)}catch(g){N(`registry.module.throw:${h.name}`,`module '${h.name}' threw during install; it was not registered.`,g);continue}this.#e.set(h.name,h);for(const g of O(h))this.#n.add(g);l.push(h.name),this.#f({reason:"module",name:h.name,capabilities:this.capabilities(),regions:f(h)})}return l}unregisterModule(n){const c=this.#e.get(n);if(!c)return!1;if(D(c.uninstall))try{c.uninstall({registry:this,grid:this.#o})}catch(o){N(`registry.module.uninstall:${n}`,`module '${n}' threw during uninstall.`,o)}return this.#e.delete(n),this.#c(),this.#f({reason:"unmodule",name:n,capabilities:this.capabilities(),regions:f(c)}),!0}modules(){return[...this.#e.values()]}has(n){return this.#e.has(n)}#c(){this.#n.clear();for(const n of this.#e.values())for(const c of O(n))this.#n.add(c)}#u(n,c){!n||n===c||b(n,c)||N(`registry.module.reconfigure:${c.name}`,`module '${c.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(n){return this.#n.has(n)}onChange(n){return D(n)?(this.#r.add(n),this.#a.set(n,this.#o),()=>{this.#r.delete(n),this.#a.delete(n)}):()=>{}}#f(n){for(const c of[...this.#r])try{c(n)}catch(o){N("registry.onChange.throw","a registry change handler threw.",o)}}register(n,c,o){const l=this.#t.get(n);if(!l){N(`registry.kind:${n}`,`unknown registry kind '${n}'; expected one of ${G.join(", ")}.`);return}if(!c||typeof c!="string"){N(`registry.name:${n}`,`register('${n}', ...) needs a name.`);return}l.has(c)&&l.get(c)!==o&&N(`registry.replace:${n}:${c}`,`'${c}' was already registered as a ${n} and has been replaced.`),l.set(c,o),this.#f({reason:"register",name:c,kind:n,capabilities:this.capabilities(),regions:a(n)})}registerAll(n,c){if(c)for(const o of Object.keys(c))this.register(n,o,c[o])}get(n,c){const o=this.#t.get(n);return o?o.get(c):void 0}names(n){const c=this.#t.get(n);return c?[...c.keys()]:[]}#d(n,c){const o=this.#t.get(n).get(c);return o!==void 0?o:this.#t.get("component").get(c)}renderer(n){return this.#d("renderer",n)}editor(n){return this.#d("editor",n)}filter(n){return this.#d("filter",n)}dataType(n){return this.get("dataType",n)}totalFn(n){return this.get("totalFn",n)}pipe(n){return this.get("pipe",n)}setLicence(n){return this.#i.set(n)}licence(){return this.#i.info()}licenceVerified(){return this.#i.verify()}watermark(){return this.#i.watermark()}attach(n){n!=null&&(this.#l.add(n),this.#o=n)}detach(n){if(n!=null){this.#l.delete(n);for(const[c,o]of[...this.#a])o===n&&(this.#r.delete(c),this.#a.delete(c));if(this.#o===n){const c=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#o=c}this.#l.size===0&&this.#s&&(this.#s(),this.#s=null)}}destroy(n){if(n!=null){this.detach(n);return}for(const c of[...this.#e.keys()])this.unregisterModule(c);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#s&&this.#s(),this.#s=null,this.#o=null}}function O(i){const n=i.capabilities,c=Array.isArray(n)?n.filter(o=>typeof o=="string"):[];return[i.name,...c]}function b(i,n){return i.install!==n.install||i.uninstall!==n.uninstall||(i.version||"")!==(n.version||"")?!1:u(O(i),O(n))&&u(f(i),f(n))}function u(i,n){const c=new Set(i),o=new Set(n);if(c.size!==o.size)return!1;for(const l of c)if(!o.has(l))return!1;return!0}function f(i){const n=i.regions;return!Array.isArray(n)||n.length===0?["all"]:n.filter(c=>z.includes(c))}function a(i){switch(i){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const r=new j;function t(){return r}function s(i,n={}){return r.registerModules(i,n)}}),Ie("packages/core/src/internal/text.js",function(e,U){"use strict";Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return B}});function te(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(/^./,K=>K.toUpperCase()):""}const N={"&":"&","<":"<",">":">",'"':""","'":"'"};function X(D){const q=D==null?"":String(D);return/[&<>"']/.test(q)?q.replace(/[&<>"']/g,K=>N[K]):q}function B(D){return String(D).replace(/\w\S*/g,q=>q[0].toUpperCase()+q.slice(1).toLowerCase())}}),Ie("packages/core/src/format/mask.js",function(e,U){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return q}});const te=new Set(["0","#","?",",","."]),N="\0";function X(x){const G=[];let z="",j=!1;for(let O=0;O<x.length;O++){const b=x[O];if(b==="\\"){z+=b+(x[O+1]??""),O+=1;continue}if(b==='"'){j=!j,z+=b;continue}if(b===";"&&!j){G.push(z),z="";continue}z+=b}return G.push(z),G}function B(x){let G="",z="",j="",O=1,b=!1,u=!1;const f=l=>{u?z+=l:G+=l};for(let l=0;l<x.length;l++){const h=x[l];if(h==="\\"){f(x[l+1]??""),l+=1;continue}if(h==='"'){const w=x.indexOf('"',l+1);f(w===-1?x.slice(l+1):x.slice(l+1,w)),l=w===-1?x.length:w;continue}if(h==="%"){O*=100,f("%");continue}if(h==="@"){b=!0,f("\0");continue}if(te.has(h)){j+=h,u=!0;continue}f(h)}let a=-1;for(let l=j.length-1;l>=0;l--){const h=j[l];if(h==="0"||h==="#"||h==="?"){a=l;break}}let r=!1,t="";for(let l=0;l<j.length;l++){const h=j[l];if(h===","){l>a?O/=1e3:r=!0;continue}t+=h}const s=t.indexOf("."),i=s===-1?t:t.slice(0,s),n=s===-1?"":t.slice(s+1);let c=0;for(const l of i)l==="0"&&(c+=1);let o=0;for(const l of n)l==="0"&&(o+=1);return{prefix:G,suffix:z,minInt:c,minDec:o,maxDec:n.length,grouping:r,scale:O,hasNumber:a!==-1,isText:b}}function D(x,G){const z=new Intl.NumberFormat(G,{minimumIntegerDigits:Math.max(x.minInt,1),minimumFractionDigits:x.minDec,maximumFractionDigits:Math.max(x.maxDec,x.minDec),useGrouping:x.grouping}),{prefix:j,suffix:O,scale:b,hasNumber:u}=x;return f=>{if(!u)return j+O;const a=b===1?f:f*b;return j+z.format(a)+O}}function q(x,G){const j=X(String(x)).map(B),O=j.map(t=>D(t,G)),b=0,u=j.length>1?1:-1,f=j.length>2?2:-1,a=j.length>3?3:-1,r=t=>{if(t==null||t==="")return"";if(typeof t!="number"||Number.isNaN(t)){const s=Number(t);if(Number.isNaN(s))return a===-1?String(t):(j[a].prefix+j[a].suffix).split("\0").join(String(t));t=s}return t===0&&f!==-1?O[f](0):t<0&&u!==-1?O[u](-t):O[b](t)};return r.spec={mask:x},{format:r,ooxml:K(String(x))}}function K(x){return x.trim()}}),Ie("packages/core/src/format/pattern.js",function(e,U){"use strict";Object.defineProperty(e,"parseNumberPattern",{enumerable:!0,get:function(){return D}});const N=U("packages/core/src/format/mask.js").splitSections;function X(q){let K="",x="",G="",z="",j=!1,O=!1,b=!1,u=!1;const f=r=>{b?x+=r:K+=r};for(let r=0;r<q.length;r++){const t=q[r];if(t==="\\"){f(q[r+1]??""),r+=1;continue}if(t==='"'){const s=q.indexOf('"',r+1);f(s===-1?q.slice(r+1):q.slice(r+1,s)),r=s===-1?q.length:s;continue}if(t==="%"){O=!0;continue}if(t==="0"||t==="#"){b=!0,u?z+=t:G+=t;continue}if(t===","){u||(j=!0);continue}if(t==="."&&!u){u=!0;continue}f(t)}if(!b)return{hasDigit:!1,prefix:K,suffix:x,minDec:0,maxDec:0,grouping:!1,percent:O};let a=0;for(const r of z)r==="0"&&(a+=1);return{hasDigit:!0,prefix:K,suffix:x,minDec:a,maxDec:z.length,grouping:j,percent:O}}function B(q,K){const x=K.trim(),G=q.trim();return x.startsWith("(")&&x.endsWith(")")&&x.slice(1,-1).trim()===G?"parentheses":x.endsWith("-")?"suffix":"minus"}function D(q){if(typeof q!="string")return null;const K=N(q);if(K.length===0)return null;const x=X(K[0]);if(!x.hasDigit)return null;const G={style:x.percent?"percent":"decimal",prefix:x.prefix,suffix:x.suffix,minDecimals:x.minDec,maxDecimals:Math.max(x.maxDec,x.minDec),thousandsSeparator:x.grouping?void 0:!1};if(K.length>1&&(G.negative=B(K[0],K[1])),K.length>2){const z=X(K[2]);z.hasDigit||(G.zeroDisplay=z.prefix+z.suffix)}return G}}),Ie("packages/core/src/format/number.js",function(e,U){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return K}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/internal/warn.js").warnOnce,q=U("packages/core/src/format/pattern.js").parseNumberPattern;function K(x,G){const z=typeof x=="string"?{pattern:x}:x||{};let j=z;if(typeof z.pattern=="string"){const v=q(z.pattern);if(v){const{pattern:y,...E}=z;j={...v,...E}}else B(`format:pattern:${z.pattern}`,`invalid number format pattern "${z.pattern}"; the value will use the default number format`)}const O=j.locale||G||void 0,b=j.style||"decimal",u=typeof j.scale=="number"?j.scale:1,f=j.nullDisplay??"",a=j.zeroDisplay,r=j.prefix||"",t=j.suffix||"",s=j.negative||"minus",i=j.signed===!0,n={style:b,notation:j.notation||"standard"};b==="currency"&&(n.currency=j.currency||"USD",j.currencyDisplay&&(n.currencyDisplay=j.currencyDisplay)),typeof j.decimals=="number"?(n.minimumFractionDigits=j.decimals,n.maximumFractionDigits=j.decimals):(typeof j.minDecimals=="number"&&(n.minimumFractionDigits=j.minDecimals),typeof j.maxDecimals=="number"&&(n.maximumFractionDigits=j.maxDecimals),n.minimumFractionDigits>(n.maximumFractionDigits??20)&&(n.maximumFractionDigits=n.minimumFractionDigits)),j.thousandsSeparator===!1&&(n.useGrouping=!1),n.notation==="compact"&&(n.compactDisplay=j.compactDisplay||"short");const c=new Intl.NumberFormat(O,n),o=typeof j.thousandsSeparator=="string"?j.thousandsSeparator:null,l=typeof j.decimalSeparator=="string"?j.decimalSeparator:null;let h=",",w=".";if(o||l)for(const v of c.formatToParts(12345.6))v.type==="group"?h=v.value:v.type==="decimal"&&(w=v.value);const g=v=>{let y=v;return o&&(y=y.split(h).join("")),l&&(y=y.split(w).join("")),o&&(y=y.split("").join(o)),l&&(y=y.split("").join(l)),y},k=!!(o||l),d=r!==""&&b==="currency",p=v=>{let y;if(d){const E=c.formatToParts(v);let M=!1;y="";for(const F of E)y+=F.value,!M&&F.type==="currency"&&(y+=r,M=!0);M||(y=r+y)}else y=r+c.format(v);return k&&(y=g(y)),y+t},m=v=>{if(N(v)||v==="")return f;const y=typeof v=="number"?v:Number(v);if(Number.isNaN(y))return f;const E=u===1?y:y*u;return E===0&&a!==void 0?a:E<0?s==="parentheses"?`(${p(-E)})`:s==="suffix"?`${p(-E)}-`:p(E):i&&E>0?`+${p(E)}`:p(E)};return m.negativeClass=j.negativeClass||null,m.spec=j,m}}),Ie("packages/core/src/format/date.js",function(e,U){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return t}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/internal/warn.js").warnOnce,D=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function q(s){const i=[];let n=0,c="";const o=()=>{c&&(i.push({token:null,text:c}),c="")};for(;n<s.length;){const l=s[n];if(l==="'"){if(s[n+1]==="'"){c+="'",n+=2;continue}const w=s.indexOf("'",n+1);if(w===-1){c+=s.slice(n+1),n=s.length;continue}c+=s.slice(n+1,w),n=w+1;continue}const h=D.find(w=>s.startsWith(w,n));if(h){o(),i.push({token:h,text:h}),n+=h.length;continue}/[A-Za-z]/.test(l)&&B(`date.pattern.token:${l}`,`the date pattern "${s}" contains '${l}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${D.join(" ")}.`),c+=l,n+=1}return o(),i}const K=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function x(s){if(N(s)||s==="")return null;if(s instanceof Date)return Number.isNaN(s.getTime())?null:s;if(typeof s=="number")return Number.isNaN(s)?null:new Date(s);if(typeof s=="string"){const i=K.exec(s.trim());if(i){const[,c,o,l,h="0",w="0",g="0"]=i;return new Date(+c,+o-1,+l,+h,+w,+g)}const n=new Date(s);return Number.isNaN(n.getTime())?null:n}return null}function G(s,i){return String(s).padStart(i,"0")}function z(s){if(!s)return c=>({year:c.getFullYear(),month:c.getMonth()+1,day:c.getDate(),hour:c.getHours(),minute:c.getMinutes(),second:c.getSeconds(),ms:c.getMilliseconds(),weekday:c.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),n={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return c=>{const o={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:c.getMilliseconds(),weekday:0};for(const l of i.formatToParts(c))switch(l.type){case"year":o.year=Number(l.value);break;case"month":o.month=Number(l.value);break;case"day":o.day=Number(l.value);break;case"hour":o.hour=Number(l.value)%24;break;case"minute":o.minute=Number(l.value);break;case"second":o.second=Number(l.value);break;case"weekday":o.weekday=n[l.value]??0;break;default:break}return o}}function j(s,i,n){const c=q(s),o=z(n),l=new Set(c.filter(d=>d.token).map(d=>d.token)),h=l.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:n}):null,w=l.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:n}):null,g=l.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:n}):null,k=l.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:n}):null;return d=>{const p=o(d);let m="";for(const v of c){if(!v.token){m+=v.text;continue}switch(v.token){case"yyyy":m+=G(p.year,4);break;case"yy":m+=G(p.year%100,2);break;case"MMMM":m+=w.format(d);break;case"MMM":m+=h.format(d);break;case"MM":m+=G(p.month,2);break;case"M":m+=String(p.month);break;case"dd":m+=G(p.day,2);break;case"d":m+=String(p.day);break;case"EEEE":m+=k.format(d);break;case"EEE":m+=g.format(d);break;case"HH":m+=G(p.hour,2);break;case"H":m+=String(p.hour);break;case"hh":m+=G(p.hour%12===0?12:p.hour%12,2);break;case"h":m+=String(p.hour%12===0?12:p.hour%12);break;case"mm":m+=G(p.minute,2);break;case"m":m+=String(p.minute);break;case"ss":m+=G(p.second,2);break;case"s":m+=String(p.second);break;case"SSS":m+=G(p.ms,3);break;case"a":m+=p.hour<12?"AM":"PM";break;default:m+=v.text;break}}return m}}const O=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function b(s,i){const n=s||{},c=n.locale||i||void 0,o=n.nullDisplay??"",l=n.timeZone;let h;if(n.pattern)h=j(n.pattern,c,l);else if(n.dateStyle||n.timeStyle){const p={timeZone:l};n.dateStyle&&(p.dateStyle=n.dateStyle),n.timeStyle&&(p.timeStyle=n.timeStyle);const m=new Intl.DateTimeFormat(c,p);h=v=>m.format(v)}else{const p=new Intl.DateTimeFormat(c,{dateStyle:"medium",timeZone:l});h=m=>p.format(m)}const w=n.relative?new Intl.RelativeTimeFormat(c,{numeric:"auto"}):null,k=(typeof n.relative=="object"&&n.relative?n.relative.threshold??7:7)*24*36e5,d=(p,m)=>{const v=x(p);if(!v)return o;if(w){const y=m&&typeof m.now=="number"?m.now:Date.now(),E=v.getTime()-y;if(Math.abs(E)<k){for(const[M,F]of O)if(Math.abs(E)>=F||M==="second")return w.format(Math.round(E/F),M)}}return h(v)};return d.spec=n,d}function u(s){if(N(s)||s==="")return null;if(typeof s=="string"){const c=/^(\d{4}-\d{2}-\d{2})/.exec(s.trim());if(c)return c[1];const o=x(s);return o?u(o):null}const i=x(s);if(!i)return null;const n=c=>String(c).padStart(2,"0");return`${i.getFullYear()}-${n(i.getMonth()+1)}-${n(i.getDate())}`}function f(s,i){if(N(s)||s==="")return null;if(typeof s=="string"){const c=s.trim();if(a.test(c)){const h=x(c);return h?r(h,i):null}const o=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(c);if(o){const[,h,w,g,k]=o;return`${h}T${w}:${g}${k&&k!=="00"?`:${k}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(c))return`${c}T00:00`;const l=x(c);return l?f(l):null}const n=x(s);return n?r(n,i):null}const a=/(?:Z|[+-]\d{2}:?\d{2})$/i;function r(s,i){const n=h=>String(h).padStart(2,"0");if(i)try{const h=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(s).reduce((k,d)=>(d.type!=="literal"&&(k[d.type]=d.value),k),{}),w=h.hour==="24"?"00":h.hour,g=Number(h.second);return`${h.year}-${h.month}-${h.day}T${w}:${h.minute}`+(g?`:${h.second}`:"")}catch{}const c=`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())}`,o=s.getSeconds(),l=`${n(s.getHours())}:${n(s.getMinutes())}${o?`:${n(o)}`:""}`;return`${c}T${l}`}function t(s,i){const n=N(s)||s===""?null:String(s),c=N(i)||i===""?null:String(i);return n===null?c===null?0:1:c===null||n<c?-1:n>c?1:0}}),Ie("packages/core/src/format/boolean.js",function(e,U){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return q}});const N=U("packages/core/src/internal/predicates.js").isNil,X={true:"☑",false:"☐",null:""},B={true:"◉",false:"◯",null:""};function D(K){if(N(K)||K==="")return null;if(typeof K=="boolean")return K;if(typeof K=="number")return K!==0;const x=String(K).trim().toLowerCase();return x==="true"||x==="yes"||x==="y"||x==="1"?!0:x==="false"||x==="no"||x==="n"||x==="0"?!1:null}function q(K,x){const G=K||{},z=G.display||"text",j=G.trueLabel??"Yes",O=G.falseLabel??"No",b=G.nullLabel??"";let u=j,f=O;const a=b;z==="checkbox"?(u=X.true,f=X.false):z==="switch"?(u=B.true,f=B.false):z==="icon"&&(u=G.trueIcon??j,f=G.falseIcon??O);const r=t=>{const s=D(t);return s===null?a:s?u:f};return r.display=z,r.labels={true:j,false:O,null:b},r.locale=x,r.spec=G,r}}),Ie("packages/core/src/format/text.js",function(e,U){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return D}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/internal/text.js").titleCase;function D(q,K){const x=q||{},G=x.locale||K||void 0,z=x.nullDisplay??"",j=x.emptyDisplay??"",O=x.transform||"none",b=typeof x.truncate=="number"?{chars:x.truncate}:x.truncate||null,u=b?b.chars:0,f=b?b.ellipsis??"…":"",a=t=>{switch(O){case"upper":return G?t.toLocaleUpperCase(G):t.toUpperCase();case"lower":return G?t.toLocaleLowerCase(G):t.toLowerCase();case"title":return B(t);default:return t}},r=t=>{if(N(t))return z;let s=typeof t=="string"?t:String(t);return s===""?j:(O!=="none"&&(s=a(s)),u>0&&s.length>u&&(s=s.slice(0,u)+f),s)};return r.spec=x,r}}),Ie("packages/core/src/format/shorthand.js",function(e,U){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return K}});const te=["currency","number","percent","date","boolean","text","relative"],N=/[#0?@;"\\]/,X=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function B(x){return typeof x!="string"||x===""||q(x)?!1:N.test(x)}function D(x){return typeof x!="string"||x===""||q(x)?!1:X.test(x)}function q(x){const G=x.indexOf(":"),z=G===-1?x:x.slice(0,G);return te.includes(z)?z:null}function K(x){const G=q(x);if(!G)return null;const z=x.indexOf(":"),j=z===-1?"":x.slice(z+1),O=j===""?[]:j.split(":");switch(G){case"currency":{const b={type:"number",style:"currency",currency:O[0]||"USD"};return O[1]!==void 0&&O[1]!==""&&(b.decimals=Number(O[1])),b}case"number":{const b={type:"number",style:"decimal"};return O[0]!==void 0&&O[0]!==""&&(b.decimals=Number(O[0])),b}case"percent":{const b={type:"number",style:"percent"};return O[0]!==void 0&&O[0]!==""&&(b.decimals=Number(O[0])),b}case"date":return{type:"date",pattern:j||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const b=j.split("/"),u={type:"boolean",display:"text"};return b[0]!==void 0&&b[0]!==""&&(u.trueLabel=b[0]),b[1]!==void 0&&b[1]!==""&&(u.falseLabel=b[1]),b[2]!==void 0&&(u.nullLabel=b[2]),u}case"text":{const b={type:"text"};return O[0]&&(b.transform=O[0]),O[1]!==void 0&&O[1]!==""&&(b.truncate=Number(O[1])),b}default:return null}}}),Ie("packages/core/src/format/index.js",function(e,U){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return y}});const te=U("packages/core/src/internal/predicates.js"),N=te.isFunction,X=te.isObject,D=U("packages/core/src/internal/warn.js").warnOnce,q=U("packages/core/src/format/number.js"),K=q.compileNumber,x=U("packages/core/src/format/date.js"),G=x.compileDate,z=x.scanPattern,j=U("packages/core/src/format/boolean.js"),O=j.compileBoolean,b=U("packages/core/src/format/text.js"),u=b.compileText,f=U("packages/core/src/format/mask.js"),a=f.compileMask,r=U("packages/core/src/format/shorthand.js"),t=r.parseShorthand,s=r.looksLikeMask,i=r.looksLikeDatePattern,c=U("packages/core/src/format/pattern.js").parseNumberPattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return q.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return x.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return x.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return x.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return x.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return j.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return j.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return b.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return f.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return f.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return f.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return r.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return r.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return r.looksLikeDatePattern}});const o=new Set(["decimal","currency","percent","unit"]),l=new Set(["type","locale"]),h={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale","pattern"]),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"])},w=new Set(["number","date","boolean","text"]);function g(V,I){const $=V.type;if($===void 0||w.has($)||!o.has(String($)))return;const S=I?`"${I}"`:"with no id";D(`format:unknown-style-key:${I||""}:${$}`,`column ${S} has format: { type: "${$}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${$}" instead?`)}function k(V,I,$){const S=h[I],R=$?`"${$}"`:"with no id";for(const L of V){if(l.has(L)||S.has(L))continue;const T=Object.keys(h).find(A=>A!==I&&h[A].has(L));T?D(`format:inapplicable:${$||""}:${L}`,`column ${R} has format key "${L}", which applies to a ${T} column, not the ${I} column it was applied to; it is ignored.`):D(`format:unknown:${$||""}:${L}`,`column ${R} has an unrecognised format key "${L}" for its ${I} format; it is ignored.`)}}function d(V){if(V.type==="number"||V.type==="date"||V.type==="boolean"||V.type==="text")return!0;const I=o.has(String(V.style));return!!(V.pattern||V.dateStyle||V.timeStyle||V.relative||V.timeZone||V.trueLabel||V.falseLabel||V.display||V.trueIcon||V.falseIcon||V.transform||V.truncate||V.emptyDisplay||I||V.currency||V.decimals!==void 0||V.minDecimals!==void 0||V.maxDecimals!==void 0||V.notation||V.negative||V.scale!==void 0||V.prefix||V.suffix||V.zeroDisplay!==void 0)}function p(V,I){if(V.type==="number"||V.type==="date"||V.type==="boolean"||V.type==="text")return V.type;if(V.pattern){if(s(V.pattern))return"number";if(i(V.pattern))return"date"}if(V.dateStyle||V.timeStyle||V.relative||V.timeZone)return"date";if(V.trueLabel||V.falseLabel||V.display||V.trueIcon||V.falseIcon)return"boolean";if(V.transform||V.truncate||V.emptyDisplay)return"text";if(V.style||V.currency||V.decimals!==void 0||V.minDecimals!==void 0||V.maxDecimals!==void 0||V.notation||V.negative||V.scale!==void 0||V.prefix||V.suffix||V.zeroDisplay!==void 0)return"number";const $=I&&I.base;return $==="number"?"number":$==="date"||$==="dateString"?"date":$==="boolean"?"boolean":"text"}function m(V,I=null,$=void 0,S=void 0,R=void 0){if(V==null||V==="")return null;const L=X(V)?Object.keys(V):null;if(typeof V=="function"){const C=(H,Y)=>String(V({...Y||{},value:H,locale:$})??"");return C.ooxml=I&&I.excel||"General",C}if(typeof V=="string"){if(s(V)){const{format:H,ooxml:Y}=a(V,$);return H.ooxml=Y,H}const C=t(V)||(i(V)?{type:"date",pattern:V}:null);return C?m(C,I,$,S,R):(D(`format:${V}`,`unrecognised format string "${V}"; the value will be stringified`),null)}if(!X(V))return D("format:shape","format must be a spec object or a string; ignoring",V),null;if(I&&N(I.format)&&!d(V)||I&&N(I.format)&&Array.isArray(I.formatPatterns)&&V.type===void 0)return null;const T=p(V,I);T==="date"&&S&&V.timeZone===void 0&&(V={...V,timeZone:S}),g(V,R),k(L||Object.keys(V),T,R);let A;switch(T){case"number":A=K(V,$);break;case"date":A=G(V,$);break;case"boolean":A=O(V,$);break;default:A=u(V,$);break}return A.ooxml=y(V,T,$,I),A.kind=T,A}const v={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 y(V,I,$=void 0,S=null){if(I==="date"){if(V.pattern){let C="";for(const H of z(V.pattern))C+=H.token?v[H.token]??H.text:H.text;return C}return S&&S.excel||"yyyy-mm-dd"}if(I==="boolean")return"General";if(I==="text")return"@";if(typeof V.pattern=="string"&&c(V.pattern))return String(V.pattern).trim();if(V.notation==="compact"||V.notation==="scientific")return"General";const R=typeof V.decimals=="number"?V.decimals:typeof V.minDecimals=="number"?V.minDecimals:V.style==="currency"?2:0;let T=`${V.thousandsSeparator===!1?"":"#,#"}#0${R>0?`.${"0".repeat(R)}`:""}`,A="";return V.style==="currency"&&(A+=E(F(V.currency||"USD",$))),V.prefix&&(A+=E(V.prefix)),T=A+T,V.style==="percent"&&(T=`${T}%`),V.suffix&&(T+=E(V.suffix)),V.negative==="parentheses"?`${T};(${T})`:V.negative==="suffix"?`${T};${T}-`:T}function E(V){return`"${String(V).split('"').join("")}"`}const M=new Map;function F(V,I){const $=`${V}|${I||""}`;let S=M.get($);if(S!==void 0)return S;S=V;try{const L=new Intl.NumberFormat(I,{style:"currency",currency:V}).formatToParts(0).find(T=>T.type==="currency");L&&(S=L.value)}catch{}return M.set($,S),S}}),Ie("packages/core/src/columns/types/temporal.js",function(e,U){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Ye}});const te=U("packages/core/src/internal/predicates.js"),N=te.isNil,X=te.isFunction,B=U("packages/core/src/format/date.js"),D=B.toDate,q=B.compilePattern,K=B.compileDate,x=B.toIsoDateTime,G=B.compareIso,z=864e5,j=Object.freeze({}),O=1e3,b=60*O,u=60*b,f=24*u,a=7*f,r=new WeakMap;function t(Oe,_e){const je=Oe&&Oe.locale||"",we=Oe&&Oe.column;if(!we)return je?{locale:je}:j;const He=r.get(we);if(He&&He.locale===je)return He.bag;const Ke=we.typeOptions||we[_e]||(s(we.format)?we.format:null),Xe={...Ke||j,locale:Ke&&Ke.locale||je||void 0};return r.set(we,{locale:je,bag:Xe}),Xe}function s(Oe){return Oe!==null&&typeof Oe=="object"&&!Array.isArray(Oe)&&!(Oe instanceof Date)}function i(Oe,_e){const je=Oe===null||Number.isNaN(Oe)?null:Oe,we=_e===null||Number.isNaN(_e)?null:_e;return je===null?we===null?0:1:we===null||je<we?-1:je>we?1:0}const n=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,c=/^(\d{3,6})$/;function o(Oe,_e,je,we){return!(Oe>=0&&Oe<=23)||!(_e>=0&&_e<=59)||!(je>=0&&je<=59)||!(we>=0&&we<=999)?null:Oe*u+_e*b+je*O+we}function l(Oe){if(N(Oe))return null;const _e=String(Oe).trim();if(_e==="")return null;const je=c.exec(_e);if(je){const wt=je[1];if(wt.length===5)return null;const pt=wt.length===3?1:2;return o(Number(wt.slice(0,pt)),Number(wt.slice(pt,pt+2)),Number(wt.slice(pt+2,pt+4)||0),0)}const we=n.exec(_e);if(!we)return null;let He=Number(we[1]);const Ke=Number(we[2]||0),Xe=Number(we[3]||0),nt=we[4]?Number(we[4].padEnd(3,"0")):0,it=we[5]?we[5][0].toLowerCase():null;if(it){if(He<1||He>12)return null;He=He%12,it==="p"&&(He+=12)}return o(He,Ke,Xe,nt)}function h(Oe){return N(Oe)||Oe===""?null:typeof Oe=="number"?Number.isFinite(Oe)?(Oe%f+f)%f:null:Oe instanceof Date?Number.isNaN(Oe.getTime())?null:Oe.getHours()*u+Oe.getMinutes()*b+Oe.getSeconds()*O+Oe.getMilliseconds():l(Oe)}const w=new Map;function g(Oe){const _e=Oe.pattern||"",je=Oe.timeStyle||(Oe.seconds?"medium":"short"),we=`${Oe.locale||""}|${_e}|${je}`;let He=w.get(we);if(He)return He;if(_e)He=q(_e,Oe.locale||void 0,"UTC");else{const Ke=new Intl.DateTimeFormat(Oe.locale||void 0,{timeStyle:je,timeZone:"UTC"});He=Xe=>Ke.format(Xe)}return w.set(we,He),He}function k(Oe,_e){const je=_e||j;if(Oe==null||typeof Oe!="number"||!Number.isFinite(Oe))return je.nullDisplay??"";const we=(Oe%f+f)%f;return g(je)(new Date(we))}function d(Oe){return Oe instanceof Date?!Number.isNaN(Oe.getTime()):typeof Oe=="number"?Number.isFinite(Oe)&&Oe>=0&&Oe<f:typeof Oe!="string"||!Oe.includes(":")?!1:l(Oe)!==null}function p(Oe){const _e=h(Oe);return _e==null?"":k(_e,{pattern:_e%O===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const m=new Map;function v(Oe){const _e=Oe||"";let je=m.get(_e);return je||(je=new Intl.DateTimeFormat("en-GB",{timeZone:Oe||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),m.set(_e,je)),je}function y(Oe,_e){const je={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const we of v(_e).formatToParts(new Date(Oe)))we.type==="year"?je.year=Number(we.value):we.type==="month"?je.month=Number(we.value):we.type==="day"?je.day=Number(we.value):we.type==="hour"?je.hour=Number(we.value)%24:we.type==="minute"?je.minute=Number(we.value):we.type==="second"&&(je.second=Number(we.value));return je}function E(Oe,_e){const je=y(Oe,_e);return Date.UTC(je.year,je.month-1,je.day,je.hour,je.minute,je.second,0)-Math.floor(Oe/1e3)*1e3}function M(Oe,_e){const je=Oe.hour||0,we=Oe.minute||0,He=Oe.second||0,Ke=Oe.ms||0;if(!_e)return new Date(Oe.year,Oe.month-1,Oe.day,je,we,He,Ke).getTime();const Xe=Date.UTC(Oe.year,Oe.month-1,Oe.day,je,we,He,Ke);let nt=Xe-E(Xe,_e);return nt=Xe-E(nt,_e),nt}const F=/(?:Z|[+-]\d{2}:?\d{2})$/i,V=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function I(Oe,_e){if(N(Oe))return null;const je=String(Oe).trim();if(je==="")return null;const we=_e&&_e.timeZone||void 0;if(!F.test(je)){const He=V.exec(je);if(He){const Ke=(He[4]||"").trim(),Xe=Ke===""?0:l(Ke);if(Xe===null)return null;const nt=M({year:Number(He[1]),month:Number(He[2]),day:Number(He[3]),hour:Math.floor(Xe/u),minute:Math.floor(Xe/b)%60,second:Math.floor(Xe/O)%60,ms:Xe%O},we);return Number.isNaN(nt)?null:new Date(nt)}}return D(je)}function $(Oe){if(typeof Oe=="number")return Number.isFinite(Oe)?Oe:null;const _e=D(Oe);return _e?_e.getTime():null}const S=new Map;function R(Oe){const _e=[Oe.locale||"",Oe.pattern||"",Oe.dateStyle||"",Oe.timeStyle||"",Oe.timeZone||"",Oe.seconds?"1":""].join("|");let je=S.get(_e);if(je)return je;const we=Oe.pattern?{type:"date",pattern:Oe.pattern,timeZone:Oe.timeZone}:{type:"date",dateStyle:Oe.dateStyle||"medium",timeStyle:Oe.timeStyle||(Oe.seconds?"medium":"short"),timeZone:Oe.timeZone};return je=K(we,Oe.locale||void 0),S.set(_e,je),je}function L(Oe,_e){const je=_e||j,we=$(Oe);return we==null?je.nullDisplay??"":R(je)(we)}function T(Oe){return Oe instanceof Date?!Number.isNaN(Oe.getTime()):typeof Oe!="string"||!V.test(Oe.trim())?!1:I(Oe)!==null}const A=Object.freeze([{key:"w",ms:a,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:f,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:u,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:b,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:O,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),C=new Map;for(const Oe of A)for(const _e of Oe.names)C.set(_e,Oe);const H=Object.freeze(A.filter(Oe=>Oe.key!=="w")),Y=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,Z=/^\d+(?:\.\d+)?$/,_=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function J(Oe){const _e=Oe&&Oe.defaultUnit?C.get(String(Oe.defaultUnit).toLowerCase()):null;return _e?_e.ms:b}function ee(Oe){return(Oe&&Oe.defaultUnit?C.get(String(Oe.defaultUnit).toLowerCase()):null)||C.get("m")}function ne(Oe,_e){if(N(Oe))return null;let je=String(Oe).trim().toLowerCase();if(je==="")return null;let we=1;if(je[0]==="-"?(we=-1,je=je.slice(1).trim()):je[0]==="+"&&(je=je.slice(1).trim()),je==="")return null;const He=_.exec(je);if(He){const it=He[3]!==void 0,wt=Number(He[1])*u+Number(He[2])*b+(it?Number(He[3])*O:0)+(He[4]?Number(He[4].padEnd(3,"0")):0);return we*wt}if(Z.test(je))return Math.round(we*Number(je)*J(_e||j));let Ke=je,Xe=0,nt=0;for(;Ke!=="";){const it=Y.exec(Ke);if(!it)return null;const wt=C.get(it[2]);if(!wt)return null;Xe+=Number(it[1])*wt.ms,Ke=Ke.slice(it[0].length),nt++}return nt===0?null:Math.round(we*Xe)}function se(Oe){return N(Oe)||Oe===""?null:typeof Oe=="number"?Number.isFinite(Oe)?Oe:null:ne(Oe)}const oe=new Map;function fe(Oe,_e,je){const we=`${je||""}|${_e.intl}`;let He=oe.get(we);if(He===void 0){try{He=new Intl.NumberFormat(je||void 0,{style:"unit",unit:_e.intl,unitDisplay:"long"})}catch{He=null}oe.set(we,He)}return He?He.format(Oe):`${Oe} ${Oe===1?_e.long[0]:_e.long[1]}`}function pe(Oe,_e){return String(Oe).padStart(_e,"0")}function he(Oe,_e){const je=_e||j;if(Oe==null||typeof Oe!="number"||!Number.isFinite(Oe))return je.nullDisplay??"";const we=je.style||"short",He=Oe<0;let Ke=Math.round(Math.abs(Oe));const Xe=He?"-":"";if(Ke===0&&je.zeroDisplay!=null)return je.zeroDisplay;if(we==="clock"){const pt=Math.floor(Ke/u),St=Math.floor(Ke/b)%60,Ct=Math.floor(Ke/O)%60;return`${Xe}${pe(pt,2)}:${pe(St,2)}:${pe(Ct,2)}`}if(Ke===0){const pt=ee(je);return we==="long"?fe(0,pt,je.locale):`0${pt.key}`}const nt=je.weeks===!0?A:H,it=typeof je.maxUnits=="number"&&je.maxUnits>0?je.maxUnits:je.maxUnits===void 0?2:1/0,wt=[];for(const pt of nt){if(wt.length>=it)break;const St=Math.floor(Ke/pt.ms);St!==0&&(Ke-=St*pt.ms,wt.push(we==="long"?fe(St,pt,je.locale):`${St}${pt.key}`))}return Xe+wt.join(" ")}function Re(Oe){if(typeof Oe!="string")return!1;const _e=Oe.trim();return _e===""||_.test(_e)||!/[a-z]/i.test(_e)?!1:ne(_e)!==null}const Ue=Date.UTC(1899,11,30),Le=new Map;function ie(Oe,_e){const je=Oe||"";let we=Le.get(je);we||(we=new Intl.DateTimeFormat("en-GB",{timeZone:Oe||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),Le.set(je,we));const He=typeof _e=="number"?_e:Date.now();for(const Ke of we.formatToParts(new Date(He)))if(Ke.type==="timeZoneName")return Ke.value;return""}function ge(Oe){if(Oe)return Oe;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function ke(Oe,_e){const je=ge(Oe),we=ie(Oe,_e);return we?`${je} (${we})`:je}function Se(Oe,_e){if(Oe&&Oe.timeZone)return Oe.timeZone;const je=_e&&_e.grid;return(je&&X(je.get)?je.get("timeZone"):void 0)||void 0}function Ae(Oe,_e){const je=_e||j,we=$(Oe);if(we==null)return je.nullDisplay??"";const He=R(je)(we);if(!je.showOrigin)return He;const Ke=je.originZone;return Ke?Ke===(je.timeZone||ge(je.timeZone))?He:`${He} (${ke(Ke,we)})`:`${He} (no origin recorded)`}function xe(Oe,_e,je,we){if(_e==="instant"||!_e)return Oe;const He=y(Oe,je);if(_e==="month")return M({year:He.year,month:He.month,day:1},je);if(_e==="week"){const Ke=we>=1&&we<=7?we:1,nt=((new Date(Date.UTC(He.year,He.month-1,He.day)).getUTCDay()+6)%7+1-Ke+7)%7,it=new Date(Date.UTC(He.year,He.month-1,He.day-nt));return M({year:it.getUTCFullYear(),month:it.getUTCMonth()+1,day:it.getUTCDate()},je)}return M({year:He.year,month:He.month,day:He.day},je)}function me(Oe,_e){const je=Oe&&Oe.group,we=je&&je.granularity||"day";if(we==="instant")return null;const He=je&&je.weekStart;return Ke=>typeof Ke=="number"?xe(Ke,we,_e,He):Ke}const ye={time:{base:"number",storage:"float64",matches:d,format:Oe=>k(h(Oe.value),t(Oe,"time")),parse:Oe=>l(Oe.text),compare:(Oe,_e)=>i(h(Oe),h(_e)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Oe=>{const _e=h(Oe);return _e===null?null:_e/z},toStorage:Oe=>h(Oe),toClipboard:p,fromClipboard:l},datetime:{base:"dateString",storage:"dictionary",matches:T,format:Oe=>L(Oe.value,t(Oe,"datetime")),parse:Oe=>x(I(Oe.text,t(Oe,"datetime"))??Oe.text),compare:G,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Oe,_e)=>x(Oe,_e&&_e.timeZone),toClipboard:Oe=>N(Oe)?"":String(Oe),fromClipboard:Oe=>x(Oe)},duration:{base:"number",storage:"float64",matches:Re,format:Oe=>he(se(Oe.value),t(Oe,"duration")),parse:Oe=>ne(Oe.text,t(Oe,"duration")),compare:(Oe,_e)=>i(se(Oe),se(_e)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Oe=>{const _e=se(Oe);return _e===null?null:_e/z},toStorage:Oe=>se(Oe),toClipboard:Oe=>he(se(Oe),{style:"short",maxUnits:-1}),fromClipboard:Oe=>ne(Oe)},timestamp:{base:"number",storage:"float64",format:Oe=>{const _e=t(Oe,"timestamp");return Ae(Oe.value,{..._e,timeZone:Se(_e,Oe)})},parse:Oe=>{const _e=t(Oe,"timestamp"),je=I(Oe.text,{timeZone:Se(_e,Oe)});return je?je.getTime():null},compare:(Oe,_e)=>i($(Oe),$(_e)),groupProjector:(Oe,_e)=>me(Oe,_e),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Oe,_e)=>{const je=$(Oe);if(je==null)return null;const we=y(je,_e&&_e.timeZone||void 0);return(Date.UTC(we.year,we.month-1,we.day,we.hour,we.minute,we.second)-Ue)/z},toStorage:Oe=>$(Oe),toClipboard:Oe=>{const _e=$(Oe);return _e==null?"":new Date(_e).toISOString()},fromClipboard:Oe=>$(Oe)}},Te=["datetime","time","duration"],Ye=ye}),Ie("packages/core/src/internal/lru.js",function(e,U){"use strict";Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return te}});class te{#e;#t=new Map;#n;constructor(X=256,B=null){this.#e=X,this.#n=B}get size(){return this.#t.size}get max(){return this.#e}set max(X){this.#e=X,this.#r()}has(X){return this.#t.has(X)}get(X){const B=this.#t;if(!B.has(X))return;const D=B.get(X);return B.delete(X),B.set(X,D),D}peek(X){return this.#t.get(X)}set(X,B){const D=this.#t;return D.has(X)&&D.delete(X),D.set(X,B),this.#r(),B}delete(X){const B=this.#t.get(X);return this.#t.delete(X)&&this.#n&&this.#n(B,X),B}clear(){if(this.#n)for(const[X,B]of this.#t)this.#n(B,X);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const X=this.#t;for(;X.size>this.#e;){const B=X.keys().next().value,D=X.get(B);X.delete(B),this.#n&&this.#n(D,B)}}}}),Ie("packages/core/src/columns/types/network.js",function(e,U){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/internal/lru.js").Lru,D=4294967295,q=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function K(S){if(N(S))return null;if(typeof S=="string")return x(S);const R=Number(S);return Number.isFinite(R)?R<0?R<-2147483648?null:R>>>0:R>D?null:Math.trunc(R)>>>0:null}function x(S){if(N(S))return null;const R=String(S).trim();if(R==="")return null;const L=q.exec(R);if(!L)return null;let T=0;for(let A=1;A<=4;A++){const C=L[A];if(C.length>1&&C.charCodeAt(0)===48)return null;const H=Number(C);if(H>255)return null;T=T*256+H}return T}function G(S){const R=K(S);return R===null?"":`${R>>>24&255}.${R>>>16&255}.${R>>>8&255}.${R&255}`}function z(S){return typeof S=="string"&&x(S)!==null}function j(S,R){const L=K(S),T=K(R);return L===null?T===null?0:1:T===null||L<T?-1:L>T?1:0}const O=64,b=D*O+32,u=/^(?:0|[1-9]\d?)$/;function f(S,R){return S*O+R}function a(S){if(N(S))return null;if(typeof S=="string"){const T=r(S);return T===null?null:a(T)}if(typeof S=="object"){const T=K(S.address),A=Number(S.prefix);return T===null||!Number.isInteger(A)||A<0||A>32?null:{address:T,prefix:A}}const R=Number(S);if(!Number.isInteger(R)||R<0||R>b)return null;const L=R%O;return L>32?null:{address:(R-L)/O,prefix:L}}function r(S){if(N(S))return null;const R=String(S).trim();if(R==="")return null;const L=R.indexOf("/");if(L<0)return null;const T=x(R.slice(0,L));if(T===null)return null;const A=R.slice(L+1).trim();if(!u.test(A))return null;const C=Number(A);return C>32?null:f(T,C)}function t(S){const R=a(S);return R?`${G(R.address)}/${R.prefix}`:""}function s(S){return typeof S=="string"&&r(S)!==null}function i(S,R){const L=a(S),T=a(R);return L?T?L.address!==T.address?L.address<T.address?-1:1:L.prefix-T.prefix:-1:T?1:0}function n(S){return S===0?0:4294967295<<32-S>>>0}function c(S){const R=a(S);return R?(R.address&n(R.prefix))>>>0:null}function o(S){const R=a(S);return R?(R.address&n(R.prefix)|~n(R.prefix)>>>0)>>>0:null}function l(S){const R=a(S);return R?2**(32-R.prefix):null}function h(S){const R=a(S);return R?R.prefix===32?1:R.prefix===31?2:2**(32-R.prefix)-2:null}function w(S,R){const L=a(S);if(!L)return!1;const T=K(R);if(T===null)return!1;const A=n(L.prefix);return(T&A)>>>0===(L.address&A)>>>0}function g(S,R){const L=c(S),T=c(R);return L===null||T===null?!1:L<=o(R)&&T<=o(S)}const k=/^[0-9a-fA-F]{1,4}$/,d=new B(512);function p(S){if(N(S))return null;let R=String(S).trim();if(R==="")return null;const L=R.indexOf("%");if(L>=0&&(R=R.slice(0,L)),R==="")return null;if(R.indexOf(".")>=0){const Z=R.lastIndexOf(":");if(Z<0)return null;const _=x(R.slice(Z+1));if(_===null)return null;R=`${R.slice(0,Z+1)}${(_>>>16&65535).toString(16)}:${(_&65535).toString(16)}`}const T=R.split("::");if(T.length>2)return null;const A=m(T[0]);if(A===null)return null;if(T.length===1)return A.length===8?A:null;const C=m(T[1]);if(C===null)return null;const H=8-A.length-C.length;if(H<1)return null;const Y=A.slice();for(let Z=0;Z<H;Z++)Y.push(0);for(const Z of C)Y.push(Z);return Y}function m(S){if(S==="")return[];const R=[];for(const L of S.split(":")){if(!k.test(L))return null;R.push(parseInt(L,16))}return R}function v(S){if(typeof S!="string")return p(S);if(d.has(S))return d.get(S);const R=p(S);return d.set(S,R),R}function y(S){if(S[0]===0&&S[1]===0&&S[2]===0&&S[3]===0&&S[4]===0&&S[5]===65535)return`::ffff:${G((S[6]<<16|S[7])>>>0)}`;let R=-1,L=0,T=-1,A=0;for(let Y=0;Y<8;Y++)S[Y]===0?(T<0?(T=Y,A=1):A++,A>L&&(L=A,R=T)):(T=-1,A=0);if(L<2)return S.map(Y=>Y.toString(16)).join(":");const C=S.slice(0,R).map(Y=>Y.toString(16)).join(":"),H=S.slice(R+L).map(Y=>Y.toString(16)).join(":");return`${C}::${H}`}function E(S){const R=p(S);return R===null?null:y(R)}function M(S){return E(S)??""}function F(S){return typeof S=="string"&&S.indexOf(":")>=0&&p(S)!==null}function V(S,R){const L=v(S),T=v(R);if(!L)return T?1:0;if(!T)return-1;for(let A=0;A<8;A++)if(L[A]!==T[A])return L[A]<T[A]?-1:1;return 0}const I=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:z,parse:S=>x(S.text),compare:j,format:S=>G(S.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:S=>K(S),toClipboard:S=>G(S),fromClipboard:S=>x(S)},cidr:{base:"number",storage:"float64",matches:s,parse:S=>r(S.text),compare:i,format:S=>t(S.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:S=>{const R=a(S);return R===null?null:f(R.address,R.prefix)},toClipboard:S=>t(S),fromClipboard:S=>r(S)},ipv6:{base:"text",storage:"dictionary",matches:F,parse:S=>E(S.text),compare:V,format:S=>M(S.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:S=>E(S),toClipboard:S=>M(S),fromClipboard:S=>E(S)}}),$=I}),Ie("packages/core/src/i18n/catalogue.js",function(e,U){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return B}});const N=U("packages/core/src/registry/free-tier-notice.js").FREE_TIER_NOTICE,X=Object.freeze({"count.rows":{one:"{count} row",other:"{count} rows"},"count.comments":{one:"{count} comment",other:"{count} comments"},"comments.someUnresolved":"{comments}, {unresolved} unresolved","comments.allResolved":"{comments}, all resolved","count.unresolvedComments":{one:"{count} unresolved comment",other:"{count} unresolved comments"},"count.items":{one:"{count} item",other:"{count} items"},"count.keys":{one:"{count} key",other:"{count} keys"},"count.values":{one:"value",other:"values"},"count.waiting":{one:"{count} waiting",other:"{count} waiting"},"count.rowsAdded":{one:"{count} row added",other:"{count} rows added"},"count.rowsRemoved":{one:"{count} row removed",other:"{count} rows removed"},"value.empty":"empty","a11y.sort.cleared":"Sort cleared","a11y.sort.by":"Sorted by {columns}","a11y.sort.column":"{column} {direction}","a11y.sort.ascending":"ascending","a11y.sort.descending":"descending","a11y.filter.cleared":"Filter cleared, {rows}","a11y.filter.applied":"Filtered to {shown} of {total}","a11y.find.count":{one:"{current} of {count} match",other:"{current} of {count} matches"},"a11y.find.countLoaded":{one:"{current} of {count} match in loaded rows",other:"{current} of {count} matches in loaded rows"},"a11y.find.none":"No matches","a11y.find.noneLoaded":"No matches in loaded rows","a11y.selection.cleared":"Selection cleared","a11y.selection.count":{one:"{count} row selected",other:"{count} rows selected"},"tabs.tablist":"Tabs","a11y.tabs.selected":"{label} tab selected","a11y.scrollbar.horizontal":"Horizontal scrollbar","a11y.scrollbar.vertical":"Vertical scrollbar","designer.canvas":"Dashboard canvas","designer.chrome":"Designer tools","designer.page":"Page {n}","a11y.designer.edit":"Edit mode","a11y.designer.view":"View mode","layout.region":"Dashboard layout","layout.move":"Move {title}","layout.resize":"Resize {title}","layout.close":"Close {title}","a11y.layout.grabbed":"{title} grabbed, column {x} of {columns}, row {y}","a11y.layout.position":"{title}, column {x} of {columns}, row {y}","a11y.layout.dropped":"{title} dropped, column {x} of {columns}, row {y}","a11y.layout.cancelled":"{title} move cancelled","a11y.layout.resizeCancelled":"{title} resize cancelled","a11y.layout.reverted":"{title} returned to column {x}, row {y}","a11y.layout.resizeGrabbed":"{title} resize grabbed, {w} by {h} cells","a11y.layout.resizeStep":"{title}, {w} by {h} cells","a11y.layout.resized":"{title} resized to {w} by {h} cells","a11y.layout.closed":"{title} closed","layout.maximise":"Maximise {title}","layout.minimise":"Minimise {title}","layout.restore":"Restore {title}","a11y.layout.maximised":"{title} maximised, filling the dashboard; press Escape to restore it","a11y.layout.minimised":"{title} minimised","a11y.layout.restored":"{title} restored to column {x}, row {y}","a11y.group.cleared":"Grouping cleared","a11y.group.by":"Grouped by {columns}","a11y.group.expanded":"{label} expanded, {rows} shown","a11y.group.collapsed":"{label} collapsed, {rows} shown","a11y.page.position":"Page {page} of {pages}","a11y.updates.paused":"Updates paused","a11y.updates.resumed":"Updates resumed","a11y.edit.refusedOne":"Edit to {column} was refused and put back to {value}{reason}","a11y.edit.refusedMany":{one:"{count} edit was refused and put back{reason}",other:"{count} edits were refused and put back{reason}"},"a11y.edit.reason":", {reason}","a11y.history.undo":"Undid {label}","a11y.history.redo":"Redid {label}","a11y.history.undoLast":"Undid the last change","a11y.history.redoLast":"Redid the last change","a11y.column.cannotResize":"{column} cannot be resized","a11y.column.resized":"{column} is {width} pixels wide","a11y.column.atMinimum":"{column} is at its narrowest, {width} pixels","a11y.column.atMaximum":"{column} is at its widest, {width} pixels","a11y.column.cannotMove":"{column} cannot be moved","a11y.column.alreadyFirst":"{column} is already first in its group","a11y.column.alreadyLast":"{column} is already last in its group","a11y.column.cannotMoveThere":"{column} cannot be moved there","a11y.column.moved":"{column} moved to position {at} of {of}","a11y.group.formed":"{column} grouped with {other} in a new band","a11y.group.dissolved":"band {group} dissolved","a11y.group.renamed":"band renamed to {group}","a11y.group.moved":"band {group} moved to position {at} of {of}","a11y.column.addedToGroup":"{column} added to band {group}","a11y.column.removedFromGroup":"{column} removed from its band","a11y.column.notInGroup":"{column} is not in a band","a11y.column.cannotGroup":"{column} cannot be grouped","a11y.group.cannotMove":"band {group} cannot be moved there","columngroup.newGroup":"New group","columngroup.rename":"Rename band","columngroup.dissolve":"Dissolve band","columngroup.group":"Group with adjacent column","columngroup.untitled":"Untitled band","panel.bandCollapse":"Collapse band {band}","panel.bandExpand":"Expand band {band}","panel.bandVisible":"Show or hide every column in band {band}","panel.bandRenameFor":"Rename band {band}","panel.bandDissolveFor":"Dissolve band {band}","header.filter":"Filter {column}","header.menu":"Column menu for {column}","header.toggleGroup":"Toggle {group}","header.dragHint":"Drag {column} to reorder, or onto another column to group","header.dragRole":"draggable column header","header.group":"group","header.selectAllRows":"Select all rows","header.clearSelection":"Clear selection","cell.selectRow":"Select row","cell.detail.show":"Show detail","cell.detail.hide":"Hide detail","cell.detail.showInPane":"Show in the detail pane","cell.detail.showingInPane":"Showing in the detail pane","cell.group.expand":"Expand","cell.group.collapse":"Collapse","cell.delta.up":"up","cell.delta.down":"down","cell.delta.unchanged":"unchanged","cell.delta.moved":"{direction} {magnitude}","cell.delta.describedUnchanged":"{label}, unchanged","cell.delta.described":"{label}, {direction} by {magnitude}","cell.qr.of":"QR code for {text}","cell.qr.empty":"No QR code","cell.barcode.of":"Barcode for {text}","cell.barcode.empty":"No barcode","cell.barcode.invalid":"Invalid value for this barcode","cell.rating.of":"{rating} of {max}","cell.rating.empty":"Not rated","cell.stage.of":"Stage {current} of {total}: {label}","cell.stage.empty":"No stage","a11y.panel.cannotMove":"{column} cannot be moved","a11y.panel.alreadyFirst":"{column} is already first","a11y.panel.alreadyLast":"{column} is already last","a11y.panel.moved":"{column} moved to position {at} of {of}","a11y.panel.removedFrom":"{column} removed from {list}","a11y.panel.addedTo":"{column} added to {list}","a11y.panel.cannotAddTo":"{column} cannot be added to {list}","a11y.annotate.erased":"Annotation removed","a11y.annotate.noMarks":"No annotations to erase","a11y.annotate.focusedMark":"Mark {at} of {of} selected","a11y.annotate.confirmClear":"Clear all annotations? Choose Clear or Keep.","a11y.annotate.cleared":"All annotations cleared","a11y.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"a11y.range.cleared":{one:"{count} cell cleared",other:"{count} cells cleared"},"paste.preview.title":"Review paste","paste.preview.summary":{one:"{changes} cell will change, {rejected} rejected.",other:"{changes} cells will change, {rejected} rejected."},"paste.preview.changesHeading":{one:"{count} change",other:"{count} changes"},"paste.preview.rejectedHeading":{one:"{count} rejected",other:"{count} rejected"},"paste.preview.colOld":"Current","paste.preview.colNew":"New","paste.preview.colCell":"Cell","paste.preview.colReason":"Reason","paste.preview.empty":"This paste would change nothing.","paste.preview.confirm":"Apply","paste.preview.cancel":"Cancel","paste.preview.reason.permission":"Not permitted","paste.preview.reason.readOnly":"Read-only","paste.preview.reason.validation":"Invalid value","paste.preview.reason.locked":"Being edited","paste.preview.reason.missing":"No such cell","a11y.paste.previewOpened":{one:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel.",other:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel."},"a11y.paste.cancelled":"Paste cancelled; nothing changed","status.total":"{rows}","status.counting":"Counting rows…","status.shownOfTotal":"{shown} of {total}","status.selected":"{count} selected","status.selectedAcrossSource":"{count} selected across the source","status.selectedAcrossSourceCounting":"All matching rows selected, counting…","status.count":"Count {count}","status.loading":"Loading {count}…","status.loadingOf":"Loading {loaded} of {total} ({percent}%)","status.stat.sum":"Sum","status.stat.min":"Min","status.stat.max":"Max","status.stat.avg":"Avg","status.paused":"Paused","status.pausedWaiting":"Paused · {waiting}","status.coalesced":"{count} coalesced","status.hiddenComments":"{comments} on hidden rows","pagination.label":"Pagination","pagination.first":"First page","pagination.previous":"Previous page","pagination.next":"Next page","pagination.last":"Last page","pagination.page":"Page","pagination.ofPages":"of {pages}","pagination.summary":"{from}–{to} of {total}","pagination.pageSize":"Rows per page","pagination.range":"{from}–{to}","pagination.counting":"{from}–{to}, counting…","pagination.jump":"Page number, press Enter to jump","pagination.jumpBounded":"Page number, 1 to {pages}, press Enter to jump","panel.columns":"Columns","panel.filters":"Filters","panel.views":"Views","panel.quickFilter":"Quick filter","find.label":"Find in grid","find.placeholder":"Find in grid","find.next":"Next match","find.previous":"Previous match","find.close":"Close find","find.matchCase":"Match case","find.wholeCell":"Whole cell","find.columnScope":"Search in","find.allColumns":"All columns","find.count":"{current} of {total}","find.countPartial":"{current} of {total} so far","find.none":"No matches","find.searching":"Searching…","find.loadedRows":"in loaded rows","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","insights.subset":"Filtered subset vs whole","insights.dataset":"This grid vs another dataset","insights.groups":"Group comparison","insights.noFilter":"Filter the grid to compare the subset against the whole.","insights.by":"Group by","insights.test":"Test","insights.effect":"Effect size","insights.interval":"Confidence interval","insights.pValue":"p-value","insights.smallSample":"small sample — interpret with care","insights.needGroups":"Choose two columns with groups to compare.","insights.empty":"No columns to analyse.","insights.anomalies":"Anomalies","insights.anomalyCount":"{count} flagged of {n}","insights.anomalyMethod":"Method","insights.anomalyThreshold":"Threshold","anomaly.chip":"{count} anomalies flagged","anomaly.chipActive":"Showing {count} anomalies — clear","compare.first":"First column","compare.second":"Second column","compare.needTwo":"Two numeric columns are needed to compare","compare.noPairs":"No rows have a value in both","compare.pairs":"{count} pairs","compare.pearson":"Correlation (Pearson)","compare.spearman":"Rank correlation (Spearman)","compare.kendall":"Kendall’s tau","compare.covariance":"Covariance","compare.slope":"Slope","compare.intercept":"Intercept","compare.r2":"R²","compare.stdError":"Standard error","compare.weighted":"Weighted average","panel.zone.group":"row groups","panel.zone.values":"values","panel.zone.pivot":"pivot columns","groupZone.label":"Row groups","groupZone.title":"Group by","groupZone.hint":"Drag a column here to group rows by its values","groupZone.chip":"{column}, group {at} of {of}","groupZone.remove":"Stop grouping by {column}","groupZone.add":"Add a group","total.sum":"Sum","total.avg":"Average","total.min":"Min","total.max":"Max","total.count":"Count","total.countValues":"Count of values","total.first":"First","total.last":"Last","total.custom":"Total","total.median":"Median","total.p25":"25th percentile","total.p75":"75th percentile","total.p90":"90th percentile","total.p95":"95th percentile","total.p99":"99th percentile","total.iqr":"Interquartile range","total.mad":"Median absolute deviation","total.variance":"Variance","total.varianceP":"Variance (population)","total.stddev":"Standard deviation","total.stddevP":"Standard deviation (population)","total.range":"Range","total.distinct":"Distinct","total.mode":"Mode","total.skewness":"Skewness","total.kurtosis":"Kurtosis","total.geomean":"Geometric mean","total.harmean":"Harmonic mean","total.sumSquares":"Sum of squares","total.weightedAvg":"Weighted average","total.argmin":"Lowest by","total.argmax":"Highest by","total.hhi":"Concentration (HHI)","total.entropy":"Entropy","total.evenness":"Evenness","total.top3Share":"Top 3 share","total.top10Share":"Top 10 share","total.gini":"Gini coefficient","total.trimmedMean":"Trimmed mean","total.winsorizedMean":"Winsorized mean","total.robustOutliers":"Outliers (robust)","total.jarqueBera":"Jarque–Bera","total.passRate":"Pass rate","total.failureCount":"Failures","stats.column":"Column","stats.choose":"Choose a column to profile","stats.noColumns":"No numeric columns to profile","stats.noValues":"Nothing numeric in this column","stats.count":"Count","stats.present":"Present","stats.missing":"Missing","stats.distinct":"Distinct","stats.min":"Minimum","stats.max":"Maximum","stats.mean":"Mean","stats.median":"Median","stats.q1":"Lower quartile","stats.q3":"Upper quartile","stats.iqr":"Interquartile range","stats.stddev":"Standard deviation","stats.outliers":"Outliers","stats.distribution":"Distribution","stats.distribution.detail":"Distribution: rows per range","stats.bin":"{count} between {from} and {to}","stats.topValues":"Top values","stats.section.shape":"Shape","stats.section.robust":"Robust","stats.section.concentration":"Concentration","stats.section.capability":"Capability","stats.cp":"Cp","stats.cpk":"Cpk","stats.pp":"Pp","stats.ppk":"Ppk","stats.outOfSpec":"Out of specification","stats.filtered":"Over the {count} filtered rows","stats.unavailable":"Not computed by the source: {stats}.","stats.unavailable.notPlain":"`{column}` is not a plain column the engine can name","stats.unavailable.where":"a `where` predicate is in force ({list}), which only the browser can run","stats.unavailable.filter":"the grid's filter did not fully push to the engine","stats.unavailable.quick":"the quick search did not push to the engine","stats.unavailable.client":'the source did not compute "{fn}" in the engine ({reason}); set the pushdown source\'s `{setting}`',"stats.unavailable.outliers":"the count of values outside Tukey's fences is not an engine aggregate","stats.unavailable.histogram":"the shape of the column is not an engine aggregate","stats.unavailable.topValues":"the source did not answer a grouped count in the engine","regression.noModel":"No model configured. Set predictors and a response on the panel.","regression.cannotFit":"The model cannot be fitted over the current rows.","regression.observations":"Fitted over {count} rows","regression.r2":"R²","regression.adjR2":"Adjusted R²","regression.coefficients":"Coefficients","regression.term":"Term","regression.estimate":"Estimate ± SE","regression.stdError":"Std error","regression.t":"t","regression.p":"p","regression.vif":"Variance inflation (VIF)","regression.heteroscedasticity":"Heteroscedasticity (Breusch–Pagan)","regression.heteroscedastic":"Heteroscedastic: BP {statistic}, p {p}","regression.homoscedastic":"No heteroscedasticity detected: BP {statistic}, p {p}","menu.sortAscending":"Sort ascending","menu.sortDescending":"Sort descending","menu.clearSort":"Clear sort","menu.groupBy":"Group by this column","menu.ungroup":"Stop grouping by this column","menu.hideColumn":"Hide column","menu.pinStart":"Pin to start","menu.pinEnd":"Pin to end","menu.unpin":"Unpin","menu.autosize":"Fit to content","ai.valuesNotAmongOptions":'{values} {shown} not among the options for "{column}"',"menu.clearCells":{one:"Clear cell",other:"Clear {count} cells"},"menu.fillDown":"Fill down","menu.copy":"Copy","menu.copyWithHeaders":"Copy with headers","menu.paste":"Paste","menu.filterEllipsis":"Filter…","menu.columnStatistics":"Column statistics","menu.pinColumn":"Pin column","menu.sizeToFit":"Size to fit content","menu.sizeAllToFit":"Size all columns to fit","menu.width":"Width","menu.narrower":"Narrower","menu.wider":"Wider","menu.moveColumn":"Move column","menu.moveLeft":"Move left","menu.moveRight":"Move right","menu.moveToStart":"Move to start","menu.moveToEnd":"Move to end","menu.unpivot":"Remove from pivot","menu.pivotBy":"Pivot by this column","menu.stopTotalling":"Stop totalling","menu.totalColumn":"Total this column","menu.aggregate":"Aggregate","menu.aggregateNone":"None","menu.aggregateGroup":"Group subtotals","menu.aggregateGrand":"Grand total","menu.aggregateSame":"Same as total","menu.redactColumn":"Redact column","menu.stopRedacting":"Stop redacting","menu.stopRedactingAll":"Stop redacting everything","menu.sortGroupsAscending":"Sort groups ascending","menu.sortGroupsDescending":"Sort groups descending","menu.filterGroups":"Filter groups…","menu.expandAll":"Expand all","menu.collapseAll":"Collapse all","menu.clearGrouping":"Clear grouping","menu.colour":"Colour","menu.importCsv":"Import rows from CSV…","import.title":"Import rows","import.clipboard":"the clipboard","import.summary":{one:"{count} row from {name}",other:"{count} rows from {name}"},"import.opened":{one:"Import preview open, {count} row",other:"Import preview open, {count} rows"},"import.done":{one:"{count} row imported",other:"{count} rows imported"},"import.confirm":"Import","import.cancel":"Cancel","import.colSource":"Column","import.colField":"Maps to","import.colType":"Type","import.skip":"— skip —","import.mapLabel":'Map "{source}" to a field',"import.modeLabel":"On import","import.sheetLabel":"Sheet","import.append":"Add to existing rows","import.replace":"Replace all rows","menu.deleteRow":{one:"Delete row",other:"Delete {count} rows"},"toolbar.undo":"Undo","toolbar.redo":"Redo","toolbar.undoLabelled":"Undo {label}","toolbar.redoLabelled":"Redo {label}","toolbar.exportCsv":"Export to CSV","toolbar.exportExcel":"Export to Excel","toolbar.clipboard":"Copy visible rows to the clipboard","toolbar.print":"Print","toolbar.pause":"Hold incoming updates","toolbar.resume":"Resume updates","toolbar.applyHeld":{one:"Apply {count} held update",other:"Apply {count} held updates"},"toolbar.restoreView":"Restore the default view","toolbar.maximiseGrid":"Maximise the grid to fill the window","toolbar.restoreSize":"Restore the grid to the page (Esc)","toolbar.annotate.pen":"Draw freehand","toolbar.annotate.arrow":"Draw an arrow","toolbar.annotate.rect":"Draw a rectangle","toolbar.annotate.highlight":"Highlight","toolbar.annotate.erase":"Erase","toolbar.annotate.clearAll":"Clear all annotations","toolbar.annotate.clearAllConfirm":"Clear","toolbar.annotate.clearAllKeep":"Keep","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","overlay.loadingRows":"Loading rows {from} to {to}","overlay.rowError":"Failed to load","comments.panel":"Cell comments","comments.close":"Close comments","comments.write":"Write a comment","comments.post":"Comment","comments.delete":"Delete","comments.valueMoved":"Written when the value was {was}: it is now {now}.","comments.resolve":"Resolve","comments.reopen":"Reopen","comments.loading":"Loading…","comments.empty":"No comments yet.","comments.unknownAuthor":"Unknown","comments.edited":"{time} (edited)","comments.cellTitle":"{column}: {row}","presence.hidden":{one:"{count} not in view",other:"{count} not in view"},"presence.someoneElse":"someone else","a11y.presence.refused":"This cell is being edited by {name}","presence.peer":"{name}: jump to their cursor","presence.peerIdle":"{name}, idle: jump to their cursor","presence.peerHidden":"{name}, not in the current view","facets.filter":"{column} distribution filter","header.totalOf":"{total} of {column}","diff.before":"Was: {value}","diff.empty":"(empty)","kanban.columnCards":{one:"{title}, {count} card",other:"{title}, {count} cards"},"kanban.laneCards":{one:"{lane}, {title}, {count} card",other:"{lane}, {title}, {count} cards"},"kanban.blocked":"Blocked","kanban.ready":"Ready","kanban.blockedBy":{one:"blocked by {count} card",other:"blocked by {count} cards"},"kanban.card.assignedTo":"Assigned to {names}","kanban.card.overdue":"Overdue","kanban.card.dueSoon":"Due soon","kanban.card.progress":"{percent}% complete","kanban.card.checklist":"{done} of {total} done","gantt.lag":"+{days}d","gantt.lead":"{days}d","gantt.a11y.moved":"{name} moved to {date}","gantt.a11y.day":"day {day}","gantt.a11y.resized":"{name} resized to {days} days","gantt.a11y.linkFrom":"Linking from {name}. Focus the successor and press L.","gantt.a11y.linked":"Linked {from} to {to}, finish to start.","gantt.a11y.linkCancelled":"Link cancelled.","gantt.a11y.deleted":"{name} deleted.","gantt.a11y.readOnly":"Read-only.","gantt.row.moveHandle":"Drag to reorder or re-parent {name}","gantt.a11y.rowMoved":"{name} moved.","gantt.a11y.rowReparented":"{name} moved under {parent}.","gantt.a11y.rowPromoted":"{name} moved to the top level.","gantt.a11y.rowMoveCancelled":"Move cancelled.","gantt.a11y.copied":"{count} tasks copied.","gantt.a11y.cut":"{count} tasks cut.","gantt.a11y.pasted":"{count} tasks pasted.","gantt.task.newName":"New task","gantt.a11y.taskAdded":"{name} added.","gantt.menu.addAbove":"Add task above","gantt.menu.addBelow":"Add task below","gantt.menu.addChild":"Add subtask","gantt.menu.addSuccessor":"Add successor","gantt.menu.addPredecessor":"Add predecessor","gantt.menu.toMilestone":"Convert to milestone","gantt.menu.toTask":"Convert to task","gantt.menu.delete":"Delete task","gantt.a11y.linkCycle":"Linking {from} to {to} would create a cycle; link not created.","gantt.a11y.linkCreated":"{from} linked to {to}, {type}.","gantt.a11y.linkDeleted":"Link from {from} to {to} deleted.","gantt.a11y.linkLabel":"Link, {from} to {to}, {type}","gantt.linkEditor.title":"Edit link from {from} to {to}","gantt.linkEditor.type":"Link type","gantt.linkEditor.lag":"Lag, in days","gantt.linkEditor.apply":"Apply","gantt.linkEditor.delete":"Delete link","gantt.linkEditor.cancel":"Cancel","gantt.a11y.undone":"Undone.","gantt.a11y.redone":"Redone.","gantt.a11y.nothingToUndo":"Nothing to undo.","gantt.a11y.nothingToRedo":"Nothing to redo.","gantt.workload.title":"Resource workload","gantt.workload.resource":"Resource","gantt.workload.total":"Total","gantt.workload.unassigned":"Unassigned","gantt.workload.ungrouped":"No group","gantt.workload.cell":"{hours} h from {date}","gantt.workload.over":"{hours} h from {date}, over a capacity of {capacity} h","gantt.workload.expand":"Show {name}’s tasks","gantt.workload.collapse":"Hide {name}’s tasks","gantt.workload.expandGroup":"Show the {name} group","gantt.workload.collapseGroup":"Hide the {name} group","gantt.workload.unitToggle":"Hours / % / Cost","gantt.workload.unitHours":"Showing hours","gantt.workload.unitPercent":"Showing percent of capacity","gantt.workload.unitCost":"Showing cost","gantt.workload.cellPercent":"{percent}% from {date}","gantt.workload.overPercent":"{percent}% from {date}, over capacity","gantt.workload.cellNoCapacity":"No available hours from {date}","gantt.workload.cellCost":"{cost} from {date}","gantt.workload.otherProjectLabel":"{name} (other project)","gantt.workload.external":"External booking","gantt.a11y.hoursSet":"{name}: {hours} h from {date}","gantt.a11y.hoursCleared":"{name}: no hours from {date}","gantt.a11y.hoursRefused":"{date} is not a working day; {name} was not changed.","gantt.histogram.title":"Resource histogram","gantt.histogram.tableTitle":"Resource histogram data","gantt.histogram.resource":"Resource","gantt.histogram.period":"Period","gantt.histogram.hours":"Hours","gantt.histogram.percent":"Percent of capacity","gantt.histogram.cost":"Cost","gantt.histogram.capacity":"Capacity","gantt.histogram.overAllocated":"Over-allocated","gantt.histogram.yes":"Yes","gantt.histogram.no":"No","gantt.histogram.tip":"{name}, {from} to {to}: {value}{capacity}{tasks}","gantt.histogram.tipHours":"{hours} h","gantt.histogram.tipPercent":"{percent}% of capacity","gantt.histogram.tipCost":"{cost}","gantt.histogram.tipCapacity":", capacity {hours} h","gantt.histogram.tipTasks":" ({tasks})","gantt.histogram.tipOver":", over capacity","gantt.histogram.tipNoCapacity":"no available hours","gantt.picker.title":"Assign resources to {name}","gantt.picker.open":"Edit assignments for {name}","gantt.picker.search":"Search resources","gantt.picker.list":"Resources","gantt.picker.selected":"Assigned resources","gantt.picker.load":"{load}% booked of {capacity}% over these dates","gantt.picker.none":"No matching resources","gantt.picker.units":"{name}, units in percent","gantt.picker.remove":"Remove {name}","gantt.picker.apply":"Apply","gantt.picker.cancel":"Cancel","gantt.picker.warn":"{name} would be over-allocated: {load}% booked of {capacity}%","gantt.picker.ok":"No resource would be over-allocated","gantt.picker.assign":"Assign","gantt.col.effort":"Effort","gantt.col.units":"Units","gantt.unscheduled":"Unscheduled","gantt.col.unscheduled":"Unscheduled","gantt.inactive":"Inactive","gantt.col.inactive":"Inactive","gantt.col.slack":"Slack","gantt.col.deadline":"Deadline","gantt.col.constraint":"Constraint","gantt.col.constraintDate":"Constraint date","gantt.col.earlyStart":"Early start","gantt.col.lateStart":"Late start","gantt.col.lateFinish":"Late finish","gantt.col.baselineStart":"Baseline start","gantt.col.baselineEnd":"Baseline finish","gantt.col.variance":"Variance","gantt.col.note":"Note","gantt.col.sequence":"#","gantt.col.predecessors":"Predecessors","gantt.col.successors":"Successors","gantt.link.invalid":"Cannot read “{token}” as a link. Write a task number, a type and a lag, like 3FS+2; links not changed.","gantt.link.unknownRef":"No task is numbered “{token}”; links not changed.","gantt.link.self":"“{token}” links a task to itself; links not changed.","gantt.link.duplicate":"“{token}” repeats a link already listed; links not changed.","gantt.link.cycle":"“{token}” would create a cycle; links not changed.","gantt.constraint.ASAP":"As soon as possible","gantt.constraint.MSO":"Must start on","gantt.constraint.MFO":"Must finish on","gantt.constraint.ALAP":"As late as possible","gantt.constraint.SNET":"Start no earlier than","gantt.constraint.SNLT":"Start no later than","gantt.constraint.FNET":"Finish no earlier than","gantt.constraint.FNLT":"Finish no later than","gantt.row.ancestor":"Shown because a task inside it matches the filter","gantt.progress.handle":"Drag to set the progress of {name}","gantt.a11y.progress":"{name} {percent}% complete","gantt.col.name":"Task name","gantt.col.start":"Start","gantt.col.end":"Finish","gantt.col.duration":"Duration","gantt.col.assignee":"Assignee","gantt.col.progress":"%","gantt.col.wbs":"WBS","gantt.zoom.label":"Zoom","gantt.zoom.day":"Day","gantt.zoom.week":"Week","gantt.zoom.month":"Month","gantt.zoom.quarter":"Quarter","gantt.zoom.fit":"Fit to plan","gantt.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","gantt.tip.effort":"{hours}h","gantt.tip.row":"{label}: {value}","gantt.tip.start":"Start","gantt.tip.end":"End","gantt.tip.date":"Date","gantt.tip.durationLabel":"Duration","gantt.tip.durationValue":"{days} days","gantt.tip.complete":"Complete","gantt.tip.effortLabel":"Effort","gantt.tip.effortValue":"{hours} h","gantt.tip.assigned":"Assigned","gantt.tip.cost":"Cost","gantt.tip.slackLabel":"Slack","gantt.tip.slackValue":"{days} days","gantt.tip.deadline":"Deadline","gantt.mode.fixedDuration":"Fixed duration","gantt.mode.fixedEffort":"Fixed effort","gantt.mode.fixedUnits":"Fixed units","gantt.scurve.spi":"SPI {index}","gantt.scurve.cpi":"CPI {index}","gantt.print.page":"Page {page} of {pages}","gantt.print.printed":"Printed {date}","gantt.dataBand.title":"Data band","gantt.dataBand.name":"Task","gantt.dataBand.resource":"Resource","gantt.dataBand.total":"Total","gantt.dataBand.unassigned":"Unassigned","gantt.dataBand.collapse":"Collapse {name}","gantt.dataBand.expand":"Expand {name}","gantt.dataBand.cell":"{name}, {date}: {value}","gantt.issues.title":"Scheduling conflicts","gantt.issues.empty":"No scheduling conflicts","gantt.issues.count":"{count} scheduling conflicts","gantt.issues.toggle":"Toggle the conflicts panel","gantt.issues.cycle":"Circular dependency: {tasks}","gantt.issues.constraint":"{task} cannot meet its {constraint} constraint of {date}","gantt.issues.lock":"{task} is locked but a dependency would move it","gantt.issues.deadline":"{task} finishes after its deadline of {date}","gantt.issues.fixRemoveLink":"Remove link","gantt.issues.fixAsap":"Set as soon as possible","gantt.issues.fixUnlock":"Unlock task","gantt.issues.fixClearDeadline":"Clear deadline","gantt.resize.startHandle":"Drag to change the start of {name}","gantt.a11y.resizedStart":"{name} start moved to {date}, now {days} days","gantt.a11y.startEdge":"Start edge can be resized: drag the left edge, or press Ctrl+Shift+Left or Right.","gantt.a11y.chain":"Dependency chain highlighted: {preds} predecessors, {succs} successors.","timeline.scrub":"Scrub through recent changes","timeline.goLive":"Go live","timeline.returnToPresent":"Return to the present","a11y.fillHandle":"Drag to fill","panel.icons":"Icons","value.tooLong":"Too long","shortcuts.title":"Keyboard shortcuts","shortcuts.close":"Close keyboard shortcuts","shortcuts.hint":"Press Escape to close.","shortcuts.or":"or","a11y.reorder.moved":"Moved to position {position} of {total}","a11y.reorder.sorted":"Rows cannot be reordered while the grid is sorted","a11y.reorder.filtered":"Rows cannot be reordered while a filter is applied","a11y.reorder.grouped":"Rows cannot be reordered while the grid is grouped","a11y.reorder.grab":"Reorder row","a11y.reorder.sortedManual":"Rows cannot be reordered while the grid is sorted. Press Alt+Shift+M, or the Manual order button in the heading, to order them by hand","a11y.reorder.groupDerived":"The row cannot join that group: the group is worked out from the value, so there is no single value to give it","a11y.reorder.groupReadOnly":"The row cannot join that group: its grouping value cannot be edited","a11y.reorder.invalid":"The row cannot join that group: the new value was not valid","a11y.reorder.vetoed":"The move was declined; the row stays where it was","a11y.reorder.vetoedBecause":"The move was declined ({reason}); the row stays where it was","a11y.reorder.refused":"The row cannot be moved there","a11y.reorder.regrouped":"Moved into {group}","a11y.rowOrder.entered":"Manual order: the rows keep their places and can be moved by hand","a11y.rowOrder.exited":"Manual order ended; the rows follow the sort","rowOrder.button":"Manual order","rowOrder.enter":"Order the rows by hand instead of by the sort","rowOrder.exit":"Return to the sorted order","a11y.transfer.moved":"Row moved to the other grid","a11y.transfer.copied":"Row copied to the other grid","a11y.transfer.refused":"That grid does not accept this row","a11y.transfer.declined":"The drop was declined; the row stays where it was","a11y.transfer.stale":"The drop target changed while it was being confirmed; the row stays where it was","shortcuts.group.grid":"In the data","shortcuts.group.header":"On a column heading","shortcuts.group.panel":"In the column list","shortcut.moveCell":"Move the focused cell","shortcut.rowEnds":"First / last cell of the row","shortcut.gridEnds":"First cell of the first row / last cell of the last row","shortcut.pageRows":"Move one viewport of rows","shortcut.nextCell":"Leave the grid for the next / previous focusable element (arrows move between cells)","shortcut.undo":"Undo the last edit, paste, fill or clear","shortcut.redo":"Redo the step that was undone","shortcut.startEdit":"Start editing the focused cell","shortcut.toggleRow":"Toggle selection of the focused row","shortcut.cancel":"Cancel the current edit or drag","shortcut.expandCollapse":"Expand / collapse a group or tree row","shortcut.focusHeader":"Move focus to the column header","shortcut.focusPanel":"Move focus to the tool panel","shortcut.contextMenu":"Open the context menu for the focused cell","shortcut.moveRow":"Move the focused row, when row reorder is enabled","shortcut.manualOrder":"Order the rows by hand, or return to the sort, when row reorder allows a manual order","shortcut.headingMove":"Move between headings","shortcut.headingEnds":"First / last heading","shortcut.headingSort":"Sort by the column, Shift to add to the sort","shortcut.headingResize":"Resize the column, Ctrl for a coarse step","shortcut.headingAutosize":"Size the column to its content","shortcut.headingReorder":"Move the column","shortcut.headingMenu":"Open the column menu","shortcut.headingExit":"Return focus to the data","shortcut.listGroup":"Group by the column, or stop grouping by it","shortcut.listValues":"Add the column to values, or take it out","shortcut.listPivot":"Pivot by the column, or stop pivoting by it","shortcut.listMove":"Move the column","shortcut.find":"Find in the grid","tags.label":"Show columns","tags.all":"All columns","tags.showing":"Showing {tag}","form.title":"Edit row","form.save":"Save","form.cancel":"Cancel","form.loading":"Loading…","form.loadFailed":"Could not load this record.","form.loadTimeout":"The record did not arrive in time.","form.retry":"Try again","form.choose":"Choose…","form.newTitle":"New row","form.createFailed":"Could not add this record.","presentation.cards":"Showing records as cards","presentation.table":"Showing records as a table","editor.format":"Format","editor.codeHint":"Tab indents · Esc cancels · Ctrl+Enter saves","editor.colours":"Colours","editor.customColour":"Custom colour","editor.hexValue":"Hex value","editor.hexPlaceholder":"#rrggbb","editor.clearColour":"Clear colour","editor.time":"Time","editor.noIcon":"No icon","editor.selectAll":"Select all","editor.passwordHint":"Enter the value twice to save it.","editor.clearRating":"Clear rating","editor.clear":"Clear","editor.value":"Value","editor.currency":"Currency","editor.richtext.formatting":"Formatting","editor.richtext.richText":"Rich text","editor.richtext.placeholder":"Start writing…","editor.richtext.linkLabel":"Link address","editor.richtext.linkPlaceholder":"https://","editor.richtext.linkAdd":"Add link","editor.richtext.bold":"Bold (Ctrl+B)","editor.richtext.italic":"Italic (Ctrl+I)","editor.richtext.underline":"Underline (Ctrl+U)","editor.richtext.strike":"Strikethrough","editor.richtext.heading":"Paragraph style","editor.richtext.alignLeft":"Align left","editor.richtext.alignCenter":"Align centre","editor.richtext.alignRight":"Align right","editor.richtext.ul":"Bulleted list","editor.richtext.ol":"Numbered list","editor.richtext.color":"Text colour","editor.richtext.link":"Link (Ctrl+K)","editor.richtext.image":"Insert image","editor.richtext.clear":"Clear formatting","editor.richtext.source":"HTML source","editor.richtext.undo":"Undo (Ctrl+Z)","editor.richtext.redo":"Redo (Ctrl+Y)","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":N,"filter.op.contains":"Contains","filter.op.notContains":"Does not contain","filter.op.equals":"Equals","filter.op.notEqual":"Does not equal","filter.op.startsWith":"Starts with","filter.op.endsWith":"Ends with","filter.op.blank":"Is blank","filter.op.notBlank":"Is not blank","filter.op.lessThan":"Less than","filter.op.lessThanOrEqual":"Less than or equal","filter.op.greaterThan":"Greater than","filter.op.greaterThanOrEqual":"Greater than or equal","filter.op.inRange":"In range","filter.op.matches":"Matches","filter.op.before":"Before","filter.op.after":"After","filter.op.relative":"Relative to today","filter.rel.today":"Today","filter.rel.yesterday":"Yesterday","filter.rel.tomorrow":"Tomorrow","filter.rel.lastNDays":"Last N days","filter.rel.nextNDays":"Next N days","filter.rel.thisWeek":"This week","filter.rel.lastWeek":"Last week","filter.rel.thisMonth":"This month","filter.rel.lastMonth":"Last month","filter.rel.thisQuarter":"This quarter","filter.rel.quarterToDate":"Quarter to date","filter.rel.thisYear":"This year","filter.rel.yearToDate":"Year to date","filter.operator":"Operator","filter.join":"Join","filter.value":"Value","filter.from":"From","filter.to":"To","filter.addCondition":"Add condition","filter.noConditions":"No conditions","filter.removeCondition":"Remove condition","filter.search":"Search","filter.searchValues":"Search values","filter.noMatches":"No values match","filter.selectAll":"Select all","filter.clear":"Clear","filter.all":"All","filter.allExcept":"All but {count}","filter.loadingValues":"Loading values…","filter.topValues":"Top {shown} of {total} values","filter.valuesFailed":"Values could not be loaded: {error}","filter.valuesUnsupported":"This source cannot list the values of {column}; filter by condition instead.","filter.true":"True","filter.false":"False","filter.expression":"Filter expression","filter.column":"Column","filter.relativePeriod":"Relative period","filter.days":"Number of days","filter.tab.set":"Values","filter.tab.text":"Text","filter.tab.number":"Number","filter.tab.date":"Date","filter.tab.advanced":"Advanced","filterRow.label":"Filter row","filterRow.conditions":{one:"{count} condition",other:"{count} conditions"},"chart.empty":"Nothing to chart","chart.summary":"{type} chart of {measure} by {dimension}","chart.summaryShare":"{type} chart of {measure}","chart.summaryType":"{type} chart","chart.summaryGauge":"{type} chart of {measure}, {fn}: {value}","chart.waterfallTotal":"Total","chart.summaryEngine":"Figures computed by the data engine over every matching row","chart.summaryEngineViewport":"{count} points in this view, fetched from the data engine","chart.summaryEngineDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells counted by the data engine","chart.summaryClientDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells computed in the browser","chart.viewportOverCap":"{count} rows in this view, more than the {cap} this map draws; zoom in or narrow the filter","chart.dataTable":"Chart data","chart.viewportFilter.label":"Map view","chart.annotate.rail":"Drawing tools","chart.annotate.select":"Select and move a drawing","chart.annotate.trendLine":"Trend line","chart.annotate.horizontalLine":"Horizontal line","chart.annotate.verticalLine":"Vertical line","chart.annotate.channel":"Parallel channel","chart.annotate.fibonacci":"Fibonacci retracement","chart.annotate.arrow":"Arrow","chart.annotate.pen":"Freehand pen","chart.annotate.pen.described":"Freehand drawing from {from} to {to}","chart.annotate.measure-x":"Date range","chart.annotate.measure-y":"Price range","chart.annotate.measure-xy":"Date and price range","chart.annotate.measure.bars":{one:"{count} bar",other:"{count} bars"},"chart.annotate.measure.points":{one:"{count} point",other:"{count} points"},"chart.annotate.measure.volume":"Vol {value}","chart.annotate.measure.seconds":"{count}s","chart.annotate.measure.minutes":"{count}m","chart.annotate.measure.hours":"{count}h","chart.annotate.measure.days":"{count}d","chart.annotate.measure.weeks":"{count}w","chart.annotate.measure.months":"{count}mo","chart.annotate.measure.years":"{count}y","chart.annotate.measure":"Measure","chart.annotate.measure.dx":"Δx {value}","chart.annotate.measure.dy":"Δy {value}","chart.annotate.measure.pct":"{value}%","chart.annotate.measure.categories":{one:"{count} category",other:"{count} categories"},"chart.annotate.measure.slope.perDay":"Slope {value} per day","chart.annotate.measure.slope.perCategory":"Slope {value} per category","chart.annotate.measure.slope.perUnit":"Slope {value} per unit","chart.annotate.measure.dur.d":"{count} d","chart.annotate.measure.dur.h":"{count} h","chart.annotate.measure.dur.min":"{count} min","chart.annotate.measure.dur.s":"{count} s","chart.annotate.measure.dur.ms":"{count} ms","chart.annotate.measure.announce":"Measurement: {readout}","chart.annotate.measure.start":"Measure start: {x}, {y}","chart.annotate.text":"Text","chart.annotate.callout":"Callout","chart.annotate.note":"Note","chart.annotate.delete":"Delete the selected drawing","chart.annotate.editLabel":"Annotation text","chart.zoom.toolbar":"Zoom controls","chart.zoom.in":"Zoom in","chart.zoom.out":"Zoom out","chart.zoom.left":"Pan left","chart.zoom.right":"Pan right","chart.zoom.reset":"Reset the zoom","chart.legendMore":{one:"+{count} more",other:"+{count} more"},"chart.type.line":"Line","chart.type.area":"Area","chart.type.bar":"Bar","chart.type.pie":"Pie","chart.type.donut":"Donut","chart.type.sunburst":"Sunburst","chart.type.scatter":"Scatter","chart.type.step":"Step","chart.type.rangeArea":"Range","chart.type.horizontalBar":"Horizontal bar","chart.type.waterfall":"Waterfall","chart.type.floatingBar":"Floating bar","chart.type.horizontalFloatingBar":"Horizontal floating bar","chart.type.populationPyramid":"Population pyramid","chart.type.bullet":"Bullet","chart.type.bubble":"Bubble","chart.type.histogram":"Histogram","chart.type.boxplot":"Box plot","chart.type.forest":"Forest plot","chart.type.qq":"QQ plot","chart.type.ecdf":"ECDF","chart.type.lorenz":"Lorenz","chart.type.correlogram":"Correlogram","chart.type.control":"Control","chart.type.capability":"Capability","chart.type.movingRange":"Moving range","chart.type.treemap":"Treemap","chart.type.combo":"Combination","chart.type.pareto":"Pareto","chart.type.heatmap":"Heat map","chart.type.radar":"Radar","chart.type.gauge":"Gauge","chart.type.funnel":"Funnel","chart.type.candlestick":"Candlestick","chart.type.ohlc":"OHLC","chart.type.polarArea":"Polar area","chart.type.nightingale":"Nightingale rose","chart.type.rose":"Rose","chart.type.radialBar":"Radial bar","chart.type.polarScatter":"Polar scatter","chart.type.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.pyramid":"Pyramid","chart.type.pictorial":"Pictorial","chart.type.serpentine":"Serpentine timeline","chart.type.spiral":"Spiral timeline","chart.edit.aggregated":"This value is a total of several rows, so it cannot be dragged.","chart.edit.refused":"That change was not applied.","chart.edit.refusedWhy":"That change was not applied: {reason}","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","chart.type.forceTree":"Force-directed tree","chart.type.pack":"Packed circles","chart.type.tree":"Tree","chart.type.voronoiTreemap":"Voronoi treemap","chart.type.alluvial":"Alluvial","chart.type.arc":"Arc diagram","chart.type.barRace":"Bar chart race","chart.type.bubblemap":"Bubble map","chart.type.bump":"Bump chart","chart.type.calendar":"Calendar heat map","chart.type.choropleth":"Choropleth map","chart.type.decomposition":"Decomposition tree","chart.type.diverging":"Diverging bar","chart.type.dumbbell":"Dumbbell","chart.type.fan":"Fan chart","chart.type.hexbin":"Hexagonal bin","chart.type.hexmap":"Hex map","chart.type.icicle":"Icicle","chart.type.markermap":"Marker map","chart.type.motion":"Motion chart","chart.type.parallel":"Parallel coordinates","chart.type.ridgeline":"Ridgeline","chart.type.roc":"ROC curve","chart.type.scatter3d":"3D scatter","chart.type.slope":"Slope chart","chart.type.splom":"Scatter plot matrix","chart.type.venn":"Venn diagram","chart.type.waffle":"Waffle","chart.type.wordCloud":"Word cloud","chart.tasksDropped":{one:"{count} more task not shown",other:"{count} more tasks not shown"},"chart.geoUnmatched":{one:"{count} row could not be placed on the map",other:"{count} rows could not be placed on the map"},"chart.r2":"R² {value}","ai.insights":"Insights","ai.explainView":"Explain this view","ai.explain":"Explain","ai.ask":"Ask","ai.apply":"Apply","ai.discard":"Discard","ai.propose":"Propose","ai.approve":"Approve","ai.thinking":"Thinking…","ai.applying":"Applying…","ai.applied":"Applied: {what}","ai.couldNotApply":"Could not apply: {why}","ai.applyFailed":"it failed","ai.discarded":"Discarded.","ai.discardedNothingWritten":"Discarded. Nothing was written.","ai.nothingWritten":"Nothing was written.","ai.nothingWrittenVetoed":"Nothing was written — a before-handler vetoed it.","ai.scope":"Scope: {scope}","ai.unsafeQuery":"I could not turn that into a safe query: {why}","ai.nothingToDo":"nothing to do","ai.insightsFailed":"Could not generate insights right now. The grid is unaffected.","ai.modelUnreachable":"Could not reach the model right now. The grid is unaffected.","ai.flagged":{one:"{count} unverified figure was removed as ungrounded.",other:"{count} unverified figures were removed as ungrounded."},"ai.askPlaceholder":"Ask your data: “EMEA deals over 50k, biggest first”","ai.askLabel":"Ask your data","ai.actorPlaceholder":"Ask AI to change data: “set the Network Upgrade project to In Progress”","ai.actorLabel":"Ask AI to change data","editor.password.show":"Show value","editor.password.hide":"Hide value","editor.password.showField":"Show {column}","editor.password.hideField":"Hide {column}","facets.computing":"Computing…","facets.suppressed.cardinality":"Too many distinct values to chart","facets.suppressed.rows":"Too many rows to chart","facets.suppressed.streaming":"Paused while live data is streaming","facets.suppressed.noProvider":"No distribution available for this data source","facets.suppressed.type":"This column has no chartable distribution","facets.bucketOf":"{count} of {whole} rows","history.undo":"Undo","history.redo":"Redo","history.described":"{action} {label}","history.nothingToUndo":"Nothing to undo","history.nothingToRedo":"Nothing to redo","history.undoDisabled":"Undo (nothing to undo)","history.redoDisabled":"Redo (nothing to redo)","a11y.presence.joined":"{name} joined","a11y.presence.left":"{name} left","prompt.asking":"Asking…","prompt.moreNotes":{one:"and {count} more",other:"and {count} more"},"shortcuts.key.cmd":"Cmd","timeline.live":"Live","timeline.recording":"recording…","panel.zoneHint.group":"Drag a column here to group rows by its values","panel.zoneHint.values":"Drag a column here to total it","panel.zoneHint.pivot":"Drag a column here to pivot across its values","panel.zoneHint.any":"Drag a column here","panel.rowsOf":"{shown} of {total} rows","views.empty":"No saved views yet. Set the grid up as you want it, then save it below.","views.applied":"Applied","views.matchesGrid":"Matches the grid as it is","views.delete":"Delete","views.confirmDelete":"Delete {name}?","views.confirmDeleteLabel":"Confirm deleting {name}","gantt.row.expand":"Expand {name}","gantt.row.collapse":"Collapse {name}","gantt.resource.over":"{name} — over-allocated","kanban.board":"Board","kanban.requiredTitle":"Required fields","kanban.requiredSave":"Save","kanban.requiredCancel":"Cancel","kanban.moveRefused":'Move refused: a card in "{from}" cannot move to "{to}".',"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"}),B=Object.freeze(Object.keys(X))}),Ie("packages/core/src/i18n/format.js",function(e,U){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return O}});const N=U("packages/core/src/internal/predicates.js").isFunction,X=/\{(\w+)\}/g,B=new Map,D=new Map;function q(b){const u=b||"";if(B.has(u))return B.get(u);let f=null;try{f=new Intl.PluralRules(b||void 0)}catch{f=null}return B.set(u,f),f}function K(b,u,f="conjunction"){const a=Array.isArray(b)?b.filter(s=>s!=null&&s!==""):[];if(a.length===0)return"";if(a.length===1)return String(a[0]);const r=`${u||""}|${f}`;let t=D.get(r);if(t===void 0){try{t=new Intl.ListFormat(u||void 0,{style:"long",type:f})}catch{t=null}D.set(r,t)}return t?t.format(a.map(String)):a.map(String).join(", ")}function x(b,u){return b==null?"":typeof b=="number"?Number.isFinite(b)?b.toLocaleString(u||void 0,{maximumFractionDigits:20}):"":String(b)}function G(b,u,f){if(typeof b=="string")return b;if(!b||typeof b!="object")return"";const a=u&&typeof u.count=="number"?u.count:null;if(a===null)return b.other??"";const r=q(f),t=r?r.select(a):a===1?"one":"other";return b[t]??b.other??""}function z(b,u={},f){const a=G(b,u,f);return a?a.replace(X,(r,t)=>Object.prototype.hasOwnProperty.call(u,t)?x(u[t],f):r):""}function j(b,u,f="en-GB"){return typeof b=="string"&&b?b:typeof u=="string"&&u?u:f}function O(b,u){const f=b?b[u]:void 0;return f==null||N(f)?u:f}}),Ie("packages/core/src/i18n/registry.js",function(e,U){"use strict";Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"localeCatalogue",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"registeredTags",{enumerable:!0,get:function(){return q}});const N=U("packages/core/src/i18n/catalogue.js").EN_GB,X=new Map([["en-gb",N]]);function B(K,x){const G=typeof K=="string"?K.toLowerCase():"";return!G||!x||typeof x!="object"?!1:(X.set(G,x),!0)}function D(K){if(typeof K!="string"||!K)return null;const x=K.toLowerCase(),G=X.get(x);if(G)return G;const z=x.split("-")[0],j=X.get(z);if(j)return j;for(const[O,b]of X)if(O.split("-")[0]===z)return b;return null}function q(){return[...X.keys()]}}),Ie("packages/core/src/i18n/index.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return i}});const te=U("packages/core/src/i18n/catalogue.js"),N=te.EN_GB,X=te.MESSAGE_KEYS,B=U("packages/core/src/i18n/format.js"),D=B.formatMessage,q=B.formatList,K=B.lookup,x=B.resolveLocale,z=U("packages/core/src/internal/predicates.js").isFunction,O=U("packages/core/src/internal/warn.js").warnOnce,b=U("packages/core/src/i18n/registry.js"),u=b.registerLocale,f=b.localeCatalogue;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return te.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return te.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return B.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return B.resolveLocale}}),Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return b.registerLocale}});const a="en-GB";class r{#e=a;#t=N;constructor(c={}){this.configure(c)}configure(c={}){this.#e=x(c.locale,c.declared,a);const o=c.messages,l=f(this.#e);if(!l&&this.#e.toLowerCase()!=="en-gb"&&(!o||typeof o!="object")&&O(`i18n:locale:not-loaded:${this.#e.toLowerCase()}`,`locale "${this.#e}" is not loaded: import "@toclocoinc/lattice-grid/locales/${this.#e}" to add its text; English is used until then.`),!o||typeof o!="object"){this.#t=l?{...N,...l}:N;return}const w=Object.keys(o).filter(g=>!(g in N));w.length&&O(`i18n:unknown:${w[0]}`,`message keys not in the catalogue and so ignored: ${w.slice(0,5).join(", ")}${w.length>5?`, and ${w.length-5} more`:""}`),this.#t={...N,...l||{},...o}}get locale(){return this.#e}t(c,o){return D(K(this.#t,c),o||{},this.#e)}list(c,o){return q(c,this.#e,o)}number(c,o){const l=Number(c);return Number.isFinite(l)?l.toLocaleString(this.#e,o||{maximumFractionDigits:20}):""}}const t=new r;function s(n){return n instanceof r?n:new r(n||{})}function i(n){const c=n&&typeof n=="object"?n:{},o=X.filter(h=>{const w=c[h];return w==null||w===""||z(w)}),l=Object.keys(c).filter(h=>!(h in N));return{missing:o,unknown:l}}}),Ie("packages/core/src/columns/types/structured.js",function(e,U){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const te=U("packages/core/src/internal/predicates.js"),N=te.isNil,X=te.isObject,D=U("packages/core/src/i18n/index.js").defaultMessages,q=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function K(r,t){const s=t||{},i=s.emptyDisplay??q.emptyDisplay;if(N(r)||r==="")return i;const c=[...typeof s.char=="string"&&s.char!==""?s.char:q.char][0]||q.char,o=s.fixedLength??q.fixedLength,l=Number.isFinite(s.length)&&Number(s.length)>0?Math.floor(Number(s.length)):q.length,h=typeof r=="string"?r:typeof r=="number"||typeof r=="boolean"||typeof r=="bigint"?String(r):null;let w=0;if(h!==null){const g=Number.isFinite(s.lastVisible)?Math.floor(Number(s.lastVisible)):q.lastVisible,k=[...h];if(w=g>0&&g<k.length?g:0,w>0){const d=k.slice(k.length-w).join(""),p=Math.max(1,(o?l:k.length)-w);return c.repeat(p)+d}return c.repeat(o?l:Math.max(1,k.length))}return c.repeat(l)}const x=48;function G(r){try{const t=JSON.stringify(r);return t===void 0?null:t}catch{return null}}function z(r,t){if(N(r))return"";const s=Number.isFinite(t&&t.inlineLimit)?Number(t.inlineLimit):x;if(typeof r=="string")return r.length>s?`${r.slice(0,s-1)}…`:r;if(typeof r!="object")return String(r);const i=G(r);if(i!==null&&i.length<=s)return i;if(Array.isArray(r)){const c=r.length;return`[${D.t("count.items",{count:c})}]`}const n=Object.keys(r).length;return`{${D.t("count.keys",{count:n})}}`}function j(r,t){if(r==null)return"null";const s=typeof r;if(s==="number"||s==="boolean"||s==="bigint")return String(r);if(s==="string")return JSON.stringify(r);if(s!=="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=>j(o,i)).join(",")}]`:`{${Object.keys(r).sort().map(o=>`${JSON.stringify(o)}:${j(r[o],i)}`).join(",")}}`)}function O(r,t){if(N(r))return N(t)?0:1;if(N(t))return-1;const s=j(r),i=j(t);return s<i?-1:s>i?1:0}function b(r){if(N(r))return null;const t=String(r);if(t.trim()==="")return null;try{return JSON.parse(t)}catch{return t}}function u(r){const t=r&&r.cell&&r.cell.props;return X(t)?t:{}}const f=Object.freeze({json:{base:"object",storage:"object",format:r=>z(r&&r.value,u(r&&r.column)),parse:r=>b(r&&r.text),compare:O,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:r=>{if(N(r))return"";if(typeof r=="string")return r;try{const t=JSON.stringify(r,null,2);return t===void 0?String(r):t}catch{return String(r)}},fromClipboard:r=>b(r)},secret:{base:"text",storage:"object",format:r=>K(r&&r.value,u(r&&r.column)),parse:r=>{const t=r&&r.text;return N(t)||String(t)===""?null:String(t)},compare:(r,t)=>{const s=N(r)||r==="",i=N(t)||t==="";return s===i?0:s?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:r=>K(r),fromClipboard:r=>N(r)||String(r)===""?null:String(r)}}),a=f}),Ie("packages/core/src/columns/types/unit.js",function(e,U){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/internal/warn.js").warnOnce;function D(A,C,H,Y){return Object.freeze({symbol:A,factor:C,aliases:Object.freeze(H||[]),binary:!!(Y&&Y.binary),prefix:Y&&Y.prefix||null,auto:!(Y&&Y.auto===!1)})}function q(A,C,H,Y){return D(A,C,H,Y)}const K=Object.freeze({data:Object.freeze([D("B",1,["byte","bytes"]),D("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),D("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),D("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),D("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),D("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),D("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),D("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),D("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),D("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([D("bps",1,["bit","bits","bit/s","b/s"]),D("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),D("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),D("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),D("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([D("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),D("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),D("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),D("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),D("in",.0254,["inch","inches"],{auto:!1}),D("ft",.3048,["foot","feet"],{auto:!1}),D("yd",.9144,["yard","yards"],{auto:!1}),D("m",1,["metre","metres","meter","meters"]),D("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),D("mi",1609.344,["mile","miles"],{auto:!1}),D("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([D("mg",.001,["milligram","milligrams"]),D("g",1,["gram","grams"]),D("oz",28.349523125,["ounce","ounces"],{auto:!1}),D("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),D("kg",1e3,["kilogram","kilograms"]),D("st",6350.29318,["stone"],{auto:!1}),D("t",1e6,["tonne","tonnes","ton"],{auto:!1}),D("ton (US)",907184.74,["ton","shortton"],{auto:!1}),D("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([D("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),D("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),D("ms",.001,["msec","msecs","millisecond","milliseconds"]),D("s",1,["sec","secs","second","seconds"]),D("m",60,["min","mins","minute","minutes"]),D("h",3600,["hr","hrs","hour","hours"]),D("d",86400,["day","days"])]),speed:Object.freeze([D("mm/s",.001,["millimetre/s","millimeter/s"]),D("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),D("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),D("mph",.44704,["mile/h","miles/h"],{auto:!1}),D("kn",1852/3600,["knot","knots"],{auto:!1}),D("m/s",1,["metre/s","meter/s","mps"]),D("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([D("mm/s²",.001,["mm/s2"]),D("ft/s²",.3048,["ft/s2"],{auto:!1}),D("m/s²",1,["m/s2","metre/s2","meter/s2"]),D("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([D("mm²",1e-6,["mm2"]),D("cm²",1e-4,["cm2"]),D("in²",64516e-8,["in2","sqin"],{auto:!1}),D("ft²",.09290304,["ft2","sqft"],{auto:!1}),D("yd²",.83612736,["yd2","sqyd"],{auto:!1}),D("m²",1,["m2","sqm"]),D("ha",1e4,["hectare","hectares"],{auto:!1}),D("ac",4046.8564224,["acre","acres"],{auto:!1}),D("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([D("µL",1e-6,["ul","microlitre","microliter"]),D("mL",.001,["millilitre","milliliter"]),D("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),D("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),D("L",1,["litre","litres","liter","liters"]),D("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),D("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),D("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),D("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([D("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),D("J",1,["joule","joules"]),D("cal",4.184,["calorie","calories"],{auto:!1}),D("kJ",1e3,["kilojoule","kilojoules"]),D("BTU",1055.05585262,["btu"],{auto:!1}),D("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),D("MJ",1e6,["megajoule","megajoules"]),D("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),D("GJ",1e9,["gigajoule","gigajoules"]),D("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([D("mW",.001,["milliwatt","milliwatts"]),D("W",1,["watt","watts"]),D("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),D("kW",1e3,["kilowatt","kilowatts"]),D("hp",745.6998715822702,["horsepower"],{auto:!1}),D("MW",1e6,["megawatt","megawatts"]),D("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([D("mN",.001,["millinewton","millinewtons"]),D("N",1,["newton","newtons"]),D("lbf",4.4482216152605,["poundforce"],{auto:!1}),D("kgf",9.80665,["kilogramforce"],{auto:!1}),D("kN",1e3,["kilonewton","kilonewtons"]),D("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([D("Pa",1,["pascal","pascals"]),D("mbar",100,["millibar"],{auto:!1}),D("inH₂O",249.0889,["inh2o"],{auto:!1}),D("mmHg",133.322387415,["torr"],{auto:!1}),D("kPa",1e3,["kilopascal","kilopascals"]),D("inHg",3386.388640341,["inhg"],{auto:!1}),D("psi",6894.757293168361,["lbf/in2"],{auto:!1}),D("bar",1e5,[],{auto:!1}),D("atm",101325,["atmosphere","atmospheres"],{auto:!1}),D("MPa",1e6,["megapascal","megapascals"]),D("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([D("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),D("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),D("kN·m",1e3,["knm","kn.m"],{auto:!1}),D("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([D("kg/m³",1,["kg/m3"]),D("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),D("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),D("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([D("L/min",1/6e4,["lpm","l/min"],{auto:!1}),D("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),D("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),D("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),D("cfm",.0004719474432,["ft3/min"],{auto:!1}),D("L/s",.001,["lps","l/s"],{auto:!1}),D("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([D("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),D("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),D("mrad",.001,["milliradian","milliradians"],{auto:!1}),D("mil",Math.PI/3200,["nato-mil"],{auto:!1}),D("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),D("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),D("rad",1,["radian","radians"]),D("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([D("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),D("rad/s",1,["radps","radians/s"]),D("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),D("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([D("ppt",1e-12,["partspertrillion"],{auto:!1}),D("ppb",1e-9,["partsperbillion"]),D("ppm",1e-6,["partspermillion"]),D("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),D("‰",.001,["permille","permil"],{auto:!1}),D("%",.01,["pct","percent"]),D("×",1,["x","ratio","times"])]),molarity:Object.freeze([D("pM",1e-12,["picomolar","picomolarity"]),D("nM",1e-9,["nanomolar","nanomolarity"]),D("µM",1e-6,["um-molar","micromolar","micromolarity"]),D("mM",.001,["millimolar","millimolarity"]),D("M",1,["molar","mol/l","mol/L","molarity"]),D("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([D("mg/s",1e-6,["milligrams/s"]),D("g/s",.001,["grams/s"]),D("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),D("kg/s",1,["kilograms/s","kgps"]),D("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),D("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),D("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([D("µPa·s",1e-6,["upas","micropascalsecond"]),D("cP",.001,["centipoise"],{auto:!1}),D("mPa·s",.001,["mpas","millipascalsecond"]),D("P",.1,["poise"],{auto:!1}),D("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([D("cSt",1e-6,["centistokes","centistoke"]),D("mm²/s",1e-6,["mm2/s"],{auto:!1}),D("St",1e-4,["stokes","stoke"],{auto:!1}),D("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([D("mW/(m·K)",.001,["mw/mk"]),D("W/(m·K)",1,["w/mk","wmk"]),D("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),D("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([D("J/(kg·K)",1,["j/kgk","jkgk"]),D("kJ/(kg·K)",1e3,["kj/kgk"]),D("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([D("nSv/h",1e-9,["nsvh"]),D("µSv/h",1e-6,["usv/h","usvh"]),D("mSv/h",.001,["msvh"]),D("Sv/h",1,["svh"]),D("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),x=Symbol("ambiguous"),G=new Map,z=new Map;function j(A,C){const H=String(A||"").trim();if(!H)throw new Error("[lattice] a unit system needs a name");if(K[H]||z.has(H))throw new Error(`[lattice] unit system "${H}" already exists`);const Y=[...C||[]];if(!Y.length)throw new Error(`[lattice] unit system "${H}" has no units`);if(!Y.some(_=>_.factor===1))throw new Error(`[lattice] unit system "${H}" has no base unit (none with factor 1)`);const Z=new Set;for(const _ of Y){if(Z.has(_.symbol))throw new Error(`[lattice] unit system "${H}" declares "${_.symbol}" twice`);Z.add(_.symbol)}return z.set(H,Object.freeze(Y)),G.delete(H),H}function O(){return[...Object.keys(K),...z.keys()]}function b(A){const C=u(A);return C?C.units:[]}function u(A){const C=String(A||""),H=G.get(C);if(H!==void 0)return H;const Y=K[C]||z.get(C);if(!Y)return G.set(C,null),null;const Z=Object.freeze([...Y].sort((se,oe)=>se.factor-oe.factor)),_=new Map,J=new Map,ee=(se,oe)=>{const fe=_.get(se);fe===void 0?_.set(se,oe):fe!==oe&&_.set(se,x)};for(const se of Z){ee(se.symbol.toLowerCase(),se);for(const oe of se.aliases)ee(oe.toLowerCase(),se);if(se.prefix){const oe=J.get(se.prefix)||[];oe.push(se),J.set(se.prefix,oe)}}const ne={units:Z,byToken:_,byPrefix:J,decimal:Z.filter(se=>!se.binary&&se.auto),binary:Z.some(se=>se.binary)?Z.filter(se=>(se.binary||se.factor===1)&&se.auto):null};return G.set(C,ne),ne}function f(A,C){return C&&A.binary||A.decimal}function a(A,C){const H=u(A);if(!H||N(C))return null;const Y=H.units.find(_=>_.symbol===String(C));if(Y)return Y;const Z=H.byToken.get(String(C).trim().toLowerCase());return Z&&Z!==x?Z:null}const r=new WeakMap;function t(A){const C=A||{};if(typeof C=="object"&&C!==null){const _=r.get(C);if(_!==void 0)return _}const H=C.system||"data",Y=u(H);let Z=null;if(!Y)B(`unit:system:${H}`,`unknown unit system "${H}"; known systems are ${O().join(", ")}`);else{let _=C.unit?a(H,C.unit):null;_||(C.unit&&B(`unit:unit:${H}:${C.unit}`,`unknown unit "${C.unit}" in system "${H}"; falling back to ${Y.units[0].symbol}`),_=Y.units.find(J=>J.factor===1)||Y.units[0]),Z={index:Y,base:_,binary:C.binary===!0}}return typeof C=="object"&&C!==null&&r.set(C,Z),Z}const s=new WeakMap;function i(A,C){if(!A||!C||!Array.isArray(A.compound)||A.compound.length===0)return null;const H=s.get(A);if(H!==void 0)return H;const Y=new Set,Z=[];for(const J of A.compound){const ee=a(A.system||"data",J);if(!ee){B(`unit:compound:${A.system}:${J}`,`unknown compound unit "${J}" in system "${A.system||"data"}"; ignoring it`);continue}Y.has(ee.symbol)||(Y.add(ee.symbol),Z.push(ee))}Z.sort((J,ee)=>ee.factor-J.factor);const _=Z.length>=2?Z:null;return s.set(A,_),_}function n(A,C,H){return C===H||C.factor===H.factor?A:A*C.factor/H.factor}const c=new Map;function o(A){const C=A||"",H=c.get(C);if(H)return H;const Y={group:",",decimal:"."};try{for(const Z of new Intl.NumberFormat(A||void 0).formatToParts(12345.6))Z.type==="group"?Y.group=Z.value:Z.type==="decimal"&&(Y.decimal=Z.value)}catch{}return c.set(C,Y),Y}const l=/[\s ]/g,h=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,w=/^[^\d+\-(.,\s]+\s*/,g=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function k(A,C){const{group:H,decimal:Y}=o(C);let Z=String(A).replace(l,"");if(Z==="")return null;const _=Y?Z.indexOf(Y):-1;if(H&&H!==Y){if(_>=0&&Z.indexOf(H,_+Y.length)>=0)return null;Z=Z.split(H).join("")}if(Y&&Y!=="."&&(Z=Z.split(Y).join(".")),!g.test(Z))return null;const J=Number(Z);return Number.isFinite(J)?J:null}function d(A,C,H){const Y=String(A).trim().replace(/\.$/,"");if(Y==="")return null;const Z=C.units.find(oe=>oe.symbol===Y);if(Z)return Z;const _=Y.toLowerCase(),J=C.byToken.get(_);if(J===x)return null;if(J)return J;const ee=C.byPrefix.get(_);if(!ee||!ee.length)return null;const ne=f(C,H),se=ee.filter(oe=>ne.includes(oe));return se.length===1?se[0]:null}function p(A,C,H,Y){let Z=A,_=0,J=!1,ee=!1;for(;Z!=="";){const ne=h.exec(Z)[0];if(ne==="")return null;const se=k(ne,Y&&Y.locale);if(se===null)return null;Z=Z.slice(ne.length).trim();const oe=Z.search(/[+-]?[\d]/),fe=(oe>=0?Z.slice(0,oe):Z).trim();if(Z=oe>=0?Z.slice(oe).trim():"",fe===""){if(J)return null;ee=!0,_+=n(se,H[0],C.base)}else{const pe=d(fe,C.index,C.binary);if(!pe)return null;_+=n(se,pe,C.base)}if(J=!0,ee&&Z!=="")return null}return J?_:null}function m(A,C){if(N(A))return null;if(typeof A=="number")return Number.isFinite(A)?A:null;const H=t(C);if(!H)return null;let Y=String(A).trim();if(Y==="")return null;let Z=!1;Y.startsWith("(")&&Y.endsWith(")")&&(Z=!0,Y=Y.slice(1,-1).trim());const _=i(C,H);if(_){Y.startsWith("-")&&(Z=!0,Y=Y.slice(1).trim());const he=p(Y,H,_,C);return he===null?null:Z?-he:he}let J=null;const ee=w.exec(Y);if(ee&&ee[0]){const he=d(ee[0].trim(),H.index,H.binary);he&&(J=he,Y=Y.slice(ee[0].length).trim())}const ne=h.exec(Y)[0],se=k(ne,C&&C.locale);if(se===null)return null;const oe=Y.slice(ne.length).trim();if(J&&oe!=="")return null;const fe=J||(oe===""?H.base:d(oe,H.index,H.binary));if(!fe)return null;const pe=n(se,fe,H.base);return Z?-pe:pe}const v=new Map;function y(A,C,H,Y){const Z=`${A||""}|${C}|${H}|${Y?1:0}`;let _=v.get(Z);return _||(_=new Intl.NumberFormat(A||void 0,{minimumFractionDigits:C,maximumFractionDigits:H,useGrouping:Y}),v.set(Z,_)),_}function E(A,C){if(!Number.isFinite(A)||A===0)return Math.max(0,C-1);const H=Math.floor(Math.log10(Math.abs(A)));return Math.min(20,Math.max(0,C-1-H))}function M(A,C){if(!Number.isFinite(A)||A===0)return A;const H=Math.ceil(Math.log10(Math.abs(A))),Y=10**(C-H);return Math.round(A*Y)/Y}function F(A,C,H){if(!H||H===C.base.symbol)return C.base;if(H!=="auto")return V(C,H);if(A===0||!Number.isFinite(A))return C.base;const Y=Math.abs(A)*C.base.factor,Z=f(C.index,C.binary);let _=Z[0];for(const ne of Z)Y>=ne.factor&&(_=ne);if(Y>=_.factor)return _;let J=_;for(const ne of C.index.units)ne.binary!==C.binary&&ne.factor!==1||ne.factor<=Y&&ne.factor>(J===_?0:J.factor)&&(J=ne);if(J!==_)return J;let ee=_;for(const ne of C.index.units)ne.binary!==C.binary&&ne.factor!==1||ne.factor<ee.factor&&(ee=ne);return ee.factor<C.base.factor?ee:C.base}function V(A,C){const H=A.index.units.find(Z=>Z.symbol===C);if(H)return H;const Y=A.index.byToken.get(String(C).toLowerCase());return Y&&Y!==x?Y:(B(`unit:display:${C}`,`unknown display unit "${C}"; rendering in ${A.base.symbol}`),A.base)}function I(A,C,H,Y){const Z=A<0;let _=Math.abs(A)*C.base.factor;const J=typeof Y.decimals=="number"?Y.decimals:Y.minDecimals??0,ee=typeof Y.decimals=="number"?Y.decimals:Y.maxDecimals??Math.max(J,2),ne=Y.space??" ",se=[];for(let fe=0;fe<H.length;fe++){const pe=H[fe],he=fe===H.length-1;let Re=he?_/pe.factor:Math.floor(_/pe.factor);if(_-=Re*pe.factor,he){const Le=10**ee;Re=Math.round(Re*Le)/Le+0}const Ue=he?y(Y.locale,J,ee,Y.group!==!1):y(Y.locale,0,0,Y.group!==!1);se.push(`${Ue.format(Re)}${ne}${pe.symbol}`)}const oe=se.join(" ");return Z?`-${oe}`:oe}function $(A,C){const H=C||{},Y=H.nullDisplay??"";if(N(A)||A==="")return Y;const Z=typeof A=="number"?A:Number(A);if(!Number.isFinite(Z))return Y;const _=t(H);if(!_)return String(Z);const J=i(H,_);if(J)return I(Z,_,J,H);const ee=typeof H.significantFigures=="number"&&H.significantFigures>0?H.significantFigures:0,ne=ee?M(Z,ee):Z,se=F(ne,_,H.display),oe=n(ne,_.base,se);let fe=typeof H.decimals=="number"?H.decimals:H.minDecimals??0,pe=typeof H.decimals=="number"?H.decimals:H.maxDecimals??Math.max(fe,2);ee&&(fe=E(oe,ee),pe=fe);const he=y(H.locale,fe,pe,H.group!==!1).format(oe),Re=H.space??" ";return H.placement==="prefix"?`${se.symbol}${H.space??""}${he}`:`${he}${Re}${se.symbol}`}function S(A,C){const H=N(A)||Number.isNaN(A)?null:Number(A),Y=N(C)||Number.isNaN(C)?null:Number(C);return H===null||Number.isNaN(H)?Y===null||Number.isNaN(Y)?0:1:Y===null||Number.isNaN(Y)||H<Y?-1:H>Y?1:0}function R(A){const C=typeof A.decimals=="number"&&A.decimals>0?`.${"0".repeat(A.decimals)}`:"";return`${typeof A.decimals=="number"?`#,##0${C}`:"#,##0.##"}" ${A.symbol}"`}function L(A){const C={system:"data",...A||{}},H=t(C),Y=H?H.base.symbol:String(C.unit||""),Z=Object.freeze({...C,unit:Y}),_=Object.freeze({...Z,display:Y,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[Z.locale||"",Z]]),ee=ne=>{const se=ne||"";let oe=J.get(se);return oe||(oe=Object.freeze({...Z,locale:ne||void 0}),J.set(se,oe)),oe};return{base:"number",extends:"number",storage:"float64",unitConfig:Z,format:ne=>$(ne.value,ne.locale?ee(ne.locale):Z),parse:ne=>m(ne.text,ne.locale?ee(ne.locale):Z),compare:S,defaults:{filter:"number",editor:"unit",align:"end",total:C.total||"sum"},...C.totals?{totals:C.totals}:{},excel:C.excel||R({decimals:C.decimals,symbol:Y}),toStorage:ne=>typeof ne=="number"?Number.isFinite(ne)?ne:null:typeof ne=="string"?m(ne,Z):N(ne)?null:m(String(ne),Z),toClipboard:ne=>$(ne,_),fromClipboard:ne=>m(ne,Z)}}const T=L}),Ie("packages/core/src/columns/types/engineering.js",function(e,U){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return D}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/columns/types/unit.js").createUnitType;function D(x){const G=2*Math.PI/x;return z=>{let j=0,O=0,b=0;for(const f of z||[]){if(N(f))continue;const a=Number(f);Number.isFinite(a)&&(j+=Math.cos(a*G),O+=Math.sin(a*G),b+=1)}return!b||Math.hypot(j,O)/b<1e-12?null:(Math.atan2(O,j)/G%x+x)%x}}function q(x){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:D(x)}}}const K=Object.freeze({metres:B({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:B({system:"length",unit:"mm",maxDecimals:2}),kilometres:B({system:"length",unit:"km",maxDecimals:3}),grams:B({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:B({system:"mass",unit:"kg",maxDecimals:3}),tonnes:B({system:"mass",unit:"t",maxDecimals:3}),seconds:B({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:B({system:"duration",unit:"ms",maxDecimals:3}),hours:B({system:"duration",unit:"h",maxDecimals:2}),speed:B({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:B({system:"speed",unit:"km/h",maxDecimals:1}),mph:B({system:"speed",unit:"mph",maxDecimals:1}),knots:B({system:"speed",unit:"kn",maxDecimals:1}),acceleration:B({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:B({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:B({system:"area",unit:"ha",maxDecimals:4}),volume:B({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:B({system:"volume",unit:"m³",maxDecimals:3}),energy:B({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:B({system:"energy",unit:"kWh",maxDecimals:2}),power:B({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:B({system:"power",unit:"kW",maxDecimals:2}),force:B({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:B({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:B({system:"pressure",unit:"bar",maxDecimals:3}),psi:B({system:"pressure",unit:"psi",maxDecimals:1}),torque:B({system:"torque",unit:"N·m",maxDecimals:2}),density:B({system:"density",unit:"kg/m³",maxDecimals:2}),flow:B({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:B({system:"flow",unit:"L/min",maxDecimals:1}),radians:B({system:"angle",unit:"rad",maxDecimals:4,totals:q(2*Math.PI)}),degrees:B({system:"angle",unit:"°",maxDecimals:2,totals:q(360)}),rpm:B({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:B({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:B({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:B({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:B({system:"fraction",unit:"bp",maxDecimals:1}),molarity:B({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:B({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:B({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:B({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:B({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:B({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:B({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:B({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Ie("packages/core/src/columns/types/si.js",function(e,U){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return j}});const te=U("packages/core/src/columns/types/unit.js"),N=te.defineUnit,X=te.registerUnitSystem,B=te.createUnitType,D=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})]),q=Object.freeze(["p","n","µ","m","","k","M","G"]);function K(O){const b=String(O.base),u=new Set([...O.prefixes||q,""]),f=[];for(const a of D){if(!u.has(a.symbol))continue;const r=`${a.symbol}${b}`,t=[];if(O.name){t.push(`${a.name}${O.name}`,`${a.name}${O.name}s`);const s=a.name.slice(-1);if(s&&O.name.startsWith(s)){const i=`${a.name.slice(0,-1)}${O.name}`;t.push(i,`${i}s`)}}a.symbol==="µ"&&t.push(`u${b}`),a.factor===1&&O.aliases&&t.push(...O.aliases),f.push(N(r,a.factor,t))}for(const a of O.extra||[])f.push(a);return f}function x(O,b){const u=K(b);return X(O,u)}function G(O,b,u){return x(O,b),B({system:O,unit:b.base,display:"auto",maxDecimals:3,...u||{}})}const z=Object.freeze({voltage:G("voltage",{base:"V",name:"volt"}),current:G("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:G("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:G("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:G("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:G("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[N("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),N("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:G("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:G("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[N("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:G("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:G("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:G("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:G("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:G("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:G("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:G("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[N("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:G("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),j=G}),Ie("packages/core/src/columns/types/temperature.js",function(e,U){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const N=U("packages/core/src/internal/predicates.js").isNil,X=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:f=>f+273.15,fromKelvin:f=>f-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:f=>(f+459.67)*(5/9),fromKelvin:f=>f*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:f=>f,fromKelvin:f=>f}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:f=>f*(5/9),fromKelvin:f=>f*(9/5)})});function B(f){if(N(f))return null;const a=String(f).trim();if(a==="")return null;for(const[t,s]of Object.entries(X))if(a===t||a===s.symbol)return{key:t,scale:s};const r=a.toLowerCase();for(const[t,s]of Object.entries(X))if(s.aliases.includes(r))return{key:t,scale:s};return null}function D(f,a,r){const t=B(a),s=B(r);return!t||!s||!Number.isFinite(Number(f))?null:t.key===s.key?Number(f):s.scale.fromKelvin(t.scale.toKelvin(Number(f)))}const q=new Map;function K(f,a,r){const t=`${f||""}|${a}|${r}`;let s=q.get(t);return s||(s=new Intl.NumberFormat(f||void 0,{minimumFractionDigits:a,maximumFractionDigits:r}),q.set(t,s)),s}function x(f,a){const r=a||{},t=r.nullDisplay??"";if(N(f)||f==="")return t;const s=Number(f);if(!Number.isFinite(s))return t;const i=B(r.scale||"C");if(!i)return String(s);const n=B(r.display||r.scale||"C")||i,c=n.key===i.key?s:n.scale.fromKelvin(i.scale.toKelvin(s)),o=typeof r.decimals=="number"?r.decimals:null,l=o??r.minDecimals??0,h=o??r.maxDecimals??1;return`${K(r.locale,l,h).format(c)}${r.space??" "}${n.scale.symbol}`}const G=/^[+-]?[\d\s., ]*\d/;function z(f,a){const r=String(f).trim();if(r==="")return null;const t=new Intl.NumberFormat(a||void 0).formatToParts(1.1).find(c=>c.type==="decimal")?.value||".",s=t===","?".":",",i=r.split(s).join("").split(/[\s ]/).join("").replace(t,"."),n=Number(i);return Number.isFinite(n)?n:null}function j(f,a){if(N(f))return null;const r=a||{},t=B(r.scale||"C");if(!t)return null;if(typeof f=="number")return Number.isFinite(f)?f:null;let s=String(f).trim();if(s==="")return null;let i=!1;s.startsWith("(")&&s.endsWith(")")&&(i=!0,s=s.slice(1,-1).trim());const n=G.exec(s);if(!n)return null;const c=z(n[0],r.locale);if(c===null)return null;const o=s.slice(n[0].length).trim();if(o==="")return i?-c:c;const l=B(o);if(!l)return null;const h=l.key===t.key?c:t.scale.fromKelvin(l.scale.toKelvin(c));return i?-h:h}function O(f){const a=Object.freeze({scale:"C",...f||{}}),t=(B(a.scale)||B("C")).scale.symbol,s=Object.freeze({...a,display:a.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),i=new Map([[a.locale||"",a]]),n=c=>{const o=c||"";let l=i.get(o);return l||(l=Object.freeze({...a,locale:c||void 0}),i.set(o,l)),l};return{base:"number",extends:"number",storage:"float64",temperatureConfig:a,format:c=>x(c.value,c.locale?n(c.locale):a),parse:c=>j(c.text,c.locale?n(c.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:c=>typeof c=="number"?Number.isFinite(c)?c:null:typeof c=="string"?j(c,a):N(c)?null:j(String(c),a),toClipboard:c=>x(c,s),fromClipboard:c=>j(c,a)}}const b=Object.freeze({celsius:O({scale:"C"}),fahrenheit:O({scale:"F"}),kelvin:O({scale:"K"})}),u=O}),Ie("packages/core/src/columns/types/radix.js",function(e,U){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const N=U("packages/core/src/internal/predicates.js").isNil,B=U("packages/core/src/internal/warn.js").warnOnce,D=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}),q=Object.freeze({2:1,8:3,16:4}),K=Object.freeze({2:"0b",8:"0o",16:"0x"}),x=Object.freeze({2:4,8:3,16:2}),G=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),z=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),j=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),O=/[\s\u00a0\u202f_,']/g,b=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,u=Object.freeze([8,16,32,53]),f=new WeakSet,a=new WeakMap,r=new Map,t=new WeakMap,s=new WeakMap,i=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function n($){if($==null)return 16;const S=typeof $=="string"?$.toLowerCase():$,R=D[S];return R||(B(`radix:base:${String($)}`,`unsupported radix ${String($)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function c($,S){return Math.ceil($/q[S])}function o($,S){if(!$)return S?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!S)return{min:0,max:2**$-1};const R=2**($-1);return{min:-R,max:R-1}}function l($){return z[$]||"hexadecimal"}function h($){if(typeof $=="string"){const S=i[$];return S||B(`radix:preset:${$}`,`unknown radix preset "${$}"; known presets are ${Object.keys(i).join(", ")}`),{...S||{}}}if($&&typeof $.preset=="string"){const S=i[$.preset];return S||B(`radix:preset:${$.preset}`,`unknown radix preset "${$.preset}"; known presets are ${Object.keys(i).join(", ")}`),{...S||{},...$}}return $||{}}function w($){const S=h($),R=n(S.radix),L=q[R];let T=null;if(S.bitWidth!==void 0&&S.bitWidth!==null&&S.bitWidth!==!1){const ne=Number(S.bitWidth);u.includes(ne)?T=ne:B(`radix:width:${String(S.bitWidth)}`,`unsupported bitWidth ${String(S.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let A=S.signed!==!1;!A&&T===null&&(B("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),T=32);const C=S.prefix===void 0||S.prefix===!0?K[R]:S.prefix===!1?"":String(S.prefix);let H=0;S.pad===!0?H=T?c(T,R):0:typeof S.pad=="number"&&S.pad>0&&(H=Math.floor(S.pad));let Y=0;S.group===!0?Y=x[R]:typeof S.group=="number"&&S.group>0&&(Y=Math.floor(S.group));const Z=o(T,A),_=typeof S.min=="number"?Math.max(Z.min,S.min):Z.min,J=typeof S.max=="number"?Math.min(Z.max,S.max):Z.max,ee=Object.freeze({radix:R,bits:L,prefix:C,uppercase:S.uppercase!==!1,pad:H,group:Y,groupSeparator:typeof S.groupSeparator=="string"?S.groupSeparator:" ",bitWidth:T,signed:A,min:_,max:J<_?_:J,nullDisplay:typeof S.nullDisplay=="string"?S.nullDisplay:"",name:l(R)});return f.add(ee),ee}function g($){if($&&f.has($))return $;if(typeof $=="string"){let S=r.get($);return S||(S=w($),r.set($,S)),S}if($&&typeof $=="object"){let S=a.get($);return S||(S=w($),a.set($,S)),S}return g("hex")}function k($){return $<0?-Math.round(-$):Math.round($)}function d($,S,R){if(S<=0||$.length<=S)return $;const L=$.length%S||S,T=[$.slice(0,L)];for(let A=L;A<$.length;A+=S)T.push($.slice(A,A+S));return T.join(R)}function p($){const S=g($),{radix:R,prefix:L,uppercase:T,pad:A,group:C,groupSeparator:H,signed:Y,bitWidth:Z,nullDisplay:_}=S,J=Z?2**Z:0,ee=ne=>{if(N(ne)||ne==="")return _;const se=typeof ne=="number"?ne:Number(ne);if(!Number.isFinite(se))return _;const oe=k(se);let fe="",pe=oe;oe<0&&(Y?(fe="-",pe=-oe):pe=(oe%J+J)%J);let he=pe.toString(R);return he=T?he.toUpperCase():he.toLowerCase(),A>0&&he.length<A&&(he=he.padStart(A,"0")),C>0&&(he=d(he,C,H)),fe+L+he};return ee.options=S,ee}function m($,S){const R=g(S);let L=t.get(R);return L||(L=p(R),t.set(R,L)),L($)}function v($){const S=g($),{radix:R,groupSeparator:L,signed:T,min:A,max:C}=S,H=G[R],Y=Z=>{if(N(Z))return{ok:!0,value:null,reason:"blank"};let _=String(Z);if(L&&L!==""&&(_=_.split(L).join("")),_=_.replace(O,""),_==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((_[0]==="-"||_[0]==="+")&&(J=_[0]==="-",_=_.slice(1)),_==="")return{ok:!1,value:null,reason:"digits"};let ee=null;for(const[se,oe]of j){const fe=se.exec(_);if(!fe)continue;const pe=_.slice(fe[0].length);if(pe==="")break;if(!G[oe].test(pe))return{ok:!1,value:null,reason:"digits"};ee=parseInt(pe,oe);break}if(ee===null)if(H.test(_))ee=parseInt(_,R);else if(b.test(_))ee=Number(_);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(ee))return{ok:!1,value:null,reason:"digits"};const ne=k(J?-ee:ee);return!T&&ne<0?{ok:!1,value:ne,reason:"negative"}:ne<A||ne>C?{ok:!1,value:ne,reason:"range"}:{ok:!0,value:ne,reason:"ok"}};return Y.options=S,Y}function y($,S){const R=g(S);let L=s.get(R);return L||(L=v(R),s.set(R,L)),L($)}function E($,S){const R=y($,S);return R.ok?R.value:null}function M($,S){const R=N($)||Number.isNaN($)?null:Number($),L=N(S)||Number.isNaN(S)?null:Number(S);return R===null?L===null?0:1:L===null||R<L?-1:R>L?1:0}function F($){const S=$.min>=-2147483648&&$.max<=2147483647;return $.bitWidth&&S?"int32":"float64"}function V($){const S=w($),R=p(S),L=v(S);return{base:"number",extends:"number",storage:F(S),matches:null,format:T=>R(T.value),parse:T=>{const A=L(T.text);return A.ok?A.value:null},compare:M,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:T=>R(T),fromClipboard:T=>{const A=L(T);return A.ok?A.value:null},radix:S,formatValue:R,parseText:L}}const I=V}),Ie("packages/core/src/columns/types/aggregable.js",function(e,U){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return D}});const N=U("packages/core/src/internal/predicates.js").isNil;function X(z){const j=[];for(const O of z||[]){if(N(O))continue;const b=Number(O);Number.isFinite(b)&&j.push(b)}return j}function B(z){return j=>{const O=X(j);if(!O.length)return null;let b=0;for(const u of O)b+=10**(u/z);return z*Math.log10(b)}}function D(z){return j=>{const O=X(j);if(!O.length)return null;let b=0;for(const u of O)b+=10**(u/z);return z*Math.log10(b/O.length)}}function q(z,j){const O=j&&j.column,u=(O&&O.typeOptions||{}).weight,f=j&&j.valueAt;if(!u||typeof f!="function")return null;let a=0,r=0;for(let t=0;t<z.length;t++){if(N(z[t]))continue;const s=Number(z[t]);if(!Number.isFinite(s))continue;const i=f(u,t);if(N(i))continue;const n=Number(i);!Number.isFinite(n)||n<=0||(a+=s*n,r+=n)}return r===0?null:a/r}function K(z={}){const j=z.factor===20?20:10,O=typeof z.suffix=="string"?z.suffix:"",b=Number.isInteger(z.decimals)?z.decimals:1;return{base:"number",storage:"float64",name:z.name||"logarithmic",format:u=>{const f=u&&u.value;return N(f)||!Number.isFinite(Number(f))?"":`${Number(f).toFixed(b)}${O}`},parse:u=>{const f=String((u&&u.text)??"").replace(O,"").trim();if(!f)return null;const a=Number(f);return Number.isFinite(a)?a:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:B(j),avg:D(j)}}}}function x(z={}){const j=Number.isInteger(z.decimals)?z.decimals:1,O=z.percent===!0;return{base:"number",storage:"float64",name:z.name||"ratio",format:b=>{const u=b&&b.value;return N(u)||!Number.isFinite(Number(u))?"":O?`${Number(u).toFixed(j)}%`:Number(u).toFixed(j)},parse:b=>{const u=String((b&&b.text)??"").replace("%","").trim();if(!u)return null;const f=Number(u);return Number.isFinite(f)?f:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:q}}}}const G=Object.freeze({decibel:K({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:K({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:x({name:"ratio"}),percentRate:x({name:"percentRate",percent:!0})})}),Ie("packages/core/src/columns/types/currency.js",function(e,U){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return f}}),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 s}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const N=U("packages/core/src/internal/predicates.js").isNil,X="⚠ no rate";function B(c){if(N(c))return null;const o=String(c).trim().toUpperCase();return o===""?null:o}function D(c){if(N(c))return null;if(typeof c=="object"&&!Array.isArray(c)){const o=Number(c.amount),l=B(c.code);return!l||!Number.isFinite(o)?null:{amount:o,code:l}}if(Array.isArray(c)&&c.length===2){const o=Number(c[0]),l=B(c[1]);return!l||!Number.isFinite(o)?null:{amount:o,code:l}}return null}const q=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),K=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),x=/[+-]?[\d\s., ]*\d/;function G(c,o){const l=String(c).trim();if(l==="")return null;const h=new Intl.NumberFormat(o||void 0).formatToParts(1.1).find(d=>d.type==="decimal")?.value||".",w=h===","?".":",",g=l.split(w).join("").split(/[\s ]/).join("").replace(h,"."),k=Number(g);return Number.isFinite(k)?k:null}function z(c,o){const l=o||{},h=B(l.code);if(N(c))return null;const w=D(c);if(w)return w;if(typeof c=="number")return Number.isFinite(c)&&h?{amount:c,code:h}:null;let g=String(c).trim();if(g==="")return null;let k=!1;g.startsWith("(")&&g.endsWith(")")&&(k=!0,g=g.slice(1,-1).trim());let d=null;for(const[M,F]of Object.entries(q)){if(g.startsWith(M)){d=F,g=g.slice(M.length).trim();break}if(g.endsWith(M)){d=F,g=g.slice(0,-M.length).trim();break}}const p=x.exec(g);if(!p)return null;const m=G(p[0],l.locale);if(m===null)return null;const v=(g.slice(0,p.index)+" "+g.slice(p.index+p[0].length)).trim();!d&&v!==""&&(d=B(v));const y=d||h;return y?{amount:k?-m:m,code:y}:null}function j(c,o){if(typeof c=="function")return(l,h)=>{if(l===h)return 1;const w=c(l,h);return typeof w=="number"&&Number.isFinite(w)&&w>0?w:null};if(c&&typeof c=="object"){const l=c;return(h,w)=>{if(h===w)return 1;const g=Number(l[h]),k=Number(l[w]);return!Number.isFinite(g)||!Number.isFinite(k)||g<=0||k<=0?null:k/g}}return(l,h)=>l===h?1:null}function O(c,o,l){if(!c)return null;if(c.code===o)return c.amount;const h=l(c.code,o);return h===null?null:c.amount*h}const b=new Map;function u(c,o,l){const h=`${c||""}|${o}|${l??""}`;let w=b.get(h);if(!w){const g={style:"currency",currency:o};typeof l=="number"&&(g.minimumFractionDigits=l,g.maximumFractionDigits=l);try{w={fmt:new Intl.NumberFormat(c||void 0,g),currency:!0}}catch{w={fmt:new Intl.NumberFormat(c||void 0,typeof l=="number"?{minimumFractionDigits:l,maximumFractionDigits:l}:{}),currency:!1}}b.set(h,w)}return w}function f(c,o){const l=o||{},h=l.nullDisplay??"",w=D(c);if(!w)return h;const g=B(l.display)||w.code;let k=w.amount,d=w.code;if(g!==w.code){const v=l.rateFn||j(l.rates,l.rateBase),y=O(w,g,v);if(y===null)return`${l.missingRate??X} ${w.code}→${g}`;k=y,d=g}const{fmt:p,currency:m}=u(l.locale,d,l.decimals);return m?p.format(k):`${p.format(k)} ${d}`}function a(c){const o=D(c);return o?`${o.amount} ${o.code}`:""}function r(c){const o=c||{},l=B(o.display),h=o.rateFn||j(o.rates,o.rateBase);return(w,g)=>{const k=D(w),d=D(g);if(!k&&!d)return 0;if(!k)return 1;if(!d)return-1;if(l){const p=O(k,l,h),m=O(d,l,h);if(p!==null&&m!==null)return p===m?0:p<m?-1:1}return k.code===d.code?k.amount===d.amount?0:k.amount<d.amount?-1:1:k.code<d.code?-1:1}}function t(c){const o=c||{},l=(w,g)=>{const k=[];for(const y of w||[]){const E=D(y);E&&k.push(E)}if(!k.length)return null;if(new Set(k.map(y=>y.code)).size===1){const y=k[0].code;return{amount:g(k.map(E=>E.amount)),code:y}}const p=B(o.display);if(!p)return`${o.missingRate??X}: mixed currencies, no display currency set`;const m=o.rateFn||j(o.rates,o.rateBase),v=[];for(const y of k){const E=O(y,p,m);if(E===null)return`${o.missingRate??X}: ${y.code}→${p}`;v.push(E)}return{amount:g(v),code:p}},h=w=>w.reduce((g,k)=>g+k,0);return{sum:w=>l(w,h),avg:w=>l(w,g=>h(g)/g.length),min:w=>l(w,g=>Math.min(...g)),max:w=>l(w,g=>Math.max(...g))}}function s(c){const o=Object.freeze({code:"USD",...c||{}}),l=j(o.rates,o.rateBase),h=Object.freeze({...o,rateFn:l}),w=t(h),g=r(h),k=new Map([[o.locale||"",h]]),d=v=>{const y=v||"";let E=k.get(y);return E||(E=Object.freeze({...h,locale:v||void 0}),k.set(y,E)),E},p=K[B(o.display||o.code)]||"",m=typeof o.decimals=="number"&&o.decimals>0?`.${"0".repeat(o.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:h,format:v=>f(v.value,v.locale?d(v.locale):h),parse:v=>z(v.text,v.locale?d(v.locale):h),compare:g,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:w},excel:o.excel||(p?`"${p}"#,##0${m}`:`#,##0${m}`),toStorage:v=>{const y=D(v);return y||(typeof v=="string"||typeof v=="number"?z(v,h):null)},toClipboard:v=>a(v),fromClipboard:v=>z(v,h)}}const i=Object.freeze({currency:s({code:"USD"}),usd:s({code:"USD"}),eur:s({code:"EUR"}),gbp:s({code:"GBP"}),jpy:s({code:"JPY",decimals:0})}),n=s}),Ie("packages/core/src/columns/types/index.js",function(e,U){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return M}});const te=U("packages/core/src/columns/types/temporal.js"),N=te.TEMPORAL_TYPES,X=U("packages/core/src/columns/types/network.js"),B=X.NETWORK_TYPES,D=U("packages/core/src/columns/types/structured.js"),q=D.STRUCTURED_TYPES,K=U("packages/core/src/columns/types/unit.js"),x=K.createUnitType,G=K.UNIT_SYSTEMS,z=K.parseUnit,j=K.formatUnit,O=K.registerUnitSystem,b=K.unitSystemNames,u=K.unitsOf,f=K.defineUnit,a=U("packages/core/src/columns/types/engineering.js"),r=a.ENGINEERING_TYPES,t=U("packages/core/src/columns/types/si.js"),s=t.SI_TYPES,i=t.createSiType,n=t.createSiSystem,c=t.siUnits,o=t.SI_PREFIXES,l=U("packages/core/src/columns/types/temperature.js"),h=l.TEMPERATURE_TYPES,w=l.createTemperatureType,g=l.convertTemperature,k=l.formatTemperature,d=l.parseTemperature,p=l.TEMPERATURE_SCALES,m=U("packages/core/src/columns/types/radix.js"),v=m.createRadixType,y=m.RADIX_PRESETS,E=m.parseRadix,M=m.formatRadix,F=U("packages/core/src/columns/types/aggregable.js"),V=F.AGGREGABLE_TYPES,I=U("packages/core/src/columns/types/currency.js"),$=I.CURRENCY_TYPES,S=I.createCurrencyType,R=I.parseMoney,L=I.formatMoney,T=I.convertMoney,A=I.toMoney,C=I.rateFunction,H=I.moneyComparator,Y=I.normaliseCode,Z=I.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return K.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 l.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return l.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return l.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return l.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return l.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return l.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return l.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return I.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return I.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return I.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return I.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return I.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return I.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return I.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return I.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return I.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return I.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return te.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return X.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return D.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 te.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return te.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return te.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return te.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return te.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return te.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return X.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return X.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return X.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return X.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return X.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return X.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return X.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return X.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return X.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return X.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return X.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return D.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return D.summariseJson}});const _=Object.freeze({...N,...B,...q,...V,hex:v(y.hex),hex8:v(y.hex8),hex16:v(y.hex16),hex32:v(y.hex32),binary:v(y.binary),binary8:v(y.binary8),octal:v(y.octal),bytes:x({system:"data",unit:"B",display:"auto"}),megabytes:x({system:"data",unit:"MB"}),gigabytes:x({system:"data",unit:"GB"}),bitrate:x({system:"bitrate",unit:"Mbps"}),gigabits:x({system:"bitrate",unit:"Gbps"}),...r,...s,...h,...$});{const J=new Set;for(const ee of[N,B,q,V,r,s,h,$])for(const ne of Object.keys(ee)){if(J.has(ne))throw new Error(`[lattice] data type "${ne}" is declared twice`);J.add(ne)}}}),Ie("packages/core/src/compute/handle.js",function(e,U){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return s}});const te=U("packages/core/src/internal/compare.js"),N=te.collator,X=te.defaultCompare,D=U("packages/core/src/internal/warn.js").warnOnce;function q(i){const n=new Uint32Array(i);for(let c=0;c<i;c++)n[c]=c;return n}function K(i,n){if(n&&typeof n.count=="number")return n.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const c=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):c?i.kind==="bitset"?typeof c.size=="number"?c.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(D(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${c.length*8}`),c.length*8):c.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const x=new WeakMap;function G(i){const n=i.constructor;if(!n)return"unknown";const c=x.get(n);if(c)return c;let o="unknown";try{let l=null;typeof n.from=="function"?l=n.from([!1,!0]):(l=new n(8),l.set(1));const h=l&&l.words;h&&h.length&&(h[0]===2?o="lsb":h[0]===64&&(o="msb"))}catch{o="unknown"}return x.set(n,o),o}function z(i){if(!i)return()=>0;const n=i instanceof Uint8Array?i:i.words;if(n instanceof Uint8Array){const c=i instanceof Uint8Array?"lsb":G(i);if(c==="lsb")return o=>n[o>>>3]>>>(o&7)&1;if(c==="msb")return o=>n[o>>>3]>>>7-(o&7)&1}return typeof i.get=="function"?c=>i.get(c)?1:0:()=>0}function j(i){return!i||!i.presence?null:z(i.presence)}function O(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function b(i,n){return i?typeof i.valueOf=="function"?i.valueOf(n):typeof i.values=="function"?i.values()[n]:null:null}function u(i,n){const c=i.offsets,o=i.values;if(!c||!o)return[];const l=c[n],h=c[n+1];if(!(h>l))return[];const w=i.dict,g=new Array(h-l);for(let k=l;k<h;k++)g[k-l]=w?b(w,o[k]):o[k];return g}function f(i){if(!i)return()=>{};const n=i.values,c=j(i),o=i.kind;if(o==="dictionary"){const l=i.dict;return c?h=>c(h)?b(l,n[h]):null:h=>b(l,n[h])}if(o==="bitset"){const l=z(n);return c?h=>c(h)?l(h)===1:null:h=>l(h)===1}if(o==="multi")return c?l=>c(l)?u(i,l):null:l=>u(i,l);if(!n&&typeof i.get=="function"){const l=i.get.bind(i);return h=>{const w=l(h);return w===void 0?null:w}}return c?l=>{if(!c(l))return null;const h=n[l];return h===void 0?null:h}:l=>{const h=n[l];return h===void 0?null:h}}function a(i,n){if(i<n)return-1;if(i>n)return 1;if(i===n){const l=Object.is(i,-0),h=Object.is(n,-0);return l===h?0:l?-1:1}const c=Number.isNaN(i),o=Number.isNaN(n);return c&&o?0:c?1:-1}function r(i){const n=N(i);return(c,o)=>{if(c===o)return 0;const l=typeof c,h=typeof o;if(l==="string"&&h==="string")return n.compare(c,o);if(l==="number"&&h==="number")return a(c,o);if(l==="boolean"&&h==="boolean")return c===o?0:c?1:-1;if(c instanceof Date||o instanceof Date){const w=c instanceof Date?c.getTime():Number(c),g=o instanceof Date?o.getTime():Number(o);return a(w,g)}return X(c,o)}}function t(i,n){if(i&&typeof i.ranks=="function")return i.ranks(n);const c=i&&typeof i.values=="function"?i.values():[],o=c.length,l=r(n),h=new Array(o);for(let g=0;g<o;g++)h[g]=g;h.sort((g,k)=>l(c[g],c[k])||g-k);const w=new Uint32Array(o);for(let g=0;g<o;g++)w[h[g]]=g;return w}function s(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Ie("packages/core/src/compute/filter.js",function(e,U){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return pe}});const N=U("packages/core/src/internal/predicates.js").isBlank,B=U("packages/core/src/internal/merge.js").toArray,q=U("packages/core/src/internal/warn.js").warnOnce,K=U("packages/core/src/format/date.js"),x=K.toDate,G=K.toIsoDate,z=U("packages/core/src/compute/handle.js"),j=z.bitReader,O=z.dictSize,b=z.dictValue,u=z.presenceReader,f=z.valueComparator,a=z.valueReader,r=/^\d{4}-\d{2}-\d{2}$/,t="\0null\0";function s(he,Re){const Ue=he&&he.pool;if(Ue){const Le=Ue.mask||Ue.acquireMask||Ue.acquire||Ue.take;if(typeof Le=="function"){const ie=Le.call(Ue,Re);if(ie&&ie.length>=Re)return ie}}return new Uint8Array(Re)}function i(he,Re){const Ue=he&&he.pool;if(!Ue||!Re)return;const Le=Ue.release||Ue.releaseMask||Ue.free||Ue.recycle;typeof Le=="function"&&Le.call(Ue,Re)}function n(he,Re,Ue){return he.fill(Ue,0,Re),he}function c(he){return he==null||typeof he=="number"&&Number.isNaN(he)}function o(he,Re){if(he==null)return he;if(Re==="number")return typeof he=="number"?he:Number(he);if(Re==="date"||Re==="dateString"){const Ue=G(he);return Ue===null?l(he):Ue}return Re==="boolean"?typeof he=="boolean"?he:he==="true"||he===1?!0:he==="false"||he===0?!1:!!he:he}function l(he){return he instanceof Date?he.getTime():typeof he=="number"?he:Date.parse(String(he))}function h(he){return typeof he=="number"?he:he instanceof Date?he.getTime():he==null||he===""?NaN:Number(he)}function w(he,Re){const Ue=typeof he=="string"?he:String(he);return Re?Ue:Ue.toLowerCase()}function g(he,Re){return he==null?t:typeof he=="string"?Re?he:he.toLowerCase():he instanceof Date?he.getTime():he}function k(he,Re,Ue){const Le=new Set;for(const ie of B(he)){const ge=o(ie,Ue);Le.add(g(ge,Re)),typeof ge=="string"&&ge!==""&&Number.isFinite(Number(ge))?Le.add(Number(ge)):typeof ge=="number"&&Number.isFinite(ge)&&Le.add(g(String(ge),Re))}return Le}function d(he,Re,Ue){if(he==null||Re===null||Re===void 0)return he==null&&Re==null;const Le=typeof he,ie=typeof Re;return Le==="string"&&ie==="string"?Ue?he===Re:he.toLowerCase()===Re.toLowerCase():he instanceof Date||Re instanceof Date?l(he)===l(Re):Le==="number"&&ie==="number"?he===Re||Number.isNaN(he)&&Number.isNaN(Re):Le==="number"&&ie==="string"?he===Number(Re):Le==="string"&&ie==="number"?Number(he)===Re:Le==="boolean"||ie==="boolean"?he===Re:Array.isArray(he)&&Array.isArray(Re)?he.length===Re.length&&he.every((ge,ke)=>d(ge,Re[ke],Ue)):he===Re}function p(he,Re){try{if(he instanceof RegExp){const Ue=he.flags.replace(/[gy]/g,"");return new RegExp(he.source,Re||Ue.includes("i")?Ue:`${Ue}i`)}return new RegExp(String(he),Re?"":"i")}catch(Ue){return q(`regex:${String(he)}`,`filter operator "matches" received an invalid pattern: ${String(he)}`,Ue),null}}function m(he,Re){if(he&&he.type==="datetime"&&v.has(he.op))return V(he,Re);const Ue=I(he,Re),Le=he&&he.type;return Le!=="date"&&Le!=="dateString"?Ue:ie=>Ue(typeof ie=="string"&&r.test(ie)?ie:G(ie)??ie)}const v=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),y=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,E=new Map;function M(he,Re){let Ue=E.get(Re);if(Ue===void 0){try{Ue=new Intl.DateTimeFormat("en-CA",{timeZone:Re,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{Ue=null}E.set(Re,Ue)}if(!Ue)return null;const Le={};for(const ie of Ue.formatToParts(he))ie.type!=="literal"&&(Le[ie.type]=ie.value);return Le}function F(he,Re){if(he==null||he==="")return null;if(typeof he=="string"){const ge=y.exec(he.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 Ue=x(he);if(!Ue)return null;const Le=Ue.getUTCMilliseconds(),ie=Re?M(Ue,Re):null;return ie?Date.UTC(+ie.year,+ie.month-1,+ie.day,ie.hour==="24"?0:+ie.hour,+ie.minute,+ie.second,Le):Date.UTC(Ue.getFullYear(),Ue.getMonth(),Ue.getDate(),Ue.getHours(),Ue.getMinutes(),Ue.getSeconds(),Le)}function V(he,Re){const Ue=typeof he.timeZone=="string"&&he.timeZone?he.timeZone:void 0,Le=ke=>F(ke,Ue),ie=Array.isArray(he.value)?he.value.map(Le):Le(he.value),ge=I({...he,type:"number",value:ie},Re);return ke=>ge(F(ke))}function I(he,Re){const Ue=he&&he.op,Le=!!(he&&he.caseSensitive),ie=he&&he.type,ge=f(Re),ke=Se=>Ae=>!Se(Ae);switch(Ue){case"eq":{const Se=o(he.value,ie);return Ae=>d(Ae,Se,Le)}case"ne":{const Se=o(he.value,ie);return Ae=>!d(Ae,Se,Le)}case"lt":case"lte":case"gt":case"gte":{const Se=o(he.value,ie);if(c(Se))return()=>!1;const Ae=Ue==="lt"?-1:Ue==="lte"?0:Ue==="gt"?1:2;return xe=>{if(c(xe))return!1;const me=ge(xe,Se);return Ae===-1?me<0:Ae===0?me<=0:Ae===1?me>0:me>=0}}case"between":case"notBetween":{const Se=B(he.value),Ae=o(Se[0],ie),xe=o(Se[1],ie),me=he.bounds||"[]",ye=me.charAt(0)!=="(",Te=me.charAt(1)!==")";if(c(Ae)||c(xe))return Ue==="between"?()=>!1:()=>!0;const Ye=Oe=>{if(c(Oe))return!1;const _e=ge(Oe,Ae),je=ge(Oe,xe);return(ye?_e>=0:_e>0)&&(Te?je<=0:je<0)};return Ue==="between"?Ye:ke(Ye)}case"in":case"notIn":{const Se=k(he.value,Le,ie),Ae=xe=>Se.has(g(xe,Le));return Ue==="in"?Ae:ke(Ae)}case"contains":case"notContains":{const Se=w(o(he.value,ie),Le),Ae=xe=>xe==null?!1:w(xe,Le).includes(Se);return Ue==="contains"?Ae:ke(Ae)}case"startsWith":{const Se=w(o(he.value,ie),Le);return Ae=>Ae==null?!1:w(Ae,Le).startsWith(Se)}case"endsWith":{const Se=w(o(he.value,ie),Le);return Ae=>Ae==null?!1:w(Ae,Le).endsWith(Se)}case"matches":{const Se=p(he.value,Le);return Se?Ae=>Ae==null?!1:Se.test(String(Ae)):()=>!1}case"blank":return Se=>N(Se)||Array.isArray(Se)&&Se.length===0;case"notBlank":return Se=>!(N(Se)||Array.isArray(Se)&&Se.length===0);case"containsAny":case"containsNone":{const Se=k(he.value,Le,ie),Ae=xe=>{const me=xe==null?[]:B(xe);for(let ye=0;ye<me.length;ye++)if(Se.has(g(me[ye],Le)))return!0;return!1};return Ue==="containsAny"?Ae:ke(Ae)}case"containsAll":{const Se=B(he.value).map(Ae=>g(o(Ae,ie),Le));return Ae=>{const xe=Ae==null?[]:B(Ae);if(Se.length===0)return!0;const me=new Set(xe.map(ye=>g(ye,Le)));for(let ye=0;ye<Se.length;ye++)if(!me.has(Se[ye]))return!1;return!0}}default:{const Se=pe(Ue);return Se?Se.compile(he.value):(q(`op:${String(Ue)}`,`unknown filter operator "${String(Ue)}"; the condition is refused rather than matching every row`),()=>!1)}}}function $(he,Re,Ue){return m(Re,Ue)(he)}const S=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),R=new Set(["containsAny","containsAll","containsNone"]);function L(he,Re,Ue){const Le=he&&he.op,ie=S[Le]||Le,ge=m({...he,op:ie,type:Re.type},Ue),ke=Re.items,Se=Ae=>{const xe=ke(Ae);if(!xe)return!1;for(let me=0;me<xe.length;me++)if(ge(xe[me]))return!0;return!1};return S[Le]?Ae=>!Se(Ae):Se}function T(he,Re,Ue,Le){const ie=u(he);if(ie){const Se=Re?1:0;for(let Ae=0;Ae<Le;Ae++)Ue[Ae]=ie(Ae)===Se?1:0;return Ue}const ge=he.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return n(Ue,Le,Re?1:0);const ke=a(he);for(let Se=0;Se<Le;Se++){const Ae=ke(Se),xe=N(Ae)||Array.isArray(Ae)&&Ae.length===0;Ue[Se]=xe===Re?0:1}return Ue}function A(he,Re,Ue,Le){const ie=he.dict,ge=O(ie),ke=new Uint8Array(ge);for(let me=0;me<ge;me++)ke[me]=Re(b(ie,me))?1:0;const Se=he.values,Ae=u(he);if(!Ae){for(let me=0;me<Le;me++)Ue[me]=ke[Se[me]];return Ue}const xe=Re(null)?1:0;for(let me=0;me<Le;me++)Ue[me]=Ae(me)===1?ke[Se[me]]:xe;return Ue}function C(he,Re,Ue,Le){const ie=j(he.values),ge=Re(!0)?1:0,ke=Re(!1)?1:0,Se=u(he);if(!Se){for(let xe=0;xe<Le;xe++)Ue[xe]=ie(xe)===1?ge:ke;return Ue}const Ae=Re(null)?1:0;for(let xe=0;xe<Le;xe++)Ue[xe]=Se(xe)===0?Ae:ie(xe)===1?ge:ke;return Ue}function H(he,Re,Ue,Le,ie){const ge=he.values,ke=Re.type,Se=Re.op;let Ae=!0;switch(Se){case"eq":case"ne":{const me=h(o(Re.value,ke)),ye=typeof Re.value=="number"&&Number.isNaN(Re.value),Te=Se==="ne"?1:0;if(ye)for(let Ye=0;Ye<ie;Ye++)Le[Ye]=(Number.isNaN(ge[Ye])?1:0)^Te;else for(let Ye=0;Ye<ie;Ye++)Le[Ye]=(ge[Ye]===me?1:0)^Te;break}case"lt":{const me=h(o(Re.value,ke));for(let ye=0;ye<ie;ye++)Le[ye]=ge[ye]<me?1:0;break}case"lte":{const me=h(o(Re.value,ke));for(let ye=0;ye<ie;ye++)Le[ye]=ge[ye]<=me?1:0;break}case"gt":{const me=h(o(Re.value,ke));for(let ye=0;ye<ie;ye++)Le[ye]=ge[ye]>me?1:0;break}case"gte":{const me=h(o(Re.value,ke));for(let ye=0;ye<ie;ye++)Le[ye]=ge[ye]>=me?1:0;break}case"between":case"notBetween":{const me=B(Re.value),ye=h(o(me[0],ke)),Te=h(o(me[1],ke)),Ye=Re.bounds||"[]",Oe=Ye.charAt(0)!=="(",_e=Ye.charAt(1)!==")",je=Se==="notBetween"?1:0;if(Oe&&_e)for(let we=0;we<ie;we++)Le[we]=(ge[we]>=ye&ge[we]<=Te?1:0)^je;else if(Oe)for(let we=0;we<ie;we++)Le[we]=(ge[we]>=ye&ge[we]<Te?1:0)^je;else if(_e)for(let we=0;we<ie;we++)Le[we]=(ge[we]>ye&ge[we]<=Te?1:0)^je;else for(let we=0;we<ie;we++)Le[we]=(ge[we]>ye&ge[we]<Te?1:0)^je;break}case"in":case"notIn":{const me=new Set;for(const Te of B(Re.value)){const Ye=h(o(Te,ke));Number.isNaN(Ye)||me.add(Ye)}const ye=Se==="notIn"?1:0;for(let Te=0;Te<ie;Te++)Le[Te]=(me.has(ge[Te])?1:0)^ye;break}default:Ae=!1;break}if(!Ae)return!1;const xe=u(he);if(xe){const me=Ue(null)?1:0;for(let ye=0;ye<ie;ye++)xe(ye)===0&&(Le[ye]=me)}return!0}function Y(he,Re,Ue,Le){const ie=a(he);for(let ge=0;ge<Le;ge++)Ue[ge]=Re(ie(ge))?1:0;return Ue}function Z(he,Re,Ue){const Le=Re.count|0,ie=Ue||s(Re,Le);if(!he)return n(ie,Le,1);const ge=typeof Re.handle=="function"?Re.handle(he.col):void 0,ke=typeof Re.custom=="function"?Re.custom:null;if(!ge){if(ke){for(let me=0;me<Le;me++)ie[me]=ke(he,me)?1:0;return ie}return q(`filter:col:${String(he.col)}`,`filter references unknown column "${String(he.col)}"; the condition is refused rather than matching every row`),n(ie,Le,0)}const Se=he.op;if(Se==="blank"||Se==="notBlank")return T(ge,Se==="notBlank",ie,Le);const Ae=typeof Re.itemwise=="function"?Re.itemwise(he.col):null;if(Ae&&!pe(Se)&&!R.has(Se))return Y(ge,L(he,Ae,Re.locale),ie,Le);const xe=m(he,Re.locale);switch(ge.kind){case"dictionary":return A(ge,xe,ie,Le);case"bitset":return C(ge,xe,ie,Le);case"float64":case"int32":return H(ge,he,xe,ie,Le)?ie:Y(ge,xe,ie,Le);default:return Y(ge,xe,ie,Le)}}function _(he,Re,Ue){if(!he)return n(s(Re,Ue),Ue,1);if(Array.isArray(he.conditions)){const Le=he.conditions.filter(ke=>ke!=null),ie=he.op==="or"?"or":he.op==="not"?"not":"and";if(Le.length===0)return n(s(Re,Ue),Ue,1);const ge=_(Le[0],Re,Ue);for(let ke=1;ke<Le.length;ke++){const Se=_(Le[ke],Re,Ue);if(ie==="or")for(let Ae=0;Ae<Ue;Ae++)ge[Ae]|=Se[Ae];else for(let Ae=0;Ae<Ue;Ae++)ge[Ae]&=Se[Ae];i(Re,Se)}if(ie==="not")for(let ke=0;ke<Ue;ke++)ge[ke]^=1;return ge}return Z(he,Re,s(Re,Ue))}function J(he,Re){return _(he,Re,Re.count|0)}function ee(he,Re){if(!he||!Re)return he||null;const Ue=he;if(Array.isArray(Ue.conditions)){if((Ue.op==="or"?"or":Ue.op==="not"?"not":"and")!=="and")return ne(Ue,Re)?null:he;const ie=[];for(const ge of Ue.conditions){const ke=ee(ge,Re);ke&&ie.push(ke)}return ie.length?{...Ue,op:"and",conditions:ie}:null}return Ue.col===Re?null:he}function ne(he,Re){if(!he||typeof he!="object")return!1;const Ue=he;if(Ue.col===Re)return!0;if(Array.isArray(Ue.conditions)){for(const Le of Ue.conditions)if(ne(Le,Re))return!0}return!1}function se(he,Re,Ue){if(Ue&&Ue.length>=Re){let ke=0;for(let Se=0;Se<Re;Se++)he[Se]&&(Ue[ke++]=Se);return Ue.subarray(0,ke)}let Le=0;for(let ke=0;ke<Re;ke++)Le+=he[ke]?1:0;const ie=new Uint32Array(Le);let ge=0;for(let ke=0;ke<Re;ke++)he[ke]&&(ie[ge++]=ke);return ie}const oe=new Map;function fe(he){if(!(!he||typeof he!="object"))for(const[Re,Ue]of Object.entries(he))Ue&&typeof Ue.compile=="function"&&oe.set(Re,Ue)}function pe(he){return typeof he=="string"?oe.get(he):void 0}}),Ie("packages/core/src/columns/datatypes.js",function(e,U){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return L}});const te=U("packages/core/src/internal/compare.js"),N=te.collator,X=te.defaultCompare,B=U("packages/core/src/internal/predicates.js"),D=B.isNil,q=B.isObject,K=B.isFunction,G=U("packages/core/src/internal/warn.js").fail,j=U("packages/core/src/internal/text.js").titleCase,O=U("packages/core/src/format/date.js"),b=O.toDate,u=O.toIsoDate,f=O.compareIso,r=U("packages/core/src/format/boolean.js").toTriState,s=U("packages/core/src/columns/types/index.js").EXTENDED_TYPES,i=U("packages/core/src/formula/index.js"),n=i.evaluateFormula,c=i.looksLikeFormula,l=U("packages/core/src/compute/filter.js").declareOperators,h=/^\d{4}-\d{2}-\d{2}$/;function w(T){return T.getHours()===0&&T.getMinutes()===0&&T.getSeconds()===0&&T.getMilliseconds()===0}const g=new Map;function k(T){const A=T||"",C=g.get(A);if(C)return C;const H={group:",",decimal:"."};try{for(const Y of new Intl.NumberFormat(T||void 0).formatToParts(12345.6))Y.type==="group"?H.group=Y.value:Y.type==="decimal"&&(H.decimal=Y.value)}catch{}return g.set(A,H),H}const d=/\d\s*[*/^]\s*[\d.(]/;function p(T,A){if(D(T))return null;let C=String(T).trim();if(C===""||C.startsWith("=")||d.test(C))return null;let H=1;C.startsWith("(")&&C.endsWith(")")&&(H=-1,C=C.slice(1,-1));const Y=C.endsWith("%"),{group:Z,decimal:_}=k(A);if(C=C.replace(/[\s\u00a0\u202f\u2009']/g,""),Z&&Z!=="."&&Z!==","&&(C=C.split(Z).join("")),C=C.replace(/[^0-9eE+\-.,]/g,""),_===","?C=C.split(".").join("").replace(",","."):C=C.split(",").join(""),C===""||C==="-"||C==="+")return null;const J=Number(C);return Number.isNaN(J)?null:H*(Y?J/100:J)}function m(T,A){const C=D(T)||Number.isNaN(T)?null:Number(T),H=D(A)||Number.isNaN(A)?null:Number(A);return C===null?H===null?0:1:H===null||C<H?-1:C>H?1:0}function v(T,A){const C=r(T),H=r(A);return C===null?H===null?0:1:H===null?-1:C===H?0:C?1:-1}function y(T,A){const C=b(T),H=b(A);if(!C)return H?1:0;if(!H)return-1;const Y=C.getTime(),Z=H.getTime();return Y<Z?-1:Y>Z?1:0}const E=new Map;function M(T){const A=b(T.value);if(!A)return"";const C=T.locale||"";let H=E.get(C);return H||(H=new Intl.DateTimeFormat(T.locale||void 0,{dateStyle:"medium"}),E.set(C,H)),H.format(A)}const F={boolean:{base:"boolean",storage:"bitset",matches:T=>typeof T=="boolean",parse:T=>r(T.text),compare:v,format:T=>r(T.value)===null?"":r(T.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:T=>r(T)===null?"":String(r(T)),fromClipboard:T=>r(T)},number:{base:"number",storage:"float64",matches:T=>typeof T=="number"&&!Number.isNaN(T),parse:T=>{if(c(T.text)){const A=n(T.text,T);if(!A.ok)return null;const C=Number(A.value);return Number.isFinite(C)?C:null}return p(T.text,T.locale)},compare:m,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:T=>D(T)?"":String(T),fromClipboard:(T,A)=>p(T,A&&A.locale)},date:{base:"dateString",storage:"dictionary",matches:T=>typeof T=="string"&&h.test(T)&&!Number.isNaN(Date.parse(T))||T instanceof Date&&!Number.isNaN(T.getTime())&&w(T),parse:T=>u(T.text),compare:f,format:M,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:T=>u(T),toClipboard:T=>D(T)?"":String(T),fromClipboard:T=>u(T)},dateString:{base:"dateString",storage:"dictionary",matches:T=>typeof T=="string"&&h.test(T)&&!Number.isNaN(Date.parse(T)),parse:T=>u(T.text),compare:f,format:M,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:T=>u(T),toClipboard:T=>D(T)?"":String(T),fromClipboard:T=>u(T)},text:{base:"text",storage:"dictionary",matches:T=>typeof T=="string",parse:T=>T.text===""?null:String(T.text),compare:(T,A)=>D(T)?D(A)?0:1:D(A)?-1:N().compare(String(T),String(A)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:T=>D(T)?"":String(T),fromClipboard:T=>T},image:{base:"text",storage:"dictionary",parse:T=>T.text===""||T.text==null?null:String(T.text).trim(),compare:(T,A)=>D(T)?D(A)?0:1:D(A)?-1:N().compare(String(T),String(A)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:T=>D(T)?"":String(T),fromClipboard:T=>T},lookup:{base:"text",storage:"dictionary",parse:T=>{if(T.text===""||T.text==null)return null;const A=T.column&&T.column.lookup,C=A&&K(A.options)?A.options():null;if(!C)return T.text;const H=String(T.text),Y=C.find(J=>String(J.id)===H);if(Y)return Y.id;const Z=H.trim().toLowerCase(),_=C.find(J=>String(J.label).toLowerCase()===Z);return _?_.id:T.text},compare:X,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:T=>D(T)?"":String(T),fromClipboard:T=>T},object:{base:"object",storage:"object",matches:T=>T!==null&&typeof T=="object"&&!(T instanceof Date),parse:T=>{try{return T.text===""?null:JSON.parse(T.text)}catch{return T.text}},compare:(T,A)=>X(T,A),format:T=>{const A=T.value;if(D(A))return"";if(typeof A=="string")return A;try{return JSON.stringify(A)}catch{return String(A)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:T=>D(T)?"":typeof T=="string"?T:JSON.stringify(T),fromClipboard:T=>T}},V=["boolean","number","date","dateString","datetime","text","object"];function I(T,A,C,H){const Y=C.get(T);if(Y)return Y;H.includes(T)&&G(`circular data type extends chain: ${[...H,T].join(" → ")}`);const Z=A[T];Z||G(`unknown data type "${T}"`);let _=null;Z.extends&&(_=I(Z.extends,A,C,[...H,T]));const J={..._||{},...Z,name:T,defaults:{..._&&_.defaults||{},...Z.defaults||{}}};return J.base||(J.base=_&&_.base||"text"),J.storage||(J.storage=_&&_.storage||"object"),C.set(T,J),J}function $(T,A){const C={...F,...s};if(A&&typeof A.dataType=="function"&&typeof A.names=="function")for(const Y of A.names("dataType")){const Z=A.dataType(Y);Z&&(C[Y]=Z)}if(q(T))for(const[Y,Z]of Object.entries(T))C[Y]=Z;const H=new Map;for(const Y of V)I(Y,C,H,[]);I("lookup",C,H,[]);for(const Y of Object.keys(C))I(Y,C,H,[]);for(const Y of H.values())l(Y.operators);return H}function S(T,A){if(T.base==="text"&&(!T.compare||T.compare===F.text.compare)){const C=N(A);return(H,Y)=>D(H)?D(Y)?0:1:D(Y)?-1:C.compare(String(H),String(Y))}return T.compare||X}function R(T,A){return A?T.multiStorage||"multi":T.storage||"object"}function L(T){return j(String(T).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Ie("packages/core/src/columns/infer.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return K}});const N=U("packages/core/src/internal/warn.js").infoOnce,B=U("packages/core/src/internal/predicates.js").isNil,D=100;function q(x,G,z={}){const j=z.sampleSize??D,O=[];for(let b=0;b<x.length&&O.length<j;b++){const u=x[b];B(u)||typeof u=="number"&&Number.isNaN(u)||O.push(u)}if(O.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[b,u]of G){if(typeof u.matches!="function")continue;let f=!0;for(let a=0;a<O.length;a++)if(!u.matches(O[a])){f=!1;break}if(f)return{type:b,unanimous:!0,sampled:O.length}}return z.quiet||N(`infer:${z.colId||"?"}`,`column "${z.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:O.length}}function K(x,G,z,j,O={}){const b=O.sampleSize??D,u=[];for(let f=0;f<G.length&&u.length<b;f++){const a=z(G[f]);B(a)||typeof a=="number"&&Number.isNaN(a)||u.push(a)}return q(u,j,{...O,colId:x}).type}}),Ie("packages/core/src/columns/graph.js",function(e,U){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return j}});const te=U("packages/core/src/internal/warn.js"),N=te.DEV,X=te.fail,B=te.warnOnce,q=U("packages/core/src/internal/predicates.js").isFunction,K="*";function x(O){const b=O.value||{};if(!q(b.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const f=b.pure!==!1;return b.deps===K?{computed:!0,wholeRow:!0,deps:[],pure:f}:Array.isArray(b.deps)?{computed:!0,wholeRow:!1,deps:b.deps.slice(),pure:f}:(B(`deps:missing:${O.id}`,`computed column "${O.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:f})}function G(O){const b=new Map;for(const h of O)b.set(h.id,h);const u=new Map,f=new Map,a=new Set,r=new Set,t=new Set,s=new Set;for(const h of O){const w=x(h);if(!w.computed){u.set(h.id,[]);continue}r.add(h.id),(w.pure?t:s).add(h.id),w.wholeRow&&a.add(h.id);const g=[],k=[];for(const d of w.deps)(b.has(d)?g:k).push(d);u.set(h.id,g),k.length&&f.set(h.id,k)}for(const h of t)for(const w of u.get(h))s.has(w)&&X(`pure computed column "${h}" depends on impure column "${w}". Mark it \`value.pure: false\` or make the dependency pure.`);const i=[],n=new Map,c=[],o=h=>{const w=n.get(h);if(w!=="done"){if(w==="open"){const g=c.indexOf(h);X(`circular column dependency: ${[...c.slice(g),h].join(" → ")}`)}n.set(h,"open"),c.push(h);for(const g of u.get(h)||[])b.has(g)&&o(g);c.pop(),n.set(h,"done"),i.push(h)}};for(const h of O)o(h.id);const l=new Map;for(const h of O)l.set(h.id,[]);for(const h of O)for(const w of u.get(h.id)||[]){const g=l.get(w);g&&!g.includes(h.id)&&g.push(h.id)}if(a.size)for(const h of O){if(r.has(h.id))continue;const w=l.get(h.id);for(const g of a)w.includes(g)||w.push(g)}return{order:i,dependents:l,pure:t,impure:s,computed:r,deps:u,wholeRow:a,external:f,index:b}}function z(O,b){const u=Array.isArray(b)?b:[b],f=new Set,a=[...u];for(;a.length;){const r=a.shift();for(const t of O.dependents.get(r)||[])f.has(t)||(f.add(t),a.push(t))}for(const r of u)f.delete(r);return O.order.filter(r=>f.has(r))}function j(O,b,u){if(!N)return O;const f=b instanceof Set?b:new Set(b);return new Proxy(O,{get(a,r){return typeof r=="string"&&!f.has(r)&&!Object.hasOwn(a,r)&&B(`undeclared:${u}:${r}`,`computed column "${u}" read undeclared dependency "${r}". Add it to \`value.deps\` or the value will go stale.`),a[r]}})}}),Ie("packages/core/src/model/rowkey.js",function(e,U){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return r}});const N=U("packages/core/src/internal/warn.js").warnOnce,B=U("packages/core/src/internal/paths.js").pathGetter,D=U("packages/core/src/internal/predicates.js"),q=D.isFunction,K=D.isBlank,x=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],G="";function z(t){if(t===null)return"\0n";if(t===void 0)return"\0u";const s=typeof t;if(s==="string")return t;if(s==="number"||s==="bigint"||s==="boolean")return String(t);if(t instanceof Date)return`\0d${t.getTime()}`;try{return`\0o${JSON.stringify(t)}`}catch{return"\0o?"}}function j(t){if(t.length===1)return z(t[0]);let s="";for(let i=0;i<t.length;i++)i&&(s+=G),s+=z(t[i]);return s}function O(t,s={}){const i=s.warn!==!1;if(q(t)){const n=t;return{stable:!0,fields:[],disabled:[],key(c,o){try{const l=n(c);return Array.isArray(l)?j(l):z(l)}catch(l){return N("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",l),`#${o??-1}`}},keyEmpty(c){try{const o=n(c);return Array.isArray(o)?o.length===0||o.some(K):K(o)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(t)&&t.length>0){const n=t.filter(l=>typeof l=="string"),c=n.map(l=>B(l)),o=c.length;return{stable:!0,fields:n,disabled:[],key(l){const h=new Array(o);for(let w=0;w<o;w++)h[w]=c[w](l);return j(h)},keyEmpty(l){for(let h=0;h<o;h++)if(K(c[h](l)))return!0;return!1},missingFields(l){const h=[];for(let w=0;w<o;w++)K(c[w](l))&&h.push(n[w]);return h}}}if(typeof t=="string"&&t.length>0){const n=B(t);return{stable:!0,fields:[t],disabled:[],key(c){return z(n(c))},keyEmpty(c){return K(n(c))},missingFields(c){return K(n(c))?[t]:[]}}}return i&&N("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,c){if(n===null||typeof n!="object")return`#${c??0}:${String(n)}`;let o=b.get(n);return o===void 0&&(o=`#${u++}`,b.set(n,o)),o}}}const b=new WeakMap;let u=0;function f(t,s){if(!t||t.stable===!1||!q(t.keyEmpty)||!Array.isArray(s)||s.length===0)return;let i=0,n=null,c;for(let w=0;w<s.length;w++){const g=s[w];t.keyEmpty(g)&&(i++,n===null&&(n=q(t.missingFields)?t.missingFields(g):[],c=g))}if(i===0)return;const o=t.fields.length?t.fields.join(","):"(function)",l=n&&n.length?n.join(", "):t.fields.length?t.fields.join(", "):"the rowKey function",h=c!==null&&typeof c=="object"?Object.keys(c).join(", ")||"(no fields)":String(c);N(`rowKey.emptyValue:${o}`,`rowKey ${l} is missing on ${i} of ${s.length} rows; the first such row has: ${h}. 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 a(t){return j(t)}function r(t){return t.split(G)}}),Ie("packages/core/src/columns/lookup.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return t}});const te=U("packages/core/src/internal/compare.js"),N=te.collator,X=te.defaultCompare,B=U("packages/core/src/internal/predicates.js"),D=B.isFunction,q=B.isNil,x=U("packages/core/src/internal/warn.js").warnOnce,z=U("packages/core/src/model/rowkey.js").compositeKey,j=", ",O="";function b(s,i,n,c){if(s===null||typeof s!="object")return{id:s,label:s==null?"":String(s)};const o=s[i],l=s[n],h={id:o,label:l==null?String(o??""):String(l)};s.disabled&&(h.disabled=!0),s.variant&&(h.variant=s.variant),s.icon&&(h.icon=s.icon);const w=c?s[c]:s.group;return w!==void 0&&(h.group=w),h}function u(s,i,n=0,c=[],o=[]){for(const l of s||[]){const h=l&&typeof l=="object"?l[i]:null;if(o.push({raw:l,depth:n,path:c}),Array.isArray(h)&&h.length){const w=String(l&&typeof l=="object"?l.label??l.name??l.id??"":l);u(h,i,n+1,[...c,w],o)}}return o}function f(s){return!!s&&typeof s=="object"&&!Array.isArray(s)&&D(s.router&&s.router.subscribe)}class a{#e;#t;#n;#r;#i=[];#s=new Map;#o=new Map;#l=0;#a="idle";#c=null;#u;#f=null;#d=new Map;constructor(i,n={}){this.#e=i||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#u=N(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??j}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#i}setLocale(i){this.#n=i,this.#u=N(i)}#h(i){const n=this.#e,c=n.valueKey||"id",o=n.labelKey||"label",l=n.childrenKey||"children";this.#i=u(i,l).map(h=>{const w=b(h.raw,c,o,n.groupKey);return h.depth&&(w.depth=h.depth,w.path=h.path),w}),this.#s=new Map,this.#o=new Map,this.#i.forEach((h,w)=>{this.#s.set(h.id,h),this.#o.set(h.id,w)}),this.#a="ready",this.#l+=1}load(){if(this.#c)return this.#c;const i=this.#e.options;if(Array.isArray(i)||i===void 0)return this.#c=Promise.resolve(this.#i),this.#c;if(f(i))return this.#c=this.#p(i),this.#c;if(!D(i))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.#c=Promise.resolve([]),this.#c;this.#a="loading";let n;try{n=i()}catch(c){return this.#a="error",x(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,c),this.#c=Promise.resolve([]),this.#c}return!n||!D(n.then)?(this.#h(n),this.#c=Promise.resolve(this.#i),this.#r&&this.#r(this),this.#c):(this.#c=n.then(c=>(this.#h(c),this.#r&&this.#r(this),this.#i),c=>(this.#a="error",x(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,c),[])),this.#c)}refresh(){return this.#c=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#i)):this.load()}#p(i){if(this.#f)return Promise.resolve(this.#i);const n=this.#e,c=n.valueKey||"id",o=n.labelKey||"label",l=n.groupKey,h=D(i.map)?i.map:null,w=k=>b(h?h(k):k,c,o,l).id,g=k=>this.#m(k,h,c,o,l);return i.router.subscribe(i.predicate,g,{rowKey:w}),this.#f=()=>{D(i.router.detach)&&i.router.detach(g)},this.#a="ready",Promise.resolve(this.#i)}#m(i,n,c,o,l){const h=i&&i.add||[],w=i&&i.update||[],g=i&&i.remove||[];if(!(!h.length&&!w.length&&!g.length)){for(const k of h)this.#g(k,n,c,o,l);for(const k of w)this.#g(k,n,c,o,l);for(const k of g){if(!this.#d.has(k))continue;const d=this.#d.get(k);this.#d.delete(k),this.#s.delete(d);const p=this.#i.findIndex(m=>m.id===d);p>=0&&this.#i.splice(p,1)}this.#o=new Map(this.#i.map((k,d)=>[k.id,d])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(i,n,c,o,l){const h=b(n?n(i):i,c,o,l);this.#d.set(z([h.id]),h.id);const w=this.#i.findIndex(g=>g.id===h.id);w>=0?this.#i[w]=h:this.#i.push(h),this.#s.set(h.id,h)}destroy(){this.#f&&(this.#f(),this.#f=null)}search(i,n){const c=this.#e;if(!D(c.search)){const h=String(i||"").toLowerCase();return Promise.resolve(h===""?this.#i:this.#i.filter(w=>w.label.toLowerCase().includes(h)))}const o=c.valueKey||"id",l=c.labelKey||"label";return Promise.resolve(c.search(i,n)).then(h=>(h||[]).map(w=>b(w,o,l,c.groupKey)))}option(i){return this.#s.get(i)}has(i){return this.#s.has(i)}label(i){if(q(i)||i==="")return"";const n=this.#s.get(i);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(i)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const c=this.#e.unknownLabel;return D(c)?String(c(i)??""):typeof c=="string"?c:String(i)}text(i){if(this.multiple){const n=r(i);return n.length===0?"":n.map(c=>this.label(c)).join(this.separator)}return this.label(i)}dictionary(){return this.#i.map(i=>i.id)}sorted(){const i=this.sortBy;if(i==="optionOrder"||i==="count")return this.#i.slice();if(i==="value")return this.#i.slice().sort((c,o)=>X(c.id,o.id));const n=this.#u;return this.#i.slice().sort((c,o)=>n.compare(c.label,o.label))}comparator(){const i=this.sortBy,n=this.multiple,c=this.#u,o=this.#o;if(n&&i==="count")return(h,w)=>r(h).length-r(w).length;const l=n?h=>r(h)[0]:h=>h;return i==="value"?(h,w)=>X(l(h),l(w)):i==="optionOrder"?(h,w)=>{const g=o.has(l(h))?o.get(l(h)):Number.MAX_SAFE_INTEGER,k=o.has(l(w))?o.get(l(w)):Number.MAX_SAFE_INTEGER;return g-k}:(h,w)=>{const g=l(h),k=l(w);return q(g)?q(k)?0:1:q(k)?-1:c.compare(this.label(g),this.label(k))}}groupKey(i){return this.multiple?r(i).map(c=>String(c)).sort().join(O):q(i)?"":String(i)}countValues(i){return this.multiple?r(i).length:q(i)?0:1}contains(i,n,c){const o=this.multiple?r(i):q(i)?[]:[i],l=Array.isArray(n)?n:[n];switch(c){case"containsAll":return l.every(h=>o.includes(h));case"containsNone":return!l.some(h=>o.includes(h));default:return l.some(h=>o.includes(h))}}exportText(i,n="label"){return n==="value"?this.multiple?r(i).join(this.separator):q(i)?"":String(i):this.text(i)}exportColumns(){const i=this.multiple;return this.#i.map(n=>({id:n.id,label:n.label,has:c=>i?r(c).includes(n.id):c===n.id}))}}function r(s){return Array.isArray(s)?s:q(s)||s===""?[]:[s]}function t(s,i={}){const n=s.lookup;if(!n)return null;const c=new a(n,{colId:s.id,locale:i.locale,onChange:i.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&c.load(),c}}),Ie("packages/core/src/columns/value.js",function(e,U){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return a}});const N=U("packages/core/src/internal/paths.js").getPath,X=U("packages/core/src/internal/predicates.js"),B=X.isFunction,D=X.isNil,K=U("packages/core/src/internal/lru.js").Lru,G=U("packages/core/src/internal/warn.js").warnOnce,j=U("packages/core/src/columns/graph.js").depsProxy,O="\0";function b(i,n={}){const c=n.locale,o=n.grid??null,l=n.context,h=i.value&&i.value.format,w=i.formatter||null,g=i.dataType&&i.dataType.format,k=i.lookup||null,d=(p,m,v)=>({value:p,data:v,row:m,column:i,colId:i.id,grid:o,context:l,locale:c});if(B(h))return(p,m,v)=>{const y=h(d(p,m,v));return y==null?"":String(y)};if(w){if(k){const p=w.kind==="text";return(m,v,y)=>w(p?k.text(m):m,d(m,v,y))}return(p,m,v)=>w(p,d(p,m,v))}return B(g)?(p,m,v)=>{const y=g(d(p,m,v));return y==null?"":String(y)}:k?p=>k.text(p):p=>D(p)?"":typeof p=="string"?p:String(p)}function u(i,n){!i||!i.value||i.value.pure!==!1||G(`impure:${n}:${i.id}`,`column "${i.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${n}. The result is not stable across passes.`)}class f{#e;#t;#n;#r;#i;#s;#o=new K(4096);constructor(n){this.#e=n.columns instanceof Map?n.columns:new Map((n.columns||[]).map(c=>[c.id,c])),this.#t=n.graph,this.#n=n.grid??null,this.#r=n.context,this.#s=n.stored||null,this.#i=n.rowKey||a}get graph(){return this.#t}setGraph(n){this.#t=n,this.#o.clear()}beginPass(){this.#o.clear()}endPass(){this.#o.clear()}invalidate(n){if(this.#o.size===0)return;const c=n&&n.rows?new Set([...n.rows].map(String)):null,o=n&&n.columns?[...n.columns]:null;if(!c&&!o){this.#o.clear();return}const l=o?this.#l(o):null;for(const h of[...this.#o.keys()]){const w=String(h).split(O);w.length===3&&(c&&!c.has(w[0])||l&&!l.has(w[2])||this.#o.delete(h))}}#l(n){const c=new Set,o=this.#t,l=[...n];for(;l.length;){const h=l.pop();if(!c.has(h)){c.add(h);for(const w of o?o.dependents.get(h)||[]:[])l.push(w)}}return c}value(n,c,o){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return;if(!l.computed)return this.#c(l,c,o);if(l.value.pure!==!1&&this.#s&&o&&o.physical!=null&&this.#s.has(l.id))return this.#s.get(l.id,o.physical);if(l.volatile)return this.compute(l,c,o);if(l.value.pure===!1)return this.compute(l,c,o);const h=`${this.#a(c,o)}${O}${l.id}`;if(this.#o.has(h))return this.#o.get(h);const w=this.compute(l,c,o);return this.#o.set(h,w),w}#a(n,c){return`${this.#i(n,c)}${O}${r(n)}`}#c(n,c,o){if(this.#s&&o&&o.physical!=null&&this.#s.has(n.id))return this.#s.get(n.id,o.physical);if(n.field)return n.read?n.read(c):N(c,n.field)}compute(n,c,o){const l=this.#t,h=l&&l.wholeRow.has(n.id);let w;if(h)w=c??{};else{w={};const k=l&&l.deps.get(n.id)||[];for(const p of k)w[p]=this.value(p,c,o);const d=l&&l.external.get(n.id)||[];for(const p of d)w[p]=N(c,p);w=j(w,[...k,...d],n.id)}const g={data:c,row:o,column:n,grid:this.#n,context:this.#r};return n.value.compute(w,g)}values(n,c){const o={},l=this.#t?this.#t.order:[...this.#e.keys()];for(const h of l)o[h]=this.value(h,n,c);return o}text(n,c,o){const l=typeof n=="string"?this.#e.get(n):n;return l?l.formatValue(this.value(l,c,o),o,c):""}key(n,c,o){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return"";const h=this.value(l,c,o);return B(l.value.key)?String(l.value.key(this.#u(l,h,c,o))):l.lookup?l.lookup.groupKey(h):D(h)?"":String(h)}quickFilterText(n,c,o){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return"";if(B(l.value.quickFilterText)){const h=this.value(l,c,o);return String(l.value.quickFilterText(this.#u(l,h,c,o))??"")}return this.text(l,c,o)}#u(n,c,o,l){return{value:c,data:o,row:l,column:n,colId:n.id,grid:this.#n,context:this.#r}}parse(n,c,o,l){const h=typeof n=="string"?this.#e.get(n):n;if(!h)return c;const w={text:c,value:this.value(h,o,l),data:o,row:l,column:h,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(h.value.parse)?h.value.parse(w):h.dataType&&B(h.dataType.parse)?h.dataType.parse(w):c}validate(n,c,o,l,h){const w=typeof n=="string"?this.#e.get(n):n;if(!w||!B(w.edit.validate))return!0;const g=w.edit.validate({value:c,oldValue:o,data:l,row:h,column:w,grid:this.#n,context:this.#r});return g===!0||g===void 0?!0:String(g)}apply(n,c,o,l){const h=typeof n=="string"?this.#e.get(n):n;if(!h)return!1;const w=this.value(h,o,l);if(B(h.value.apply)){const g=h.value.apply({value:c,oldValue:w,data:o,row:l,column:h,grid:this.#n,context:this.#r});return this.#f(h,o,l),g!==!1}return h.field?w===c?!1:(h.write(o,c),this.#f(h,o,l),!0):(G(`apply:${h.id}`,`column "${h.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(n,c,o,l){const h=typeof n=="string"?this.#e.get(n):n;if(!h)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const w=this.value(h,o,l),g=this.parse(h,c,o,l),k=this.validate(h,g,w,o,l);if(k!==!0)return{ok:!1,value:g,oldValue:w,changed:!1,error:k};const d=this.apply(h,g,o,l);return{ok:!0,value:g,oldValue:w,changed:d}}#f(n,c,o){if(this.#o.size===0)return;const l=this.#a(c,o);this.#o.delete(`${l}${O}${n.id}`);for(const h of this.#t?this.#t.dependents.get(n.id)||[]:[])this.#o.delete(`${l}${O}${h}`)}}function a(i,n){return n&&n.key!=null?String(n.key):r(i)}function r(i){if(i&&typeof i=="object"){let n=t.get(i);return n===void 0&&(n=`#${s++}`,t.set(i,n)),n}return String(i)}const t=new WeakMap;let s=0}),Ie("packages/core/src/model/shadow.js",function(e,U){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return f}}),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 N=U("packages/core/src/internal/warn.js").warnOnce,X=2e5,B=20,D=1e3,q=50;function K(l){return Math.min(D,Math.max(q,Math.floor(l)))}const x=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"]),G=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"]),j=.6745,O=3.5,b=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),u=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),f=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(l,h){if(!h)return null;const w=Number.isFinite(Number(h.lower))?Number(h.lower):null,g=Number.isFinite(Number(h.upper))?Number(h.upper):null;if(w===null&&g===null||!Number.isFinite(l))return null;if(w!==null&&l<w||g!==null&&l>g)return b.FAIL;const k=Number.isFinite(Number(h.warnLower))?Number(h.warnLower):null,d=Number.isFinite(Number(h.warnUpper))?Number(h.warnUpper):null;return k!==null&&l<k||d!==null&&l>d?b.WARN:b.PASS}function r(l,h,w){if(!h||typeof h!="object")return null;if(h.kind!=="time")return h.kind!==void 0&&N(`shadow.history.window.kind:${l}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${h.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 g=h.minutes!=null?Number(h.minutes)*6e4:Number(h.span);if(!(g>0))return N(`shadow.history.window.span:${l}`,"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 k=Math.max(2,Math.floor(w)||B);return{span:g,bucketMs:Math.max(1,Math.floor(g/k))}}class t{#e;#t=new Map;#n=new Map;#r=new Map;#i=new Map;#s=new Map;#o=new Map;#l=0;#a;#c;#u;#f;#d=new Map;#h=null;#p=null;#m=null;constructor(h){this.#e=h.colId,this.#a=Math.max(2,h.depth||B),this.#c=Math.max(1,h.max||X),this.#u=h.now||(()=>Date.now()),this.#f=r(this.#e,h.historyWindow,this.#a),this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#f}observe(h,w){const g=c(w);if(g===null)return;if(!this.#n.has(h)){this.#p=null,this.#m=null,this.#g(),this.#t.set(h,g),this.#n.set(h,g),this.#r.set(h,0),this.#i.set(h,this.#u()),this.#s.set(h,[g]),this.#f&&this.#d.set(h,[g]),this.#o.set(h,0);return}const k=this.#n.get(h);if(k===g)return;this.#p=null,this.#m=null,this.#n.set(h,g),this.#r.set(h,(this.#r.get(h)||0)+1),this.#i.set(h,this.#u());const d=this.#s.get(h)||[];d.push(g),d.length>this.#a&&d.splice(0,d.length-this.#a),this.#s.set(h,d);const p=Math.sign(g-k),m=this.#o.get(h)||0;this.#o.set(h,Math.sign(m)===p?m+p:p)}#g(){if(this.#n.size<this.#c)return;const h=this.#n.keys().next().value;h!==void 0&&(this.#t.delete(h),this.#n.delete(h),this.#r.delete(h),this.#i.delete(h),this.#s.delete(h),this.#d.delete(h),this.#o.delete(h),this.#l++)}rebase(){for(const[h,w]of this.#n)this.#t.set(h,w);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#i.clear(),this.#s.clear(),this.#d.clear(),this.#o.clear(),this.#l=0,this.#p=null,this.#m=null,this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}retain(h){const w=h instanceof Set?h:new Set(h);let g=0;for(const k of[...this.#n.keys()])w.has(k)||(this.#t.delete(k),this.#n.delete(k),this.#r.delete(k),this.#i.delete(k),this.#s.delete(k),this.#d.delete(k),this.#o.delete(k),g++);return g&&(this.#p=null,this.#m=null),g}advanceHistoryWindow(h=this.#u()){const w=this.#f;if(!w)return 0;const g=Math.floor(h/w.bucketMs),k=g-this.#h;if(!(k>0))return 0;const d=Math.min(k,this.#a);for(const[p,m]of this.#d){const v=this.#n.get(p);for(let y=0;y<d;y++)m.push(v);m.length>this.#a&&m.splice(0,m.length-this.#a)}return this.#h=g,k}read(h,w,g,k){switch(h){case"updates":return this.#r.has(w)?this.#r.get(w):0;case"updatedAt":{const d=this.#i.get(w);return d===void 0?null:new Date(d)}case"sinceUpdate":{const d=this.#i.get(w);return d===void 0?null:this.#u()-d}case"firstValue":return this.#t.has(w)?this.#t.get(w):null;case"delta":return this.#n.has(w)?this.#n.get(w)-this.#t.get(w):null;case"deltaPercent":{if(!this.#n.has(w))return null;const d=this.#t.get(w);return d?(this.#n.get(w)-d)/Math.abs(d)*100:null}case"rate":{const d=this.#s.get(w),p=this.#i.get(w);if(!d||d.length<2||p===void 0)return null;const m=this.#u()-p,v=d[d.length-1]-d[d.length-2];return m>0?v/m*1e3:v}case"history":return this.#f?this.#d.has(w)?[...this.#d.get(w)]:null:this.#s.has(w)?[...this.#s.get(w)]:null;case"streak":return this.#o.has(w)?this.#o.get(w):0;case"specStatus":return this.#n.has(w)?a(this.#n.get(w),k):null;default:return u.includes(h)?this.#A(h,w,g,k):null}}#b(h){if(h){if(this.#m&&this.#m.only===h)return this.#m.view;const w=this.#y(h);return this.#m={only:h,view:w},w}return this.#p?this.#p:(this.#p=this.#y(null),this.#p)}#y(h){const w=[];for(const[F,V]of this.#n)h&&!h.has(F)||w.push(V);const g=w.sort((F,V)=>F-V);let k=0,d=0,p=0,m=0;for(const F of g){m+=F,k++;const V=F-d;d+=V/k,p+=V*(F-d)}const v=[];for(const[F,V]of this.#t)h&&!h.has(F)||v.push(V);const y=k?s(g):0,E=g.map(F=>Math.abs(F-y)).sort((F,V)=>F-V),M=k?s(E):0;return{sorted:g,baseline:v.sort((F,V)=>F-V),sum:m,mean:k?d:0,sd:k>1?Math.sqrt(p/(k-1)):0,median:y,mad:M}}#A(h,w,g,k){if(!this.#n.has(w)||g&&!g.has(w))return null;const d=this.#n.get(w),p=this.#b(g),m=p.sorted.length;if(!m)return null;switch(h){case"rank":return m-n(p.sorted,d)+1;case"rankAsc":return i(p.sorted,d)+1;case"rankChange":{if(!this.#t.has(w)||!p.baseline.length)return null;const v=p.baseline.length-n(p.baseline,this.#t.get(w))+1,y=m-n(p.sorted,d)+1;return v-y}case"percentile":return n(p.sorted,d)/m*100;case"quartile":{const v=n(p.sorted,d)/m;return Math.min(4,Math.max(1,Math.ceil(v*4)))}case"zScore":return p.sd?(d-p.mean)/p.sd:null;case"anomalyScore":return p.mad?j*(d-p.median)/p.mad:null;case"anomalyFlag":{if(!p.mad)return null;const v=k&&Number.isFinite(Number(k.threshold))?Number(k.threshold):O;return Math.abs(j*(d-p.median)/p.mad)>v}case"shareOfTotal":return p.sum?d/p.sum*100:null;default:return null}}}function s(l){const h=l.length;if(!h)return 0;const w=(h-1)*.5,g=Math.floor(w),k=Math.ceil(w);return g===k?l[g]:l[g]+(w-g)*(l[k]-l[g])}function i(l,h){let w=0,g=l.length;for(;w<g;){const k=w+g>>1;l[k]<h?w=k+1:g=k}return w}function n(l,h){let w=0,g=l.length;for(;w<g;){const k=w+g>>1;l[k]<=h?w=k+1:g=k}return w}function c(l){if(l==null||l==="")return null;if(l instanceof Date){const w=l.getTime();return Number.isFinite(w)?w:null}const h=typeof l=="number"?l:Number(l);return Number.isFinite(h)?h:null}function o(l){const h=[];for(const w of l||[]){const g=w.shadow;if(!g)continue;const k=typeof g=="string"?{kind:g}:g,d=k.kind;x.includes(d)&&(G.includes(d)||z.includes(d)||h.push({colId:w.id||w.field,of:k.of||w.field||w.id,kind:d,depth:k.depth,historyWindow:d==="history"?k.window:void 0}))}return h}}),Ie("packages/core/src/columns/model.js",function(e,U){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return Re}});const te=U("packages/core/src/internal/merge.js"),N=te.expand,X=te.merge,B=te.toArray,D=U("packages/core/src/internal/warn.js"),q=D.fail,K=D.warnOnce,x=U("packages/core/src/internal/paths.js"),G=x.getPath,z=x.pathGetter,j=x.pathSetter,b=U("packages/core/src/internal/text.js").humanise,u=U("packages/core/src/internal/predicates.js"),f=u.isFunction,a=u.isObject,t=U("packages/core/src/internal/uid.js").uid,i=U("packages/core/src/format/index.js").compileFormat,n=U("packages/core/src/columns/datatypes.js"),c=n.comparatorFor,o=n.createTypeRegistry,l=n.storageKind,h=U("packages/core/src/columns/infer.js"),w=h.inferColumnType,g=h.DEFAULT_SAMPLE,k=U("packages/core/src/columns/graph.js"),d=k.buildGraph,p=k.affectedBy,v=U("packages/core/src/columns/lookup.js").createLookup,y=U("packages/core/src/columns/value.js"),E=y.compileDisplay,M=y.ValuePipeline,F=y.warnImpureUse,I=U("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,$=Object.freeze({geometry:"geometry",list:"list"}),S={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},R={centre:"center"},L=new Set(["start","center","end","left","right"]);function T(Le){if(typeof Le!="string")return;const ie=Le.toLowerCase();return R[ie]?R[ie]:L.has(ie)?ie:void 0}function A(Le){if(typeof Le!="string")return;const ie=Le.toLowerCase();return ie==="center"||ie==="centre"?"middle":ie==="top"||ie==="middle"||ie==="bottom"?ie:void 0}const C=["cell","layout","header"];function H(Le){if(!a(Le))return{};const ie={...Le},ge=(ke,Se)=>{if(Le[ke]===void 0)return;const Ae=N(Le[ke],Se);Ae&&C.includes(ke)&&!a(Le[ke])&&delete Ae.enabled,ie[ke]=Ae};return ge("sort","direction"),ge("filter","type"),ge("cell","render"),ge("edit","editor"),ge("layout","width"),ge("group","index"),ge("pivot","index"),ge("header","render"),ge("facet","strategy"),ie}function Y(Le,ie){const ge={...Le||{}},ke=a(ie)&&a(ie.layout)&&ie.layout.width!==void 0;return ge.fit==="content"&&!ke&&delete ge.width,ge}const Z=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","diff","edit","export","facet","field","filter","filterRow","format","grandTotal","group","groupTotal","header","headerControls","id","layout","lookup","nullable","pivot","preset","quickFilter","rowSpan","running","shadow","showWhen","sort","spec","tags","title","total","type","typeOptions","validation","value","verticalAlign"]),_=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function J(Le,ie,ge,ke){const Se=ge==="columnGroup"?"column group":"column";for(const Ae of Object.keys(Le))if(!ie.has(Ae)){if(Ae==="timeZone"&&ge==="column"){K("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${ke}". 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}K(`${ge}.unknown:${Ae}`,`'${Ae}' is not a configuration key this grid recognises, so it had no effect on ${Se} "${ke}". Check the spelling against the reference.`)}}function ee(Le){a(Le.cell)&&Le.cell.autoHeight!==void 0&&K("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${Le.id||Le.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function ne(Le,ie){const ge=ie&&f(Le.defaultsFor)?Le.defaultsFor(ie):null,ke={...Le.defaults||{},...a(ge)?ge:{}},Se={};return ke.align&&(Se.align=ke.align,Se.cell={align:ke.align},Se.header={align:ke.align}),ke.filter&&(Se.filter=ke.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:ke.filter}),ke.editor&&(Se.edit=ke.editor==="none"?{editor:null}:{editor:ke.editor}),ke.total&&(Se.total=ke.total),ke.render&&(Se.cell={...Se.cell||{},render:ke.render}),Le.export&&(Se.export={...Le.export}),Se}function se(Le){if(typeof Le=="string")return Le.trim()?[Le.trim()]:[];if(!Array.isArray(Le))return[];const ie=[];for(const ge of Le){if(typeof ge!="string")continue;const ke=ge.trim();ke&&!ie.includes(ke)&&ie.push(ke)}return ie}class oe{#e=new Map;#t=[];#n=[];#r=new WeakMap;#i;#s;#o;#l;#a;#c;#u(ie,ge,ke){const Se=this.#f(ie,ge,ke);if(typeof Se!="string"||!this.#d)return Se??null;const Ae=ge&&ge.totals&&ge.totals.implement;if(Ae&&f(Ae[Se])){const me=Ae[Se];return me.totalName=Se,me}const xe=this.#d.totalFn?.(Se);return f(xe)?xe:Se}#f(ie,ge,ke){if(typeof ie!="string")return ie;const Se=ge&&ge.totals&&ge.totals.supported;if(!Array.isArray(Se)||Se.includes(ie))return ie;const Ae=Se.length?Se.join(", "):"none";return q(`column "${ke}" is typed ${ge.name||"a type"}, for which the total "${ie}" is not meaningful. Supported: ${Ae}. Aggregating it anyway would produce a confident wrong number.`),ie}#d;#h;#p;#m;#g;#b;#y=!1;#A;#w;constructor(ie={}){this.#s=H(ie.columnDefaults||{}),this.#o=ie.columnPresets||{},this.#a=ie.locale,this.#l=ie.timeZone,this.#c=A(ie.verticalAlign),this.#d=ie.registry||null,this.#h=ie.grid||null,this.#p=ie.context,this.#A=ie.sampleSize??g,this.#w=ie.onChange||null,this.#b=f(ie.rowKey)?ie.rowKey:void 0,this.#i=o(ie.dataTypes,this.#d);const{leaves:ge,groups:ke}=Re(ie.columns||[]);this.#n=ke;for(const Se of ge){Se.facet!==void 0&&this.#r.set(Se.def,Se.facet);const Ae=this.#O(Se.def,null);if(Ae.groupPath=Se.path,this.#e.has(Ae.id)){K(`columns.duplicate:${Ae.id}`,`two columns resolve to the id '${Ae.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}Se.column=Ae,this.#e.set(Ae.id,Ae),this.#t.push(Ae.id)}this.#E(ie.stored||null)}#O(ie,ge){J(ie,Z,"column",ie.id||ie.field||"(unnamed)"),ee(ie);const ke=H(ie),Se=B(ie.preset),Ae=Se.map(Ke=>{const Xe=this.#o[Ke];return Xe?H(Xe):(K(`preset:${Ke}`,`unknown column preset "${Ke}"; ignoring`),{})}),xe=this.#S(ke,Ae,ge),me=this.#i.get(xe)||this.#i.get("text");if(!this.#i.has(xe)&&ie.type){const Ke=$[xe];K(`type:${xe}`,`unknown data type "${xe}"; falling back to "text"`+(Ke?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Ke}'.`:""))}const ye=f(me.items)?this.#T(ke,Ae,ie.id||ie.field||"(unnamed)"):null;let Te=S;Te=X(Te,this.#s),ie.type!==!1&&(Te=X(Te,ne(me,ye)));for(const Ke of Ae)Te=X(Te,Ke);this.#r.has(ie)&&(Te=X(Te,H({facet:this.#r.get(ie)}))),Te=X(Te,ke);const Ye=Te.edit;Ye&&Ye.editor&&Ye.enabled!==!0&&!f(Ye.enabled)&&(ie.edit||{}).editor&&K(`column.editor-not-enabled:${ie.id||ie.field}`,`column '${ie.id||ie.field}' names the editor '${Ye.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Oe=ie.id||ie.field||t("col");if(ie.shadow&&!f(Te.value&&Te.value.compute)){const Ke=typeof ie.shadow=="string"?{kind:ie.shadow}:ie.shadow,Xe=Ke.of||ie.field||Oe,nt=I.includes(Ke.kind),it=nt?Ke.model||Ke:null,wt=nt&&it?[...Array.isArray(it.predictors)?it.predictors:[],it.response].filter(Boolean):null;Te.value={...Te.value||{},deps:wt&&wt.length?wt:Ke.orderBy&&Ke.orderBy!==Xe?[Xe,Ke.orderBy]:[Xe],pure:!1,compute:(pt,St)=>{const Ct=St.grid&&St.grid.statistics;if(!Ct)return null;const Mt=St.row&&St.row.key||Ct.keyOf(St.data);if(!Mt)return null;if(nt){if(!f(Ct.fitShadow))return null;const at=Ke.model?{...Ke.model,threshold:Ke.threshold}:Ke;return Ct.fitShadow(Ke.kind,Mt,at)}return Ct.shadow(Xe,Ke.kind,Mt,Ke.scope,Ke)}}}if(ie.running&&!f(Te.value&&Te.value.compute)){const Ke=typeof ie.running=="string"?{kind:ie.running}:ie.running,Xe=Ke.of||ie.field||Oe;Te.value={...Te.value||{},deps:[Xe],pure:!1,compute:(nt,it)=>{const wt=it.grid&&it.grid.statistics;if(!wt||!f(wt.running))return null;const pt=it.row&&it.row.key||wt.keyOf(it.data);return pt?wt.running(Xe,Ke.kind||"total",pt):null}},ie.sort===void 0&&(Te.sort={...Te.sort||{},enabled:!1})}const _e=ie.field??(f(Te.value&&Te.value.compute)?null:ie.id??null),je=f(Te.value&&Te.value.compute),we={id:Oe,field:_e,shadow:ie.shadow||null,running:ie.running||null,spec:ie.spec||null,validation:ie.validation||null,volatile:!!(ie.shadow||ie.running),title:Te.title??b(_e||Oe),type:me.name,dataType:me,itemType:ye,nullable:Te.nullable!==!1,align:T(ke.cell&&ke.cell.align||ke.align||Te.cell&&Te.cell.align||Te.align||me.defaults&&me.defaults.align)||"start",verticalAlign:A(ke.cell&&ke.cell.verticalAlign||ke.verticalAlign||Te.cell&&Te.cell.verticalAlign||Te.verticalAlign)||this.#c,rowSpan:f(Te.rowSpan)?Te.rowSpan:null,colSpan:f(Te.colSpan)?Te.colSpan:null,value:{pure:!0,...Te.value||{}},cell:{...Te.cell||{}},edit:{...Te.edit||{}},sort:{...Te.sort||{}},filter:{...Te.filter||{}},group:{enabled:!1,index:-1,explode:!1,...Te.group||{}},pivot:{enabled:!1,index:-1,...Te.pivot||{}},total:this.#u(Te.total,me,ie.id||ie.field||"(unnamed)"),groupTotal:Te.groupTotal===void 0?null:this.#u(Te.groupTotal,me,ie.id||ie.field||"(unnamed)"),grandTotal:Te.grandTotal===void 0?null:this.#u(Te.grandTotal,me,ie.id||ie.field||"(unnamed)"),tags:se(Te.tags),typeOptions:Te.typeOptions??null,...a(Te[xe])?{[xe]:Te[xe]}:{},layout:Y(Te.layout,ke),header:{...Te.header||{}},contextMenu:Te.contextMenu===void 0?null:Te.contextMenu,facet:{...Te.facet||{}},export:{...Te.export||{}},allowGroup:Te.allowGroup!==!1,allowPivot:Te.allowPivot!==!1,allowTotal:Te.allowTotal!==!1,quickFilter:Te.quickFilter!==!1,def:ie,format:Te.format,presets:Se,inferred:ge!=null&&!ie.type,computed:je,diff:ie.diff===void 0?void 0:!!ie.diff,read:_e?z(_e):null,write:_e?j(_e):null};we.cell.align=T(ke.cell&&ke.cell.align)||we.align,we.header.align=T(ke.header&&ke.header.align)||we.align;const He=Te.lookup||null;return we.lookup=He?v({id:Oe,lookup:He},{locale:this.#a,onChange:()=>{this.#w&&this.#w("lookup",{colId:Oe})}}):null,we.group.explode&&we.lookup&&we.lookup.multiple&&K(`explode:${Oe}`,`column "${Oe}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#v(we),we}#v(ie){ie.formatter=i(ie.format,ie.dataType,this.#a,this.#l,ie.id),ie.formatValue=E(ie,{locale:this.#a,grid:this.#h,context:this.#p}),ie.itemCompare=ie.itemType?c(ie.itemType,this.#a):null,ie.compare=f(ie.value.compare)?ie.value.compare:ie.lookup?ie.lookup.comparator():f(ie.dataType.compareFor)?ie.dataType.compareFor(ie):c(ie.dataType,this.#a),ie.excel=ie.formatter&&ie.formatter.ooxml||ie.dataType&&ie.dataType.excel||"General",ie.storeKind=l(ie.dataType,!!(ie.lookup&&ie.lookup.multiple))}#T(ie,ge,ke){let Se=a(ie.typeOptions)?ie.typeOptions:null;for(let ye=ge.length-1;!Se&&ye>=0;ye--)a(ge[ye].typeOptions)&&(Se=ge[ye].typeOptions);!Se&&a(this.#s.typeOptions)&&(Se=this.#s.typeOptions);const Ae=Se&&Se.of!==void 0?Se.of:"text",xe=typeof Ae=="string"?this.#i.get(Ae):void 0;return xe&&!f(xe.items)&&xe.storage!=="object"?xe:(K(`type:of:${String(Ae)}`,`column "${ke}" names "${String(Ae)}" as its item type (typeOptions.of), which is not ${xe?"a scalar data type":"a known data type"}; its items are read as text.`),this.#i.get("text"))}#S(ie,ge,ke){if(ie.type===!1)return"text";if(ie.type)return ie.type;for(let Se=ge.length-1;Se>=0;Se--)if(ge[Se].type)return ge[Se].type;if(this.#s.type)return this.#s.type;if(ie.shadow){const Se=typeof ie.shadow=="string"?ie.shadow:ie.shadow.kind;if(Se==="fitInfluence")return"boolean";if(Se==="fitPredicted"||Se==="fitResidual"||Se==="fitStdResidual"||Se==="fitLeverage"||Se==="fitCooksD"||Se==="tsTrend"||Se==="tsSeasonal"||Se==="tsResidual"||Se==="tsCoverage"||Se==="tsSmoothed"||Se==="tsSmoothingAlpha"||Se==="tsSmoothingBeta")return"number"}return ke||(ie.lookup?"lookup":"text")}#E(ie){const ge=this.all();this.#m=d(ge),this.#g?this.#g.setGraph(this.#m):this.#g=new M({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:ie||null,rowKey:this.#b});const ke=this.#g;for(const Se of ge)Se.getValue=(Ae,xe)=>ke.value(Se,Ae,xe)}all(){return this.#t.map(ie=>this.#e.get(ie))}visible(){return this.all().filter(ie=>!ie.layout.hidden)}get(ie){return this.#e.get(ie)}groups(){const ie=ge=>{const ke=[];for(const Se of ge)Array.isArray(Se.columns)?ke.push({...Se,columns:ie(Se.columns)}):Se.column&&ke.push(Se.column);return ke};return ie(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#i}affectedBy(ie){return p(this.#m,ie)}value(ie,ge,ke){return this.#g.value(ie,ge,ke)}text(ie,ge,ke){return this.#g.text(ie,ge,ke)}checkImpure(ie,ge){F(this.#e.get(ie),ge)}setLocale(ie){this.#a=ie;for(const ge of this.all())ge.lookup&&ge.lookup.setLocale(ie),this.#v(ge);this.#w&&this.#w("locale",{locale:ie})}infer(ie){const ge={};if(this.#y||!Array.isArray(ie)||ie.length===0)return ge;this.#y=!0;let ke=!1;for(const Se of this.all()){const Ae=Se.def;if(Ae.type!==void 0||!Se.field||Se.computed||Se.lookup||this.#N(Se))continue;const xe=Se.read||(Te=>G(Te,Se.field)),me=w(Se.id,ie,xe,this.#i,{sampleSize:this.#A});if(me===Se.type)continue;ge[Se.id]=me;const ye=this.#O(Ae,me);ye.groupPath=Se.groupPath,ye.layout={...ye.layout,...fe(Se.layout)},this.#e.set(Se.id,ye),Ue(this.#n,Se.id,ye),ke=!0}return ke&&this.#E(null),ge}redecorate(ie,ge,ke={}){const Se=this.#e.get(ie);if(!Se){K(`redecorate:${ie}`,`columns.decorate('${ie}', …): no column with id '${ie}'.`);return}const Ae=Se.def||{},xe={...a(Ae.cell)?Ae.cell:{}};xe.decoration=ge??void 0,ke&&"variant"in ke&&(xe.variant=ke.variant);const me={...Ae,cell:xe};this.#r.has(Ae)&&this.#r.set(me,this.#r.get(Ae));const ye=this.#O(me,Se.type);return ye.groupPath=Se.groupPath,ye.layout={...ye.layout,...fe(Se.layout)},Se.lookup&&Se.lookup!==ye.lookup&&f(Se.lookup.destroy)&&Se.lookup.destroy(),this.#e.set(ie,ye),Ue(this.#n,ie,ye),this.#E(null),this.#w&&this.#w("decorate",{colId:ie}),ye}destroy(){for(const ie of this.#e.values())ie.lookup&&f(ie.lookup.destroy)&&ie.lookup.destroy()}#N(ie){for(const ge of ie.presets){const ke=this.#o[ge];if(ke&&ke.type)return!0}return!!this.#s.type}#P(ie){return!ie.computed&&f(ie.dataType&&ie.dataType.toStorage)}storeReader(ie){if(ie.computed)return ge=>this.#g.value(ie,ge,null);if(this.#P(ie)){const ge=ie.dataType.toStorage,ke={timeZone:this.#l,colId:ie.id,itemType:ie.itemType||null};return Se=>ge(ie.read(Se),ke)}return ie.read}storeValue(ie,ge){if(!(!ie||ie.computed)&&f(ie.read))return this.storeReader(ie)(ge)}storeSchema(){const ie=[];for(const ge of this.all()){if(ge.computed&&ge.value.pure===!1||!ge.computed&&!ge.field)continue;const ke=this.storeReader(ge);let Se=null;!ge.computed&&!this.#P(ge)&&typeof ge.field=="string"&&!ge.lookup&&(Se=ge.field);const Ae={id:ge.id,kind:ge.storeKind,nullable:ge.nullable,read:ke};Se!==null&&(Ae.field=Se),ge.lookup&&(Ae.dictionary=ge.lookup.dictionary()),ie.push(Ae)}return ie}state(){return this.all().map(ie=>({id:ie.id,width:ie.layout.width,flex:ie.layout.flex||void 0,hidden:!!ie.layout.hidden,headerWrap:ie.header?.wrap===!0?!0:void 0,headerOrientation:ie.header?.orientation==="vertical"?"vertical":void 0,pin:ie.layout.pin??null,sort:ie.sort.direction??null,sortIndex:ie.sort.direction?ie.sort.order??0:null,groupIndex:ie.group.enabled?ie.group.index??0:null,pivotIndex:ie.pivot.enabled?ie.pivot.index??0:null,total:typeof ie.total=="string"?ie.total:null,groupTotal:typeof ie.groupTotal=="string"?ie.groupTotal:void 0,grandTotal:typeof ie.grandTotal=="string"?ie.grandTotal:void 0,decoration:ie.cell&&ie.cell.decoration!=null?pe(ie.cell.decoration):void 0,variant:ie.cell&&ie.cell.variant!=null?pe(ie.cell.variant):void 0}))}applyState(ie,ge={}){const ke={applied:[],skipped:[]},Se=Array.isArray(ie)?ie:ie&&ie.columns||[],Ae=!Array.isArray(ie)&&ie&&ie.columnOrder||null;for(const me of Se){if(!me||!me.id){ke.skipped.push({key:"?",reason:"no id"});continue}let ye=this.#e.get(me.id);if(!ye){ke.skipped.push({key:me.id,reason:"unknown column"});continue}if(Object.hasOwn(me,"decoration")||Object.hasOwn(me,"variant")){const Te=ye.cell?ye.cell.decoration:void 0,Ye=me.decoration??null,Oe=Object.hasOwn(me,"variant"),_e=Oe&&!he(ye.cell?ye.cell.variant:void 0,me.variant);(!he(Te,Ye)||_e)&&(this.redecorate(me.id,Ye,Oe?{variant:me.variant??void 0}:{}),ye=this.#e.get(me.id)||ye)}me.width!=null&&(ye.layout.width=me.width),me.flex!=null&&(ye.layout.flex=me.flex),me.hidden!=null&&(ye.layout.hidden=!!me.hidden),me.headerWrap!==void 0&&(ye.header.wrap=!!me.headerWrap),me.headerOrientation!==void 0&&(ye.header.orientation=me.headerOrientation==="vertical"?"vertical":"horizontal"),me.pin!==void 0&&(ye.layout.pin=me.pin),me.sort!==void 0&&(ye.sort.direction=me.sort),me.sortIndex!=null&&(ye.sort.order=me.sortIndex),me.groupIndex!=null&&(ye.group.enabled=!0,ye.group.index=me.groupIndex),me.pivotIndex!=null&&(ye.pivot.enabled=!0,ye.pivot.index=me.pivotIndex),me.total!==void 0&&(ye.total=me.total),me.groupTotal!==void 0&&(ye.groupTotal=me.groupTotal),me.grandTotal!==void 0&&(ye.grandTotal=me.grandTotal),ke.applied.push(me.id)}const xe=Ae||(ge&&ge.keepOrder?[]:Se.map(me=>me&&me.id).filter(Boolean));if(xe.length){const me=xe.filter(Te=>this.#e.has(Te)),ye=this.#t.filter(Te=>!me.includes(Te));this.#t=[...me,...ye]}return this.#w&&this.#w("state",ke),ke}move(ie,ge){this.#M(ie,ge)&&(this.#$(),this.#w&&this.#w("move",{id:ie,to:ge}))}reorder(ie){const ge={applied:[],skipped:[]},ke=[];let Se=0;for(const Ae of Array.isArray(ie)?ie:[]){const xe=Se++;this.#M(Ae,xe)&&(ge.applied.push(Ae),ke.push({id:Ae,to:xe}))}if(!ke.length)return ge;if(this.#$(),this.#w)for(const Ae of ke)this.#w("move",Ae);return ge}#M(ie,ge){const ke=this.#t.indexOf(ie);if(ke===-1||Math.max(0,Math.min(Number(ge)||0,this.#t.length-1))===ke)return!1;const Ae=this.#e.get(ie);if(Ae.layout.movable===!1||Ae.layout.lockPosition)return K(`move:${ie}`,`column "${ie}" is not movable; the move was ignored`),!1;const xe=this.#R(ie,ge);return xe?(K(`move.married:${xe}`,`band "${xe}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(ke,1),this.#t.splice(Math.max(0,Math.min(ge,this.#t.length)),0,ie),!0)}#R(ie,ge){if(!this.#n||!this.#n.length)return null;const ke=this.#t.filter(me=>me!==ie),Se=Math.max(0,Math.min(ge,ke.length)),Ae=(me,ye)=>{if(Array.isArray(me.columns)){for(const Ye of me.columns)Ae(Ye,ye);return ye}const Te=me.column?me.column.id:me.id;return Te&&ye.push(Te),ye},xe=me=>{for(const ye of me){if(!Array.isArray(ye.columns))continue;if(ye.marryChildren===!0){const Ye=Ae(ye,[]),Oe=Ye.includes(ie),_e=Ye.map(je=>ke.indexOf(je)).filter(je=>je>=0);if(_e.length){const je=Math.min(..._e),we=Math.max(..._e);if(Oe?Se<je||Se>we+1:Se>je&&Se<=we)return ye.id}}const Te=xe(ye.columns);if(Te)return Te}return null};return xe(this.#n)}#$(){const ie=new Map(this.#t.map((Se,Ae)=>[Se,Ae])),ge=Se=>{if(!Array.isArray(Se.columns)){const xe=Se.column?Se.column.id:Se.id;return ie.has(xe)?ie.get(xe):1/0}let Ae=1/0;for(const xe of Se.columns)Ae=Math.min(Ae,ge(xe));return Ae},ke=Se=>{Se.sort((Ae,xe)=>ge(Ae)-ge(xe));for(const Ae of Se)Array.isArray(Ae.columns)&&ke(Ae.columns)};ke(this.#n)}#G(ie){const ge=ke=>{for(let Se=0;Se<ke.length;Se++){const Ae=ke[Se];if(Array.isArray(Ae.columns)){const xe=ge(Ae.columns);if(xe)return xe}else if(Ae.column&&Ae.column.id===ie)return ke.splice(Se,1)[0]}return null};return ge(this.#n)}#V(ie){const ge=[];for(let ke=ie.length-1;ke>=0;ke--){const Se=ie[ke];Array.isArray(Se.columns)&&(ge.push(...this.#V(Se.columns)),Se.columns.length===0&&(ge.push(Se.id),ie.splice(ke,1)))}return ge}#F(){const ie=(ge,ke,Se)=>{for(const Ae of ge)Array.isArray(Ae.columns)?ie(Ae.columns,[...ke,Ae.id]):Ae.column&&(Ae.column.groupPath=ke)};ie(this.#n,[])}#x(ie){const ge=new Set(ie),ke=this.#t.filter(me=>ge.has(me));if(!ke.length)return;const Se=Math.min(...ke.map(me=>this.#t.indexOf(me))),Ae=this.#t.slice(0,Se).filter(me=>!ge.has(me)),xe=this.#t.slice(Se).filter(me=>!ge.has(me));this.#t=[...Ae,...ke,...xe]}#Y(ie){const ge=[],ke=Se=>{if(Array.isArray(Se.columns))for(const Ae of Se.columns)ke(Ae);else Se.column&&ge.push(Se.column.id)};return ke(ie),ge}#D(ie){const ge=ke=>{for(const Se of ke){if(!Array.isArray(Se.columns))continue;if(Se.id===ie)return{node:Se,parent:ke};const Ae=ge(Se.columns);if(Ae)return Ae}return null};return ge(this.#n)}groupColumns(ie,ge={}){const ke=B(ie).filter(ye=>this.#e.has(ye));if(!ke.length)return K("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const ye of ke)if(this.#e.get(ye).layout.lockPosition)return K(`columns.group.locked:${ye}`,`column "${ye}" is position-locked and cannot be grouped.`),null;const Se=ge.groupId?this.#D(ge.groupId):null;if(ge.groupId&&!Se)return K(`columns.group.unknown:${ge.groupId}`,`no band "${ge.groupId}" to add to; nothing was grouped.`),null;let Ae=null;if(!Se&&ge.id!=null&&(Ae=String(ge.id),this.#D(Ae)||this.#e.has(Ae)))return K(`columns.group.idtaken:${Ae}`,`band id "${Ae}" is already in use; nothing was grouped.`),null;const xe=ke.map(ye=>this.#G(ye)).filter(Boolean);if(!xe.length)return null;let me;if(Se)Se.node.columns.push(...xe),me=Se.node.id;else{const ye={id:Ae||t("grp"),title:ge.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:xe},Te=Number.isInteger(ge.at)?Math.max(0,Math.min(ge.at,this.#n.length)):this.#n.length;this.#n.splice(Te,0,ye),me=ye.id}return this.#V(this.#n),this.#x(ke),this.#F(),this.#$(),this.#w&&this.#w("columngroup",{action:"formed",groupId:me,ids:ke}),me}ungroupColumn(ie){const ge=this.#e.get(ie);if(!ge){K(`columns.ungroup.unknown:${ie}`,`no column "${ie}" to ungroup.`);return}const ke=ge.groupPath||[];if(!ke.length)return;const Se=ke[ke.length-1],Ae=this.#D(Se);if(!Ae)return;const xe=this.#G(ie);if(!xe)return;const me=Ae.parent.indexOf(Ae.node);Ae.parent.splice(me+1,0,xe);const ye=this.#V(this.#n),Te=this.#Y(Ae.node);if(Te.length){this.#x(Te);const Ye=Math.max(...Te.map(_e=>this.#t.indexOf(_e))),Oe=this.#t.filter(_e=>_e!==ie);Oe.splice(Ye+1,0,ie),this.#t=Oe}this.#F(),this.#$(),this.#w&&this.#w("columngroup",{action:"removed",id:ie,dissolved:ye})}renameGroup(ie,ge){const ke=this.#D(ie);if(!ke){K(`columns.group.rename:${ie}`,`no band "${ie}" to rename.`);return}ke.node.title=String(ge??""),this.#w&&this.#w("columngroup",{action:"renamed",groupId:ie,title:ke.node.title})}dissolveGroup(ie){const ge=this.#D(ie);if(!ge){K(`columns.group.dissolve:${ie}`,`no band "${ie}" to dissolve.`);return}const ke=ge.parent.indexOf(ge.node);ge.parent.splice(ke,1,...ge.node.columns),this.#F(),this.#$(),this.#w&&this.#w("columngroup",{action:"dissolved",groupId:ie})}moveGroup(ie,ge){const ke=this.#D(ie);if(!ke){K(`columns.group.move:${ie}`,`no band "${ie}" to move.`);return}const Se=ke.parent,Ae=Se.indexOf(ke.node);Ae!==-1&&(Se.splice(Ae,1),Se.splice(Math.max(0,Math.min(ge,Se.length)),0,ke.node),this.#K(),this.#F(),this.#w&&this.#w("columngroup",{action:"moved",groupId:ie,to:ge}))}#K(){const ie=[],ge=Se=>{for(const Ae of Se)Array.isArray(Ae.columns)?ge(Ae.columns):Ae.column&&ie.push(Ae.column.id)};ge(this.#n);const ke=new Set(ie);this.#t=[...ie,...this.#t.filter(Se=>!ke.has(Se))]}groupTree(){const ie=ke=>ke.map(Se=>Array.isArray(Se.columns)?{id:Se.id,title:Se.title||"",collapsible:!!Se.collapsible,openByDefault:Se.openByDefault!==!1,columns:ie(Se.columns)}:Se.column?Se.column.id:null).filter(Se=>Se!==null),ge=ie(this.#n);return ge.some(ke=>ke&&typeof ke=="object")?ge:[]}applyGroupTree(ie){if(!Array.isArray(ie))return;const ge=new Set,ke=Ae=>{const xe=[];for(const me of Ae)if(me&&typeof me=="object"&&Array.isArray(me.columns)){const ye=ke(me.columns);if(!ye.length)continue;xe.push({id:me.id||t("grp"),title:me.title||"",collapsible:me.collapsible===!0,openByDefault:me.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:ye})}else if(typeof me=="string"){const ye=this.#e.get(me);ye&&!ge.has(me)&&(ge.add(me),xe.push({column:ye,path:[]}))}return xe},Se=ke(ie);for(const Ae of this.#t){if(ge.has(Ae))continue;const xe=this.#e.get(Ae);xe&&Se.push({column:xe,path:[]})}this.#n=Se,this.#F(),this.#$(),this.#w&&this.#w("columngroup",{action:"applied"})}show(ie){this.#H(ie,!1)}hide(ie){this.#H(ie,!0)}#H(ie,ge){const ke=[];for(const Se of B(ie)){const Ae=this.#e.get(Se);if(Ae){if(ge&&Ae.layout.lockVisible){K(`lockVisible:${Se}`,`column "${Se}" is \`layout.lockVisible\` and cannot be hidden`);continue}Ae.layout.hidden!==ge&&(Ae.layout.hidden=ge,ke.push(Se))}}ke.length&&this.#w&&this.#w("visible",{ids:ke,hidden:ge})}pin(ie,ge){const ke=this.#e.get(ie);ke&&(ke.layout.pin=ge??null,this.#w&&this.#w("pin",{id:ie,side:ke.layout.pin}))}pinMany(ie){const ge={};for(const[Se,Ae]of ie){const xe=this.#e.get(Se);xe&&(xe.layout.pin=Ae??null,ge[Se]=xe.layout.pin)}const ke=Object.keys(ge);ke.length&&this.#w&&this.#w("pin",{ids:ke,pins:ge})}#B(ie,ge){const ke=ie.layout.min??0,Se=ie.layout.max;let Ae=Math.max(ke,ge);return Se!=null&&(Ae=Math.min(Se,Ae)),ie.layout.width=Ae,ie.layout.flex=0,Ae}resize(ie,ge){const ke=this.#e.get(ie);if(!ke)return;if(ke.layout.resizable===!1){K(`resize:${ie}`,`column "${ie}" is not resizable; the resize was ignored`);return}const Se=this.#B(ke,ge);this.#w&&this.#w("resize",{id:ie,width:Se})}resizeMany(ie){const ge={};for(const[Se,Ae]of ie){const xe=this.#e.get(Se);if(xe){if(xe.layout.resizable===!1){K(`resize:${Se}`,`column "${Se}" is not resizable; the resize was ignored`);continue}ge[Se]=this.#B(xe,Ae)}}const ke=Object.keys(ge);ke.length&&this.#w&&this.#w("resize",{ids:ke,widths:ge})}}function fe(Le){const ie={};return Le.width!=null&&(ie.width=Le.width),Le.hidden!=null&&(ie.hidden=Le.hidden),Le.pin!==void 0&&(ie.pin=Le.pin),ie}function pe(Le){if(Le===null||typeof Le!="object")return Le;try{return structuredClone(Le)}catch{}try{return JSON.parse(JSON.stringify(Le))}catch{return Le}}function he(Le,ie){const ge=Le??null,ke=ie??null;if(ge===ke)return!0;if(ge===null||ke===null)return!1;if(typeof ge!="object"||typeof ke!="object")return ge===ke;try{return JSON.stringify(ge)===JSON.stringify(ke)}catch{return!1}}function Re(Le){const ie=[],ge=(Se,Ae,xe)=>{const me=[];for(const ye of Se){if(!a(ye)){q("a column definition must be an object");continue}if(Array.isArray(ye.columns)){J(ye,_,"columnGroup",ye.title||ye.id||"(unnamed)");const Te={id:ye.id||t("grp"),title:ye.title||"",collapsible:ye.collapsible===!0,openByDefault:ye.openByDefault!==!1,showWhen:ye.showWhen||"always",marryChildren:ye.marryChildren===!0,header:ye.header||{},def:ye,columns:[]};Te.columns=ge(ye.columns,[...Ae,Te.id],ye.facet!==void 0?ye.facet:xe),me.push(Te)}else{const Te={def:ye,path:Ae,facet:xe};ie.push(Te),me.push(Te)}}return me},ke=ge(Le,[],void 0);return{leaves:ie,groups:ke}}function Ue(Le,ie,ge){for(const ke of Le){if(ke.columns){if(Ue(ke.columns,ie,ge))return!0;continue}if(ke.column&&ke.column.id===ie)return ke.column=ge,!0}return!1}}),Ie("packages/core/src/columns/autogroup.js",function(e,U){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return K}});const N=U("packages/core/src/internal/warn.js").warnOnce,X="__lattice_group",B=240,D=.5;function q(x){const{columns:G,groupBy:z}=x,j=z.map(u=>G.get(u)).filter(Boolean),O=j.length?j.map(u=>u.title||u.id).join(" > "):"Group",b=x.config&&x.config.autoGroupColumnWidth||B;return{id:X,field:null,title:O,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!0},groupedIds:z.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:b,min:120,pin:x.config&&x.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(u,f){return f&&f.group?f.groupValue:null},formatValue(u,f){if(!f||!f.group)return"";if(f.grandTotal)return x.config&&x.config.grandTotalLabel||"Total";const a=j[Math.min(f.level||0,j.length-1)];return a&&typeof a.formatValue=="function"?a.formatValue(u,f):u==null?"":String(u)}}}function K(x,G,z){!x.length||z<100||G<z*D||N(`grouping.cardinality:${x.join(",")}`,`grouping by ${x.join(", ")} produced ${G} 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.`)}}),Ie("packages/core/src/columns/selectcolumn.js",function(e,U){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return B}});const te="__lattice_select",N=44;function X(D){const q=D.selection||{},K=D.config&&D.config.selectionColumnWidth||N;return{id:te,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:K,min:K,max:K,pin:D.config&&D.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:q.headerCheckbox===!0,def:{},getValue(x,G){return G?G.selected:!1},formatValue(){return""}}}const B=X}),Ie("packages/core/src/columns/rownumbercolumn.js",function(e,U){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return G}});const N=U("packages/core/src/internal/predicates.js").isFunction,X="__lattice_rownumber",B=40,D=9,q=22;function K(z){const j=String(Math.max(1,Math.trunc(Math.abs(z))||1)).length;return Math.max(B,j*D+q)}function x(z){const j=z.rowNumbers,O=j&&typeof j=="object"?j:{},b=Number.isFinite(O.start)?O.start:1,u=Number.isFinite(O.width)?O.width:K((z.maxNumber||0)+b),f=N(z.rank)?z.rank:()=>null;return{id:X,field:null,title:typeof O.title=="string"?O.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:u,min:u,max:u,pin:"start",hidden:!1,resizable:O.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(a,r){const t=f(r);return t==null?null:t-1+b},formatValue(a){return a==null?"":String(a)}}}const G=x}),Ie("packages/core/src/model/detail.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return G}});const N=U("packages/core/src/internal/predicates.js").isFunction,B=U("packages/core/src/internal/warn.js").warnOnce,D=240,q=10;function K(z){if(!z)return null;const j=z===!0?{}:z;return j.enabled===!1?null:!N(j.rows)&&!j.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:j.render||null,config:j.config||null,rows:N(j.rows)?j.rows:null,height:j.height??D,maxHeight:j.maxHeight??null,cacheLimit:Number.isFinite(j.cacheLimit)?Math.max(0,j.cacheLimit):q,isMaster:N(j.isMaster)?j.isMaster:null,target:j.target||null,onCreate:N(j.onCreate)?j.onCreate:null,path:typeof j.path=="string"?j.path:null}}class x{#e;#t=new Set;#n;#r=0;constructor(j){this.#e=j.config,this.#n=N(j.onChange)?j.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(j){if(!j||j.group||j.detail)return!1;const O=this.#e.isMaster;return O?!!O(j.data,j):!0}isOpen(j){return this.#t.has(j)}keys(){return[...this.#t]}activeKey(){for(const j of this.#t)return j;return null}heightOf(j){const O=this.#e.height;return N(O)?Number(O(j))||D:O==="auto"?D:Number(O)||D}open(j){return this.#t.has(j)?!1:(this.inline||this.#t.clear(),this.#t.add(j),this.#i(),!0)}close(j){return this.#t.delete(j)?(this.#i(),!0):!1}toggle(j){return this.#t.has(j)?(this.close(j),!1):(this.open(j),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#i())}prune(j){if(!this.#t.size||!N(j))return;let O=!1;for(const b of[...this.#t])j(b)||(this.#t.delete(b),O=!0);O&&this.#i()}signature(){return`${this.#r}`}set(j){this.#t.clear();const O=Array.isArray(j)?j:[];for(const b of this.inline?O:O.slice(0,1))this.#t.add(b);this.#i()}#i(){this.#r++,this.#n()}}const G=x}),Ie("packages/core/src/compute/special.js",function(e,U){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return a}});const te=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),N=3e-12,X=1e-300;function B(r){if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-B(1-r);const t=r-1;let s=.9999999999998099;const i=t+7.5;for(let n=0;n<te.length;n++)s+=te[n]/(t+n+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(i)-i+Math.log(s)}function D(r,t,s){const i=r+t,n=r+1,c=r-1;let o=1,l=1-i*s/n;Math.abs(l)<X&&(l=X),l=1/l;let h=l;for(let w=1;w<=300;w++){const g=2*w;let k=w*(t-w)*s/((c+g)*(r+g));l=1+k*l,Math.abs(l)<X&&(l=X),o=1+k/o,Math.abs(o)<X&&(o=X),l=1/l,h*=l*o,k=-(r+w)*(i+w)*s/((r+g)*(n+g)),l=1+k*l,Math.abs(l)<X&&(l=X),o=1+k/o,Math.abs(o)<X&&(o=X),l=1/l;const d=l*o;if(h*=d,Math.abs(d-1)<N)break}return h}function q(r,t,s){if(!(r>0)||!(t>0)||!Number.isFinite(s))return Number.NaN;if(s<=0)return 0;if(s>=1)return 1;const i=Math.exp(B(r+t)-B(r)-B(t)+r*Math.log(s)+t*Math.log(1-s));return s<(r+1)/(r+t+2)?i*D(r,t,s)/r:1-i*D(t,r,1-s)/t}function K(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],s=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],i=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],n=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],c=.02425;let o,l,h;r<c?(o=Math.sqrt(-2*Math.log(r)),h=(((((i[0]*o+i[1])*o+i[2])*o+i[3])*o+i[4])*o+i[5])/((((n[0]*o+n[1])*o+n[2])*o+n[3])*o+1)):r<=1-c?(o=r-.5,l=o*o,h=(((((t[0]*l+t[1])*l+t[2])*l+t[3])*l+t[4])*l+t[5])*o/(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+1)):(o=Math.sqrt(-2*Math.log(1-r)),h=-(((((i[0]*o+i[1])*o+i[2])*o+i[3])*o+i[4])*o+i[5])/((((n[0]*o+n[1])*o+n[2])*o+n[3])*o+1));const g=(.5*x(-h/Math.SQRT2)-r)*Math.sqrt(2*Math.PI)*Math.exp(h*h/2);return h-g/(1+h*g/2)}function x(r){const t=Math.abs(r),s=2/(2+t),i=4*s-2,n=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let c=0,o=0,l;for(let w=n.length-1;w>0;w--)l=o,o=i*o-c+n[w],c=l;const h=s*Math.exp(-t*t+.5*(n[0]+i*o)-c);return r>=0?h:2-h}function G(r){return .5*x(-r/Math.SQRT2)}function z(r,t){if(!(t>0)||!Number.isFinite(r))return Number.NaN;const s=.5*q(t/2,.5,t/(t+r*r));return r>0?1-s:s}function j(r,t){if(!(r>0)||!(r<1)||!(t>0))return Number.NaN;if(t>1e7)return K(r);let s=-1e4,i=1e4,n=K(r);const c=B(t/2)+B(.5)-B((t+1)/2);for(let o=0;o<60;o++){const l=z(n,t);l<r?s=n:i=n;const h=Math.exp(-((t+1)/2)*Math.log(1+n*n/t)-c)/Math.sqrt(t),w=h>0?(l-r)/h:0;if(Math.abs(w)<1e-12)break;const g=n-w;if(n=g>s&&g<i&&Number.isFinite(g)?g:(s+i)/2,i-s<1e-12)break}return n}function O(r,t){let s=r,i=1/r,n=i;for(let c=0;c<300&&(s+=1,n*=t/s,i+=n,!(Math.abs(n)<Math.abs(i)*N));c++);return i*Math.exp(-t+r*Math.log(t)-B(r))}function b(r,t){let s=t+1-r,i=1/X,n=1/s,c=n;for(let o=1;o<=300;o++){const l=-o*(o-r);s+=2,n=l*n+s,Math.abs(n)<X&&(n=X),i=s+l/i,Math.abs(i)<X&&(i=X),n=1/n;const h=n*i;if(c*=h,Math.abs(h-1)<N)break}return Math.exp(-t+r*Math.log(t)-B(r))*c}function u(r,t){return!(r>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<r+1?O(r,t):1-b(r,t)}function f(r,t){return t>0?u(t/2,r/2):Number.NaN}function a(r,t){const s=f(r,t);return Number.isNaN(s)?Number.NaN:Math.min(1,Math.max(0,1-s))}}),Ie("packages/core/src/compute/linalg.js",function(e,U){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return q}});function te(K){const x=K.length,G=Array.from({length:x},()=>new Array(x).fill(0));for(let z=0;z<x;z++)for(let j=0;j<=z;j++){let O=K[z][j];for(let b=0;b<j;b++)O-=G[z][b]*G[j][b];if(z===j){if(!(O>0))return null;G[z][j]=Math.sqrt(O)}else G[z][j]=O/G[j][j]}return G}function N(K,x){const G=K.length,z=new Array(G).fill(0);for(let O=0;O<G;O++){let b=x[O];for(let u=0;u<O;u++)b-=K[O][u]*z[u];z[O]=b/K[O][O]}const j=new Array(G).fill(0);for(let O=G-1;O>=0;O--){let b=z[O];for(let u=O+1;u<G;u++)b-=K[u][O]*j[u];j[O]=b/K[O][O]}return j}function X(K){const x=K.length,G=Array.from({length:x},()=>new Array(x).fill(0));for(let z=0;z<x;z++){const j=new Array(x).fill(0);j[z]=1;const O=N(K,j);for(let b=0;b<x;b++)G[b][z]=O[b]}return G}function B(K,x,G){const z=K.length,j=z?K[0].length:0,O=Array.from({length:j},()=>new Array(j).fill(0)),b=new Array(j).fill(0);for(let u=0;u<z;u++){const f=G?G[u]:1,a=K[u];for(let r=0;r<j;r++){const t=f*a[r];b[r]+=t*x[u];for(let s=r;s<j;s++)O[r][s]+=t*a[s]}}for(let u=0;u<j;u++)for(let f=0;f<u;f++)O[u][f]=O[f][u];return{xtwx:O,xtwy:b}}function D(K,x){return K.map(G=>G.reduce((z,j,O)=>z+j*x[O],0))}function q(K,x){let G=0;for(let z=0;z<K.length;z++){let j=0;for(let O=0;O<K.length;O++)j+=x[z][O]*K[O];G+=K[z]*j}return G}}),Ie("packages/core/src/compute/sketch.js",function(e,U){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});class te{#e=0;#t=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#e}add(u){if(!Number.isFinite(u))return;this.#e++;const f=u-this.#t;this.#t+=f/this.#e,this.#n+=f*(u-this.#t)}merge(u){if(u.#e===0)return;if(this.#e===0){this.#e=u.#e,this.#t=u.#t,this.#n=u.#n;return}const f=this.#e+u.#e,a=u.#t-this.#t;this.#t+=a*(u.#e/f),this.#n+=u.#n+a*a*(this.#e*u.#e/f),this.#e=f}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 u=this.variance();return u===null?null:Math.sqrt(u)}stddevP(){const u=this.varianceP();return u===null?null:Math.sqrt(u)}}class N{#e=[];#t=0;#n;#r;constructor(u,f=Math.random){if(!(u>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(u),this.#r=f}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(u){if(!Number.isFinite(u))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(u);return}const f=Math.floor(this.#r()*this.#t);f<this.#n&&(this.#e[f]=u)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let u=0;for(const f of this.#e)u+=f;return u/this.#e.length}quantile(u){const f=this.#e.length;if(!f)return null;const a=this.#e.slice().sort((i,n)=>i-n);if(f===1)return a[0];const r=(f-1)*Math.min(1,Math.max(0,u)),t=Math.floor(r),s=Math.ceil(r);return t===s?a[t]:a[t]+(r-t)*(a[s]-a[t])}}function X(b){return b^=b>>>16,b=Math.imul(b,2246822507),b^=b>>>13,b=Math.imul(b,3266489909),b^=b>>>15,b>>>0}function B(b){if(typeof b=="number"){const a=new DataView(new ArrayBuffer(8));return a.setFloat64(0,b===0?0:b),X(a.getUint32(0)^a.getUint32(4))}const u=typeof b=="string"?b:String(b);let f=2166136261;for(let a=0;a<u.length;a++)f^=u.charCodeAt(a),f=Math.imul(f,16777619);return X(f)}class D{#e;#t;#n;constructor(u=14){const f=Math.floor(u);if(f<4||f>16)throw new RangeError("HLL precision must be 4..16");this.#e=f,this.#t=1<<f,this.#n=new Uint8Array(this.#t)}static errorBoundFor(u=14){const f=1<<Math.floor(u),a=1.04/Math.sqrt(f);return Object.freeze({kind:"probabilistic",metric:"relative",value:a,statement:`distinct count within ~${(a*100).toFixed(2)}% relative standard error (m=${f} buckets)`})}errorBound(){return D.errorBoundFor(this.#e)}add(u){const f=B(u),a=f&this.#t-1,r=f>>>this.#e|1<<32-this.#e;let t=1,s=r;for(;(s&1)===0;)t++,s>>>=1;t>this.#n[a]&&(this.#n[a]=t)}count(){const u=this.#t,f=32-this.#e,a=new Float64Array(f+2);for(let s=0;s<u;s++)a[this.#n[s]]++;let r=u*x(1-a[f+1]/u);for(let s=f;s>=1;s--)r=.5*(r+a[s]);r+=u*K(a[0]/u);const t=q*u*u/r;return Math.round(t)}}const q=.5/Math.log(2);function K(b){if(b===1)return 1/0;let u=1,f=b,a;do b*=b,a=f,f+=b*u,u+=u;while(f!==a);return f}function x(b){if(b===0||b===1)return 0;let u=1,f=1-b,a;do b=Math.sqrt(b),a=f,u*=.5,f-=(1-b)**2*u;while(f!==a);return f/3}class G{#e=new Map;#t;#n=0;constructor(u){if(!(u>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(u)}errorBoundFor(u){const f=u/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:f,statement:`each count overestimates the truth by at most N/m = ${f.toFixed(2)} (N=${u}, m=${this.#t})`})}get seen(){return this.#n}add(u){this.#n++;const f=this.#e.get(u);if(f){f.count++;return}if(this.#e.size<this.#t){this.#e.set(u,{count:1,error:0});return}let a,r=1/0;for(const[t,s]of this.#e)s.count<r&&(r=s.count,a=t);this.#e.delete(a),this.#e.set(u,{count:r+1,error:r})}top(u=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(u)))}}class z{#e;#t=[[]];#n=0;#r;#i;constructor(u=200,f=Math.random){this.#e=Math.max(8,Math.floor(u)),this.#r=f,this.#i=2/3}static errorBoundFor(u=200){const f=1/Math.max(8,Math.floor(u));return Object.freeze({kind:"probabilistic",metric:"rank",value:f,statement:`queried quantile's true rank within ~${(f*100).toFixed(2)}% of N of the requested rank (k=${u})`})}errorBound(){return z.errorBoundFor(this.#e)}get count(){return this.#n}#s(u){const a=this.#t.length-1-u,r=Math.ceil(this.#e*this.#i**a);return Math.max(2,r)}add(u){Number.isFinite(u)&&(this.#n++,this.#t[0].push(u),this.#t[0].length>=this.#s(0)&&this.#o(0))}#o(u){const f=this.#t[u];f.sort((t,s)=>t-s),u+1>=this.#t.length&&this.#t.push([]);const a=this.#t[u+1],r=this.#r()<.5?0:1;for(let t=r;t<f.length;t+=2)a.push(f[t]);this.#t[u]=[];for(let t=0;t<this.#t.length;t++)if(this.#t[t].length>=this.#s(t)){this.#o(t);return}}#l(){const u=[];for(let f=0;f<this.#t.length;f++){const a=1<<f;for(const r of this.#t[f])u.push({v:r,w:a})}return u}quantile(u){const f=this.#l();if(!f.length)return null;f.sort((s,i)=>s.v-i.v);let a=0;for(const s of f)a+=s.w;const r=Math.min(1,Math.max(0,u))*a;let t=0;for(const s of f)if(t+=s.w,t>=r)return s.v;return f[f.length-1].v}rank(u){let f=0;for(let a=0;a<this.#t.length;a++){const r=1<<a;for(const t of this.#t[a])t<=u&&(f+=r)}return f}}const j=Object.freeze({distinct:D.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"})}),O={Welford:te,Reservoir:N,HyperLogLog:D,SpaceSaving:G,KLL:z,hash32:B,SKETCH_BOUNDS:j}}),Ie("packages/core/src/compute/statistics.js",function(e,U){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return at}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return Pe}});const te=U("packages/core/src/compute/handle.js"),N=te.presenceReader,X=te.valueReader,B=U("packages/core/src/compute/special.js"),D=B.studentTQuantile,q=B.studentT,K=B.normalQuantile,x=B.normalCdf,G=B.chiSquareUpperTail,z=U("packages/core/src/compute/linalg.js"),j=z.cholesky,O=z.choleskySolve,b=z.choleskyInverse,u=z.normalEquations,f=z.quadForm,r=U("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,t=5e3,s=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 n(le){const be=le==="sum"||le==="avg"||le==="countValues"||le==="min"||le==="max"?"maintained":Object.prototype.hasOwnProperty.call(s,le)?s[le]:null,ue=Object.prototype.hasOwnProperty.call(i,le)?i[le]:null;return{stat:le,exact:be,approximate:ue}}function c(le,be){const ue=be.length,ve=new Float64Array(ue);let Ce=0;if(le&&(le.kind==="float64"||le.kind==="int32")){const Be=le.values,Ve=N(le);for(let Je=0;Je<ue;Je++){const $e=be[Je];if(Ve&&Ve($e)!==1)continue;const ze=Be[$e];Number.isNaN(ze)||(ve[Ce++]=ze)}return ve.subarray(0,Ce)}const Fe=X(le);for(let Be=0;Be<ue;Be++){const Ve=Fe(be[Be]);if(Ve==null||Ve==="")continue;const Je=typeof Ve=="number"?Ve:Number(Ve);Number.isFinite(Je)&&(ve[Ce++]=Je)}return ve.subarray(0,Ce)}function o(le,be){const ue=new Map,ve=X(le);let Ce=0;for(let Fe=0;Fe<be.length;Fe++){const Be=ve(be[Fe]);if(Be==null||Be===""||typeof Be=="number"&&Number.isNaN(Be))continue;const Ve=typeof Be=="object"?String(Be):Be;ue.set(Ve,(ue.get(Ve)||0)+1),Ce++}const Ee=[...ue.values()].sort((Fe,Be)=>Be-Fe);return{counts:Ee,total:Ce,distinct:Ee.length}}function l(le){return le.total>0?le.counts.map(be=>be/le.total):[]}function h(le,be){const ue=o(le,be);if(!ue.total)return null;let ve=0;for(const Ce of l(ue))ve+=Ce*Ce;return ve}function w(le,be){const ue=o(le,be);if(!ue.total)return null;let ve=0;for(const Ce of l(ue))Ce>0&&(ve-=Ce*Math.log2(Ce));return ve}function g(le,be){const ue=o(le,be);if(!ue.total||ue.distinct<2)return ue.total?1:null;let ve=0;for(const Ce of l(ue))Ce>0&&(ve-=Ce*Math.log2(Ce));return ve/Math.log2(ue.distinct)}function k(le,be,ue=3){const ve=o(le,be);if(!ve.total)return null;const Ce=Math.max(1,Math.floor(ue));let Ee=0;for(let Fe=0;Fe<Math.min(Ce,ve.counts.length);Fe++)Ee+=ve.counts[Fe];return Ee/ve.total}function d(le,be){const ue=c(le,be),ve=ue.length;if(!ve)return null;const Ce=ue.slice().sort();if(Ce[0]<0)return null;let Ee=0,Fe=0;for(let Be=0;Be<ve;Be++)Ee+=Ce[Be],Fe+=(Be+1)*Ce[Be];return Ee===0?0:2*Fe/(ve*Ee)-(ve+1)/ve}function p(le){let be=0,ue=0,ve=0;for(let Ce=0;Ce<le.length;Ce++){const Ee=le[Ce];be++;const Fe=Ee-ue;ue+=Fe/be,ve+=Fe*(Ee-ue)}return{n:be,mean:ue,m2:ve}}function m(le,be){const ue=le.length;if(!ue)return NaN;if(ue===1)return le[0];const ve=(ue-1)*Math.min(1,Math.max(0,be)),Ce=Math.floor(ve),Ee=Math.ceil(ve);return Ce===Ee?le[Ce]:le[Ce]+(ve-Ce)*(le[Ee]-le[Ce])}function v(le,be){if(!le.length)return NaN;const ue=le.slice().sort();return m(ue,be)}function y(le,be){const ue=X(le);let ve=0,Ce=0,Ee=0;for(let Fe=0;Fe<be.length;Fe++){const Be=ue(be[Fe]);if(Be==null||Be==="")continue;const Ve=String(Be).toUpperCase();Ve==="PASS"?ve++:Ve==="FAIL"?Ce++:Ve==="WARN"&&Ee++}return{pass:ve+Ee,fail:Ce,warn:Ee,judged:ve+Ee+Ce}}const E=Object.freeze({hhi:(le,be)=>h(le,be),entropy:(le,be)=>w(le,be),evenness:(le,be)=>g(le,be),top3Share:(le,be)=>k(le,be,3),top10Share:(le,be)=>k(le,be,10),gini:(le,be)=>d(le,be),trimmedMean:(le,be)=>$(c(le,be),.1),winsorizedMean:(le,be)=>S(c(le,be),.1),robustOutliers:(le,be)=>R(c(le,be),3.5),jarqueBera:(le,be)=>L(c(le,be)),variance:(le,be)=>{const{n:ue,m2:ve}=p(c(le,be));return ue>1?ve/(ue-1):null},varianceP:(le,be)=>{const{n:ue,m2:ve}=p(c(le,be));return ue>0?ve/ue:null},stddev:(le,be)=>{const{n:ue,m2:ve}=p(c(le,be));return ue>1?Math.sqrt(ve/(ue-1)):null},stddevP:(le,be)=>{const{n:ue,m2:ve}=p(c(le,be));return ue>0?Math.sqrt(ve/ue):null},median:(le,be)=>{const ue=c(le,be);return ue.length?v(ue,.5):null},p25:(le,be)=>{const ue=c(le,be);return ue.length?v(ue,.25):null},p75:(le,be)=>{const ue=c(le,be);return ue.length?v(ue,.75):null},p90:(le,be)=>{const ue=c(le,be);return ue.length?v(ue,.9):null},p95:(le,be)=>{const ue=c(le,be);return ue.length?v(ue,.95):null},p99:(le,be)=>{const ue=c(le,be);return ue.length?v(ue,.99):null},iqr:(le,be)=>{const ue=c(le,be);if(!ue.length)return null;const ve=ue.slice().sort();return m(ve,.75)-m(ve,.25)},mad:(le,be)=>{const ue=c(le,be);if(!ue.length)return null;const ve=v(ue,.5),Ce=new Float64Array(ue.length);for(let Ee=0;Ee<ue.length;Ee++)Ce[Ee]=Math.abs(ue[Ee]-ve);return v(Ce,.5)},range:(le,be)=>{const ue=c(le,be);if(!ue.length)return null;let ve=1/0,Ce=-1/0;for(let Ee=0;Ee<ue.length;Ee++)ue[Ee]<ve&&(ve=ue[Ee]),ue[Ee]>Ce&&(Ce=ue[Ee]);return Ce-ve},distinct:(le,be)=>{const ue=X(le),ve=new Set;for(let Ce=0;Ce<be.length;Ce++){const Ee=ue(be[Ce]);Ee==null||Ee===""||ve.add(Ee instanceof Date?Ee.getTime():Ee)}return ve.size},mode:(le,be)=>{const ue=X(le),ve=new Map;for(let Fe=0;Fe<be.length;Fe++){const Be=ue(be[Fe]);if(Be==null||Be==="")continue;const Ve=Be instanceof Date?Be.getTime():Be;ve.set(Ve,(ve.get(Ve)||0)+1)}let Ce=null,Ee=1;for(const[Fe,Be]of ve)Be>Ee&&(Ee=Be,Ce=Fe);return Ce},skewness:(le,be)=>{const ue=c(le,be),{n:ve,mean:Ce,m2:Ee}=p(ue);if(ve<3||Ee<=0)return null;const Fe=Math.sqrt(Ee/(ve-1));let Be=0;for(let Ve=0;Ve<ue.length;Ve++)Be+=((ue[Ve]-Ce)/Fe)**3;return ve/((ve-1)*(ve-2))*Be},kurtosis:(le,be)=>{const ue=c(le,be),{n:ve,mean:Ce,m2:Ee}=p(ue);if(ve<4||Ee<=0)return null;const Fe=Math.sqrt(Ee/(ve-1));let Be=0;for(let $e=0;$e<ue.length;$e++)Be+=((ue[$e]-Ce)/Fe)**4;const Ve=ve*(ve+1)/((ve-1)*(ve-2)*(ve-3)),Je=3*(ve-1)**2/((ve-2)*(ve-3));return Ve*Be-Je},geomean:(le,be)=>{const ue=c(le,be);if(!ue.length)return null;let ve=0;for(let Ce=0;Ce<ue.length;Ce++){if(ue[Ce]<=0)return null;ve+=Math.log(ue[Ce])}return Math.exp(ve/ue.length)},harmean:(le,be)=>{const ue=c(le,be);if(!ue.length)return null;let ve=0;for(let Ce=0;Ce<ue.length;Ce++){if(ue[Ce]===0)return null;ve+=1/ue[Ce]}return ue.length/ve},sumSquares:(le,be)=>{const ue=c(le,be);let ve=0;for(let Ce=0;Ce<ue.length;Ce++)ve+=ue[Ce]*ue[Ce];return ve},passRate:(le,be)=>{const{pass:ue,judged:ve}=y(le,be);return ve?ue/ve:null},failureCount:(le,be)=>y(le,be).fail}),M=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(le,be,ue){const ve=X(le),Ce=X(be);let Ee=0,Fe=0;for(let Be=0;Be<ue.length;Be++){const Ve=ue[Be],Je=Number(ve(Ve)),$e=Number(Ce(Ve));!Number.isFinite(Je)||!Number.isFinite($e)||(Ee+=Je*$e,Fe+=$e)}return Fe===0?null:Ee/Fe}function V(le,be,ue){const ve=X(le);let Ce=null,Ee=ue?-1/0:1/0;for(let Fe=0;Fe<be.length;Fe++){const Be=be[Fe],Ve=Number(ve(Be));Number.isFinite(Ve)&&(ue?Ve>Ee:Ve<Ee)&&(Ee=Ve,Ce=Be)}return Ce}function I(le,be,ue){const ve=X(le),Ce=X(be);let Ee=0,Fe=0,Be=0,Ve=0,Je=0,$e=0;for(let et=0;et<ue.length;et++){const dt=ue[et],ft=Number(ve(dt)),lt=Number(Ce(dt));!Number.isFinite(ft)||!Number.isFinite(lt)||(Ee++,Fe+=ft,Be+=lt,Ve+=ft*ft,Je+=lt*lt,$e+=ft*lt)}if(Ee<2)return null;const ze=Ee*$e-Fe*Be,Qe=Math.sqrt((Ee*Ve-Fe*Fe)*(Ee*Je-Be*Be));if(Qe===0)return null;const tt=ze/Qe;return Math.max(-1,Math.min(1,tt))}function $(le,be=.1){const ue=le.length;if(!ue)return null;const ve=Array.from(le).sort((Be,Ve)=>Be-Ve),Ce=Math.floor(ue*Math.min(.49,Math.max(0,be))),Ee=ve.slice(Ce,ue-Ce);if(!Ee.length)return m(ve,.5);let Fe=0;for(const Be of Ee)Fe+=Be;return Fe/Ee.length}function S(le,be=.1){const ue=le.length;if(!ue)return null;const ve=Array.from(le).sort((Ve,Je)=>Ve-Je),Ce=Math.floor(ue*Math.min(.49,Math.max(0,be))),Ee=ve[Ce],Fe=ve[ue-1-Ce];let Be=0;for(const Ve of ve)Be+=Math.min(Fe,Math.max(Ee,Ve));return Be/ue}function R(le,be=3.5){if(!le.length)return null;const ve=Array.from(le).sort((Ve,Je)=>Ve-Je),Ce=m(ve,.5),Ee=ve.map(Ve=>Math.abs(Ve-Ce)).sort((Ve,Je)=>Ve-Je),Fe=m(Ee,.5);if(Fe===0)return null;let Be=0;for(const Ve of ve)Math.abs(.6745*(Ve-Ce)/Fe)>be&&Be++;return Be}function L(le){const be=le.length;if(be<8)return null;let ue=0;for(const Ve of le)ue+=Ve;ue/=be;let ve=0,Ce=0,Ee=0;for(const Ve of le){const Je=Ve-ue;ve+=Je*Je,Ce+=Je*Je*Je,Ee+=Je*Je*Je*Je}if(ve/=be,Ce/=be,Ee/=be,ve===0)return null;const Fe=Ce/ve**1.5,Be=Ee/(ve*ve)-3;return be/6*(Fe*Fe+Be*Be/4)}function T(le,be,ue){const ve=[];let Ce=0;for(let Ve=0;Ve<le.length;Ve++){const Je=Number(le[Ve]),$e=Number(be[Ve]);!Number.isFinite(Je)||!Number.isFinite($e)||$e<=0||(ve.push([Je,$e]),Ce+=$e)}if(!ve.length||Ce<=0)return null;if(ve.sort((Ve,Je)=>Ve[0]-Je[0]),ve.length===1)return ve[0][0];const Ee=[];let Fe=0;for(const[,Ve]of ve)Ee.push((Fe+Ve/2)/Ce),Fe+=Ve;const Be=Math.max(0,Math.min(1,ue));if(Be<=Ee[0])return ve[0][0];if(Be>=Ee[Ee.length-1])return ve[ve.length-1][0];for(let Ve=1;Ve<Ee.length;Ve++){if(Be>Ee[Ve])continue;const Je=Ee[Ve]-Ee[Ve-1],$e=Je>0?(Be-Ee[Ve-1])/Je:0;return ve[Ve-1][0]+(ve[Ve][0]-ve[Ve-1][0])*$e}return ve[ve.length-1][0]}function A(le,be,ue){const ve=X(le),Ce=X(be),Ee=new Float64Array(ue.length),Fe=new Float64Array(ue.length);let Be=0;for(let Ve=0;Ve<ue.length;Ve++){const Je=ue[Ve],$e=Number(ve(Je)),ze=Number(Ce(Je));!Number.isFinite($e)||!Number.isFinite(ze)||(Ee[Be]=$e,Fe[Be]=ze,Be++)}return{xs:Ee.subarray(0,Be),ys:Fe.subarray(0,Be),n:Be}}function C(le,be,ue,ve=!1){const{xs:Ce,ys:Ee,n:Fe}=A(le,be,ue);if(Fe<2)return null;let Be=0,Ve=0;for(let $e=0;$e<Fe;$e++)Be+=Ce[$e],Ve+=Ee[$e];Be/=Fe,Ve/=Fe;let Je=0;for(let $e=0;$e<Fe;$e++)Je+=(Ce[$e]-Be)*(Ee[$e]-Ve);return Je/(ve?Fe:Fe-1)}function H(le,be,ue){const{xs:ve,ys:Ce,n:Ee}=A(le,be,ue);if(Ee<2)return null;let Fe=0,Be=0;for(let ft=0;ft<Ee;ft++)Fe+=ve[ft],Be+=Ce[ft];Fe/=Ee,Be/=Ee;let Ve=0,Je=0,$e=0;for(let ft=0;ft<Ee;ft++){const lt=ve[ft]-Fe,jt=Ce[ft]-Be;Ve+=lt*lt,Je+=lt*jt,$e+=jt*jt}if(Ve===0)return null;const ze=Je/Ve,Qe=Be-ze*Fe,tt=$e===0?1:Math.max(0,Math.min(1,Je*Je/(Ve*$e))),et=Math.max(0,$e-ze*Je),dt=Ee>2?Math.sqrt(et/(Ee-2)/Ve):0;return{slope:ze,intercept:Qe,r2:tt,stdError:dt,n:Ee}}const Y=new Set(["ols","wls","robust"]),Z=new Set(["quantile"]),_=new Set(["ridge","lasso","elasticnet","mixed","gls"]),J=1.345;function ee(le,be,ue){const{xtwx:ve,xtwy:Ce}=u(le,be,ue),Ee=j(ve);if(!Ee)return null;const Fe=O(Ee,Ce),Be=b(Ee),Ve=ne(le,Fe),Je=be.map(($e,ze)=>$e-Ve[ze]);return{beta:Fe,cov:Be,fitted:Ve,residuals:Je}}function ne(le,be){return le.map(ue=>ue.reduce((ve,Ce,Ee)=>ve+Ce*be[Ee],0))}function se(le,be){const ue=le.length,ve=le.map(Je=>Je[be]),Ce=le.map(Je=>[1,...Je.filter(($e,ze)=>ze!==be)]),Ee=ee(Ce,ve,null);if(!Ee)return 1;const Fe=ve.reduce((Je,$e)=>Je+$e,0)/ue;let Be=0,Ve=0;for(let Je=0;Je<ue;Je++)Be+=Ee.residuals[Je]**2,Ve+=(ve[Je]-Fe)**2;return Ve===0?1:Math.max(0,Math.min(1,1-Be/Ve))}function oe(le){const be=[...le].sort((Ce,Ee)=>Ce-Ee),ue=fe(be),ve=le.map(Ce=>Math.abs(Ce-ue)).sort((Ce,Ee)=>Ce-Ee);return fe(ve)/.6745}function fe(le){const be=le.length;if(!be)return 0;const ue=Math.floor(be/2);return be%2?le[ue]:(le[ue-1]+le[ue])/2}function pe(le,be,ue={}){const ve=ue.method||"ols";if(_.has(ve))throw new Error(`[lattice] regression method "${ve}" is out of scope; use ols, wls or robust.`);if(Z.has(ve))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!Y.has(ve))throw new Error(`[lattice] unknown regression method "${ve}"; use ols, wls or robust.`);const Ce=Array.isArray(be)?be.length:0,Ee=Ce&&Array.isArray(le[0])?le[0].length:0,Fe=Ee+1;if(!(Ce>Fe))return null;for(let Lt=0;Lt<Ce;Lt++){if(!Number.isFinite(be[Lt])||!Array.isArray(le[Lt])||le[Lt].length!==Ee)return null;for(let Dt=0;Dt<Ee;Dt++)if(!Number.isFinite(le[Lt][Dt]))return null}let Be=null;if(ve==="wls"){if(Be=ue.weights,!Array.isArray(Be)||Be.length!==Ce)return null;for(let Lt=0;Lt<Ce;Lt++)if(!(Be[Lt]>0)||!Number.isFinite(Be[Lt]))return null}const Ve=le.map(Lt=>[1,...Lt]);let Je,$e=null;if(ve==="robust"){if(Je=ee(Ve,be,null),!Je)return null;for(let Lt=0;Lt<50;Lt++){const Dt=oe(Je.residuals);if(!(Dt>0))break;const zt=Je.residuals.map(Qt=>{const Xt=Math.abs(Qt/Dt);return Xt<=J?1:J/Xt}),Kt=ee(Ve,be,zt);if(!Kt)return null;const qt=Kt.beta.reduce((Qt,Xt,nn)=>Math.max(Qt,Math.abs(Xt-Je.beta[nn])),0);if(Je=Kt,$e=zt,qt<1e-10)break}}else if(Je=ee(Ve,be,Be),!Je)return null;const ze=ve==="robust"?$e:Be,{beta:Qe,cov:tt,fitted:et,residuals:dt}=Je;let ft=0,lt=0,jt=0;for(let Lt=0;Lt<Ce;Lt++){const Dt=ze?ze[Lt]:1;ft+=Dt*dt[Lt]**2,lt+=Dt,jt+=Dt*be[Lt]}const Tt=jt/lt;let xt=0;for(let Lt=0;Lt<Ce;Lt++){const Dt=ze?ze[Lt]:1;xt+=Dt*(be[Lt]-Tt)**2}const Ge=Ce-Fe,vt=ft/Ge,ht=xt===0?1:Math.max(0,Math.min(1,1-ft/xt)),kt=1-(1-ht)*(Ce-1)/Ge,Nt=Array.isArray(ue.names)&&ue.names.length===Ee?ue.names:le[0].map((Lt,Dt)=>`x${Dt+1}`),bt=it(ue.confidence),mt=Ge>0?D(1-(1-bt)/2,Ge):1/0,$t=Qe.map((Lt,Dt)=>{const zt=Math.sqrt(Math.max(0,vt*tt[Dt][Dt])),Kt=zt>0?Lt/zt:Lt===0?0:1/0,qt=Number.isFinite(Kt)?2*(1-q(Math.abs(Kt),Ge)):0,Qt=Number.isFinite(mt)?mt*zt:null;return{name:Dt===0?"(intercept)":Nt[Dt-1],estimate:Lt,stdError:zt,t:Kt,p:Math.max(0,Math.min(1,qt)),lower:Qt===null?null:Lt-Qt,upper:Qt===null?null:Lt+Qt}}),Ht=new Array(Ce),Yt=new Array(Ce);for(let Lt=0;Lt<Ce;Lt++){const Dt=ze?ze[Lt]:1,zt=Math.max(0,Math.min(1,Dt*f(Ve[Lt],tt)));Ht[Lt]=zt;const Kt=(1-zt)**2;Yt[Lt]=Kt>0&&vt>0?dt[Lt]**2/(Fe*vt)*(zt/Kt):null}const pn=le[0].map((Lt,Dt)=>{if(Ee<2)return 1;const zt=se(le,Dt);return zt>=1?1/0:1/(1-zt)});let un=null;{const Lt=dt.map(zt=>zt*zt),Dt=ee(Ve,Lt,null);if(Dt){const zt=Lt.reduce((Jt,mn)=>Jt+mn,0)/Ce;let Kt=0,qt=0;for(let Jt=0;Jt<Ce;Jt++)Kt+=Dt.residuals[Jt]**2,qt+=(Lt[Jt]-zt)**2;const Qt=qt===0?0:Math.max(0,Math.min(1,1-Kt/qt)),Xt=Ce*Qt,nn=G(Xt,Ee);un={statistic:Xt,df:Ee,p:nn,heteroscedastic:nn<.05}}}let on=null;if(Ee===1){const Lt=le.map((Dt,zt)=>zt).sort((Dt,zt)=>le[Dt][0]-le[zt][0]);on={confidence:bt,points:Lt.map(Dt=>{const zt=Ve[Dt],Kt=Math.sqrt(Math.max(0,vt*f(zt,tt)));return{x:le[Dt][0],yhat:et[Dt],lower:et[Dt]-mt*Kt,upper:et[Dt]+mt*Kt}})}}return{method:ve,coefficients:$t,r2:ht,adjR2:kt,n:Ce,df:Ge,sigma2:vt,fitted:et,residuals:dt,leverage:Ht,cooksD:Yt,vif:pn,heteroscedasticity:un,band:on,weights:ze?[...ze]:null}}function he(le){const be=le.length,ue=Array.from({length:be},(Ee,Fe)=>Fe).sort((Ee,Fe)=>le[Ee]-le[Fe]),ve=new Float64Array(be);let Ce=0;for(;Ce<be;){let Ee=Ce;for(;Ee+1<be&&le[ue[Ee+1]]===le[ue[Ce]];)Ee++;const Fe=(Ce+Ee)/2+1;for(let Be=Ce;Be<=Ee;Be++)ve[ue[Be]]=Fe;Ce=Ee+1}return ve}const Re=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function Ue(le){const be=[.01,.05,.1],ue=[Re["1%"],Re["5%"],Re["10%"]];if(le<=ue[0]){const Ee=(Math.log(be[1])-Math.log(be[0]))/(ue[1]-ue[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(be[0])+Ee*(le-ue[0]))))}if(le>=ue[2]){const Ee=(Math.log(be[2])-Math.log(be[1]))/(ue[2]-ue[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(be[2])+Ee*(le-ue[2]))))}const ve=le<ue[1]?0:1,Ce=(le-ue[ve])/(ue[ve+1]-ue[ve]);return Math.exp(Math.log(be[ve])+Ce*(Math.log(be[ve+1])-Math.log(be[ve])))}function Le(le,be,ue,ve){const Ce=ue-ve,Ee=ve+3,Fe=new Array(Ce),Be=new Array(Ce);let Ve=!0,Je=ve;for(let et=0;et<Ce;et++){const dt=ve+et,ft=new Float64Array(Ee);ft[0]=1,ft[1]=et+1,ft[2]=le[dt];for(let lt=1;lt<=ve;lt++)ft[2+lt]=be[dt-lt];for(let lt=1;lt<Ee;lt++)Number.isFinite(ft[lt])||(Je=Math.min(Je,lt-3));Fe[et]=ft,Be[et]=be[dt],Number.isFinite(Be[et])||(Ve=!1)}if(!Ve)return 0;const{xtwx:$e,xtwy:ze}=u(Fe,Be,null);let Qe=0,tt=1/0;for(let et=0;et<=Je;et++){const dt=et+3;if(!(Ce>dt))continue;const ft=new Array(dt);for(let ht=0;ht<dt;ht++)ft[ht]=$e[ht].slice(0,dt);const lt=j(ft);if(!lt)continue;const jt=O(lt,ze.slice(0,dt));let Tt=0;for(let ht=0;ht<Ce;ht++){const kt=Fe[ht];let Nt=0;for(let bt=0;bt<dt;bt++)Nt+=kt[bt]*jt[bt];Tt+=(Be[ht]-Nt)**2}const Ge=Tt/(Ce-dt)*(Ce-dt);if(!(Ge>0))continue;const vt=Ce*Math.log(Ge/Ce)+2*dt;vt<tt&&(tt=vt,Qe=et)}return Qe}function ie(le,be={}){const ue=[];for(let tt=0;tt<le.length;tt++){const et=Number(le[tt]);Number.isFinite(et)&&ue.push(et)}const ve=ue.length,Ce=ve-1;if(ve<8||Ce<6)return null;const Ee=new Array(Ce);for(let tt=0;tt<Ce;tt++)Ee[tt]=ue[tt+1]-ue[tt];let Fe=Number.isFinite(be.maxlag)?Math.floor(be.maxlag):Math.ceil(12*(ve/100)**.25);Fe=Math.max(0,Math.min(Fe,Math.floor((Ce-5)/2)));const Be=(tt,et)=>{const dt=[],ft=[];for(let lt=et;lt<Ce;lt++){const jt=[lt-et+1,ue[lt]];for(let Tt=1;Tt<=tt;Tt++)jt.push(Ee[lt-Tt]);dt.push(jt),ft.push(Ee[lt])}return pe(dt,ft,{method:"ols"})},Ve=Le(ue,Ee,Ce,Fe),Je=Be(Ve,Ve);if(!Je||!Je.coefficients[2])return null;const $e=Je.coefficients[2].t,ze=Ue($e),Qe=$e<Re["5%"];return{statistic:$e,usedLag:Ve,nobs:Ce-Ve,criticalValues:{...Re},pValue:ze,pApproximate:!0,stationary:Qe,verdict:Qe?"stationary":"non-stationary",regression:"ct"}}function ge(le,be={}){const ue=[];for(let Qe=0;Qe<le.length;Qe++){const tt=Number(le[Qe]);Number.isFinite(tt)&&ue.push(tt)}const ve=ue.length;if(ve<3)return null;let Ce=Number.isFinite(be.maxlag)?Math.floor(be.maxlag):Math.min(10,ve-1);Ce=Math.max(1,Math.min(Ce,ve-1));let Ee=0;for(const Qe of ue)Ee+=Qe;Ee/=ve;const Fe=ue.map(Qe=>Qe-Ee);let Be=0;for(const Qe of Fe)Be+=Qe*Qe;Be/=ve;const Ve=new Array(Ce+1).fill(0);Ve[0]=1;for(let Qe=1;Qe<=Ce;Qe++){let tt=0;for(let et=Qe;et<ve;et++)tt+=Fe[et]*Fe[et-Qe];Ve[Qe]=Be>0?tt/ve/Be:0}const Je=new Array(Ce+1).fill(0);Je[0]=1;let $e=[];for(let Qe=1;Qe<=Ce;Qe++){let tt=Ve[Qe];for(let lt=1;lt<Qe;lt++)tt-=$e[lt-1]*Ve[Qe-lt];let et=1;for(let lt=1;lt<Qe;lt++)et-=$e[lt-1]*Ve[lt];const dt=et!==0?tt/et:0,ft=new Array(Qe);for(let lt=1;lt<Qe;lt++)ft[lt-1]=$e[lt-1]-dt*$e[Qe-1-lt];ft[Qe-1]=dt,Je[Qe]=dt,$e=ft}const ze=1.96/Math.sqrt(ve);return{acf:Ve,pacf:Je,bounds:{upper:ze,lower:-ze},n:ve,nlags:Ce,approximate:!0}}function ke(le,be,ue){const{xs:ve,ys:Ce,n:Ee}=A(le,be,ue);if(Ee<2)return null;const Fe=he(ve),Be=he(Ce);let Ve=0,Je=0;for(let tt=0;tt<Ee;tt++)Ve+=Fe[tt],Je+=Be[tt];Ve/=Ee,Je/=Ee;let $e=0,ze=0,Qe=0;for(let tt=0;tt<Ee;tt++){const et=Fe[tt]-Ve,dt=Be[tt]-Je;$e+=et*dt,ze+=et*et,Qe+=dt*dt}return ze===0||Qe===0?null:Math.max(-1,Math.min(1,$e/Math.sqrt(ze*Qe)))}function Se(le,be,ue){const{xs:ve,ys:Ce,n:Ee}=A(le,be,ue);if(Ee<2||Ee>t)return null;let Fe=0,Be=0,Ve=0,Je=0;for(let Qe=0;Qe<Ee;Qe++)for(let tt=Qe+1;tt<Ee;tt++){const et=Math.sign(ve[Qe]-ve[tt]),dt=Math.sign(Ce[Qe]-Ce[tt]),ft=et*dt;ft>0?Fe++:ft<0?Be++:et===0&&dt===0||(et===0?Ve++:Je++)}const $e=Fe+Be+Je,ze=Fe+Be+Ve;return $e===0||ze===0?null:(Fe-Be)/Math.sqrt($e*ze)}function Ae(le,be={}){const ue=le.length;if(ue<2)return null;const ve=le[0],Ce=le[ue-1],Ee=[];for(let lt=1;lt<ue;lt++){const jt=le[lt-1];jt!==0&&Ee.push((le[lt]-jt)/Math.abs(jt))}let Fe=null;if(Ee.length>1){let lt=0;for(const Tt of Ee)lt+=Tt;lt/=Ee.length;let jt=0;for(const Tt of Ee)jt+=(Tt-lt)**2;Fe=Math.sqrt(jt/(Ee.length-1))}const Be=Number(be.periodsPerYear)>0?Number(be.periodsPerYear):null;let Ve=le[0],Je=0,$e=0,ze=0,Qe=0;for(let lt=1;lt<ue;lt++){if(le[lt]>Ve){Ve=le[lt],Je=lt;continue}if(Ve<=0)continue;const jt=(Ve-le[lt])/Ve;jt>$e&&($e=jt,ze=Je,Qe=lt)}let tt=null;if(ue>2){let lt=0;for(let xt=0;xt<ue;xt++)lt+=le[xt];lt/=ue;let jt=0,Tt=0;for(let xt=0;xt<ue;xt++){const Ge=le[xt]-lt;Tt+=Ge*Ge,xt>0&&(jt+=Ge*(le[xt-1]-lt))}tt=Tt>0?jt/Tt:null}let et=0,dt=0;for(const lt of Ee)lt>0?et++:lt<0&&dt++;let ft=null;if(ve>0&&Ce>0){const lt=(Ce/ve)**(1/(ue-1))-1;ft=Be?(1+lt)**Be-1:lt}return{n:ue,first:ve,last:Ce,change:Ce-ve,changePercent:ve===0?null:(Ce-ve)/Math.abs(ve)*100,volatility:Fe,annualisedVolatility:Fe!==null&&Be?Fe*Math.sqrt(Be):null,growth:ft,maxDrawdown:$e,maxDrawdownFrom:ze,maxDrawdownTo:Qe,autocorrelation:tt,upDays:et,downDays:dt}}const xe=1.128,me=3.267;function ye(le){const be=le.length;if(be<2)return null;const ue=[];for(let Ce=1;Ce<be;Ce++)ue.push(Math.abs(le[Ce]-le[Ce-1]));const ve=ue.reduce((Ce,Ee)=>Ce+Ee,0)/ue.length;return{ranges:ue,centre:ve,upper:me*ve,lower:0}}function Te(le){const be=le.length;if(be<2)return null;let ue=0;for(let Ce=1;Ce<be;Ce++)ue+=Math.abs(le[Ce]-le[Ce-1]);const ve=ue/(be-1);return{sigma:ve/xe,meanRange:ve}}function Ye(le,be){const ue=le.length;if(ue<2||!be)return null;const ve=Number.isFinite(Number(be.lower))?Number(be.lower):null,Ce=Number.isFinite(Number(be.upper))?Number(be.upper):null;if(ve===null&&Ce===null)return null;let Ee=0;for(let et=0;et<ue;et++)Ee+=le[et];Ee/=ue;let Fe=0;for(let et=0;et<ue;et++)Fe+=(le[et]-Ee)**2;const Be=Math.sqrt(Fe/(ue-1)),Ve=Te(le),Je=Ve?Ve.sigma:null,$e=et=>{if(!et||et<=0)return{index:null,k:null};const ft=ve!==null&&Ce!==null?(Ce-ve)/(6*et):null,lt=Ce!==null?(Ce-Ee)/(3*et):1/0,jt=ve!==null?(Ee-ve)/(3*et):1/0;return{index:ft,k:Math.min(lt,jt)}},ze=$e(Je),Qe=$e(Be);let tt=0;for(let et=0;et<ue;et++){if(ve!==null&&le[et]<ve){tt++;continue}Ce!==null&&le[et]>Ce&&tt++}return{n:ue,mean:Ee,lower:ve,upper:Ce,target:Number.isFinite(Number(be.target))?Number(be.target):null,sigmaWithin:Je,sigmaOverall:Be,cp:ze.index,cpk:ze.k,pp:Qe.index,ppk:Qe.k,outOfSpec:tt,defectRate:ue?tt/ue:null}}function Oe(le){const be=le.length;if(be<2)return null;const ue=Te(le);if(!ue||!(ue.sigma>0))return null;let ve=0;for(let Ce=0;Ce<be;Ce++)ve+=le[Ce];return ve/=be,{centre:ve,sigma:ue.sigma,upper:ve+3*ue.sigma,lower:ve-3*ue.sigma}}function _e(le,be){if(!be||!(be.sigma>0))return[];const ue=le.length,{centre:ve,sigma:Ce}=be,Ee=Be=>(le[Be]-ve)/Ce,Fe=[];for(let Be=0;Be<ue;Be++){if(Math.abs(Ee(Be))>3&&Fe.push({index:Be,rule:1,description:"beyond three sigma"}),Be>=2)for(const Ve of[1,-1]){let Je=0;for(let $e=Be-2;$e<=Be;$e++)Ee($e)*Ve>2&&Je++;if(Je>=2){Fe.push({index:Be,rule:2,description:"two of three past two sigma"});break}}if(Be>=4)for(const Ve of[1,-1]){let Je=0;for(let $e=Be-4;$e<=Be;$e++)Ee($e)*Ve>1&&Je++;if(Je>=4){Fe.push({index:Be,rule:3,description:"four of five past one sigma"});break}}if(Be>=7)for(const Ve of[1,-1]){let Je=!0;for(let $e=Be-7;$e<=Be;$e++)if(Ee($e)*Ve<=0){Je=!1;break}if(Je){Fe.push({index:Be,rule:4,description:"eight in a row on one side"});break}}}return Fe}function je(le,be){if(!be||!(be.sigma>0))return[];const ue=le.length,{centre:ve,sigma:Ce}=be,Ee=Ve=>(le[Ve]-ve)/Ce,Fe=(Ve,Je,$e,ze)=>{for(const Qe of[1,-1]){let tt=0;for(let et=Ve;et<=Je;et++)Ee(et)*Qe>$e&&tt++;if(tt>=ze)return!0}return!1},Be=[];for(let Ve=0;Ve<ue;Ve++){if(Math.abs(Ee(Ve))>3&&Be.push({index:Ve,rule:1,description:"beyond three sigma"}),Ve>=8)for(const Je of[1,-1]){let $e=!0;for(let ze=Ve-8;ze<=Ve;ze++)if(Ee(ze)*Je<=0){$e=!1;break}if($e){Be.push({index:Ve,rule:2,description:"nine in a row on one side"});break}}if(Ve>=5)for(const Je of[1,-1]){let $e=!0;for(let ze=Ve-4;ze<=Ve;ze++)if((le[ze]-le[ze-1])*Je<=0){$e=!1;break}if($e){Be.push({index:Ve,rule:3,description:Je>0?"six rising":"six falling"});break}}if(Ve>=13){let Je=!0;for(let $e=Ve-12;$e<=Ve;$e++){const ze=le[$e]-le[$e-1],Qe=le[$e+1<=Ve?$e+1:$e]-le[$e];if($e+1>Ve)break;if(ze===0||Qe===0||ze>0==Qe>0){Je=!1;break}}Je&&Be.push({index:Ve,rule:4,description:"fourteen alternating"})}if(Ve>=2&&Fe(Ve-2,Ve,2,2)&&Be.push({index:Ve,rule:5,description:"two of three past two sigma"}),Ve>=4&&Fe(Ve-4,Ve,1,4)&&Be.push({index:Ve,rule:6,description:"four of five past one sigma"}),Ve>=14){let Je=!0;for(let $e=Ve-14;$e<=Ve;$e++)if(Math.abs(Ee($e))>=1){Je=!1;break}Je&&Be.push({index:Ve,rule:7,description:"fifteen within one sigma"})}if(Ve>=7){let Je=!0;for(let $e=Ve-7;$e<=Ve;$e++)if(Math.abs(Ee($e))<=1){Je=!1;break}Je&&Be.push({index:Ve,rule:8,description:"eight beyond one sigma"})}}return Be}const we=Object.freeze(["westernElectric","nelson"]);function He(le,be,ue="westernElectric"){return String(ue)==="nelson"?je(le,be):_e(le,be)}function Ke(le,be,ue){let ve=0;for(let Ce=0;Ce<le.length;Ce++)(le[Ce]<be||le[Ce]>ue)&&ve++;return ve}function Xe(le,be,ue,ve=20){const Ce=le.length;if(!Ce)return[];const Ee=le[0],Fe=le[Ce-1];if(Fe===Ee)return[{from:Ee,to:Fe,count:Ce}];const Be=ue-be,Ve=1.5*Be;let Je=Be>0?Math.max(Ee,be-Ve):Ee,$e=Be>0?Math.min(Fe,ue+Ve):Fe;$e>Je||(Je=Ee,$e=Fe);const ze=Be>0?2*Be/Math.cbrt(Ce):($e-Je)/(Math.ceil(Math.log2(Ce))+1),Qe=ze>0?Math.min(ve,Math.max(1,Math.ceil(($e-Je)/ze))):1,tt=($e-Je)/Qe,et=[];for(let dt=0;dt<Qe;dt++)et.push({from:Je+dt*tt,to:Je+(dt+1)*tt,count:0});for(let dt=0;dt<Ce;dt++){const ft=Math.min(Qe-1,Math.max(0,Math.floor((le[dt]-Je)/tt)));et[ft].count++}return et[0].from=Ee,et[Qe-1].to=Fe,et}const nt=.95;function it(le){const be=Number(le);return Number.isFinite(be)&&be>0&&be<1?be:nt}function wt(le,be=nt){const ue=le.length;if(ue<2)return null;let ve=0;for(let $e=0;$e<ue;$e++)ve+=le[$e];const Ce=ve/ue;let Ee=0;for(let $e=0;$e<ue;$e++){const ze=le[$e]-Ce;Ee+=ze*ze}const Fe=Math.sqrt(Ee/(ue-1)),Be=it(be),Je=D(1-(1-Be)/2,ue-1)*Fe/Math.sqrt(ue);return{mean:Ce,lower:Ce-Je,upper:Ce+Je,margin:Je,n:ue,confidence:Be}}function pt(le,be,ue=nt){const ve=Number(le),Ce=Number(be);if(!(Ce>0)||!(ve>=0)||ve>Ce)return null;const Ee=it(ue),Fe=K(1-(1-Ee)/2),Be=ve/Ce,Ve=Fe*Fe,Je=1+Ve/Ce,$e=(Be+Ve/(2*Ce))/Je,ze=Fe/Je*Math.sqrt(Be*(1-Be)/Ce+Ve/(4*Ce*Ce));return{proportion:Be,lower:Math.max(0,$e-ze),upper:Math.min(1,$e+ze),n:Ce,confidence:Ee}}function St(le,be=nt){if(!le||!(le.n>2)||!Number.isFinite(le.stdError))return null;const ue=it(be),Ce=D(1-(1-ue)/2,le.n-2)*le.stdError;return{slope:le.slope,lower:le.slope-Ce,upper:le.slope+Ce,margin:Ce,confidence:ue}}function Ct(le,be,ue=nt){const ve=Number(le),Ce=Number(be);if(!Number.isFinite(ve)||!(Ce>1))return null;const Ee=it(ue),Be=K(1-(1-Ee)/2)*Math.sqrt(1/(9*Ce)+ve*ve/(2*(Ce-1)));return{index:ve,lower:ve-Be,upper:ve+Be,margin:Be,n:Ce,confidence:Ee}}function Mt(le,be){return!le||!(le.sd>0)||!Number.isFinite(be)||!Number.isFinite(le.mean)?null:(be-le.mean)/le.sd}function at(le){return Number.isFinite(le)?Math.min(1,Math.max(0,2*x(Math.abs(le)/2)-1)):0}function ot(le,be){const ue=new Map,ve=X(le);let Ce=0;for(let Ee=0;Ee<be.length;Ee++){const Fe=ve(be[Ee]);if(Fe==null||Fe===""||typeof Fe=="number"&&Number.isNaN(Fe))continue;const Be=Fe instanceof Date?Fe.getTime():typeof Fe=="object"?String(Fe):Fe;ue.set(Be,(ue.get(Be)||0)+1),Ce++}return{map:ue,total:Ce}}function gt(le,be,ue,ve){if(!(be>0)||!(ve>0))return null;let Ce=0;const Ee=new Set(le.keys());for(const Fe of ue.keys())Ee.add(Fe);for(const Fe of Ee){const Be=(le.get(Fe)||0)/be,Ve=(ue.get(Fe)||0)/ve;Ce+=Math.abs(Be-Ve)}return Ce/2}const Et=10;function ut(le,be,ue){if(ue&&ue.numeric){const Be=c(le,be),{n:Ve,mean:Je}=p(Be),$e=Ve>0?Mt({mean:ue.mean,sd:ue.sd},Je):null;return{measure:"standardizedMeanDifference",magnitude:$e,distance:$e===null?0:at($e),direction:$e===null?0:Math.sign($e),subsetN:Ve,populationN:ue.n||0,reliable:Ve>=Et}}const{map:Ce,total:Ee}=ot(le,be),Fe=gt(Ce,Ee,ue.map,ue.total);return{measure:"categoricalTotalVariation",magnitude:Fe,distance:Fe===null?0:Fe,direction:0,subsetN:Ee,populationN:ue.total||0,reliable:Ee>=Et}}function de(le,be){if(le&&(le.kind==="float64"||le.kind==="int32"))return!0;const ue=X(le);let ve=0,Ce=0;for(let Ee=0;Ee<be.length&&ve<200;Ee++){const Fe=ue(be[Ee]);if(Fe==null||Fe==="")continue;if(Fe instanceof Date)return!1;ve++;const Be=typeof Fe=="number"?Fe:Number(Fe);Number.isFinite(Be)&&Ce++}return ve===0?!1:Ce/ve>=.9}function Pe(le,be){if(de(le,be)){const Ce=c(le,be),{n:Ee,mean:Fe,m2:Be}=p(Ce);return{numeric:!0,mean:Fe,sd:Ee>0?Math.sqrt(Be/Ee):0,n:Ee}}const{map:ue,total:ve}=ot(le,be);return{numeric:!1,map:ue,total:ve}}}),Ie("packages/core/src/compute/total.js",function(e,U){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return p}});const N=U("packages/core/src/internal/predicates.js").isFunction,B=U("packages/core/src/internal/warn.js").warnOnce,D=U("packages/core/src/compute/handle.js"),q=D.presenceReader,K=D.valueComparator,x=D.valueReader,G=U("packages/core/src/compute/statistics.js"),z=G.STAT_FNS,j=G.STAT_LABELS;function O(m){return!!m&&(m.kind==="float64"||m.kind==="int32")}function b(m,v){const y=v.length;let E=0;if(O(m)){const F=m.values,V=q(m);if(!V){for(let I=0;I<y;I++){const $=F[v[I]];Number.isNaN($)||(E+=$)}return E}for(let I=0;I<y;I++){const $=v[I];if(V($)===1){const S=F[$];Number.isNaN(S)||(E+=S)}}return E}const M=x(m);for(let F=0;F<y;F++){const V=c(M(v[F]));V!==null&&(E+=V)}return E}b.kernel=!0;function u(m,v){const y=v.length;let E=0;if(O(m)){const F=m.values,V=q(m);if(!V){for(let I=0;I<y;I++)Number.isNaN(F[v[I]])||E++;return E}for(let I=0;I<y;I++){const $=v[I];V($)===1&&!Number.isNaN(F[$])&&E++}return E}const M=x(m);for(let F=0;F<y;F++){const V=M(v[F]);V!=null&&!(typeof V=="number"&&Number.isNaN(V))&&E++}return E}u.kernel=!0;function f(m,v){return v.length}f.kernel=!0;function a(m,v){const y=u(m,v);return y===0?null:b(m,v)/y}a.kernel=!0;function r(m,v,y,E){const M=v.length;if(O(m)){const $=m.values,S=q(m);let R=null;if(!S){for(let L=0;L<M;L++){const T=$[v[L]];Number.isNaN(T)||(R===null||(y<0?T<R:T>R))&&(R=T)}return R}for(let L=0;L<M;L++){const T=v[L];if(S(T)===0)continue;const A=$[T];Number.isNaN(A)||(R===null||(y<0?A<R:A>R))&&(R=A)}return R}const F=x(m),V=K(E);let I=null;for(let $=0;$<M;$++){const S=F(v[$]);S==null||typeof S=="number"&&Number.isNaN(S)||(I===null||(y<0?V(S,I)<0:V(S,I)>0))&&(I=S)}return I}function t(m,v,y){return r(m,v,-1,y&&y.locale)}t.kernel=!0;function s(m,v,y){return r(m,v,1,y&&y.locale)}s.kernel=!0;function i(m,v){return v.length===0?null:x(m)(v[0])}i.kernel=!0;function n(m,v){return v.length===0?null:x(m)(v[v.length-1])}n.kernel=!0;function c(m){if(typeof m=="number")return Number.isNaN(m)?null:m;if(m==null||m===""||typeof m=="boolean")return null;if(m instanceof Date)return m.getTime();const v=Number(m);return Number.isNaN(v)?null:v}const o={sum:b,min:t,max:s,avg:a,count:f,first:i,last:n,countValues:u,...z},l=Object.freeze({...j,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function h(m){return m?typeof m=="string"?l[m]||m:"Total":""}const w=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function g(m){const v=m&&m.dataType&&m.dataType.totals&&m.dataType.totals.supported;if(Array.isArray(v))return v.slice();const y=w.filter(E=>E in o);for(const E of Object.keys(o))y.includes(E)||y.push(E);return y}function k(m,v){return typeof v!="string"?!0:g(m).includes(v)}function d(m,v){const y=x(m),E=[];for(let M=0;M<v.length;M++){const F=y(v[M]);F!=null&&E.push(F)}return E}function p(m,v,y,E){const M=v||[];if(typeof y=="string"){const F=o[y];return F?F(m,M,E):(B(`total:${y}`,`unknown total function "${y}"; register it in config.totalFns`),null)}return N(y)?y.kernel===!0?y(m,M,E):y(d(m,M),E||{}):null}}),Ie("packages/core/src/compute/windowed.js",function(e,U){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return q}});const N=U("packages/core/src/compute/sketch.js").Welford;class X{#e;#t;#n=[];#r;#i;constructor(x,G=0,z=Date.now){if(x!=="count"&&x!=="time"&&x!=="session")throw new RangeError(`unknown window kind: ${x}`);if((x==="count"||x==="time")&&!(G>0))throw new RangeError(`a ${x} window needs a positive span`);this.#e=x,this.#t=Math.floor(G),this.#r=z,this.#i=z()}get size(){return this.#n.length}push(x,G=this.#r()){Number.isFinite(x)&&(this.#n.push({t:G,v:x}),this.#s(G))}#s(x){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const G=x-this.#t;for(;this.#n.length&&this.#n[0].t<G;)this.#n.shift()}}spec(){const x=this.#e==="session"?this.#r()-this.#i:this.#t;return{kind:this.#e,span:x,size:this.#n.length}}values(){return this.#n.map(x=>x.v)}aggregate(){const x=this.spec();if(!this.#n.length)return{over:x,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const G=new N;let z=0,j=1/0,O=-1/0;for(const{v:b}of this.#n)z+=b,b<j&&(j=b),b>O&&(O=b),G.add(b);return{over:x,count:this.#n.length,sum:z,mean:G.mean(),min:j,max:O,variance:G.variance(),stddev:G.stddev()}}reduce(x){const G=this.aggregate(),z={sum:G.sum,avg:G.mean,mean:G.mean,min:G.min,max:G.max,count:G.count,variance:G.variance,stddev:G.stddev};if(!(x in z))throw new RangeError(`unknown windowed aggregate: ${x}`);return{value:z[x],over:G.over}}}const B=Object.freeze(["count","time","session"]);function D(K,x=Date.now){const G=K.kind==="time"&&K.minutes!=null?K.minutes*6e4:K.span??0;return new X(K.kind,G,x)}const q={Window:X,WINDOW_KINDS:B,openWindow:D}}),Ie("packages/core/src/compute/rolling.js",function(e,U){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const N=U("packages/core/src/compute/windowed.js").openWindow,B=U("packages/core/src/compute/sketch.js").KLL,D=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function q(o,l,h,w){if(o.kind==="count"){const g=Math.max(1,Math.floor(o.span||0));return{coverage:Math.min(1,l/g),partial:l<g}}if(o.kind==="time"){const g=o.minutes!=null?o.minutes*6e4:o.span||0;if(!(g>0))return{coverage:1,partial:!1};const k=h-w;return{coverage:Math.min(1,k/g),partial:k<g}}return{coverage:null,partial:!1}}function K(o,l){const h=N(l),w=new Map,g=o.length?o[0].at:0;for(let k=0;k<o.length;k++){const{key:d,at:p,value:m}=o[k];Number.isFinite(m)&&h.push(m,p);const v=h.aggregate(),y=q(l,v.count,p,g);d!=null&&w.set(String(d),{sum:v.sum,avg:v.mean,min:v.min,max:v.max,count:v.count,coverage:y.coverage,partial:y.partial})}return w}function x(o){const l=new Map;let h=0;for(const{key:w,value:g}of o)Number.isFinite(g)&&(h+=g),w!=null&&l.set(String(w),h);return l}function G(o,l=1){const h=new Map,w=Math.max(1,Math.floor(l));for(let g=0;g<o.length;g++){const{key:k,value:d}=o[g];if(k==null)continue;const p=g>=w?o[g-w].value:null,m=Number.isFinite(d)?d:null,v=Number.isFinite(p)?p:null;h.set(String(k),m!==null&&v!==null?m-v:null)}return h}const z=4096;function j(o){let l=o>>>0;return()=>{l+=1831565813;let h=l;return h=Math.imul(h^h>>>15,h|1),h^=h+Math.imul(h^h>>>7,h|61),((h^h>>>14)>>>0)/4294967296}}function O(o,l){const h=o.length;if(h===1)return o[0];const w=(h-1)*l,g=Math.floor(w),k=Math.ceil(w);return g===k?o[g]:o[g]+(w-g)*(o[k]-o[g])}function b(o,l,h={}){const w=Math.min(1,Math.max(0,h.q==null?.5:h.q)),g=Math.max(1,Math.floor(h.cap==null?z:h.cap)),k=j(h.seed==null?2654435769:h.seed),d=new Map,p=o.length?o[0].at:0;if(l.kind==="session"){const v=new B(200,k);let y=0;for(const{key:E,value:M}of o)Number.isFinite(M)&&(v.add(M),y++),E!=null&&d.set(String(E),{value:y?v.quantile(w):null,approx:y>0,count:y,coverage:null,partial:!1});return d}const m=N(l);for(const{key:v,at:y,value:E}of o){Number.isFinite(E)&&m.push(E,y);const M=m.values(),F=M.length;let V=null,I=!1;if(F)if(F<=g)V=O([...M].sort((S,R)=>S-R),w);else{const S=new B(200,k);for(const R of M)S.add(R);V=S.quantile(w),I=!0}const $=q(l,F,y,p);v!=null&&d.set(String(v),{value:V,approx:I,count:F,coverage:$.coverage,partial:$.partial})}return d}function u(o,l){const h=o.length,w=new Array(h).fill(null),g=Math.floor(l/2),k=l%2===0;for(let d=0;d<h;d++){if(d-g<0||d+g>=h)continue;let p=0,m=!0;if(k)for(let v=-g;v<=g;v++){const y=o[d+v];if(!Number.isFinite(y)){m=!1;break}p+=v===-g||v===g?y*.5:y}else for(let v=-g;v<=g;v++){const y=o[d+v];if(!Number.isFinite(y)){m=!1;break}p+=y}m&&(w[d]=p/l)}return w}function f(o,l){const h=new Map,w=Math.floor(Number(l&&l.period));if(!(w>=2))return h;const g=l&&l.model==="multiplicative",k=o.length,d=o.map(I=>Number.isFinite(I.value)?I.value:null),p=u(d,w),m=new Array(k).fill(null);for(let I=0;I<k;I++){const $=p[I],S=d[I];$===null||S===null||(g?$!==0&&(m[I]=S/$):m[I]=S-$)}const v=new Array(w).fill(0),y=new Array(w).fill(0);for(let I=0;I<k;I++){if(m[I]===null)continue;const $=I%w;v[$]+=m[I],y[$]+=1}const E=g?1:0,M=v.map((I,$)=>y[$]?I/y[$]:E),F=M.reduce((I,$)=>I+$,0)/w,V=g?M.map(I=>F!==0?I/F:1):M.map(I=>I-F);for(let I=0;I<k;I++){const{key:$}=o[I];if($==null)continue;const S=p[I],R=V[I%w],L=d[I];let T=null;S!==null&&L!==null&&(T=g?S*R!==0?L/(S*R):null:L-S-R),h.set(String($),{trend:S,seasonal:L===null?null:R,residual:T,coverage:S===null?0:1,partial:S===null})}return h}function a(o,l,h,w=80){const g=(Math.sqrt(5)-1)/2;let k=l,d=h,p=d-g*(d-k),m=k+g*(d-k),v=o(p),y=o(m);for(let E=0;E<w;E++)v<y?(d=m,m=p,y=v,p=d-g*(d-k),v=o(p)):(k=p,p=m,v=y,m=k+g*(d-k),y=o(m));return(k+d)/2}const r=1e-4,t=1-1e-4;function s(o,l){const h=o.length,w=new Array(h).fill(null),g=new Array(h).fill(null);let k=null,d=0;for(let p=0;p<h;p++){const m=o[p];if(!Number.isFinite(m)){k!==null&&(g[p]=k,w[p]=k);continue}if(k===null){k=m,g[p]=m,w[p]=m;continue}g[p]=k,d+=(m-k)**2,k=l*m+(1-l)*k,w[p]=k}return{smoothed:w,fitted:g,sse:d}}function i(o,l,h){const w=o.length,g=new Array(w).fill(null),k=new Array(w).fill(null);let d=null,p=null,m=0;for(let v=0;v<w;v++){const y=o[v];if(!Number.isFinite(y)){d!==null&&(d+=p,g[v]=d);continue}if(d===null){d=y,g[v]=y;continue}if(p===null){p=y-d;const F=d+p;k[v]=F,m+=(y-F)**2;const V=d;d=l*y+(1-l)*(V+p),p=h*(d-V)+(1-h)*p,g[v]=d;continue}const E=d+p;k[v]=E,m+=(y-E)**2;const M=d;d=l*y+(1-l)*(M+p),p=h*(d-M)+(1-h)*p,g[v]=d}return{smoothed:g,fitted:k,sse:m}}function n(o,l={}){const h=new Map,w=l.method==="holt",g=o.map(E=>Number.isFinite(E.value)?E.value:null),k=g.filter(E=>E!==null).length,d=E=>Math.min(t,Math.max(r,E)),p=()=>{for(const{key:E}of o)E!=null&&h.set(String(E),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return h};if(k<(w?2:1))return p();let m=Number.isFinite(l.alpha)?d(l.alpha):null,v=w&&Number.isFinite(l.beta)?d(l.beta):null;if(w){if(m===null||v===null){let E=m===null?.5:m,M=v===null?.5:v;for(let F=0;F<6;F++)m===null&&(E=a(V=>i(g,V,M).sse,r,t)),v===null&&(M=a(V=>i(g,E,V).sse,r,t));m=m===null?E:m,v=v===null?M:v}}else m===null&&(m=a(E=>s(g,E).sse,r,t));const y=w?i(g,m,v):s(g,m);for(let E=0;E<o.length;E++){const{key:M}=o[E];M!=null&&h.set(String(M),{smoothed:y.smoothed[E],fitted:y.fitted[E],alpha:m,beta:w?v:null,sse:y.sse})}return h}const c={ROLLING_WINDOW_FIELDS:D,QUANTILE_SPAN_CAP:z,rollingWindow:K,rollingQuantile:b,cumulativeToDate:x,periodOverPeriod:G,seasonalDecompose:f,exponentialSmoothing:n}}),Ie("packages/core/src/compute/compare.js",function(e,U){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return u}});const te=U("packages/core/src/compute/statistics.js"),N=te.numbers,X=te.moments,B=te.frequencyMap,D=te.categoricalDistance,q=te.normalTotalVariation,K=te.isNumericColumn,x=te.SUBSET_RELIABILITY_FLOOR,G=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function z(f,a){if(!f||!a||!(f.n>0)||!(a.n>0)||!Number.isFinite(f.mean)||!Number.isFinite(a.mean))return null;const r=(f.n*f.sd*f.sd+a.n*a.sd*a.sd)/(f.n+a.n);return r>0?(f.mean-a.mean)/Math.sqrt(r):null}function j(f,a){const r=N(f,a),{n:t,mean:s,m2:i}=X(r),n=t>0?Math.sqrt(i/t):0;return{mean:s,sd:n,n:t}}function O(f,a,r,t){return K(f,a)&&K(r,t)}function b(f,a,r,t){if(O(f,a,r,t)){const c=j(f,a),o=j(r,t),l=z(c,o);return{measure:G.numeric,magnitude:l,distance:l===null?0:q(l),direction:l===null?0:Math.sign(l),nA:c.n,nB:o.n,reliable:c.n>=x&&o.n>=x}}const s=B(f,a),i=B(r,t),n=D(s.map,s.total,i.map,i.total);return{measure:G.categorical,magnitude:n,distance:n===null?0:n,direction:0,nA:s.total,nB:i.total,reliable:s.total>=x&&i.total>=x}}function u(f,a,r={}){const t=new Set(f.columns),s=new Set(a.columns),i=f.columns.filter(h=>s.has(h)),n=Array.isArray(r.columns)&&r.columns.length?i.filter(h=>r.columns.includes(h)):i,c=f.indices(),o=a.indices(),l=[];for(const h of n){const w=f.handle(h),g=a.handle(h);if(!w||!g)continue;const k=b(w,c,g,o);l.push({column:h,name:f.name&&f.name(h)||a.name&&a.name(h)||h,measure:k.measure,magnitude:k.magnitude,distance:k.distance,direction:k.direction,nA:k.nA,nB:k.nB,reliable:k.reliable})}return l.sort((h,w)=>w.distance-h.distance||Math.abs(w.magnitude||0)-Math.abs(h.magnitude||0)),{ranked:l,nA:c.length,nB:o.length,unmatched:{onlyA:f.columns.filter(h=>!s.has(h)),onlyB:a.columns.filter(h=>!t.has(h))},measures:G}}}),Ie("packages/core/src/compute/anomaly.js",function(e,U){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return c}});const N=U("packages/core/src/compute/statistics.js").quantileSorted,B=U("packages/core/src/compute/special.js").logGamma,D=.6745,q=3.5,K=1.5,x=.975,G=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function z(o){if(!o.length)return null;const h=Array.from(o,Number).sort((d,p)=>d-p),w=N(h,.5),g=h.map(d=>Math.abs(d-w)).sort((d,p)=>d-p),k=N(g,.5);return{median:w,mad:k}}function j(o,l={}){const h=Number.isFinite(l.threshold)?l.threshold:q,w=o.length,g=new Array(w).fill(null),k=new Array(w).fill(!1),d=[];for(let v=0;v<w;v++){const y=Number(o[v]);Number.isFinite(y)&&d.push(y)}if(!d.length)return{median:null,mad:null,threshold:h,scores:g,flags:k,flagged:0};const p=z(d);if(p.mad===0)return{median:p.median,mad:0,threshold:h,scores:g,flags:k,flagged:0};let m=0;for(let v=0;v<w;v++){const y=Number(o[v]);if(!Number.isFinite(y))continue;const E=D*(y-p.median)/p.mad;g[v]=E,Math.abs(E)>h&&(k[v]=!0,m++)}return{median:p.median,mad:p.mad,threshold:h,scores:g,flags:k,flagged:m}}function O(o,l={}){const h=Number.isFinite(l.k)?l.k:K,w=[];for(let m=0;m<o.length;m++){const v=Number(o[m]);Number.isFinite(v)&&w.push(v)}if(!w.length)return null;const g=w.sort((m,v)=>m-v),k=N(g,.25),d=N(g,.75),p=d-k;return{q1:k,q3:d,iqr:p,lower:k-h*p,upper:d+h*p,k:h}}function b(o,l){if(l<=0)return 0;const h=B(o);if(l<o+1){let v=o,y=1/o,E=y;for(let M=0;M<1e3&&(v+=1,E*=l/v,y+=E,!(Math.abs(E)<Math.abs(y)*1e-15));M++);return y*Math.exp(-l+o*Math.log(l)-h)}const w=1e-300;let g=l+1-o,k=1/w,d=1/g,p=d;for(let v=1;v<1e3;v++){const y=-v*(v-o);g+=2,d=y*d+g,Math.abs(d)<w&&(d=w),k=g+y/k,Math.abs(k)<w&&(k=w),d=1/d;const E=d*k;if(p*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-l+o*Math.log(l)-h)*p}function u(o,l){return o<=0?0:b(l/2,o/2)}function f(o,l=x){if(!(l>0)||!(l<1))return NaN;let h=0,w=Math.max(1,o);for(;u(w,o)<l;)w*=2;for(let g=0;g<200;g++){const k=(h+w)/2;if(u(k,o)<l?h=k:w=k,w-h<1e-10)break}return(h+w)/2}function a(o){const l=o.length,h=o.map((w,g)=>{const k=w.slice();for(let d=0;d<l;d++)k.push(g===d?1:0);return k});for(let w=0;w<l;w++){let g=w;for(let d=w+1;d<l;d++)Math.abs(h[d][w])>Math.abs(h[g][w])&&(g=d);if(Math.abs(h[g][w])<1e-12)return null;if(g!==w){const d=h[g];h[g]=h[w],h[w]=d}const k=h[w][w];for(let d=0;d<2*l;d++)h[w][d]/=k;for(let d=0;d<l;d++){if(d===w)continue;const p=h[d][w];if(p!==0)for(let m=0;m<2*l;m++)h[d][m]-=p*h[w][m]}}return h.map(w=>w.slice(l))}function r(o,l){const h=o.length,w=new Array(l).fill(0);for(const d of o)for(let p=0;p<l;p++)w[p]+=d[p];for(let d=0;d<l;d++)w[d]/=h;const g=Array.from({length:l},()=>new Array(l).fill(0));for(const d of o)for(let p=0;p<l;p++){const m=d[p]-w[p];for(let v=p;v<l;v++)g[p][v]+=m*(d[v]-w[v])}const k=h>1?h-1:1;for(let d=0;d<l;d++)for(let p=d;p<l;p++)g[d][p]/=k,g[p][d]=g[d][p];return{mean:w,cov:g}}function t(o,l={}){const h=Number.isFinite(l.p)?l.p:x,w=Number.isFinite(l.ridge)?l.ridge:1e-6,g=o.length;if(!g)return null;const k=o[0].length;if(!k)return null;const d=new Array(g).fill(null),p=new Array(g).fill(null),m=new Array(g).fill(!1),v=[],y=[];for(let R=0;R<g;R++){const L=o[R];let T=L.length===k;const A=new Array(k);for(let C=0;T&&C<k;C++){const H=Number(L[C]);Number.isFinite(H)?A[C]=H:T=!1}T&&(v.push(R),y.push(A))}const E=k,M=f(E,h);if(y.length<=k)return{center:[],df:E,cutoff:M,singular:!0,used:y.length,distances:d,squared:p,flags:m,flagged:0};const{mean:F,cov:V}=r(y,k);let I=a(V),$=!1;if(!I){$=!0;let R=0;for(let A=0;A<k;A++)R+=V[A][A];const L=R/k*w||w,T=V.map((A,C)=>A.map((H,Y)=>C===Y?H+L:H));if(I=a(T),!I)return{center:F,df:E,cutoff:M,singular:!0,used:y.length,distances:d,squared:p,flags:m,flagged:0}}let S=0;for(let R=0;R<y.length;R++){const L=y[R],T=new Array(k);for(let H=0;H<k;H++)T[H]=L[H]-F[H];let A=0;for(let H=0;H<k;H++){let Y=0;for(let Z=0;Z<k;Z++)Y+=I[H][Z]*T[Z];A+=T[H]*Y}A<0&&(A=0);const C=v[R];p[C]=A,d[C]=Math.sqrt(A),A>M&&(m[C]=!0,S++)}return{center:F,df:E,cutoff:M,singular:$,used:y.length,distances:d,squared:p,flags:m,flagged:S}}const s=20,i=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function n(o,l={}){const h=l.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",w=Number.isFinite(l.windowLen)&&l.windowLen>=1?Math.floor(l.windowLen):s,g=Number.isFinite(l.threshold)?l.threshold:q,k=Number.isFinite(l.k)?l.k:K,d=Number.isFinite(l.minPeriods)&&l.minPeriods>=1?Math.floor(l.minPeriods):w,p=o.length,m=new Array(p).fill(null),v=new Array(p).fill(!1);let y=0;for(let E=0;E<p;E++){const M=Number(o[E]);if(!Number.isFinite(M))continue;const F=Math.max(0,E-w+1),V=[];for(let I=F;I<=E;I++){const $=Number(o[I]);Number.isFinite($)&&V.push($)}if(!(V.length<d))if(h==="rollingIqr"){const I=O(V,{k});if(!I)continue;(M<I.lower||M>I.upper)&&(v[E]=!0,y++)}else{const I=z(V);if(!I||I.mad===0)continue;const $=D*(M-I.median)/I.mad;m[E]=$,Math.abs($)>g&&(v[E]=!0,y++)}}return{method:h,windowLen:w,minPeriods:d,threshold:g,k,scores:m,flags:v,flagged:y}}function c(o={}){const l=o||{},h=l.field;if(typeof h!="string"||!h)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const w=l.method||"modifiedZScore";if(!(G.includes(w)||i.includes(w))||w==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${w}'`);const k=typeof l.orderBy=="string"?l.orderBy:null,d=l.latest===!0,p=i.includes(w),m=v=>Number(v==null?NaN:v[h]);return v=>{const y=Array.isArray(v)?v.slice():[...v];k&&y.sort((I,$)=>{const S=I?.[k],R=$?.[k];return S===R?0:S==null?-1:R==null?1:S<R?-1:1});const E=y.map(m);let M,F;if(p)({flags:M,scores:F}=n(E,{method:w,windowLen:l.windowLen,threshold:l.threshold,k:l.k,minPeriods:l.minPeriods}));else if(w==="iqr"){const I=O(E,{k:l.k});M=E.map($=>I?Number.isFinite($)&&($<I.lower||$>I.upper):!1),F=E.map(()=>null)}else({flags:M,scores:F}=j(E,{threshold:l.threshold}));if(d){const I=M.length-1;return I<0||!M[I]?!1:{method:w,field:h,flagged:[{row:y[I],score:F[I]}]}}const V=[];for(let I=0;I<M.length;I++)M[I]&&V.push({row:y[I],score:F[I]});return V.length?{method:w,field:h,flagged:V}:!1}}}),Ie("packages/core/src/compute/forecast.js",function(e,U){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const te=U("packages/core/src/compute/special.js"),N=te.normalQuantile,X=te.studentTQuantile,D=U("packages/core/src/internal/warn.js").warnOnce,q=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),K=1e-4,x=1-1e-4;function G(l){const h=[];for(let w=0;w<l.length;w++){const g=l[w];if(g!==null&&typeof g=="object"){const k=Number.isFinite(g.at)?g.at:w,d=Number.isFinite(g.value)?g.value:null;h.push({at:k,value:d})}else h.push({at:w,value:Number.isFinite(g)?Number(g):null})}return h}function z(l){const h=l.filter(p=>p.value!==null),w=h[0],g=h[h.length-1],k=g.at-w.at,d=h.length>1&&k>0?k/(h.length-1):1;return{lastAt:g.at,step:d}}function j(l){return Math.min(x,Math.max(K,l))}function O(l,h=K,w=x,g=80){const k=(Math.sqrt(5)-1)/2;let d=h,p=w,m=p-k*(p-d),v=d+k*(p-d),y=l(m),E=l(v);for(let M=0;M<g;M++)y<E?(p=v,v=m,E=y,m=p-k*(p-d),y=l(m)):(d=m,m=v,y=E,v=d+k*(p-d),E=l(v));return(d+p)/2}function b(l,h){let w=null,g=0,k=0;for(let d=0;d<l.length;d++){const p=l[d];if(p!==null){if(w===null){w=p;continue}g+=(p-w)**2,k+=1,w=h*p+(1-h)*w}}return{level:w,sse:g,m:k}}function u(l,h,w){let g=null,k=null,d=0,p=0;for(let m=0;m<l.length;m++){const v=l[m];if(v===null){g!==null&&k!==null&&(g+=k);continue}if(g===null){g=v;continue}k===null&&(k=v-g);const y=g+k;d+=(v-y)**2,p+=1;const E=g;g=h*v+(1-h)*(E+k),k=w*(g-E)+(1-w)*k}return{level:g,trend:k,sse:d,m:p}}function f(l,h,w,g,k){const d=l.length;if(d<2*h)return null;const p=$=>{let S=0,R=0;for(let L=$;L<$+h&&L<d;L++)l[L]!==null&&(S+=l[L],R+=1);return R?S/R:null},m=p(0),v=p(h);if(m===null||v===null)return null;let y=m,E=(v-m)/h;const M=new Array(h).fill(0);for(let $=0;$<h;$++)M[$]=l[$]===null?0:l[$]-y;const F=M.reduce(($,S)=>$+S,0)/h;for(let $=0;$<h;$++)M[$]-=F;let V=0,I=0;for(let $=h;$<d;$++){const S=$%h,R=M[S],L=l[$];if(L===null){y+=E;continue}const T=y+E+R;V+=(L-T)**2,I+=1;const A=y;y=w*(L-R)+(1-w)*(y+E),E=g*(y-A)+(1-g)*E,M[S]=k*(L-y)+(1-k)*R}return{level:y,trend:E,season:M,phase:(d-1)%h,sse:V,count:I}}function a(l,h,w){let g=1;for(const d of h)g+=d*d;const k=Math.sqrt(l*g);return{se:k,margin:w*k}}function r(l,h={}){if(!l||typeof l.length!="number"||l.length===0)return null;const w=q.includes(h.method)?h.method:"linear",g=Math.max(1,Math.floor(Number(h.horizon)||1)),k=Number.isFinite(h.confidence)&&h.confidence>0&&h.confidence<1?h.confidence:.95,d=1-(1-k)/2,p=G(l),m=p.map(V=>V.value),v=m.filter(V=>V!==null),y=v.length,{lastAt:E,step:M}=y?z(p):{lastAt:0,step:1},F=V=>E+V*M;return w==="linear"?t(p,y,g,k,d,F):w==="movingAverage"?s(v,y,g,k,d,h,F):w==="ses"?i(m,y,g,k,d,h,F):w==="holt"?n(m,y,g,k,d,h,F):c(m,y,g,k,d,h,F)}function t(l,h,w,g,k,d){if(h<2)return null;let p=0,m=0;for(const L of l)L.value!==null&&(p+=L.at,m+=L.value);p/=h,m/=h;let v=0,y=0,E=0;for(const L of l){if(L.value===null)continue;const T=L.at-p,A=L.value-m;v+=T*T,y+=T*A,E+=A*A}if(v===0)return null;const M=y/v,F=m-M*p,V=E===0?1:Math.max(0,Math.min(1,y*y/(v*E))),I=Math.max(0,E-M*y),$=h>2?Math.sqrt(I/(h-2)):null,S=h>2?X(k,h-2):null,R=[];for(let L=1;L<=w;L++){const T=d(L),A=F+M*T;let C=null,H=null,Y=null,Z=null,_=null;if($!==null){const J=1/h+(T-p)**2/v,ee=$*Math.sqrt(1+J),ne=$*Math.sqrt(J);_=ee,C=A-S*ee,H=A+S*ee,Y=A-S*ne,Z=A+S*ne}R.push({step:L,at:T,mean:A,lower:C,upper:H,lowerMean:Y,upperMean:Z,se:_})}return{method:"linear",horizon:w,confidence:g,n:h,sigma:$,r2:V,params:{slope:M,intercept:F},points:R}}function s(l,h,w,g,k,d,p){if(h<1)return null;const m=Math.max(1,Math.min(h,Math.floor(Number(d.windowLen)||h))),v=l.slice(h-m);let y=0;for(const $ of v)y+=$;const E=y/m;let M=null,F=null;if(m>1){let $=0;for(const R of v)$+=(R-E)**2;M=Math.sqrt($/(m-1))*Math.sqrt(1+1/m),F=X(k,m-1)}const V=M===null?null:F*M,I=[];for(let $=1;$<=w;$++)I.push({step:$,at:p($),mean:E,lower:V===null?null:E-V,upper:V===null?null:E+V,se:M});return{method:"movingAverage",horizon:w,confidence:g,n:h,sigma:M===null?null:M,params:{windowLen:m},points:I}}function i(l,h,w,g,k,d,p){if(h<1)return null;let m=Number.isFinite(d.alpha)?j(d.alpha):null;m===null&&(m=O(F=>b(l,F).sse));const v=b(l,m),y=N(k),E=v.m>0?v.sse/v.m:null,M=[];for(let F=1;F<=w;F++){const V=v.level;let I=null,$=null,S=null;if(E!==null){const R=[];for(let T=1;T<F;T++)R.push(m);const L=a(E,R,y);S=L.se,I=V-L.margin,$=V+L.margin}M.push({step:F,at:p(F),mean:V,lower:I,upper:$,se:S})}return{method:"ses",horizon:w,confidence:g,n:h,sigma:E===null?null:Math.sqrt(E),params:{alpha:m},points:M}}function n(l,h,w,g,k,d,p){if(h<2)return null;let m=Number.isFinite(d.alpha)?j(d.alpha):null,v=Number.isFinite(d.beta)?j(d.beta):null;if(m===null||v===null){let I=m===null?.5:m,$=v===null?.5:v;for(let S=0;S<6;S++)m===null&&(I=O(R=>u(l,R,$).sse)),v===null&&($=O(R=>u(l,I,R).sse));m=m===null?I:m,v=v===null?$:v}const y=u(l,m,v),E=N(k),M=y.m>0?y.sse/y.m:null,F=m*v,V=[];for(let I=1;I<=w;I++){const $=y.level+I*y.trend;let S=null,R=null,L=null;if(M!==null){const T=[];for(let C=1;C<I;C++)T.push(m+C*F);const A=a(M,T,E);L=A.se,S=$-A.margin,R=$+A.margin}V.push({step:I,at:p(I),mean:$,lower:S,upper:R,se:L})}return{method:"holt",horizon:w,confidence:g,n:h,sigma:M===null?null:Math.sqrt(M),params:{alpha:m,beta:v},points:V}}function c(l,h,w,g,k,d,p){const m=Math.floor(Number(d.period));if(!(m>=2))return D("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(h<2*m)return null;let v=Number.isFinite(d.alpha)?j(d.alpha):null,y=Number.isFinite(d.beta)?j(d.beta):null,E=Number.isFinite(d.gamma)?j(d.gamma):null;const M=(L,T,A)=>{const C=f(l,m,L,T,A);return C?C.sse:1/0};if(v===null||y===null||E===null){let L=v===null?.5:v,T=y===null?.5:y,A=E===null?.5:E;for(let C=0;C<8;C++)v===null&&(L=O(H=>M(H,T,A))),y===null&&(T=O(H=>M(L,H,A))),E===null&&(A=O(H=>M(L,T,H)));v=v===null?L:v,y=y===null?T:y,E=E===null?A:E}const F=f(l,m,v,y,E);if(!F)return null;const V=N(k),I=F.count>0?F.sse/F.count:null,$=v*y,S=E*(1-v),R=[];for(let L=1;L<=w;L++){const T=F.season[(F.phase+L)%m],A=F.level+L*F.trend+T;let C=null,H=null,Y=null;if(I!==null){const Z=[];for(let J=1;J<L;J++)Z.push(v+J*$+(J%m===0?S:0));const _=a(I,Z,V);Y=_.se,C=A-_.margin,H=A+_.margin}R.push({step:L,at:p(L),mean:A,lower:C,upper:H,se:Y})}return{method:"holtWinters",horizon:w,confidence:g,n:h,sigma:I===null?null:Math.sqrt(I),params:{alpha:v,beta:y,gamma:E,period:m},points:R}}const o={FORECAST_METHODS:q,forecast:r}}),Ie("packages/core/src/compute/hypothesis.js",function(e,U){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return V}});const N=U("packages/core/src/internal/warn.js").warnOnce,B=U("packages/core/src/compute/handle.js").valueReader,D=U("packages/core/src/compute/statistics.js"),q=D.numbers,K=D.moments,x=D.frequencyMap,G=D.categoricalDistance,z=D.isNumericColumn,j=D.jarqueBera,O=D.proportionInterval,b=D.SUBSET_RELIABILITY_FLOOR,f=U("packages/core/src/compute/compare.js").pooledStandardMeanDifference,a=U("packages/core/src/compute/special.js"),r=a.studentT,t=a.studentTQuantile,s=a.normalCdf,i=a.normalQuantile,n=a.chiSquareUpperTail,c=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),o=.05,l=2e6;function h(I){const $=Number(I);return Number.isFinite($)&&$>0&&$<1?$:.95}function w(I){const{n:$,mean:S,m2:R}=K(I);return{mean:S,sd:$>0?Math.sqrt(R/$):0,n:$}}function g(I,$){const S=I.length;if(S<2)return 0;let R=0;for(let L=0;L<S;L++){const T=I[L]-$;R+=T*T}return R/(S-1)}function k(I,$){return{name:"pooledStandardMeanDifference",value:f(w(I),w($))}}function d(I,$,S){const R=I.length,L=$.length;if(R<2||L<2)return null;const T=h(S),{mean:A}=K(I),{mean:C}=K($),H=g(I,A),Y=g($,C),Z=H/R+Y/L;if(!(Z>0))return null;const _=Math.sqrt(Z),J=(A-C)/_,ee=H/R*(H/R)/(R-1),ne=Y/L*(Y/L)/(L-1),se=Z*Z/(ee+ne),oe=Math.min(1,Math.max(0,2*(1-r(Math.abs(J),se)))),fe=A-C,pe=t(1-(1-T)/2,se)*_;return{test:c.WELCH,statistic:J,statisticName:"t",df:se,pValue:oe,interval:{estimate:fe,lower:fe-pe,upper:fe+pe,confidence:T,method:"welch-t (difference of means)"},effectSize:k(I,$),nA:R,nB:L,reliable:R>=b&&L>=b,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function p(I){const $=I.length;if($===0)return Number.NaN;const S=$>>1;return $%2?I[S]:(I[S-1]+I[S])/2}function m(I,$,S){const R=I.length,L=$.length,T=R*L;if(T===0||T>l)return null;const A=new Float64Array(T);let C=0;for(let ee=0;ee<R;ee++)for(let ne=0;ne<L;ne++)A[C++]=I[ee]-$[ne];A.sort();const H=p(A),Y=Math.sqrt(R*L*(R+L+1)/12),Z=i(1-(1-S)/2);let _=Math.round(T/2-Z*Y);_>=0||(_=0);const J=Math.floor((T-1)/2);return _>J&&(_=J),{estimate:H,lower:A[_],upper:A[T-1-_],confidence:S,method:"hodges-lehmann (normal approximation)"}}function v(I,$,S){const R=I.length,L=$.length;if(R<1||L<1)return null;const T=h(S),A=R+L,C=new Array(A);for(let oe=0;oe<R;oe++)C[oe]={v:I[oe],g:0};for(let oe=0;oe<L;oe++)C[R+oe]={v:$[oe],g:1};C.sort((oe,fe)=>oe.v-fe.v);let H=0,Y=0,Z=0;for(;Z<A;){let oe=Z;for(;oe<A&&C[oe].v===C[Z].v;)oe++;const fe=oe-Z,pe=(Z+1+oe)/2;for(let he=Z;he<oe;he++)C[he].g===0&&(H+=pe);Y+=fe*fe*fe-fe,Z=oe}const _=H-R*(R+1)/2,J=R*L/2,ee=R*L/12*(A+1-Y/(A*(A-1)));let ne=1;if(ee>0){const oe=Math.max(0,Math.abs(_-J)-.5);ne=Math.min(1,2*s(-oe/Math.sqrt(ee)))}const se=m(I,$,T);return{test:c.MANN_WHITNEY,statistic:_,statisticName:"U",df:null,pValue:ne,interval:se,effectSize:k(I,$),nA:R,nB:L,reliable:R>=b&&L>=b,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function y(I,$,S,R,L){const T=O(I,$,L),A=O(S,R,L);if(!T||!A)return null;const C=T.proportion-A.proportion,H=C-Math.sqrt((T.proportion-T.lower)**2+(A.upper-A.proportion)**2),Y=C+Math.sqrt((T.upper-T.proportion)**2+(A.proportion-A.lower)**2);return{lower:H,upper:Y}}function E(I,$,S,R,L,T={}){if(!($>0)||!(R>0))return null;const A=new Set([...I.keys(),...S.keys()]),C=A.size;if(C<2)return null;const H=$+R;let Y=0;for(const ne of A){const se=I.get(ne)||0,oe=S.get(ne)||0,fe=se+oe,pe=$*fe/H,he=R*fe/H;pe>0&&(Y+=(se-pe)*(se-pe)/pe),he>0&&(Y+=(oe-he)*(oe-he)/he)}const Z=C-1,_=n(Y,Z);let J=null;T.category!==void 0&&A.has(T.category)?J=T.category:C===2&&([J]=[...A]);let ee=null;if(J!==null){const ne=y(I.get(J)||0,$,S.get(J)||0,R,h(L));ne&&(ee={estimate:(I.get(J)||0)/$-(S.get(J)||0)/R,lower:ne.lower,upper:ne.upper,confidence:h(L),method:"newcombe (difference in this category's share)",category:J})}return{test:c.CHI_SQUARE,statistic:Y,statisticName:"chiSquare",df:Z,pValue:_,interval:ee,effectSize:{name:"categoricalTotalVariation",value:G(I,$,S,R)},nA:$,nB:R,reliable:$>=b&&R>=b,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function M(I){return I==null||I===""||typeof I=="number"&&Number.isNaN(I)?null:I instanceof Date?I.getTime():typeof I=="object"?String(I):I}function F(I,$,S){if(S===c.WELCH||S===c.MANN_WHITNEY)return{test:S,chosenBy:"override",reason:`caller override: ${S}`};const R=j(I),L=j($),T=R===null?null:Math.exp(-R/2),A=L===null?null:Math.exp(-L/2);return T!==null&&T<o||A!==null&&A<o?{test:c.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${o})`}:{test:c.WELCH,chosenBy:"auto",reason:T!==null||A!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function V(I,$,S,R={}){if(!I||!$)return null;const L=h(R.confidence),T=B($);let A;if(Array.isArray(R.groups)&&R.groups.length===2)A=[M(R.groups[0]),M(R.groups[1])];else{const{map:oe}=x($,S),fe=[...oe.entries()].sort((pe,he)=>he[1]-pe[1]).slice(0,2).map(pe=>pe[0]);if(fe.length<2)return N("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;A=fe}const[C,H]=A;if(C===null||H===null||C===H)return N("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const Y=[],Z=[];for(let oe=0;oe<S.length;oe++){const fe=M(T(S[oe]));fe===C?Y.push(S[oe]):fe===H&&Z.push(S[oe])}if(Y.length===0||Z.length===0)return N("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const _=R.test&&R.test!=="auto"?String(R.test):null,J=z(I,Y.concat(Z));let ee,ne,se;if(_===c.CHI_SQUARE||!_&&!J){ne=_?"override":"auto",se=_?"caller override: chiSquare":"column family: categorical";const oe=x(I,Y),fe=x(I,Z);ee=E(oe.map,oe.total,fe.map,fe.total,L,{category:R.category})}else{if((_===c.WELCH||_===c.MANN_WHITNEY)&&!J)return N("compareGroups:numeric-override",`[lattice] compareGroups: ${_} needs a numeric column, but the column is not numeric.`),null;const oe=q(I,Y),fe=q(I,Z),pe=F(oe,fe,_);ne=pe.chosenBy,se=pe.reason,ee=pe.test===c.MANN_WHITNEY?v(oe,fe,L):d(oe,fe,L)}return ee?{...ee,chosenBy:ne,reason:se,groups:[C,H]}:(N("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Ie("packages/core/src/columns/detailcolumn.js",function(e,U){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return B}});const te="__lattice_detail",N=36;function X(D){const q=D.config&&D.config.detailColumnWidth||N;return{id:te,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:q,min:q,max:q,pin:D.config&&D.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(K,x){return!!(x&&x.expanded)},formatValue(){return""}}}const B=X}),Ie("packages/core/src/columns/treecolumn.js",function(e,U){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return q}});const N=U("packages/core/src/internal/predicates.js").isFunction,X="__lattice_tree",B=260;function D(K){const x=K.tree||{},G=K.config&&K.config.treeColumnWidth||B,z=()=>(K.columns&&N(K.columns.visible)?K.columns.visible():[]).find(u=>!u.generated)||null,j=(b,u)=>{if(u&&u.group)return u.groupValue;if(N(x.label))return x.label(b,u);if(typeof x.label=="string")return b==null?null:b[x.label];const f=z();return f&&N(f.getValue)?f.getValue(b,u):null},O=()=>{if(x.title)return x.title;const b=typeof x.label=="string"?K.columns&&N(K.columns.get)?K.columns.get(x.label):null:z();return b&&(b.title||b.id)||"Hierarchy"};return{id:X,get title(){return O()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:G,min:140,pin:K.config&&K.config.treeColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(b,u){return j(b,u)},formatValue(b,u){if(u&&u.grandTotal)return K.config&&K.config.grandTotalLabel||"Total";if(b==null)return"";if(!x.label){const f=z();if(f&&N(f.formatValue))return f.formatValue(b,u)}return String(b)}}}const q=D}),Ie("packages/core/src/columns/pivotcolumns.js",function(e,U){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return D}});const N=U("packages/core/src/internal/warn.js").warnOnce,X="__lattice_pivot",B=500;function D(G){const{pivot:z,valueColumns:j,config:O}=G,b=z&&z.paths||[],u=G.separator||O&&O.pivot&&O.pivot.separator||" | ",f=O&&O.pivot&&O.pivot.maxColumns||B;if(!b.length||!j.length)return{tree:[],leaves:[],error:null};const a=q(O),r=b.length*j.length+(a?j.length:0);if(r>f){const i=`pivot would generate ${r} columns, above the limit of ${f}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return N(`pivot.maxColumns:${r}`,i),{tree:[],leaves:[],error:i}}const t=[],s=[];for(const i of b){const n=[];for(const c of j){const o=x(i,c,u);n.push(o),s.push(o)}n.length===1?(n[0].title=String(i),t.push(n[0])):t.push({id:`${X}:group:${i}`,title:String(i),columns:n,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(a){const i=j.map(c=>K(c,O));s.push(...i);const n=O&&O.pivot&&O.pivot.totalsLabel||"Total";if(i.length===1)i[0].title=n,a==="before"?t.unshift(i[0]):t.push(i[0]);else{const c={id:`${X}:group:__totals`,title:n,columns:i,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};a==="before"?t.unshift(c):t.push(c)}}return{tree:t,leaves:s,error:null}}function q(G){const z=G&&G.pivot&&G.pivot.groupTotals;return z==="before"||z==="after"?z:null}function K(G,z){return{id:`${X}:__total${z&&z.pivot&&z.pivot.separator||" | "}${G.id}`,field:null,title:G.title||G.id,type:G.type,dataType:G.dataType,nullable:!0,align:G.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:G.id,total:!0},value:{pure:!0},cell:{align:G.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:G.total,lookup:null,layout:{width:G.layout&&G.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(j,O){const b=O&&O.totals;return b&&Object.hasOwn(b,G.id)?b[G.id]:null},formatValue(j,O){return j==null?"":G.formatValue?G.formatValue(j,O):String(j)}}}function x(G,z,j){return{id:`${X}:${G}${j}${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:G,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(O,b){return O==null?"":z.formatValue?z.formatValue(O,b):String(O)}}}}),Ie("packages/core/src/compute/group.js",function(e,U){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return O}});const te=U("packages/core/src/compute/handle.js"),N=te.dictSize,X=te.identity,B=te.presenceReader,D=te.rowCount,q=te.valueReader,K="",x="\0",G=1<<20;function z(b,u,f,a){const r=b.length,t=b.map(l=>q(l)),s=Array.isArray(a)&&a.some(Boolean),i=s?t.map((l,h)=>a[h]?w=>a[h](l(w)):l):t;if(!s&&r>0&&b.every(l=>l&&l.kind==="dictionary"&&l.dict)){const l=b.map(w=>N(w.dict)+1);let h=1;for(let w=0;w<r;w++)h*=l[w];if(h<=Number.MAX_SAFE_INTEGER){const w=b.map(p=>p.values),g=b.map(p=>B(p)),k=p=>{let m=0;for(let v=0;v<r;v++){const y=g[v],E=y&&y(p)===0?l[v]-1:w[v][p];m=m*l[v]+E}return m},d=new Float64Array(f);for(let p=0;p<f;p++)d[p]=k(u[p]);return{packed:d,strings:null,product:h,readers:i,keyOf:k}}}const c=l=>{let h="";for(let w=0;w<r;w++){const g=i[w](l);h+=(w===0?"":K)+(g==null?x:String(g))}return h},o=new Array(f);for(let l=0;l<f;l++)o[l]=c(u[l]);return{packed:null,strings:o,product:1/0,readers:i,keyOf:c}}function j(b,u,f,a){const r=new Uint32Array(a+1);for(let n=0;n<f;n++)r[u[n]+1]++;for(let n=0;n<a;n++)r[n+1]+=r[n];const t=new Uint32Array(f),s=r.slice(0,a);for(let n=0;n<f;n++)t[s[u[n]]++]=b[n];const i=new Array(a);for(let n=0;n<a;n++)i[n]=t.subarray(r[n],r[n+1]);return i}function O(b,u,f={}){const a=b||[],r=u||X(D(a[0],f)),t=r.length;if(a.length===0||t===0)return{keys:[],buckets:[]};const{packed:s,strings:i,product:n,readers:c}=z(a,r,t,f.project),o=new Uint32Array(t);let l=0,h=null;if(s&&n<=Math.max(1024,Math.min(G,t*4))){const d=n,p=new Int32Array(d).fill(-1);for(let m=0;m<t;m++)p[s[m]]=0;for(let m=0;m<d;m++)p[m]===0&&(p[m]=l++);for(let m=0;m<t;m++)o[m]=p[s[m]];h=new Float64Array(l);for(let m=0;m<d;m++)p[m]>=0&&(h[p[m]]=m)}else if(s){const d=new Map;for(let p=0;p<t;p++){const m=s[p];let v=d.get(m);v===void 0&&(v=l++,d.set(m,v)),o[p]=v}h=new Float64Array(l);for(const[p,m]of d)h[m]=p}else{const d=new Map;for(let p=0;p<t;p++){const m=i[p];let v=d.get(m);v===void 0&&(v=l++,d.set(m,v)),o[p]=v}}const w=j(r,o,t,l),g=new Array(l);for(let d=0;d<l;d++){const p=w[d][0],m=new Array(c.length);for(let v=0;v<c.length;v++)m[v]=c[v](p);g[d]=m}const k={keys:g,buckets:w};return h&&(k.packed=h),k}}),Ie("packages/core/src/compute/pivot.js",function(e,U){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return t}});const N=U("packages/core/src/internal/warn.js").warnOnce,B=U("packages/core/src/compute/handle.js").valueComparator,q=U("packages/core/src/compute/group.js").packKeys,x=U("packages/core/src/compute/total.js").total,G="|",z="/",j=2e3;function O(n,c,o){return`${n}${G}${c}${G}${o}`}function b(n,c){let o="";for(let l=0;l<n.length;l++){const h=n[l];o+=(l===0?"":c)+(h==null?"":String(h))}return o}function u(n,c,o={}){const l=o.separator||z,h=c.length,{keyOf:w,readers:g}=q(n,c,0),k=new Map,d=[],p=[];for(let V=0;V<h;V++){const I=c[V],$=w(I);if(k.has($))continue;k.set($,d.length),p.push($);const S=new Array(g.length);for(let R=0;R<g.length;R++)S[R]=g[R](I);d.push(S)}const m=B(o.locale),v=d.map((V,I)=>I);v.sort((V,I)=>{const $=d[V],S=d[I];for(let R=0;R<$.length;R++){const L=f($[R],S[R],m);if(L!==0)return L}return V-I});const y=new Array(v.length),E=new Array(v.length),M=new Map;for(let V=0;V<v.length;V++){const I=v[V];y[V]=d[I],E[V]=b(d[I],l),M.set(p[I],V)}return{keys:y,paths:E,idOf:V=>{const I=M.get(w(V));return I===void 0?-1:I}}}function f(n,c,o){const l=n==null,h=c==null;return l||h?l&&h?0:l?1:-1:o(n,c)}function a(n){const c=n.values||n.totals||[];if(c.length&&typeof c[0]=="object"&&c[0]!==null)return c.filter(w=>w&&w.handle);const o=typeof n.handle=="function"?n.handle:null;if(!o)return c.length&&N("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 l=typeof n.totalOf=="function"?n.totalOf:null,h=[];for(const w of c){const g=o(w);g&&h.push({colId:w,handle:g,fn:l?l(w):"sum"})}return h}function r(n,c,o){if(Array.isArray(n)){const l=o||{};return{...l,pivotHandles:n,order:c||null,groups:l.groups||null}}return n||{}}function t(n,c,o){const l=r(n,c,o),h=l.separator||z,w=a(l),g=l.maxColumns===void 0?j:l.maxColumns,k=l.groups&&l.groups.buckets?l.groups:null,d=k?k.buckets:[l.order||new Uint32Array(0)],p=l.groupPaths||(k?k.keys.map($=>b($,h)):[""]),m=i(d),{keys:v,paths:y,idOf:E}=u(l.pivotHandles||[],m,l),M=y.length*Math.max(1,w.length),F=s(y,w,h);if(g&&M>g){const $=new Map;return{keys:v,paths:y,fields:F,groupPaths:p,columns:M,values:$,cells:$,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${M} columns, above pivot.maxColumns of ${g}. Narrow the pivot columns or raise the limit.`,columns:M,maxColumns:g}}}const V=new Map,I=y.length;for(let $=0;$<d.length;$++){const S=d[$],R=p[$]===void 0?"":p[$],L=S.length;if(L===0)continue;const T=new Int32Array(L),A=new Uint32Array(I+1);for(let Y=0;Y<L;Y++){const Z=E(S[Y]);T[Y]=Z,Z>=0&&A[Z+1]++}for(let Y=0;Y<I;Y++)A[Y+1]+=A[Y];const C=new Uint32Array(L),H=A.slice(0,I);for(let Y=0;Y<L;Y++){const Z=T[Y];Z>=0&&(C[H[Z]++]=S[Y])}for(let Y=0;Y<I;Y++){const Z=A[Y],_=A[Y+1];if(_===Z)continue;const J=C.subarray(Z,_);for(let ee=0;ee<w.length;ee++){const ne=w[ee],se=x(ne.handle,J,ne.fn,l.totalContext||{locale:l.locale});V.set(O(R,y[Y],ne.colId),se)}}}return{keys:v,paths:y,fields:F,groupPaths:p,columns:M,values:V,cells:V,error:null}}function s(n,c,o){if(c.length===0)return n.slice();const l=[];for(const h of n)for(const w of c)l.push(`${h}${o}${w.colId}`);return l}function i(n){if(n.length===1)return n[0]||new Uint32Array(0);let c=0;for(const h of n)c+=h?h.length:0;const o=new Uint32Array(c);let l=0;for(const h of n)!h||h.length===0||(o.set(h,l),l+=h.length);return o}}),Ie("packages/core/src/store/bitset.js",function(e,U){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return N}});const te=8;class N{static#e=new Uint8Array(256);static{for(let B=1;B<256;B++)N.#e[B]=N.#e[B>>1]+(B&1)}#t;#n;constructor(B=0){const D=Math.max(0,B|0);this.#n=D,this.#t=new Uint8Array(Math.ceil(D/te))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(B){return B<0||B>=this.#n?0:this.#t[B>>3]>>(B&7)&1}set(B){return B>=0&&B<this.#n&&(this.#t[B>>3]|=1<<(B&7)),this}clear(B){return B>=0&&B<this.#n&&(this.#t[B>>3]&=~(1<<(B&7))),this}assign(B,D){return D?this.set(B):this.clear(B)}fill(B=!1){return this.#t.fill(B?255:0),B&&this.#r(),this}grow(B){const D=Math.max(0,B|0);if(D<=this.#n)return this;const q=Math.ceil(D/te);if(q>this.#t.length){const K=new Uint8Array(q);K.set(this.#t),this.#t=K}return this.#n=D,this}count(){const B=this.#t,D=N.#e;let q=0;for(let K=0;K<B.length;K++)q+=D[B[K]];return q}and(B){const D=B instanceof N?B.words:B,q=this.#t,K=Math.min(q.length,D.length);for(let x=0;x<K;x++)q[x]&=D[x];for(let x=K;x<q.length;x++)q[x]=0;return this}or(B){const D=B instanceof N?B.words:B,q=this.#t,K=Math.min(q.length,D.length);for(let x=0;x<K;x++)q[x]|=D[x];return this}not(){const B=this.#t;for(let D=0;D<B.length;D++)B[D]=~B[D]&255;return this.#r(),this}clone(){const B=new N(this.#n);return B.words.set(this.#t.subarray(0,B.words.length)),B}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const B=this.#n&7;if(B===0)return;const D=this.#n>>3;D<this.#t.length&&(this.#t[D]&=(1<<B)-1)}static from(B){const D=Array.isArray(B)?B:Array.from(B),q=new N(D.length);for(let K=0;K<D.length;K++)D[K]&&q.set(K);return q}}}),Ie("packages/core/src/store/dictionary.js",function(e,U){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return B}});const te=U("packages/core/src/internal/compare.js"),N=te.collator,X=te.defaultCompare;class B{#e;#t=new Map;#n=0;#r=null;#i=-1;#s="\0";constructor(q=[]){this.#e=[];for(let K=0;K<q.length;K++){const x=q[K];this.#t.has(x)||(this.#t.set(x,this.#e.length),this.#e.push(x))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let q=this.#e.length*8;for(let K=0;K<this.#e.length;K++){const x=this.#e[K];typeof x=="string"&&(q+=x.length*2),q+=16}return q}codeOf(q){const K=this.#t.get(q);if(K!==void 0)return K;const x=this.#e.length;return this.#e.push(q),this.#t.set(q,x),this.#n++,x}lookup(q){const K=this.#t.get(q);return K===void 0?-1:K}has(q){return this.#t.has(q)}valueOf(q){return this.#e[q]}values(){return this.#e}ranks(q){const K=q||"";if(this.#r&&this.#i===this.#n&&this.#s===K)return this.#r;const x=this.#e.length,G=new Array(x);for(let b=0;b<x;b++)G[b]=b;const z=N(q).compare,j=this.#e;G.sort((b,u)=>this.#o(j[b],j[u],z));const O=new Uint32Array(x);for(let b=0;b<x;b++)O[G[b]]=b;return this.#r=O,this.#i=this.#n,this.#s=K,O}#o(q,K,x){return typeof q=="string"&&typeof K=="string"?x(q,K):X(q,K)}}}),Ie("packages/core/src/store/multivalue.js",function(e,U){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return te}});class te{#e;#t;#n=0;#r=0;constructor(X={}){const B=Math.max(1,X.rows??16),D=Math.max(1,X.values??B);this.#e=new Int32Array(D),this.#t=new Uint32Array(B+1)}get values(){return this.#e}get offsets(){return this.#t}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#e.byteLength+this.#t.byteLength}count(X){return X<0||X>=this.#n?0:this.#t[X+1]-this.#t[X]}at(X){return X<0||X>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[X],this.#t[X+1])}has(X,B){if(X<0||X>=this.#n)return!1;const D=this.#e,q=this.#t[X+1];for(let K=this.#t[X];K<q;K++)if(D[K]===B)return!0;return!1}hasAny(X,B){for(let D=0;D<B.length;D++)if(this.has(X,B[D]))return!0;return!1}hasAll(X,B){for(let D=0;D<B.length;D++)if(!this.has(X,B[D]))return!1;return!0}hasNone(X,B){return!this.hasAny(X,B)}push(X){const B=this.#n,D=X.length;this.#i(B+1),this.#s(this.#r+D);const q=this.#r;for(let K=0;K<D;K++)this.#e[q+K]=X[K]|0;return this.#r+=D,this.#n=B+1,this.#t[B]=q,this.#t[B+1]=this.#r,B}write(X,B){if(X===this.#n){this.push(B);return}if(X<0||X>this.#n)return;const D=this.#t[X],q=this.#t[X+1],K=B.length;if(q-D===K){for(let x=0;x<K;x++)this.#e[D+x]=B[x]|0;return}this.#o(X,B)}compact(X,B,D){const q=this.#e,K=this.#t,x=this.#n,G=new Int32Array(Math.max(1,this.#r)),z=new Uint32Array(B+1);let j=0;for(let O=0;O<x;O++){if(X[O]===D)continue;const b=K[O],u=K[O+1];z[X[O]]=j;for(let f=b;f<u;f++)G[j++]=q[f];z[X[O]+1]=j}this.#e=G,this.#t=z,this.#n=B,this.#r=j}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#i(X){if(X+1<=this.#t.length)return;let B=this.#t.length-1;for(;B<X;)B=B*2||16;const D=new Uint32Array(B+1);D.set(this.#t),this.#t=D}#s(X){if(X<=this.#e.length)return;let B=this.#e.length;for(;B<X;)B=B*2||16;const D=new Int32Array(B);D.set(this.#e),this.#e=D}#o(X,B){const D=this.#e,q=this.#t,K=this.#n,x=B.length-(q[X+1]-q[X]),G=new Int32Array(Math.max(1,this.#r+x)),z=new Uint32Array(q.length);let j=0;for(let O=0;O<K;O++){if(z[O]=j,O===X)for(let b=0;b<B.length;b++)G[j++]=B[b]|0;else for(let b=q[O];b<q[O+1];b++)G[j++]=D[b];z[O+1]=j}this.#e=G,this.#t=z,this.#r=j}}}),Ie("packages/core/src/compute/sort.js",function(e,U){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return I}});const te=U("packages/core/src/compute/handle.js"),N=te.bitReader,X=te.dictRanks,B=te.dictSize,D=te.identity,q=te.isMissing,K=te.presenceReader,x=te.rowCount,G=te.valueComparator,z=te.valueReader,j=new Uint32Array(0),O=new ArrayBuffer(8),b=new Float64Array(O),u=new Uint32Array(O),f=(b[0]=-1,(u[1]&2147483648)!==0?1:0),a=f===1?0:1;function r(S,R){b[0]=S;let L=u[f],T=u[a];(L&2147483648)!==0?(L=~L>>>0,T=~T>>>0):L=(L^2147483648)>>>0,R[0]=T,R[1]=L}function t(S,R,L,T){if(T<2)return S;const A=new Uint32Array(256*8);for(let ne=0;ne<T;ne++){const se=R[ne],oe=L[ne];A[se&255]++,A[256+(se>>>8&255)]++,A[512+(se>>>16&255)]++,A[768+(se>>>24&255)]++,A[1024+(oe&255)]++,A[1280+(oe>>>8&255)]++,A[1536+(oe>>>16&255)]++,A[1792+(oe>>>24&255)]++}let C=S,H=R,Y=L,Z=new Uint32Array(T),_=new Uint32Array(T),J=new Uint32Array(T);const ee=new Uint32Array(256);for(let ne=0;ne<8;ne++){const se=ne<<8,oe=(ne&3)<<3,fe=ne>=4;let pe=!1;for(let Ue=0;Ue<256;Ue++)if(A[se+Ue]===T){pe=!0;break}if(pe)continue;let he=0;for(let Ue=0;Ue<256;Ue++)ee[Ue]=he,he+=A[se+Ue];for(let Ue=0;Ue<T;Ue++){const Le=H[Ue],ie=Y[Ue],ge=(fe?ie:Le)>>>oe&255,ke=ee[ge]++;Z[ke]=C[Ue],_[ke]=Le,J[ke]=ie}let Re=C;C=Z,Z=Re,Re=H,H=_,_=Re,Re=Y,Y=J,J=Re}return C}function s(S,R,L){if(L<2)return S;const T=new Uint32Array(256*4);for(let _=0;_<L;_++){const J=R[_];T[J&255]++,T[256+(J>>>8&255)]++,T[512+(J>>>16&255)]++,T[768+(J>>>24&255)]++}let A=S,C=R,H=new Uint32Array(L),Y=new Uint32Array(L);const Z=new Uint32Array(256);for(let _=0;_<4;_++){const J=_<<8,ee=_<<3;let ne=!1;for(let fe=0;fe<256;fe++)if(T[J+fe]===L){ne=!0;break}if(ne)continue;let se=0;for(let fe=0;fe<256;fe++)Z[fe]=se,se+=T[J+fe];for(let fe=0;fe<L;fe++){const pe=C[fe],he=Z[pe>>>ee&255]++;H[he]=A[fe],Y[he]=pe}let oe=A;A=H,H=oe,oe=C,C=Y,Y=oe}return A}function i(S,R,L,T){const A=new Uint32Array(T+1);for(let Y=0;Y<L;Y++)A[R[Y]]++;let C=0;for(let Y=0;Y<=T;Y++){const Z=A[Y];A[Y]=C,C+=Z}const H=new Uint32Array(L);for(let Y=0;Y<L;Y++)H[A[R[Y]]++]=S[Y];return H}function n(S,R,L,T){return L<2?S:T<=65536||T<=L*2?i(S,R,L,T):s(S,R,L)}function c(S,R){return S.length===R&&S.byteOffset===0?S:Uint32Array.prototype.slice.call(S,0,R)}function o(S,R,L=!1){const T=R||D(S.length),A=T.length;if(A<2)return Uint32Array.from(T);const C=new Uint32Array(A),H=new Uint32Array(A),Y=new Uint32Array(A),Z=new Uint32Array(A),_=new Uint32Array(2);let J=0,ee=0;for(let oe=0;oe<A;oe++){const fe=T[oe],pe=S[fe];if(Number.isNaN(pe)){Z[ee++]=fe;continue}r(pe,_),L?(H[J]=~_[0]>>>0,Y[J]=~_[1]>>>0):(H[J]=_[0],Y[J]=_[1]),C[J++]=fe}const ne=t(C.subarray(0,J),H.subarray(0,J),Y.subarray(0,J),J);if(ee===0)return c(ne,J);const se=new Uint32Array(A);return se.set(ne.subarray(0,J),0),se.set(Z.subarray(0,ee),J),se}function l(S,R,L=!1){const T=R||D(S.length),A=T.length;if(A<2)return Uint32Array.from(T);const C=Uint32Array.from(T),H=new Uint32Array(A);for(let Y=0;Y<A;Y++){const Z=(S[C[Y]]^2147483648)>>>0;H[Y]=L?~Z>>>0:Z}return c(s(C,H,A),A)}function h(S,R,L={}){const T=R||D(x(S,L)),A=T.length;if(A<2)return Uint32Array.from(T);const C=X(S.dict,L.locale),H=S.values,Y=K(S),Z=Math.max(B(S.dict),C.length),_=Z,J=Uint32Array.from(T),ee=new Uint32Array(A),ne=!!L.descending;for(let se=0;se<A;se++){const oe=J[se];let fe=Y&&Y(oe)===0?_:C[H[oe]];fe===void 0&&(fe=_),ee[se]=ne?_-fe:fe}return c(n(J,ee,A,Z+1),A)}function w(S,R,L){const T=R.length;let A=Uint32Array.from(R);if(T<2)return A;let C=new Uint32Array(T);for(let H=1;H<T;H<<=1){for(let Z=0;Z<T;Z+=H<<1){const _=Math.min(Z+H,T),J=Math.min(Z+(H<<1),T);let ee=Z,ne=_,se=Z;for(;ee<_&&ne<J;)C[se++]=L(S[A[ee]],S[A[ne]])<=0?A[ee++]:A[ne++];for(;ee<_;)C[se++]=A[ee++];for(;ne<J;)C[se++]=A[ne++]}const Y=A;A=C,C=Y}return A}function g(S,R,L){const T=N(S.values),A=R.length,C=new Uint32Array(A),H=L?1:0;let Y=0;for(let Z=0;Z<A;Z++)T(R[Z])===H&&(C[Y++]=R[Z]);for(let Z=0;Z<A;Z++)T(R[Z])!==H&&(C[Y++]=R[Z]);return C}function k(S,R){const L=S.values,T=S.kind;if((T==="object"||T===void 0)&&(Array.isArray(L)||ArrayBuffer.isView(L))&&!S.presence)return L;const C=z(S),H=new Array(x(S)||0);for(let Y=0;Y<R.length;Y++){const Z=R[Y];H[Z]=C(Z)}return H}function d(S,R){for(let L=0;L<R.length;L++)if(typeof S[R[L]]!="string")return!1;return!0}function p(S,R,L,T,A){const C=S.length,H=Uint32Array.from(S);if(C<2||T<1)return H;const Y=new Uint32Array(C),Z=T-1;for(let _=0;_<C;_++){const J=L[R[_]];Y[_]=A?Z-J:J}return c(n(H,Y,C,T),C)}function m(S,R,L){const T=G(L),A=new Array(R);for(let H=0;H<R;H++)A[H]=H;A.sort((H,Y)=>T(S[H],S[Y])||H-Y);const C=new Uint32Array(R);for(let H=0;H<R;H++)C[A[H]]=H;return C}function v(S,R,L){const T=R.length,A=new Map,C=[],H=new Uint32Array(T);for(let _=0;_<T;_++){const J=S[R[_]];let ee=A.get(J);ee===void 0&&(ee=C.length,A.set(J,ee),C.push(J)),H[_]=ee}const Y=C.length,Z=m(C,Y,L.locale);return p(R,H,Z,Y,!!L.descending)}function y(S,R,L){const T=k(S,R);if(R.length>=2&&d(T,R)){const H=S.stringRank;return H&&H.version===S.version&&H.usable(R,T,L.locale)?H.sort(R,L):v(T,R,L)}const A=G(L.locale),C=L.descending?(H,Y)=>A(Y,H):A;return w(T,R,C)}function E(S,R,L){const T=k(S,R),A=L.compare,H=!!L.descending?(Y,Z)=>-A(Y,Z,void 0,void 0,!0):(Y,Z)=>A(Y,Z,void 0,void 0,!1);return w(T,R,H)}function M(S,R){const L=R.length,T=K(S),A=S.values,C=S.kind==="float64"&&!!A,H=S.kind==="object"||S.kind==="multi"||S.kind===void 0;if(!T&&!C&&!H)return{present:R,absent:j};const Y=new Uint32Array(L),Z=new Uint32Array(L);let _=0,J=0;if(T&&C)for(let ee=0;ee<L;ee++){const ne=R[ee];T(ne)===1&&!Number.isNaN(A[ne])?Y[_++]=ne:Z[J++]=ne}else if(C&&!T)for(let ee=0;ee<L;ee++){const ne=R[ee];Number.isNaN(A[ne])?Z[J++]=ne:Y[_++]=ne}else if(T&&!H)for(let ee=0;ee<L;ee++){const ne=R[ee];T(ne)===1?Y[_++]=ne:Z[J++]=ne}else{const ee=z(S);for(let ne=0;ne<L;ne++){const se=R[ne];q(ee(se))?Z[J++]=se:Y[_++]=se}}return J===0?{present:R,absent:j}:{present:Y.subarray(0,_),absent:Z.subarray(0,J)}}function F(S,R,L){if(R.length===0)return S;const T=new Uint32Array(S.length+R.length);return L?(T.set(R,0),T.set(S,R.length)):(T.set(S,0),T.set(R,S.length)),T}function V(S,R,L={}){const T=R||D(x(S,L));if(!S||T.length<2)return Uint32Array.from(T);const{present:A,absent:C}=M(S,T);if(A.length===0)return Uint32Array.from(T);const H=!!L.descending;let Y;if(typeof L.compare=="function")Y=E(S,A,L);else switch(S.kind){case"float64":Y=o(S.values,A,H);break;case"int32":Y=l(S.values,A,H);break;case"dictionary":Y=h(S,A,L);break;case"bitset":Y=g(S,A,H);break;default:Y=y(S,A,L);break}return F(Y,C,!!L.nullsFirst)}function I(S,R,L,T={}){const A=R||[],C=A.length&&(A[0].handle||$(S,A[0].col))||S&&S[0];let H=L||D(x(C,T));for(let Y=A.length-1;Y>=0;Y--){const Z=A[Y],_=Z.handle||$(S,Z.col)||S&&S[Y];_&&(H=V(_,H,{descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,locale:Z.locale!==void 0?Z.locale:T.locale,compare:Z.compare}))}return H instanceof Uint32Array?H:Uint32Array.from(H)}function $(S,R){if(!(!S||R===void 0)){for(let L=0;L<S.length;L++)if(S[L]&&S[L].id===R)return S[L]}}}),Ie("packages/core/src/store/stringrank.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return D}});const te=U("packages/core/src/compute/sort.js"),N=te.collateStringRanks,X=te.rankSortStrings,B=1e5;class D{#e=[];#t=new Map;#n;#r=0;#i=0;#s=-1;#o;#l=!1;#a=null;#c=-1;#u="\0";constructor(K=B){this.#o=K>0?K:B,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(K){this.#s=K}get generation(){return this.#i}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let K=this.#n.byteLength;const x=this.#e;for(let G=0;G<x.length;G++)K+=x[G].length*2+24;return K}#f(K,x){const G=this.#t.get(K);if(G!==void 0)return G;if(this.#l)return-1;if(x&&this.#e.length>=this.#o)return this.#l=!0,-1;const z=this.#e.length;return this.#e.push(K),this.#t.set(K,z),this.#i++,z}build(K,x){const G=x|0;this.#e=[],this.#t=new Map,this.#i=0,this.#l=!1,this.#a=null,this.#c=-1,this.#n=new Uint32Array(G);for(let z=0;z<G;z++){const j=K[z],O=typeof j=="string"?this.#f(j,!1):-1;this.#n[z]=O<0?0:O}this.#r=G}append(K,x,G){const z=(x|0)+(G|0);if(z>this.#n.length){const j=new Uint32Array(z);j.set(this.#n.subarray(0,this.#r)),this.#n=j}for(let j=x|0;j<z;j++){const O=K[j],b=typeof O=="string"?this.#f(O,!0):-1;this.#n[j]=b<0?0:b}this.#r=Math.max(this.#r,z)}ranks(K){const x=K||"";if(this.#a&&this.#c===this.#i&&this.#u===x)return this.#a;const G=N(this.#e,this.#e.length,K);return this.#a=G,this.#c=this.#i,this.#u=x,G}usable(K,x,G){if(this.#l||this.#e.length===0)return!1;const z=this.#n,j=this.#e,O=this.#r;for(let b=0;b<K.length;b++){const u=K[b];if(u>=O||j[z[u]]!==x[u])return!1}return!0}sort(K,x){const G=this.ranks(x.locale),z=this.#e.length,j=K.length,O=new Uint32Array(j),b=this.#n;for(let u=0;u<j;u++)O[u]=b[K[u]];return X(K,O,G,z,!!x.descending)}}}),Ie("packages/core/src/store/columnstore.js",function(e,U){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return g}});const N=U("packages/core/src/internal/warn.js").warnOnce,B=U("packages/core/src/internal/predicates.js").isFunction,q=U("packages/core/src/internal/paths.js").pathGetter,x=U("packages/core/src/store/bitset.js").Bitset,z=U("packages/core/src/store/dictionary.js").Dictionary,O=U("packages/core/src/store/multivalue.js").MultiValue,u=U("packages/core/src/store/stringrank.js").StringRankIndex,f=4294967295,a=1024,r=5e3,t=.2,s=new Set(["float64","int32","bitset","dictionary","object","multi"]);function i(k){return k==null}function n(k){if(typeof k=="number")return k;if(k instanceof Date)return k.getTime();if(typeof k=="boolean")return k?1:0;const d=Number(k);return Number.isNaN(d)&&typeof k=="string"?Date.parse(k):d}function c(k){const d=n(k);return Number.isFinite(d)?d|0:0}function o(k){return i(k)?[]:Array.isArray(k)?k:[k]}function l(k,d){switch(k.kind){case"float64":case"int32":return k.buf[d];case"bitset":return k.bits.get(d)===1;case"dictionary":return k.dict.valueOf(k.buf[d]);case"multi":{const p=k.mv.at(d),m=new Array(p.length);for(let v=0;v<p.length;v++)m[v]=k.dict.valueOf(p[v]);return m}default:return k.buf[d]}}function h(k,d){switch(k.kind){case"float64":case"int32":return k.values[d];case"bitset":return(k.values[d>>3]&1<<(d&7))!==0;case"dictionary":return(k.table||[])[k.values[d]];case"multi":{const p=k.offsets[d],m=k.offsets[d+1],v=k.table||[],y=new Array(m-p);for(let E=p;E<m;E++)y[E-p]=v[k.values[E]];return y}default:return k.values[d]}}class w{#e;#t;#n;#r;#i;#s;#o;#l=!1;#a=null;#c=null;#u=null;#f=null;#d=null;#h;#p;#m=-1;#g=null;#b=0;#y=0;#A=null;#w=null;#O=!1;constructor(d,p){this.#e=d.id;const m=s.has(d.kind)?d.kind:"object";d.kind&&!s.has(d.kind)&&N(`store.kind.${d.id}`,`column "${d.id}" declares unknown storage kind "${d.kind}"; falling back to object`),this.#n=m,this.#t=m,this.#r=d.nullable!==!1,this.#o=d.dictionary??null,this.#s=p,this.#i=B(d.read)?d.read:q(d.field||d.id),this.#h=d.stringRankIndex!=="off",this.#p=typeof d.stringRankMaxDistinct=="number"?d.stringRankMaxDistinct:0,this.#A=new Map}get id(){return this.#e}get kind(){return this.#l?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#O?null:this.#l?this.#t==="bitset"?this.#c.words:this.#t==="multi"?this.#u.values:this.#a:this.#P().values}get presence(){return this.#O||!this.#r?null:this.#l?this.#g:this.#P().presence}get dict(){return this.#O||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#f:null}get stringRank(){if(this.#O||!this.#h||this.kind!=="object")return null;const d=this.values,p=this.#s.physical();if(!d||p===0)return null;if(this.#d===null){if(typeof d[0]!="string")return null;const m=new u(this.#v());return m.build(d,p),m.version=this.#y,this.#d=m,this.#m=this.#y,m.capped?null:m}return this.#d.length<p&&this.#d.append(d,this.#d.length,p-this.#d.length),this.#d.version=this.#y,this.#m=this.#y,this.#d.capped?null:this.#d}#v(){return this.#p}#T(){this.#d=null,this.#m=-1}get offsets(){return this.#O||!this.#l||this.#t!=="multi"?null:this.#u.offsets}get version(){return this.#y}get bytes(){let d=0;return this.#a&&(d+=this.#a.byteLength??this.#a.length*8),this.#c&&(d+=this.#c.bytes),this.#u&&(d+=this.#u.bytes),this.#g&&(d+=this.#g.bytes),this.#f&&(d+=this.#f.bytes),this.#A&&(d+=this.#A.size*24),d}get(d){if(!this.#O&&!(d<0||d>=this.#s.physical())){if(!this.#l)return this.#N(d);if(this.#r&&this.#g.get(d)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[d];case"bitset":return this.#c.get(d)===1;case"dictionary":return this.#f.valueOf(this.#a[d]);case"multi":{const p=this.#u.at(d),m=new Array(p.length);for(let v=0;v<p.length;v++)m[v]=this.#f.valueOf(p[v]);return m}default:return this.#a[d]}}}set(d,p){this.#O||(this.#l?this.#E(d,p):this.#A.set(d,p===void 0?null:p),this.#d&&this.#T(),this.#y++)}read(d){return this.#i(d)}appendColumn(d,p,m){if(this.#O||m<=0)return;if(!this.#l){this.#y++;return}const v=this.#i,y=this.#r,E=this.#g;let M=!1;switch(this.#t){case"float64":{const F=this.#a;for(let V=0;V<m;V++){const I=v(d[V]);if(typeof I=="number"){y&&E.set(p+V),F[p+V]=I;continue}const $=I==null;y?E.assign(p+V,!$):$&&(M=!0),F[p+V]=$?NaN:n(I)}break}case"int32":{const F=this.#a;for(let V=0;V<m;V++){const I=v(d[V]),$=I==null;y?E.assign(p+V,!$):$&&(M=!0),F[p+V]=$?0:c(I)}break}case"bitset":{const F=this.#c;for(let V=0;V<m;V++){const I=v(d[V]),$=I==null;y?E.assign(p+V,!$):$&&(M=!0),F.assign(p+V,!$&&!!I)}break}case"dictionary":{const F=this.#a,V=this.#f;for(let I=0;I<m;I++){const $=v(d[I]),S=$==null;y?E.assign(p+I,!S):S&&(M=!0),F[p+I]=S?0:V.codeOf($)}break}case"multi":{const F=this.#u,V=this.#f;for(let I=0;I<m;I++){const $=v(d[I]),S=$==null;y?E.assign(p+I,!S):S&&(M=!0);const R=o($),L=new Array(R.length);for(let T=0;T<R.length;T++)L[T]=V.codeOf(R[T]);F.write(p+I,L)}break}default:{const F=this.#a;for(let V=0;V<m;V++){const I=v(d[V]),$=I==null;y?E.assign(p+V,!$):$&&(M=!0),F[p+V]=$?null:I}break}}M&&N(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#t==="object"&&(this.#d.append(this.#a,p,m),this.#d.version=this.#y+1,this.#m=this.#y+1),this.#y++}appendPacked(d,p,m){if(this.#O||m<=0||!d)return;if(!this.#l){this.#y++;return}const v=this.#g,y=d.presence;if(v)if(y)for(let M=0;M<m;M++)v.assign(p+M,(y[M>>3]&1<<(M&7))!==0);else for(let M=0;M<m;M++)v.set(p+M);const E=d.kind===this.#t;if(E&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(d.values,p),this.#y++;return}if(E&&this.#t==="bitset"){const M=d.values;for(let F=0;F<m;F++)this.#c.assign(p+F,(M[F>>3]&1<<(F&7))!==0);this.#y++;return}if(E&&this.#t==="dictionary"){const M=d.table||[],F=new Uint32Array(M.length);for(let S=0;S<M.length;S++)F[S]=this.#f.codeOf(M[S]);const V=d.values,I=this.#a,$=v;for(let S=0;S<m;S++){if($&&(y&&(y[S>>3]&1<<(S&7))===0)){I[p+S]=0;continue}I[p+S]=F[V[S]]??0}this.#y++;return}if(E&&this.#t==="multi"){const M=d.table||[],F=new Uint32Array(M.length);for(let $=0;$<M.length;$++)F[$]=this.#f.codeOf(M[$]);const V=d.values,I=d.offsets;for(let $=0;$<m;$++){const S=I[$],R=I[$+1],L=new Array(R-S);for(let T=S;T<R;T++)L[T-S]=F[V[T]]??0;this.#u.write(p+$,L)}this.#y++;return}for(let M=0;M<m;M++){const F=y?(y[M>>3]&1<<(M&7))===0:d.kind==="object"?d.values[M]===null:!1;this.#E(p+M,F?null:h(d,M))}this.#y++}touch(){this.#y++}columnarise(d,p){if(this.#l||this.#O)return;const m=new Array(p);for(let v=0;v<p;v++)m[v]=this.#N(v);this.#t=this.#n,this.#l=!0,this.#S(d);for(let v=0;v<p;v++)this.#E(v,m[v]);this.#A.clear(),this.#w=null,this.#T(),this.#y++}grow(d){if(!(!this.#l||this.#O||d<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const p=new this.#a.constructor(d);p.set(this.#a),this.#a=p;break}case"bitset":this.#c.grow(d);break;case"multi":break;default:this.#a.length=d;break}this.#g&&this.#g.grow(d),this.#b=d,this.#y++}}convert(d){if(this.#O||!s.has(d)||(this.#n=d,!this.#l||d===this.#t))return!1;const p={kind:this.#t,buf:this.#a,bits:this.#c,mv:this.#u,dict:this.#f},m=this.#s.physical(),v=this.#g;this.#t=d,this.#S(this.#b);for(let y=0;y<m;y++){const E=v!==null&&v.get(y)===0;E&&d!=="multi"||this.#E(y,E?null:l(p,y))}return this.#T(),this.#y++,!0}compact(d,p,m){if(!this.#O){if(this.#T(),!this.#l){const v=this.#A;if(v.size){const y=new Map;for(const[E,M]of v)d[E]!==f&&y.set(d[E],M);this.#A=y}this.#w=null,this.#y++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const v=this.#a;for(let y=0;y<p;y++)d[y]!==f&&(v[d[y]]=v[y]);if(this.#t==="object")for(let y=m;y<p;y++)v[y]=void 0;break}case"bitset":{const v=this.#c;for(let y=0;y<p;y++)d[y]!==f&&v.assign(d[y],v.get(y)===1);for(let y=m;y<p;y++)v.clear(y);break}case"multi":this.#u.compact(d,m,f);break;default:break}if(this.#g){const v=this.#g;for(let y=0;y<p;y++)d[y]!==f&&v.assign(d[y],v.get(y)===1);for(let y=m;y<p;y++)v.clear(y)}this.#y++}}release(){this.#O||(this.#O=!0,this.#a=null,this.#c&&this.#c.release(),this.#c=null,this.#u&&this.#u.release(),this.#u=null,this.#g&&this.#g.release(),this.#g=null,this.#f=null,this.#d=null,this.#A=new Map,this.#w=null,this.#b=0,this.#y++)}#S(d){const p=Math.max(1,d);switch(this.#a=null,this.#c=null,this.#u=null,this.#t){case"float64":this.#a=new Float64Array(p);break;case"int32":this.#a=new Int32Array(p);break;case"bitset":this.#c=new x(p);break;case"dictionary":this.#a=new Uint32Array(p),this.#f=this.#f??new z(this.#o??[]);break;case"multi":this.#u=new O({rows:p,values:p}),this.#f=this.#f??new z(this.#o??[]);break;default:this.#a=new Array(p);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#f=null),this.#r&&(this.#g?this.#g.grow(p):this.#g=new x(p)),this.#b=p}#E(d,p){const m=i(p);switch(this.#r?this.#g.assign(d,!m):m&&N(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[d]=m?NaN:n(p);break;case"int32":this.#a[d]=m?0:c(p);break;case"bitset":this.#c.assign(d,!m&&!!p);break;case"dictionary":this.#a[d]=m?0:this.#f.codeOf(p);break;case"multi":{const v=o(p),y=new Array(v.length);for(let E=0;E<v.length;E++)y[E]=this.#f.codeOf(v[E]);this.#u.write(d,y);break}default:this.#a[d]=m?null:p;break}}#N(d){if(this.#A.has(d))return this.#A.get(d);const p=this.#i(this.#s.rowAt(d));return p===void 0?null:p}#P(){if(this.#w&&this.#w.version===this.#y)return this.#w;const d=this.#s.physical(),p=new Array(d),m=this.#r?new x(d):null;for(let v=0;v<d;v++){const y=this.#N(v);p[v]=y,m&&!i(y)&&m.set(v)}return this.#w={version:this.#y,values:p,presence:m},this.#w}}class g{#e;#t=new Map;#n=[];#r=[];#i=0;#s=0;#o=0;#l=0;#a=new x(0);#c=!1;#u=!0;#f;#d;#h;#p=!1;constructor(d,p={}){this.#e=Array.isArray(d)?d:[],this.#d=Math.max(1,p.initialCapacity??a),this.#u=p.retainSource!==!1,this.#f=this.#u?p.columnarBelow??r:0,this.#h=p.compactRatio??t;const m={rowAt:v=>this.#r[v],physical:()=>this.#i};for(const v of this.#e){if(!v||!v.id)continue;if(this.#t.has(v.id)){N(`store.dup.${v.id}`,`duplicate column id "${v.id}" in the store schema; ignoring the second`);continue}const y=new w(v,m);this.#t.set(v.id,y),this.#n.push(y)}this.#f<=0&&this.#b()}get count(){return this.#o}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#c}get destroyed(){return this.#p}get bytes(){let d=this.#a.bytes+this.#r.length*8;for(const p of this.#n)d+=p.bytes;return d}append(d){const p=this.#i;if(this.#p||!d)return{from:p,to:p};const m=d.length|0;if(m===0)return{from:p,to:p};if(this.#u)for(let y=0;y<m;y++)this.#r[p+y]=d[y];if(this.#i=p+m,this.#o+=m,this.#a.grow(this.#i),!this.#c){if(this.#i>=this.#f)this.#b();else for(const y of this.#n)y.touch();return{from:p,to:this.#i}}this.#m(this.#i);const v=this.#n;for(let y=0;y<v.length;y++)v[y].appendColumn(d,p,m);return{from:p,to:this.#i}}appendPacked(d,p){const m=this.#i;if(this.#p||!d)return{from:m,to:m};const v=d.count|0;if(v===0)return{from:m,to:m};if(this.#u&&p)for(let E=0;E<v;E++)this.#r[m+E]=p[E];this.#i=m+v,this.#o+=v,this.#a.grow(this.#i),this.#c||this.#b(),this.#m(this.#i);const y=new Map;for(const E of d.columns)y.set(E.id,E);for(const E of this.#n){const M=y.get(E.id);M?E.appendPacked(M,m,v):E.grow(this.#s)}return{from:m,to:this.#i}}source(d){if(this.#u)return this.#r[d];if(!(d<0||d>=this.#i))return this.#g(d)}setSource(d,p){this.#p||d<0||d>=this.#i||this.#u&&(this.#r[d]=p)}get(d,p){const m=this.#t.get(d);return m?m.get(p):void 0}set(d,p,m){if(this.#p||p<0||p>=this.#i)return;const v=this.#t.get(d);if(!v){N(`store.set.${d}`,`set() on unknown column "${d}"`);return}v.set(p,m)}remove(d){return this.#p||d<0||d>=this.#i||this.#a.get(d)===1?!1:(this.#a.set(d),this.#l++,this.#o--,!0)}live(d){return d<0||d>=this.#i?!1:this.#a.get(d)===0}compact(d={}){if(this.#p||this.#l===0||!d.force&&this.#l/this.#i<this.#h)return null;const p=this.#i,m=new Uint32Array(p);let v=0;for(let y=0;y<p;y++)m[y]=this.#a.get(y)===1?f:v++;for(const y of this.#n)y.compact(m,p,v);if(this.#u){const y=this.#r;for(let E=0;E<p;E++)m[E]!==f&&(y[m[E]]=y[E]);y.length=v}return this.#i=v,this.#o=v,this.#l=0,this.#a=new x(Math.max(this.#s,v)),m}column(d){return this.#t.get(d)}columns(){return this.#n.slice()}liveIndices(){const d=new Uint32Array(this.#o);if(this.#l===0){for(let m=0;m<this.#i;m++)d[m]=m;return d}let p=0;for(let m=0;m<this.#i;m++)this.#a.get(m)===0&&(d[p++]=m);return d}convert(d,p){const m=this.#t.get(d);return m?m.convert(p):!1}destroy(){if(!this.#p){this.#p=!0;for(const d of this.#n)d.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#i=0,this.#o=0,this.#l=0,this.#s=0}}#m(d){if(d<=this.#s)return;let p=this.#s||this.#d;for(;p<d;)p*=2;for(const m of this.#n)m.grow(p);this.#a.grow(p),this.#s=p}#g(d){const p={};for(const m of this.#n)p[m.id]=m.get(d);return p}#b(){if(this.#c)return;let d=this.#d;for(;d<this.#i;)d*=2;this.#c=!0,this.#s=d,this.#a.grow(d);for(const p of this.#n)p.columnarise(d,this.#i)}}}),Ie("packages/core/src/store/pool.js",function(e,U){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return D}});const te=64,N=8;function X(K){let x=te;for(;x<K;)x*=2;return x}class B{#e=new Map;#t=new WeakSet;#n;#r=0;#i={acquired:0,reused:0,released:0};constructor(x={}){this.#n=x.limit??N}get bytes(){return this.#r}mask(x){const G=new Uint8Array(this.#s(x),0,x);return G.fill(0),G}indices(x){return new Uint32Array(this.#s(x*4),0,x)}release(x){if(!x||!x.buffer)return!1;const G=x.buffer;if(!this.#t.has(G))return!1;this.#t.delete(G),this.#i.released++;const z=G.byteLength;let j=this.#e.get(z);return j||this.#e.set(z,j=[]),j.length>=this.#n||(j.push(G),this.#r+=z),!0}releaseAll(x){for(const G of x)this.release(G)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#i,retained:this.#r}}#s(x){const G=X(x),z=this.#e.get(G);this.#i.acquired++;let j;return z&&z.length?(j=z.pop(),this.#r-=G,this.#i.reused++):j=new ArrayBuffer(G),this.#t.add(j),j}}function D(){return q??=new B,q}let q=null}),Ie("packages/core/src/compute/sortspec.js",function(e,U){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return D}});function te(q){return{locale:q===void 0?void 0:String(q),numeric:!0,sensitivity:"variant"}}function N(q){return!!q&&typeof q.compare!="function"}function X(q){if(!q)return!0;for(let K=0;K<q.length;K++)if(!N(q[K]))return!1;return!0}function B(q,K){const x=q.col!==void 0?q.col:q.handle&&q.handle.id,G=q.locale!==void 0?q.locale:K;return{col:x,descending:q.descending!==void 0?!!q.descending:q.dir==="desc",nullsFirst:!!q.nullsFirst,collation:te(G)}}function D(q,K){const x=q||[],G=new Array(x.length);for(let z=0;z<x.length;z++)G[z]=B(x[z],K);return G}}),Ie("packages/core/src/compute/facet.js",function(e,U){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return u}}),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 s}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const te=U("packages/core/src/compute/handle.js"),N=te.presenceReader,X=te.valueReader,B=te.dictSize,D=te.dictValue,q=Object.freeze(["equal","quantile","log"]),K=Object.freeze(["hour","day","week","month","quarter","year"]),x=20,G=50,z=1e4;function j(m,v){if(!m)return"none";const y=v;if(y&&(y.multi===!0||typeof y.items=="function"))return"category";const E=v&&v.base;if(E==="date"||E==="datetime"||E==="time"||E==="dateString")return"date";switch(m.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return E==="number"?"numeric":E==="boolean"?"boolean":E==="text"?"category":"none"}}function O(m){const v=m.values,y=m.kind;if((y==="float64"||y==="int32")&&v)return M=>v[M];const E=X(m);return M=>b(E(M))}function b(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(m==null||m==="")return NaN;if(typeof m=="boolean")return m?1:0;if(typeof m=="string"){const v=Number(m);if(Number.isFinite(v))return v;const y=Date.parse(m);return Number.isFinite(y)?y:NaN}return NaN}function u(m,v,y,E=G){if(!m)return{cardinality:0,exact:!0};if(m.dict)return{cardinality:B(m.dict),exact:!0};if(m.kind==="bitset")return{cardinality:2,exact:!0};const M=X(m),F=v?v.length:y,V=new Set;for(let I=0;I<F;I++){const $=M(v?v[I]:I);if($!=null&&(V.add($),V.size>E))return{cardinality:V.size,exact:!1}}return{cardinality:V.size,exact:!0}}const f=36e5,a=864e5;function r(m,v=x){const y=Number.isFinite(m)&&m>0?m:0,E=Math.max(1,v)*2;return y/f<=E?"hour":y/a<=E?"day":y/(7*a)<=E?"week":y/(30*a)<=E?"month":y/(91*a)<=E?"quarter":"year"}function t(m,v){if(!Number.isFinite(m))return NaN;const y=new Date(m);switch(v){case"hour":return y.setMinutes(0,0,0),y.getTime();case"day":return y.setHours(0,0,0,0),y.getTime();case"week":{y.setHours(0,0,0,0);const E=(y.getDay()+6)%7;return y.setDate(y.getDate()-E),y.getTime()}case"month":return y.setDate(1),y.setHours(0,0,0,0),y.getTime();case"quarter":return y.setMonth(Math.floor(y.getMonth()/3)*3,1),y.setHours(0,0,0,0),y.getTime();default:return y.setMonth(0,1),y.setHours(0,0,0,0),y.getTime()}}function s(m,v){const y=new Date(m);switch(v){case"hour":y.setHours(y.getHours()+1);break;case"day":y.setDate(y.getDate()+1);break;case"week":y.setDate(y.getDate()+7);break;case"month":y.setMonth(y.getMonth()+1);break;case"quarter":y.setMonth(y.getMonth()+3);break;default:y.setFullYear(y.getFullYear()+1);break}return y.getTime()}function i(m,v,y){const E=O(m),M=N(m),F=v?v.length:y;let V=1/0,I=-1/0,$=0,S=0;for(let R=0;R<F;R++){const L=v?v[R]:R;if(M&&!M(L)){$++;continue}const T=E(L);if(!Number.isFinite(T)){$++;continue}T<V&&(V=T),T>I&&(I=T),S++}return{min:V,max:I,nulls:$,finite:S}}function n(m,v,y,E){const M=O(m),F=N(m),V=v?v.length:y,I=V>E?V/E:1,$=[];for(let R=0;R<V;R+=I){const L=v?v[Math.floor(R)]:Math.floor(R);if(F&&!F(L))continue;const T=M(L);Number.isFinite(T)&&$.push(T)}const S=Float64Array.from($);return S.sort(),S}function c(m,v,y,E={}){const M=E.kind||j(m,E.type);return M==="none"||!m?{kind:"none",buckets:[],suppressed:"type"}:M==="boolean"?o(m,v,y):M==="category"?l(m,v,y,E):h(m,v,y,M,E)}function o(m,v,y){const E=N(m);let M=0;if(E){const V=v?v.length:y;for(let I=0;I<V;I++)E(v?v[I]:I)||M++}const F=[{value:!1,label:"false"},{value:!0,label:"true"}];return M>0&&F.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:F}}function l(m,v,y,E){const M=E.cardinalityLimit??G,{cardinality:F}=u(m,v,y,M);if(F>M&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:F};const V=X(m),I=v?v.length:y,$=new Map;let S=0;for(let C=0;C<I;C++){const H=V(v?v[C]:C);if(H==null||H===""){S++;continue}if(Array.isArray(H)){if(!H.length){S++;continue}for(const Y of H)$.set(Y,($.get(Y)||0)+1);continue}$.set(H,($.get(H)||0)+1)}let R=[...$.entries()];E.order==="alpha"?R.sort((C,H)=>String(C[0]).localeCompare(String(H[0]))):R.sort((C,H)=>H[1]-C[1]);let L=0,T=0;if(R.length>M){T=R.length-M;for(let C=M;C<R.length;C++)L+=R[C][1];R=R.slice(0,M)}const A=R.map(([C])=>({value:C,label:String(C)}));return L>0&&A.push({remainder:!0,label:`Other (${T} values)`}),S>0&&A.push({null:!0,label:"Empty"}),{kind:"category",buckets:A,cardinality:F}}function h(m,v,y,E,M){const{min:F,max:V,nulls:I,finite:$}=i(m,v,y);if(!$)return{kind:E,buckets:I?[{null:!0,label:"Empty"}]:[],empty:!0};const S=Math.max(1,Math.floor(M.buckets||x));let R=[];if(E==="date"){const T=K.includes(M.granularity)?M.granularity:r(V-F,S);let A=t(F,T);for(;A<=V&&R.length<4096;){const C=s(A,T);if(!(C>A))break;R.push({from:A,to:C}),A=C}return{kind:E,buckets:w(R,I),granularity:T}}const L=q.includes(M.strategy)?M.strategy:"equal";if(L==="quantile"){const T=n(m,v,y,z);if(T.length){const A=[T[0]];for(let C=1;C<S;C++){const H=T[Math.min(T.length-1,Math.floor(C/S*T.length))];H>A[A.length-1]&&A.push(H)}A.push(V);for(let C=0;C<A.length-1;C++)R.push({from:A[C],to:A[C+1]})}}else if(L==="log"&&F>0){const T=Math.log10(F),C=(Math.log10(V)-T)/S||1;for(let H=0;H<S;H++)R.push({from:10**(T+H*C),to:10**(T+(H+1)*C)})}if(!R.length){const T=(V-F)/S||1;for(let A=0;A<S;A++)R.push({from:F+A*T,to:F+(A+1)*T})}return R[R.length-1].to=V,{kind:E,buckets:w(R,I),strategy:L,min:F,max:V}}function w(m,v){return v>0?[...m,{null:!0,label:"Empty"}]:m}function g(m,v,y,E,M){const F=E&&E.buckets||[],V=M&&M.length>=F.length?M.subarray(0,F.length):new Uint32Array(F.length);if(V.fill(0),!m||!F.length)return V;const I=F.length-1,$=!!F[I]&&F[I].null===!0,S=v?v.length:y;if(E.kind==="boolean"){const C=X(m);for(let H=0;H<S;H++){const Y=C(v?v[H]:H);if(Y==null){$&&V[I]++;continue}V[Y?1:0]++}return V}if(E.kind==="category"){const C=new Map;for(let Z=0;Z<F.length;Z++)!F[Z].null&&!F[Z].remainder&&C.set(F[Z].value,Z);const H=F.findIndex(Z=>Z.remainder),Y=X(m);for(let Z=0;Z<S;Z++){const _=Y(v?v[Z]:Z);if(_==null||_===""){$&&V[I]++;continue}if(Array.isArray(_)){if(!_.length){$&&V[I]++;continue}for(const ee of _){const ne=C.get(ee);ne!==void 0?V[ne]++:H>=0&&V[H]++}continue}const J=C.get(_);J!==void 0?V[J]++:H>=0&&V[H]++}return V}const R=$?F.length-1:F.length,L=new Float64Array(R+1);for(let C=0;C<R;C++)L[C]=F[C].from;L[R]=R?F[R-1].to:0;const T=O(m),A=N(m);for(let C=0;C<S;C++){const H=v?v[C]:C;if(A&&!A(H)){$&&V[I]++;continue}const Y=T(H);if(!Number.isFinite(Y)){$&&V[I]++;continue}const Z=k(L,R,Y);Z>=0&&V[Z]++}return V}function k(m,v,y){if(!v||y<m[0])return-1;if(y>=m[v])return y===m[v]?v-1:-1;let E=0,M=v-1;for(;E<M;){const F=E+M+1>>>1;y>=m[F]?E=F:M=F-1}return E}function d(m,v,y,E={}){const M=E.bounds||c(m,E.boundsIndices??v,y,E);return{bounds:M,counts:g(m,v,y,M)}}const p=d}),Ie("packages/core/src/compute/pivotmatrix.js",function(e,U){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return O}}),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 N=U("packages/core/src/compute/handle.js").valueComparator,B=U("packages/core/src/compute/total.js").total,q=U("packages/core/src/compute/group.js").packKeys,K=U("packages/core/src/compute/pivot.js"),x=K.joinPath,G=K.DEFAULT_PATH_SEPARATOR,z=K.DEFAULT_MAX_COLUMNS,j="";function O(s,i,n={}){const c=n.separator||G,o=s||[],l=i instanceof Uint32Array?i:Uint32Array.from(i||[]),h=l.length;if(o.length===0)return{tuples:[[]],paths:[j],buckets:[l]};const{keyOf:w,readers:g}=q(o,l,0),k=new Map,d=[],p=[],m=[];for(let V=0;V<h;V++){const I=l[V],$=w(I);let S=k.get($);if(S===void 0){S=d.length,k.set($,S),p.push($);const R=new Array(g.length);for(let L=0;L<g.length;L++)R[L]=g[L](I);d.push(R),m.push([])}m[S].push(I)}const v=N(n.locale),y=d.map((V,I)=>I);y.sort((V,I)=>{const $=d[V],S=d[I];for(let R=0;R<$.length;R++){const L=b($[R],S[R],v);if(L!==0)return L}return V-I});const E=new Array(y.length),M=new Array(y.length),F=new Array(y.length);for(let V=0;V<y.length;V++){const I=y[V];E[V]=d[I],M[V]=x(d[I],c),F[V]=Uint32Array.from(m[I])}return{tuples:E,paths:M,buckets:F}}function b(s,i,n){const c=s==null,o=i==null;return c||o?c&&o?0:c?1:-1:n(s,i)}function u(s,i,n){const c=[];for(let o=0;o<s.length;o++)n.has(s[o])&&c.push(s[o]);return Uint32Array.from(c)}function f(s,i,n,c){return{value:i.length?B(s,i,n,c):null,leaves:i,count:i.length}}function a(s){const i=s&&s.opts||{},n=i.separator||G,c=i.totalContext||{locale:i.locale},o=(s.measures||[]).filter(M=>M&&M.handle),l=s.leaves instanceof Uint32Array?s.leaves:Uint32Array.from(s.leaves||[]),h=O(s.rowHandles||[],l,{...i,separator:n}),w=O(s.columnHandles||[],l,{...i,separator:n}),g=i.maxColumns===void 0?z:i.maxColumns,k=w.paths.length*Math.max(1,o.length),d=new Map;if(g&&k>g)return{rowAxis:h,columnAxis:w,measures:o.map(M=>({colId:M.colId,fn:M.fn})),body:d,rowMargin:d,columnMargin:d,grand:d,columns:k,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${k} columns, above pivot.maxColumns of ${g}. Narrow the pivot columns or raise the limit.`,columns:k,maxColumns:g}};const p=new Map,m=new Map,v=new Map,y=new Map,E=w.buckets.map(M=>new Set(M));for(let M=0;M<w.paths.length;M++){const F=w.buckets[M],V=w.paths[M];for(const I of o)v.set(t(V,I.colId),f(I.handle,F,I.fn,c))}for(let M=0;M<h.paths.length;M++){const F=h.buckets[M],V=h.paths[M];for(const I of o)m.set(t(V,I.colId),f(I.handle,F,I.fn,c));for(let I=0;I<w.paths.length;I++){const $=u(F,w.buckets[I],E[I]);if($.length===0)continue;const S=w.paths[I];for(const R of o)p.set(r(V,S,R.colId),f(R.handle,$,R.fn,c))}}for(const M of o)y.set(M.colId,f(M.handle,l,M.fn,c));return{rowAxis:h,columnAxis:w,measures:o.map(M=>({colId:M.colId,fn:M.fn})),body:p,rowMargin:m,columnMargin:v,grand:y,columns:k,error:null}}function r(s,i,n){return`${s}\0${i}\0${n}`}function t(s,i){return`${s}\0${i}`}}),Ie("packages/core/src/compute/reference.js",function(e,U){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return a}});const N=U("packages/core/src/internal/paths.js").getPath,X=U("packages/core/src/compute/handle.js"),B=X.isMissing,D=X.valueComparator,K=U("packages/core/src/compute/filter.js").testValue,x="",G="\0";function z(s,i){const n=i.includes(".")?N(s,i):s?.[i];return n===void 0?null:n}function j(s,i,n={}){const c=i||[];let o=s.map((l,h)=>h);if(c.length===0)return o;for(let l=c.length-1;l>=0;l--)o=O(s,o,c[l],n);return o}function O(s,i,n,c){const o=n.locale!==void 0?n.locale:c.locale,l=D(o),h=n.descending!==void 0?!!n.descending:n.dir==="desc",w=[],g=[];for(const p of i){const m=z(s[p],n.col);B(m)?g.push(p):w.push(p)}const k=new Map;for(let p=0;p<w.length;p++)k.set(w[p],p);const d=(p,m)=>{const v=z(s[p],n.col),y=z(s[m],n.col);let E;return typeof n.compare=="function"?(E=n.compare(v,y,s[p],s[m],h),h&&(E=-E)):E=h?l(y,v):l(v,y),E!==0?E:k.get(p)-k.get(m)};return w.sort(d),n.nullsFirst?g.concat(w):w.concat(g)}function b(s,i,n={}){const c=[];for(let o=0;o<s.length;o++)u(s[o],i,n,o)&&c.push(o);return c}function u(s,i,n,c){if(!i)return!0;if(Array.isArray(i.conditions)){const o=i.conditions.filter(h=>h!=null);if(o.length===0)return!0;if(i.op==="or")return o.some(h=>u(s,h,n,c));const l=o.every(h=>u(s,h,n,c));return i.op==="not"?!l:l}return i.col===void 0&&typeof n.custom=="function"?!!n.custom(i,s,c):K(z(s,i.col),i,n.locale)}function f(s,i,n,c){const o=n||s.map((g,k)=>k),l=new Map,h=[],w=[];for(const g of o){const k=i.map((m,v)=>{const y=z(s[g],m);return c&&c[v]?c[v](y):y}),d=k.map(m=>m==null?G:String(m)).join(x);let p=l.get(d);p===void 0&&(p=h.length,l.set(d,p),h.push(k),w.push([])),w[p].push(g)}return{keys:h,buckets:w}}function a(s,i,n={}){const c=D(n.locale),o=s.filter(h=>!B(h)),l=o.map(r).filter(h=>h!==null);switch(i){case"count":return s.length;case"countValues":return o.length;case"sum":return l.reduce((h,w)=>h+w,0);case"avg":return o.length===0?null:l.reduce((h,w)=>h+w,0)/o.length;case"min":return o.length===0?null:o.reduce((h,w)=>c(w,h)<0?w:h);case"max":return o.length===0?null:o.reduce((h,w)=>c(w,h)>0?w:h);case"first":return s.length===0?null:t(s[0]);case"last":return s.length===0?null:t(s[s.length-1]);default:return null}}function r(s){if(typeof s=="number")return Number.isNaN(s)?null:s;if(s==null||s===""||typeof s=="boolean")return null;if(s instanceof Date)return s.getTime();const i=Number(s);return Number.isNaN(i)?null:i}function t(s){return s===void 0?null:s}}),Ie("packages/core/src/compute/index.js",function(e,U){"use strict";const te=U("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return te.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return te.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return te.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return te.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return te.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return te.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return te.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return te.rankSortStrings}});const N=U("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return N.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return N.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return N.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return N.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return N.describeSort}});const X=U("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return X.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return X.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return X.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return X.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return X.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return X.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return X.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return X.mentionsColumn}});const B=U("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return B.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return B.packKeys}});const D=U("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return D.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return D.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return D.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return D.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return D.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return D.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return D.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return D.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return D.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return D.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return D.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return D.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return D.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return D.QUANTILE_SAMPLE}});const q=U("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return q.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return q.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return q.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return q.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return q.collectValues}});const K=U("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return K.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return K.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return K.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return K.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return K.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return K.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return K.DEFAULT_MAX_COLUMNS}});const x=U("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return x.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return x.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return x.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return x.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return x.GRAND_PATH}});const G=U("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return G.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return G.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return G.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return G.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return G.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return G.referenceValue}});const z=U("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 j=U("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return j.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return j.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return j.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return j.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return j.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return j.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return j.SKETCH_BOUNDS}});const O=U("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return O.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return O.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return O.openWindow}});const b=U("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return b.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return b.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return b.maintenanceOf}});const u=U("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return u.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return u.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return u.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return u.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u.anomalyCondition}});const f=U("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return f.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return f.forecast}})}),Ie("packages/core/src/source/rows.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return f}});const N=U("packages/core/src/internal/warn.js").warnOnce,B=U("packages/core/src/internal/predicates.js").isFunction,D=32,q="\0";function K(a){return new x(a)}class x{#e;#t;constructor(r){this.#e=B(r&&r.rowKey)?r.rowKey:null;const t=r&&r.config?r.config.rowHeight:void 0;this.#t=typeof t=="number"||B(t)?t:D}get keyed(){return this.#e!==null}keyOf(r,t){if(this.#e){const s=this.#e(r);if(s!=null)return String(s)}else N("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${t}`}heightOf(r){return B(this.#t)?Number(this.#t(r))||D:this.#t}leaf(r,t,s=0,i=null){const n={key:this.keyOf(r,t),data:r,level:s,parent:i,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:t};return n.height=this.heightOf(n),n}group(r){const t={key:u(r.keyPath||r.path),data:null,level:r.level,parent:r.parent||null,children:[],group:!0,expanded:r.expanded!==!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.column,groupValue:r.value,groupPath:r.path,hasChildren:r.hasChildren!==!1};return r.totals&&(t.totals=r.totals),t.height=this.heightOf(t),t}footer(r){const t={key:`${r.key}${q}footer`,data:null,level:r.level,parent:r,group:!0,footer:!0,expanded:!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.groupColumn,groupValue:r.groupValue,groupPath:r.groupPath,hasChildren:!1,totals:r.totals};return t.height=this.heightOf(t),t}detail(r,t){return{key:`${r.key}${q}detail`,data:r.data,level:r.level+1,parent:r,group:!1,detail:!0,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:r.key}}grandTotal(r,t){const s={key:`${q}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:t,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:r};return s.height=this.heightOf(s),s}skeleton(r,t=0,s=!1){const i={key:`${q}pending${q}${r}`,data:null,level:t,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:r,selected:!1,physical:null,pending:!0};return s&&(i.loadError=!0),i.height=this.heightOf(i),i}}function G(a,r,t,s){return{key:`${q}pinned${q}${t}${q}${r}`,data:a,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:s,index:null,selected:!1,physical:null,hasChildren:!1,pinned:t}}function z(a,r){return new Proxy([],{get(t,s,i){if(s==="length")return a();if(typeof s=="string"){const n=Number(s);if(Number.isInteger(n)&&n>=0)return r(n)}return Reflect.get(t,s,i)},has(t,s){if(typeof s=="string"){const i=Number(s);if(Number.isInteger(i)&&i>=0)return i<a()}return Reflect.has(t,s)}})}function j(a){return a==null?"":String(a)}const O="";function b(a){if(a==null)return O;const r=String(a);return r.startsWith(O)?O+r:r}function u(a){const r=a||[];let t="g";for(let s=0;s<r.length;s++)t+=q+b(r[s]);return t}function f(a){const r=new Array(a.length),t=[];for(let s=0;s<a.length;s++)t.push(a[s]),r[s]=u(t);return r}}),Ie("packages/core/src/source/handles.js",function(e,U){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return q}});const N=U("packages/core/src/internal/predicates.js").isFunction,B=U("packages/core/src/internal/warn.js").warnOnce;class D{#e;#t;#n;#r=new Map;#i=0;constructor(x,G,z){this.#e=x,this.#t=G,this.#n=N(z)?z:()=>!1}get store(){const x=this.#e.store;return x&&N(x.column)?x:null}invalidate(){this.#i++}handle(x){const G=this.store;if(G){const b=G.column(x);if(b)return b}const z=this.#r.get(x);if(z&&z.builtAt===this.#i)return z.handle;const j=this.#s(x);if(!j)return;if(G&&this.#n()){B(`source.dropped.${x}`,`column "${x}" cannot be served under ingest.dropSourceRows: it is an impure computed column (a shadow or a positional/rank column) that is never stored, so it can only be read from the caller's row objects — which dropSourceRows has released. Do not sort, filter, group or total on such a column with dropSourceRows enabled.`);return}const O=this.#o(j);return this.#r.set(x,{handle:O,builtAt:this.#i}),O}#s(x){const G=this.#e.columns;return G&&N(G.get)?G.get(x):void 0}#o(x){const G=this.#t()||[],z=G.length,j=new Array(z),O=N(x.getValue)?u=>x.getValue(u):u=>u?.[x.field||x.id];for(let u=0;u<z;u++)j[u]=G[u]===void 0?void 0:O(G[u]);const b=this.#i;return{id:x.id,kind:"object",nullable:!1,values:j,presence:null,dict:null,offsets:null,get(u){return j[u]},version:b}}}function q(K,x,G){return new D(K,x,G)}}),Ie("packages/core/src/compute/incremental.js",function(e,U){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return G}});const N=U("packages/core/src/store/columnstore.js").toFloat,X=Object.freeze(["sum","avg","countValues","min","max"]),B=Object.freeze(["float64"]),D=1e15;function q(z,j){return typeof z!="string"||!X.includes(z)?!1:!!j&&B.includes(j.kind)}function K(z){if(z==null)return null;const j=N(z);return Number.isNaN(j)?null:j}class x{#e;#t=0;#n=0;#r=0;#i=1/0;#s=-1/0;#o=!1;#l=!1;constructor(j){this.#e=j}get valid(){return this.#o&&!this.#l}get fn(){return this.#e}seed(j){this.#a();for(let O=0;O<j.length;O++){const b=K(j[O]);b!==null&&this.#c(b)}this.#o=!0}seedColumn(j,O,b){this.#a();for(let u=0;u<b.length;u++){const f=b[u];if(O&&O(f)===0)continue;const a=j[f];Number.isNaN(a)||this.#c(a)}this.#o=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#i=1/0,this.#s=-1/0,this.#l=!1}#c(j){if(!Number.isFinite(j)){this.#l=!0;return}const O=this.#t+j;this.#n+=Math.abs(this.#t)>=Math.abs(j)?this.#t-O+j:j-O+this.#t,this.#t=O,this.#r++,j<this.#i&&(this.#i=j),j>this.#s&&(this.#s=j)}#u(j){const O=this.#t-j;this.#n+=Math.abs(this.#t)>=Math.abs(j)?this.#t-O-j:-j-O+this.#t,this.#t=O,this.#r--}update(j,O){if(!this.#o)return!1;const b=K(j),u=K(O);return b===null&&u===null?!0:b!==null&&!Number.isFinite(b)||u!==null&&!Number.isFinite(u)?!1:this.#e==="min"||this.#e==="max"?b===null||u===null?!1:this.#e==="min"?u<this.#i?(this.#i=u,!0):b>this.#i:u>this.#s?(this.#s=u,!0):b<this.#s:Math.abs(this.#t)>D?!1:(b!==null&&this.#u(b),u!==null&&this.#c(u),!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.#i:null;case"max":return this.#r?this.#s:null;default:return this.#t+this.#n}}invalidate(){this.#o=!1}}const G=x}),Ie("packages/core/src/source/filterwire.js",function(e,U){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return G}}),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 s}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return v}});const N=U("packages/core/src/internal/warn.js").warnOnce,X="source.remote.hostFilter",B="source.where.pageRelative";function D(M,F){!Array.isArray(M)||!M.length||N(B,`filters.where (${M.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 q(M){const F=(M||{}).config;!F||!F.hostFilter||N(X,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const K="source.where.notApplied";function x(M,F){N(`${K}:${M}`,`filters.where("${M}") 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 G="source.where.overThreshold";function z(M,F,V,I){!Array.isArray(M)||!M.length||N(`${G}:${F}`,`filters.where (${M.join(", ")}) is not applied to the ${F} pushdown source:`,V===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${V.toLocaleString()} rows, at or past the whereRowLimit of ${I.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 j=new Map;function O(M){let F=j.get(M);return F||(F=new Intl.DateTimeFormat("en-US",{timeZone:M,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),j.set(M,F)),F}function b(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function u(M,F){const V=O(F).formatToParts(new Date(M)),I={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const $ of V)$.type==="year"?I.y=+$.value:$.type==="month"?I.m=+$.value:$.type==="day"?I.d=+$.value:$.type==="hour"?I.h=+$.value%24:$.type==="minute"?I.mi=+$.value:$.type==="second"&&(I.s=+$.value);return I}function f(M,F){const V=u(M,F);return Date.UTC(V.y,V.m-1,V.d,V.h,V.mi,V.s)-Math.floor(M/1e3)*1e3}function a(M,F,V,I){const $=Date.UTC(M,F-1,V),S=$-f($,I);return $-f(S,I)}function r(M,F,V){const I=new Date(Date.UTC(M.y,M.m-1,M.d+F));return a(I.getUTCFullYear(),I.getUTCMonth()+1,I.getUTCDate(),V)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function s(M,F){if(typeof M!="string")return null;const V=M.trim().toLowerCase().replace(/[\s_-]+/g,""),I=/^last(\d*|n)days?$/.exec(V);if(I){const $=I[1]==="n"?"":I[1],S=Number($||F);return!Number.isFinite(S)||S<=0?null:{kind:"lastNDays",n:Math.floor(S)}}switch(V){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(M,F={}){const V=s(M,F.n);if(!V)return null;const I=F.tz||b(),$=F.now instanceof Date?F.now.getTime():typeof F.now=="number"?F.now:Date.now(),S=u($,I),R=a(S.y,S.m,S.d,I),L=r(S,1,I);let T=R,A=L;switch(V.kind){case"today":break;case"yesterday":T=r(S,-1,I),A=R;break;case"lastNDays":A=F.includeToday?L:R,T=r(S,F.includeToday?-(V.n-1):-V.n,I);break;case"thisWeek":{const C=Number.isFinite(F.weekStartsOn)?Number(F.weekStartsOn):1,Y=(new Date(Date.UTC(S.y,S.m-1,S.d)).getUTCDay()-C+7)%7;T=r(S,-Y,I),A=r(S,-Y+7,I);break}case"thisMonth":T=a(S.y,S.m,1,I),A=a(S.m===12?S.y+1:S.y,S.m===12?1:S.m+1,1,I);break;case"thisQuarter":case"quarterToDate":{const C=Math.floor((S.m-1)/3)*3+1;T=a(S.y,C,1,I),A=V.kind==="quarterToDate"?L:C===10?a(S.y+1,1,1,I):a(S.y,C+3,1,I);break}case"thisYear":case"yearToDate":T=a(S.y,1,1,I),A=V.kind==="yearToDate"?L:a(S.y+1,1,1,I);break;default:return null}return{from:new Date(T).toISOString(),to:new Date(A).toISOString(),bounds:"[)",tz:I,relative:V.kind==="lastNDays"?`last${V.n}Days`:V.kind,n:V.n}}function n(M){if(!M||typeof M!="object")return null;const F=M.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(M.op==="relative"&&typeof M.value=="string")return{token:M.value,n:void 0};const V=M.meta;return V&&typeof V.relative=="string"&&M.value===void 0?{token:V.relative,n:typeof V.n=="number"?V.n:void 0}:null}function c(){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(M){const F=n(M);return F?s(F.token,F.n)!==null:!1}function l(M,F={}){const V=n(M);if(!V)return M;const I=i(V.token,{...F,n:V.n});return I?{...M,type:M.type||"date",op:"between",value:[I.from,I.to],bounds:M.bounds||I.bounds,meta:{...M.meta||{},relative:I.relative,tz:I.tz}}:(N(`source.relative.${V.token}`,`unknown relative date token "${V.token}"; sending the condition unresolved.`,c()),M)}function h(M){return!!M&&typeof M=="object"&&Array.isArray(M.conditions)}function w(M,F){if(M){if(h(M)){for(const V of M.conditions)w(V,F);return}F(M)}}function g(M,F){if(!M)return null;if(!h(M))return F(M);const V=M;let I=!1;const $=[];for(const S of V.conditions){const R=g(S,F);R!==S&&(I=!0),R&&$.push(R)}return!I&&$.length===V.conditions.length?M:$.length?{...V,conditions:$}:null}function k(M){if(!M)return null;if(!h(M))return M;const F=M,V=[];for(const I of F.conditions){const $=k(I);$&&V.push($)}return V.length?{op:F.op,conditions:V}:null}function d(M){const F=k(M);return F?h(F)&&F.op==="and"?F:{op:"and",conditions:[F]}:null}function p(M){const F=(M||[]).filter(Boolean);return F.length?{op:"and",conditions:F}:null}function m(M,F={}){const V=g(M,I=>l(I,F));return d(V)}function v(M){const F=y(M.filters??null);return JSON.stringify([F,M.sort??null,M.quick??"",M.groupBy??null,M.pivotBy??null,E(M.context)])}function y(M){if(!M)return null;if(h(M)){const I=M;return{op:I.op,conditions:I.conditions.map(y)}}const F=M,V=F.meta&&typeof F.meta.relative=="string"?F.meta.relative:n(F)?.token;return{col:F.col,op:F.op,bounds:F.bounds??null,caseSensitive:F.caseSensitive??!1,value:V?`rel:${V}`:F.value??null}}function E(M){if(M==null)return null;try{return JSON.parse(JSON.stringify(M))}catch{return N("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Ie("packages/core/src/source/tree.js",function(e,U){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return u}});const N=U("packages/core/src/internal/predicates.js").isFunction,B=U("packages/core/src/internal/warn.js").warnOnce,D="",q="\0tree:";function K(f,a){return{physical:f,key:a,level:0,children:[],value:void 0}}function x(f,a){const r=[],t=new Map;for(let s=0;s<f.length;s++){const i=f[s],n=a.pathOf(i),c=Array.isArray(n)?n.map(l=>String(l)):[];if(!c.length){const l=K(i,a.keyOf(i));r.push(l);continue}let o=null;for(let l=0;l<c.length;l++){const h=c.slice(0,l+1).join(D),w=l===c.length-1;let g=t.get(h);g&&w&&g.physical===-1&&(g.physical=i,g.key=a.keyOf(i)),g||(g=K(w?i:-1,w?a.keyOf(i):q+h),g.level=l,g.value=c[l],t.set(h,g),o?o.children.push(g):r.push(g)),o=g}}return{roots:r,nodes:t}}function G(f,a){const r=new Map,t=[];for(let c=0;c<f.length;c++){const o=f[c],l=a.keyOf(o),h=K(o,l);r.set(l,h);const w=a.parentOf(o);w!=null&&w!==""&&t.push({node:h,parent:String(w)})}let s=null;const i=new Map;for(const{node:c,parent:o}of t){const l=r.get(o);if(l){i.set(c.key,l);continue}a.orphans&&a.orphans!=="root"&&(s||(s=K(-1,`${q}orphans`),s.value=a.orphans),i.set(c.key,s))}const n=[];for(const c of r.values()){const o=i.get(c.key);o?o.children.push(c):n.push(c)}return s&&s.children.length&&n.push(s),{roots:z(n,r,a.orphans,s),nodes:r}}function z(f,a,r,t){const s=new Set,i=[...f];for(;i.length;){const h=i.pop();if(!s.has(h.key)){s.add(h.key);for(const w of h.children)i.push(w)}}const n=[];for(const h of a.values())s.has(h.key)||n.push(h);if(!n.length)return f;const c=!!r&&r!=="root";B("tree.cycle",`tree.parentKey produced ${n.length} row(s) inside a parent cycle; `+(c?`they are shown under "${r}".`:"they are shown at the root."));for(const h of n)h.children=h.children.filter(w=>s.has(w.key));if(!c)return[...f,...n];let o=t;const l=[...f];return o||(o=K(-1,`${q}orphans`),o.value=r,l.push(o)),o.children.push(...n),l}function j(f){let a=0;const r=(t,s)=>{for(const i of t)i.level=s,s>a&&(a=s),i.children.length&&r(i.children,s+1)};return r(f,0),a}function O(f,a){if(!f||typeof f!="object")return null;const r=f.path,t=f.parentKey,s=N(f.hasChildren)?i=>!!f.hasChildren(a.dataAt(i)):null;if(N(r))return{mode:"path",pathOf:i=>r(a.dataAt(i)),keyOf:a.keyOf,declaresChildren:s};if(t!=null){const i=N(t)?t:n=>n?.[t];return{mode:"parentKey",parentOf:n=>i(a.dataAt(n)),keyOf:a.keyOf,orphans:f.orphans||"root",declaresChildren:s}}return B("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function b(f,a){const r=a.mode==="path"?x(f,a):G(f,a),t=j(r.roots);return{...r,depth:t}}function u(f,a){const r=new Map,t=s=>{for(let i=0;i<s.length;i++){const n=s[i];if(n.physical>=0){const c=a?a(n.physical):!1,o=c&&n.children.length===0;r.set(n.physical,{level:n.level,posinset:i+1,setsize:s.length,hasChildren:n.children.length>0||c,lazy:o})}n.children.length&&t(n.children)}};return t(f),r}}),Ie("packages/core/src/source/settle.js",function(e,U){"use strict";Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return N}});const te=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function N(X){const B=X&&typeof X=="object"?X.reason:null;return typeof B=="string"&&te.includes(B)}}),Ie("packages/core/src/source/memory.js",function(e,U){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return Y}});const N=U("packages/core/src/internal/lru.js").Lru,X=U("packages/core/src/internal/warn.js"),B=X.warnOnce,D=X.fail,K=U("packages/core/src/internal/predicates.js").isFunction,G=U("packages/core/src/internal/compare.js").defaultCompare,j=U("packages/core/src/internal/merge.js").mergeRow,O=U("packages/core/src/source/rows.js"),b=O.createRowFactory,u=O.groupKey,f=O.groupPathElement,a=O.groupPrefixKeys,r=O.lazyRowView,s=U("packages/core/src/source/handles.js").createHandleProvider,i=U("packages/core/src/compute/incremental.js"),n=i.RunningTotal,c=i.isIncremental,l=U("packages/core/src/compute/handle.js").presenceReader,h=U("packages/core/src/source/filterwire.js"),w=h.querySignature,g=h.mapConditions,k=h.resolveRelativeCondition,d=U("packages/core/src/source/tree.js"),p=d.buildTree,m=d.resolveTree,v=d.indexTree,y=U("packages/core/src/source/settle.js"),E=y.PIPELINE_SETTLE_REASONS,M=y.isPipelineSettle,F=Object.freeze(["filter","sort","group","total","pivot","flatten"]),V=Object.freeze([]);function I(Z,_){if(!Z)return null;const J=_==="grand"?Z.grandTotal:Z.groupTotal;return J??Z.total}function $(Z){return!!Z&&!Z.running}function S(Z){if(Z)return Z.value&&K(Z.value.compare)?Z.value.compare:K(Z.compare)?Z.compare:void 0}function R(Z){const _=Z&&Z.dataType;return!_||!K(_.items)?null:{items:_.items,type:Z.itemType&&Z.itemType.name||"text"}}function L(Z){return!!Z&&(typeof Z=="object"||typeof Z=="function")&&K(Z.then)}const T=new Uint32Array(0),A=4096;function C(Z,_){return new Y(Z,_)}function H(Z,_){if(_==="regex")try{const J=new RegExp(Z,"iu");return ee=>J.test(ee)}catch{return J=>J.includes(Z)}if(_==="fuzzy"){const J=[...Z].filter(ee=>ee!==" ");return J.length?ee=>{let ne=0;for(let se=0;se<ee.length&&ne<J.length;se++)ee[se]===J[ne]&&ne++;return ne===J.length}:()=>!0}if(_==="words"){const J=Z.split(/\s+/).filter(Boolean);return J.length?ee=>J.every(ne=>ee.includes(ne)):()=>!0}return J=>J.includes(Z)}class Y{mode="memory";#e;#t;#n;#r=!1;#i=null;#s;#o;#l=new Map;#a=!1;#c=0;#u=0;#f=new Map;#d=new Map;#h;#p=null;#m=Y.#g();static#g(){return{slots:[],groupHeadings:V,unnumbered:V,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#b=new Map;#y=null;#A=new Map;#w=-1;#O=[];#v=new Map;#T=-1;#S=[];#E=null;#N=null;#P=null;#M=null;#R=null;#$=null;#G=null;#V=null;#F=Symbol("unset");#x=new Map;#Y=null;get#D(){return this.#m.slots}set#D(_){this.#m.slots=_}get#K(){return this.#m.inlineLeaves}set#K(_){this.#m.inlineLeaves=_}get#H(){return this.#m.groupHeadings}set#H(_){this.#m.groupHeadings=_}get#B(){return this.#m.unnumbered}set#B(_){this.#m.unnumbered=_}get#fe(){return this.#m.pivot}set#fe(_){this.#m.pivot=_}constructor(_,J){this.#t=_||{mode:"memory"},this.#e=J||{};const ee=this.#e.config||{};this.#n=this.#t.rows||ee.rows||[],this.#s=b(this.#e),this.#o=s(this.#e,()=>this.#n,()=>this.#r),this.#h=new N(Number(ee.rowCacheSize)||A);for(const ne of F)this.#l.set(ne,{key:null,result:null,id:0,computed:!1})}count(){this.#I();const _=this.#pe();return _?_.length:this.#D.length}#pe(){const _=Number(this.#z("pageSize",0))||0;if(_<=0)return null;const J=this.#D.length,ee=Math.max(1,Math.ceil(J/_)),se=Math.min(Math.max(0,Number(this.#z("page",0))||0),ee-1)*_;return{offset:se,length:Math.max(0,Math.min(_,J-se))}}pageInfo(){this.#I();const _=Number(this.#z("pageSize",0))||0,J=this.#D.length;if(_<=0)return{page:0,pageSize:0,total:J,pageCount:1};const ee=Math.max(1,Math.ceil(J/_));return{page:Math.min(Math.max(0,Number(this.#z("page",0))||0),ee-1),pageSize:_,total:J,pageCount:ee}}totalCount(){return this.#Ke().length}matchCount(){return this.#I(),this.#m.matchCount}at(_){this.#I();const J=this.#pe();if(J)return _<0||_>=J.length?void 0:this.#Ne(J.offset+_,_);if(!(_<0||_>=this.#D.length))return this.#Ne(_,_)}byKey(_){this.#I(),this.#p||this.#Ce();const J=this.#p.get(_);if(J!==void 0)return this.#ee(J);for(let ee=0;ee<this.#D.length;ee++){const ne=this.#D[ee];if(typeof ne!="number"&&ne&&ne.key===_)return this.#Ne(ee)}}loaded(_){return _>=0&&_<this.count()}hint(_,J){}display(){return this.#I(),this.#Y||(this.#Y=this.#ct()),this.#Y}invalidateQuickText(){this.#x.clear(),this.invalidate("filter")}invalidate(_){const J=F.indexOf(_);J<0&&D(`unknown pipeline stage "${_}"; expected one of ${F.join(", ")}`);for(let ee=J;ee<F.length;ee++){const ne=this.#l.get(F[ee]);ne.key=null,ne.computed=!1}this.#Y=null}apply(_){const J=[],ee={added:[],updated:[],removed:[],rejected:J};if(!_)return ee;let ne=!1;const se=new Set;if(_.remove&&_.remove.length)for(const oe of _.remove){const fe=this.#Pe(oe);if(fe===void 0){J.push({operation:"remove",id:this.#be(oe),reason:"unknown-id"});continue}ee.removed.push(this.#s.keyOf(this.#r?this.#ue(fe):this.#n[fe],fe)),this.#r||(this.#n[fe]=void 0),this.#h.delete(fe),this.#x.delete(fe),ne=!0}if(_.update&&_.update.length){const oe=this.#A.size||this.#qe()?this.#st():null,fe=this.#v.size?this.#lt():null,pe=fe&&fe.length?this.#st():null;for(const he of _.update){const Re=this.#Pe(he);if(Re===void 0){J.push({operation:"update",id:this.#je(he),reason:"unknown-id"});continue}const Ue=this.#r?this.#i&&this.#i.has(Re)?this.#i.get(Re):this.#ue(Re):this.#n[Re],Le=j(Ue,he);for(const ie of this.#re(Ue,Le))se.add(ie);if(this.#r||(this.#n[Re]=Le),oe&&this.#ht(oe,Re,Ue,Le),pe&&this.#wt(fe,pe,Re,Ue,Le),this.#p){const ie=this.#s.keyOf(Ue,Re),ge=this.#s.keyOf(Le,Re);ie!==ge&&(this.#p.delete(ie),this.#p.set(ge,Re))}this.#h.delete(Re),this.#x.delete(Re),ee.updated.push(this.#ee(Re))}}if(_.add&&_.add.length&&this.#r){typeof _.at=="number"&&_.at<this.#Fe()&&(this.#h.clear(),this.#x.clear()),this.#p=null;for(const oe of _.add){const fe=this.#ne(this.#je(oe));fe!==void 0&&ee.added.push(this.#ee(fe))}ne=!0}else if(_.add&&_.add.length){const oe=typeof _.at=="number"?_.at:this.#n.length,fe=this.#n.length;let pe=_.add===this.#n?_.add.slice():_.add;if(this.#s.keyed){const he=[];for(const Re of pe){const Ue=this.#je(Re);if(this.#Pe(Ue)!==void 0){J.push({operation:"add",id:Ue,reason:"duplicate-id"});continue}he.push(Re)}he.length!==pe.length&&(pe=he)}if(!pe.length)return ee;if(oe>=fe)for(let he=0;he<pe.length;he++)this.#n.push(pe[he]);else this.#n.splice(oe,0,...pe),this.#h.clear(),this.#x.clear();for(let he=0;he<pe.length;he++)ee.added.push(this.#ee(oe>=fe?fe+he:oe+he));ne=!0}return this.#c++,ne&&(this.#p=null,this.#We()),this.#o.invalidate(),this.#Y=null,ne||this.#Z(se)?(this.#u++,this.invalidate("filter")):this.invalidate("total"),this.#Je("rows:changed",{companion:!0,added:ee.added.length,updated:ee.updated.length,removed:ee.removed.length}),this.#i=null,ee}groupHeadingsAt(_){this.#I();const J=this.#H;if(!J.length||!Number.isInteger(_)||_<0)return V;let ee=0,ne=J.length-1,se=-1;for(;ee<=ne;){const fe=ee+ne>>1;J[fe].at<=_?(se=fe,ee=fe+1):ne=fe-1}if(se<0)return V;const oe=[];for(let fe=J[se].row;fe;fe=fe.parent)oe.push(fe);return oe.reverse(),oe}unnumberedRowCount(_){this.#I();const J=this.#B;if(!J.length||!Number.isInteger(_)||_<0)return 0;let ee=0,ne=J.length-1,se=-1;for(;ee<=ne;){const oe=ee+ne>>1;J[oe].at<=_?(se=oe,ee=oe+1):ne=oe-1}return se+1}moveRow(_,J){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 ee=this.#n;if(!Number.isInteger(_)||!Number.isInteger(J)||_<0||_>=ee.length)return!1;const ne=Math.max(0,Math.min(ee.length-1,J));if(ne===_)return!1;const[se]=ee.splice(_,1);return ee.splice(ne,0,se),this.#c++,this.#u++,this.#p=null,this.#h.clear(),this.#x.clear(),this.#We(),this.#o.invalidate(),this.#Y=null,this.invalidate("filter"),this.#Je("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(_){this.#se(),this.#c++,this.#u++,this.#p=null,this.#x.clear(),this.#h.clear(),this.#We(),this.#o.invalidate(),this.invalidate("filter"),this.#Je("model:changed",{reason:"reload"})}destroy(){this.#se(),this.#h.clear(),this.#x.clear(),this.#p=null,this.#D=[],this.#K=null,this.#Y=null,this.#We();for(const _ of F)this.#l.set(_,{key:null,result:null,id:0,computed:!1})}#se(){for(const{controller:_}of this.#b.values())try{_.abort()}catch{}this.#b.clear()}setRows(_){this.#n=_||[],this.#r=!1,this.#c++,this.#u++,this.#p=null,this.#x.clear(),this.#h.clear(),this.#We(),this.#o.invalidate(),this.invalidate("filter")}notePriorRows(_){this.#i=_||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#x.clear(),this.#o.invalidate()}data(){if(!this.#r)return this.#n;const _=this.#e.store;if(!_||!K(_.source))return this.#n;const J=_.physical||0,ee=new Array(J);for(let ne=0;ne<J;ne++)ee[ne]=_.live&&!_.live(ne)?void 0:_.source(ne);return ee}#Be(){const _=this.#z("detail",null);return!_||!K(_.isOpen)||_.inline===!1?null:_}#Se(){const _=(this.#e.config||{}).tree;return this.#F!==_&&(this.#F=_,this.#V=m(_,{dataAt:J=>this.#ue(J),keyOf:J=>this.#s.keyOf(this.#ue(J),J)})),this.#V}#ge(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#ge())return null;this.#I();const _=this.#m.grand;return _?this.#s.grandTotal(_,this.#nt(this.#m.grandLeaves)):null}pivot(){return this.#I(),this.#fe}pivotMatrix(){this.#I();const _=this.#m.groupLeaves,J=(this.#e.compute||{}).pivotMatrix;if(!K(J))return null;const ee=this.#z("groupBy",[]),ne=this.#z("pivotBy",[]);if(!ee.length&&!ne.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 se=this.#st().map(fe=>({colId:fe.id,handle:this.#o.handle(fe.id),fn:I(fe,"group")})).filter(fe=>fe.handle&&fe.fn),oe=this.#e.config||{};return J({rowHandles:ee.map(fe=>this.#o.handle(fe)).filter(Boolean),columnHandles:ne.map(fe=>this.#o.handle(fe)).filter(Boolean),measures:se,leaves:_||new Uint32Array(0),opts:{locale:oe.locale,separator:(oe.pivot||{}).separator,maxColumns:(oe.pivot||{}).maxColumns}})}keysForLeaves(_){const J=[];if(!_)return J;for(let ee=0;ee<_.length;ee++){const ne=this.#ee(_[ee]);ne&&ne.key!=null&&J.push(String(ne.key))}return J}leavesOf(_){this.#I();const J=this.#l.get("group"),ee=J&&J.result;if(!ee||!ee.nodes)return[];const ne=ee.nodes.get(_);if(!ne)return[];const se=[],oe=fe=>{const pe=fe.row&&fe.row.children;if(pe&&pe.length){for(const he of pe){const Re=ee.nodes.get(he.key);Re&&oe(Re)}return}if(fe.leaves)for(let he=0;he<fe.leaves.length;he++)se.push(this.#ee(fe.leaves[he]))};return oe(ne),se}#be(_){return typeof _=="string"?_:this.#je(_)}#je(_){try{return this.#s.keyOf(_,-1)}catch{return"(unkeyed)"}}#Pe(_){if(typeof _=="string")return this.#ne(_);if(this.#s.keyed){const ee=this.#s.keyOf(_,-1),ne=this.#ne(ee);if(ne!==void 0)return ne}if(this.#r)return;const J=this.#n.indexOf(_);return J>=0?J:void 0}#ne(_){return this.#p||this.#Ce(),this.#p.get(_)}#Ce(){this.#p=new Map;const _=this.#Fe(),J=this.#e.store,ee=J&&K(J.live)?ne=>J.live(ne):null;for(let ne=0;ne<_;ne++){if(ee&&!ee(ne))continue;const se=this.#ue(ne);se!==void 0&&this.#p.set(this.#s.keyOf(se,ne),ne)}}#re(_,J){const ee=[];for(const ne of this.#_())this.#ze(ne)&&this.#J(ne,_,J,new Set)&&ee.push(ne);return ee}#J(_,J,ee,ne){if(ne.has(_))return!1;ne.add(_);const se=this.#ze(_);if(!se)return!1;const oe=se.value&&se.value.deps;return Array.isArray(oe)&&oe.length?oe.some(fe=>this.#J(String(fe),J,ee,ne)):K(se.getValue)?!Object.is(se.getValue(J),se.getValue(ee)):!1}#_(){const _=new Set;for(const ee of this.#z("sort",[]))_.add(ee.col);for(const ee of this.#z("groupBy",[]))_.add(ee);const J=ee=>{if(ee){if(Array.isArray(ee.conditions)){ee.conditions.forEach(J);return}ee.col&&_.add(ee.col)}};return J(this.#z("filters",null)),[..._]}#Z(_){if(!_.size)return!1;if(this.#z("quick",""))return!0;for(const J of this.#_())if(_.has(J))return!0;return!1}#I(){if(!this.#a){this.#a=!0;try{this.#Te()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#Te(){const _=this.#U("filter",()=>this.#W(),()=>this.#ve()),J=this.#X(_),ee=this.#U("group",()=>this.#de(),()=>this.#at(J)),ne=this.#U("total",()=>this.#he(),()=>this.#Ue(ee));this.#U("pivot",()=>this.#Le(),()=>this.#Rt(ee)),this.#U("flatten",()=>this.#xe(),()=>this.#j(ee)),this.#$e(ee,ne)}#X(_){const J=this.#l.get("sort"),ee=this.#ie();if(J.computed&&J.key===ee&&!this.#b.has("sort"))return J.result;const ne=this.#b.get("sort");return ne&&ne.key===ee?J.result:J.result&&this.#we(_)?(this.#Ee(_,ee),J.result):this.#U("sort",()=>ee,()=>this.#Me(_))}#oe(){if(this.#y===null){const _=this.#e.pipelineWorker,J=K(_)?_():null;this.#y=J||!1}return this.#y||null}#Oe(){const _=this.#z("sort",[]);if(!Array.isArray(_)||!_.length)return null;const J=(this.#e.config||{}).locale,ee=[],ne=[];for(const se of _){const oe=this.#ze(se.col);if(oe&&oe.running)continue;if(oe&&oe.value&&K(oe.value.compare))return null;const fe=this.#o.handle(se.col);if(!fe)return null;ee.push({col:se.col,descending:se.dir==="desc",nullsFirst:!!se.nullsFirst,locale:J}),ne.push(fe)}return ee.length?{entries:ee,handles:ne,locale:J}:null}#we(_){if(this.#me())return!1;const J=this.#oe();if(!J)return!1;const ee=Number(J.threshold);return Number.isFinite(ee)&&_.length<ee?!1:!!this.#Oe()}#Ee(_,J){const ee=this.#oe(),ne=ee&&this.#Oe();if(!ne){this.#U("sort",()=>J,()=>this.#Me(_));return}const se=new AbortController;this.#b.set("sort",{key:J,controller:se});const oe=ne.entries.length===1?ee.sortColumn(ne.handles[0],_,{descending:ne.entries[0].descending,nullsFirst:ne.entries[0].nullsFirst,locale:ne.locale,signal:se.signal,key:"sort"}):ee.sortMulti(ne.handles,ne.entries.map((fe,pe)=>({...fe,handle:ne.handles[pe]})),_,{signal:se.signal,key:"sort"});if(!L(oe)){this.#b.delete("sort"),this.#U("sort",()=>J,()=>oe);return}oe.then(fe=>this.#ae(J,fe),fe=>this.#ce("sort",J,fe))}#ae(_,J){const ee=this.#b.get("sort");if(!(!ee||ee.key!==_)){if(this.#ie()!==_){this.#b.delete("sort");return}this.#b.delete("sort"),this.#U("sort",()=>_,()=>J),this.#Y=null,this.#I(),this.#Je("model:changed",{reason:E[0]})}}#ce(_,J,ee){const ne=this.#b.get(_);if(!(!ne||ne.key!==J)&&(this.#b.delete(_),!(ee&&ee.name==="AbortError")&&_==="sort"&&this.#ie()===J)){const se=this.#U("filter",()=>this.#W(),()=>this.#ve());this.#U("sort",()=>J,()=>this.#Me(se)),this.#Y=null,this.#I(),B("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",ee),this.#Je("model:changed",{reason:E[1]})}}#$e(_,J){const ee=_&&_.leaves?_.leaves.length:this.#m.slots.length;this.#m.matchCount=ee,this.#m.grand=J&&J.grand||null,this.#m.grandLeaves=_&&_.leaves?_.leaves.length:0,this.#m.groupLeaves=_&&_.leaves?_.leaves:null}#U(_,J,ee){const ne=this.#l.get(_),se=J();return ne.computed&&ne.key===se||(ne.result=ee(),ne.key=se,ne.computed=!0,ne.id++,_==="flatten"&&(this.#Y=null)),ne.result}#C(_){return this.#l.get(_).id}#W(){const _=(this.#e.config||{}).hostFilter,J=_&&K(_.active)&&_.active()?1:0,ee=this.#z("where",null),ne=ee?ee.version:0,se=this.#it("filter.sig",`${this.#Qe()}`,()=>w({filters:this.#z("filters",null),quick:this.#z("quick",""),quickMode:this.#z("quickMode","contains")}));return`${this.#u}|${se}|${J}|${ne}`}#ie(){const _=this.#me();return`${this.#C("filter")}|${JSON.stringify(this.#z("sort",[]))}`+(_?`|manual:${_.version}`:"")}#me(){const _=this.#z("rowOrder",null);return _&&Array.isArray(_.keys)?_:null}#le(_,J){this.#p||this.#Ce();const ee=this.#p,ne=this.#Fe(),se=J.keys.length,oe=new Float64Array(ne);for(let fe=0;fe<ne;fe++)oe[fe]=se+fe;for(let fe=0;fe<se;fe++){const pe=ee.get(J.keys[fe]);pe!==void 0&&(oe[pe]=fe)}return Uint32Array.from(_).sort((fe,pe)=>oe[fe]-oe[pe])}orderedKeys(){this.#p||this.#Ce();const _=this.#p,J=new Map;for(const[fe,pe]of _)J.set(pe,fe);const ee=Uint32Array.from([...J.keys()]).sort(),ne=this.#me(),se=ne?this.#le(ee,ne):this.#Me(ee),oe=new Array(se.length);for(let fe=0;fe<se.length;fe++)oe[fe]=J.get(se[fe]);return oe}#de(){const _=this.#z("pivotBy",[]).length>0?"p":"u";return`${this.#C("sort")}|${JSON.stringify(this.#z("groupBy",[]))}|${_}`}#he(){const _=this.#Ge()?"f":"a",J=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#C("group")}|${JSON.stringify(this.#z("totals",[]))}|${_}${J}|${this.#c}`}#Le(){return`${this.#C("group")}|${JSON.stringify(this.#z("pivotBy",[]))}`}#xe(){const J=this.#k()||!this.#ge()?this.#C("total"):"x",ee=`${this.#Qe()}`,ne=this.#it("flatten.keys",ee,()=>{const oe=this.#z("expanded",null);return oe?[...oe].sort().join(""):"*"}),se=this.#it("flatten.detail",ee,()=>{const oe=this.#z("detail",null);return oe&&K(oe.signature)?oe.signature():""});return`${J}|${this.#C("pivot")}|${ne}|${se}`}#k(){const _=this.#z("groupBy",[]);return Array.isArray(_)&&_.length>0}stageState(){const _=[];for(const[J,ee]of this.#l){const ne=ee.result;_.push({stage:J,materialised:!!ee.computed,bytes:ne&&typeof ne.byteLength=="number"?ne.byteLength:null,rows:ne&&typeof ne.length=="number"?ne.length:null,rebuilds:ee.id})}return _}facetIndices(_){return this.#ve(_||null)}facetRows(_){const J=this.facetIndices(_),ee=[];for(let ne=0;ne<J.length;ne++){const se=this.#ee(J[ne]);se&&ee.push(se)}return ee}invalidateRows(){this.#h.clear(),this.#x.clear(),this.#Y=null}invalidateHandles(){this.#o.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Ke()}filteredIndices(){const _=this.#l.get("filter");if(_&&_.computed&&_.key===this.#W())return _.result||this.#Ke();this.#I();const J=this.#l.get("filter");return(J&&J.computed?J.result:null)||this.#Ke()}unfilteredRows(){const _=this.#Ke(),J=[];for(let ee=0;ee<_.length;ee++){const ne=this.#ee(_[ee]);ne&&J.push(ne)}return J}#ve(_=null){const J=this.#Ke(),ee=this.#z("filters",null),ne=_?this.#ot("pruneColumn")(ee,_):ee,se=this.#kt(ne),oe=String(this.#z("quick","")||"").trim().toLowerCase(),fe=oe?H(oe,String(this.#z("quickMode","contains")||"contains")):null,pe=(this.#e.config||{}).hostFilter,he=!!(pe&&K(pe.active)&&pe.active()),Re=this.#z("where",null),Ue=!!(Re&&Re.active);if(!se&&!oe&&!he&&!Ue)return J;let Le=null;se&&(Le=this.#ot("evaluateFilters")(se,{handle:Se=>this.#o.handle(Se),count:this.#Fe(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:Se=>R(this.#ze(Se))}));const ie=new Uint32Array(J.length);let ge=0;for(let ke=0;ke<J.length;ke++){const Se=J[ke];if(!(Le&&!Le[Se])&&!(fe&&!this.#vt(Se,fe))){if(he||Ue){const Ae=this.#ee(Se);if(he&&!pe.passes(Ae)||Ue&&!Re.passes(Ae.data,Ae.key))continue}ie[ge++]=Se}}if(Le){const ke=(this.#e.compute||{}).releaseMask;K(ke)&&ke({pool:this.#e.pool},Le)}return ie.subarray(0,ge)}handleFor(_){return this.#o.handle(_)}#Me(_){const J=this.#me();if(J)return this.#le(_,J);const ee=this.#z("sort",[]).filter(oe=>{const fe=this.#ze(oe.col);return!fe||!fe.running?!0:(B(`source.sort.running.${oe.col}`,`sort ignores "${oe.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!ee.length)return _;const ne=(this.#e.config||{}).locale;if(ee.length===1){const oe=ee[0],fe=this.#o.handle(oe.col);if(!fe)return B(`source.sort.${oe.col}`,`sort ignores unknown column "${oe.col}".`),_;const pe=this.#ze(oe.col);return this.#ot("sortColumn")(fe,_,{descending:oe.dir==="desc",nullsFirst:oe.nullsFirst,locale:ne,compare:S(pe)})}const se=[];for(const oe of ee){const fe=this.#o.handle(oe.col);if(!fe){B(`source.sort.${oe.col}`,`sort ignores unknown column "${oe.col}".`);continue}se.push({handle:fe,descending:oe.dir==="desc",nullsFirst:oe.nullsFirst,locale:ne,compare:S(this.#ze(oe.col))})}return se.length?this.#ot("sortMulti")(se.map(oe=>oe.handle),se,_):_}#at(_){const J=this.#z("groupBy",[]),ee=this.#Se();if(ee&&!J.length){const ke=p(_,ee);return this.#$=v(ke.roots,ee.declaresChildren),{roots:null,leaves:_,nodes:new Map,tree:ke}}if(this.#$=null,ee&&J.length&&B("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!J.length)return{roots:null,leaves:_,nodes:new Map};const ne=(this.#e.config||{}).timeZone,se=[],oe=[];let fe=!1;for(const ke of J){const Se=this.#o.handle(ke);if(!Se){B(`source.group.${ke}`,`grouping ignores unknown column "${ke}".`);continue}se.push(Se);const Ae=this.#ze(ke),xe=Ae&&Ae.dataType;if(xe&&K(xe.groupProjector)){const me=Ae.typeOptions&&Ae.typeOptions.timeZone||ne||void 0,ye=xe.groupProjector(Ae,me);oe.push(ye||null),ye&&(fe=!0)}else oe.push(null)}if(!se.length)return{roots:null,leaves:_,nodes:new Map};const{keys:pe,buckets:he}=this.#ot("groupByColumns")(se,_,{locale:(this.#e.config||{}).locale,project:fe?oe:void 0}),Re=this.#z("pivotBy",[]).length>0,Ue=[],Le=new Map;for(let ke=0;ke<he.length;ke++){const Se=pe[ke];let Ae=null;const xe=[];for(let me=0;me<Se.length;me++){xe.push(f(Se[me]));const ye=u(xe),Te=me===Se.length-1;let Ye=Le.get(ye);if(!Ye){const Oe=this.#s.group({path:[...xe],column:J[me],value:Se[me],level:me,parent:Ae,expanded:Re&&Te?!1:this.#ut(ye,{key:ye,column:J[me],value:Se[me],level:me,path:[...xe]}),hasChildren:!(Re&&Te)});Ye={row:Oe,leaves:null},Le.set(ye,Ye),Ae?Ae.children.push(Oe):Ue.push(Oe)}Ye.row.leafCount+=he[ke].length,me===Se.length-1&&(Ye.leaves=he[ke]),Ae=Ye.row}}const ie=this.#z("sort",[])||[],ge=(ke,Se)=>{if(!ke||ke.length<2){if(ke)for(const ye of ke)ge(ye.children,Se+1);return}const Ae=J[Se],xe=ie.find(ye=>ye.col===Ae),me=xe&&xe.dir==="desc"?-1:1;ke.sort((ye,Te)=>me*G(ye.groupValue,Te.groupValue));for(const ye of ke)ge(ye.children,Se+1)};return ge(Ue,0),{roots:Ue,leaves:_,nodes:Le,keys:pe,buckets:he}}#_e(_,J){const ee=new Map,ne=new Map,se=oe=>{const fe=oe.physical>=0?[oe.physical]:[];for(const pe of oe.children)fe.push(...se(pe));if(oe.children.length){const pe=this.#Ye(J,Uint32Array.from(fe),null);oe.physical>=0?ee.set(oe.physical,pe):ne.set(oe.key,pe)}return fe};for(const oe of _.roots)se(oe);return{byPhysical:ee,byKey:ne}}#Ue(_){const J=this.#st();if(!J.length)return this.#N=null,this.#P=null,{grand:null};const ee={id:this.#C("group"),columns:J.map(ie=>ie.id).join("")},ne=this.#N&&this.#N.id===ee.id&&this.#N.columns===ee.columns,se=this.#qe()&&ne?this.#E:null,oe=se?J.filter(ie=>se.has(ie.id)):J,fe=ne?this.#P:null,pe=this.#Ge()?null:this.#Mt(),he=this.#ye(J),Re=ie=>{const ge=_.nodes.get(ie.key);let ke=ge&&ge.leaves?ge.leaves:null;if(ie.children&&ie.children.length){const xe=ie.children.map(Re);let me=0;for(const Ye of xe)me+=Ye.length;const ye=new Uint32Array(me);let Te=0;for(const Ye of xe)ye.set(Ye,Te),Te+=Ye.length;ke=ye}ke=ke||new Uint32Array(0);const Se=pe?pe.get(ie.key)||T:ke,Ae=this.#bt(ie,se?oe:J,Se,he);return ie.totals=se?{...ie.totals,...Ae}:Ae,ke};if(_.roots&&oe.length)for(const ie of _.roots)Re(ie);if(this.#G=_.tree?this.#_e(_.tree,J):null,this.#N=ee,this.#E=this.#qe()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#O.length=0,this.#P=null,{grand:null};const Le=pe?this.#rt():_.leaves;return this.#P=this.#Xe(J,Le,se,fe),{grand:this.#P}}#Xe(_,J,ee,ne){const se={},oe=this.#C("group");oe!==this.#w&&(this.#Ze(),this.#w=oe);const fe=this.#O;this.#O=[];for(const pe of _){if(!$(pe))continue;const he=this.#o.handle(pe.id);if(!he)continue;const Re=I(pe,"grand");if(!c(Re,he)){if(ee&&!ee.has(pe.id)&&ne&&pe.id in ne){se[pe.id]=ne[pe.id];continue}se[pe.id]=this.#Ye([pe],J,null,"grand")[pe.id];continue}let Ue=this.#A.get(pe.id);if((!Ue||Ue.fn!==Re)&&(Ue=new n(Re),this.#A.set(pe.id,Ue)),Ue.valid){let Le=!0;for(const ie of fe)if(ie.colId===pe.id&&!Ue.update(ie.before,ie.after)){Le=!1;break}if(Le){se[pe.id]=Ue.value();continue}Ue.invalidate()}Ue.seedColumn(he.values,l(he),J),se[pe.id]=Ue.valid?Ue.value():this.#Ye([pe],J,null,"grand")[pe.id]}return se}#ye(_){const J=this.#C("group");J!==this.#T&&(this.#v.clear(),this.#T=J);const ee=new Map;for(const se of _){if(!$(se))continue;const oe=this.#o.handle(se.id),fe=I(se,"group");c(fe,oe)&&ee.set(se.id,{fn:fe})}if(!ee.size)return this.#S.length=0,ee;const ne=this.#S;this.#S=[];for(const se of ne){const{beforeKeys:oe,afterKeys:fe,colDeltas:pe}=se,he=oe.length?new Set(oe):null,Re=fe.length?new Set(fe):null;for(const{colId:Ue,before:Le,after:ie}of pe)if(ee.has(Ue)){for(const ge of oe)Re&&Re.has(ge)||this.#ke(ge,Ue,Le,null);for(const ge of fe)he&&he.has(ge)||this.#ke(ge,Ue,null,ie);for(const ge of oe)Re&&!Re.has(ge)||this.#ke(ge,Ue,Le,ie)}}return ee}#ke(_,J,ee,ne){const se=this.#v.get(_),oe=se&&se.get(J);!oe||!oe.valid||oe.update(ee,ne)||oe.invalidate()}#bt(_,J,ee,ne){if(!ne||!ne.size)return this.#Ye(J,ee,_);const se={};let oe=null,fe=this.#v.get(_.key);for(const pe of J){const he=ne.get(pe.id);if(!he){(oe||(oe=[])).push(pe);continue}const Re=this.#o.handle(pe.id);if(!Re)continue;fe||(fe=new Map,this.#v.set(_.key,fe));let Ue=fe.get(pe.id);if((!Ue||Ue.fn!==he.fn)&&(Ue=new n(he.fn),fe.set(pe.id,Ue)),Ue.valid||Ue.seedColumn(Re.values,l(Re),ee),Ue.valid){se[pe.id]=Ue.value();continue}(oe||(oe=[])).push(pe)}return oe&&Object.assign(se,this.#Ye(oe,ee,_)),se}#ht(_,J,ee,ne){const se=!this.#Ge()||this.#te(J);for(const oe of _){const fe=oe.getValue;if(!K(fe))continue;const pe=fe(ee),he=fe(ne);Object.is(pe,he)||(this.#E&&this.#E.add(oe.id),se&&this.#A.has(oe.id)&&this.#O.push({colId:oe.id,before:pe,after:he}))}}#lt(){const _=this.#z("groupBy",[]),J=[];for(const ee of _){const ne=this.#ze(ee);ne&&J.push(ne)}return J}#yt(_,J){const ee=new Array(_.length);for(let ne=0;ne<_.length;ne++){const se=_[ne].getValue;ee[ne]=f(K(se)?se(J):void 0)}return ee}#wt(_,J,ee,ne,se){if(this.#Ge()&&!this.#te(ee))return;const oe=a(this.#yt(_,ne)),fe=a(this.#yt(_,se)),pe=oe.length!==fe.length||oe.some((Re,Ue)=>Re!==fe[Ue]),he=[];for(const Re of J){const Ue=Re.getValue;if(!K(Ue))continue;const Le=Ue(ne),ie=Ue(se);!pe&&Object.is(Le,ie)||he.push({colId:Re.id,before:Le,after:ie})}!he.length&&!pe||this.#S.push({beforeKeys:oe,afterKeys:fe,colDeltas:he})}#te(_){const J=this.#l.get("filter"),ee=J&&J.computed?J.result:null;if(!ee)return!0;let ne=0,se=ee.length-1;for(;ne<=se;){const oe=ne+se>>1,fe=ee[oe];if(fe===_)return!0;fe<_?ne=oe+1:se=oe-1}return!1}#Ge(){return(this.#e.config||{}).totalFilteredOnly!==!1}#nt(_){return this.#Ge()?_:this.#rt().length}#rt(){return(!this.#M||this.#M.version!==this.#u)&&(this.#M={version:this.#u,indices:this.#Ke()}),this.#M.indices}#Mt(){const _=this.#z("groupBy",[]),J=`${this.#u}|${JSON.stringify(_)}`;if(this.#R&&this.#R.key===J)return this.#R.map;const ee=new Map,ne=[];for(const se of _){const oe=this.#o.handle(se);oe&&ne.push(oe)}if(ne.length){const se=this.#rt(),{keys:oe,buckets:fe}=this.#ot("groupByColumns")(ne,se,{locale:(this.#e.config||{}).locale}),pe=new Map;for(let he=0;he<fe.length;he++){const Re=oe[he],Ue=[];for(let Le=0;Le<Re.length;Le++){Ue.push(f(Re[Le]));const ie=u(Ue);let ge=pe.get(ie);ge||(ge=[],pe.set(ie,ge));for(let ke=0;ke<fe[he].length;ke++)ge.push(fe[he][ke])}}for(const[he,Re]of pe)ee.set(he,Uint32Array.from(Re))}return this.#R={key:J,map:ee},ee}#qe(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#We(){this.#Ze(),this.#Nt(),this.#E=null,this.#N=null,this.#P=null}#Ze(){this.#A.clear(),this.#O.length=0,this.#w=-1}#Nt(){this.#v.clear(),this.#S.length=0,this.#T=-1}#Rt(_){const J=this.#z("pivotBy",[]);if(!J.length)return this.#fe=null,null;const ee=(this.#e.compute||{}).pivot;if(!K(ee))return B("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#fe=null,null;const ne=J.map(oe=>this.#o.handle(oe)).filter(Boolean),se=this.#st();return this.#fe=ee(ne,_.leaves,{groups:_.keys&&_.buckets?{keys:_.keys,buckets:_.buckets}:null,totals:se.map(oe=>oe.id),handle:oe=>this.#o.handle(oe),totalOf:oe=>I(se.find(fe=>fe.id===oe),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#fe}#j(_){const J=this.#l.get("total").result,ee=!!(this.#e.config||{}).groupFooter,ne=this.#Be();if(_.tree)return this.#He(_,J,ne);if(!_.roots&&!ne){if(J&&J.grand&&!this.#ge()){const Re=this.#s.grandTotal(J.grand,this.#nt(_.leaves.length));if(this.#K===_.leaves&&Array.isArray(this.#D))this.#D[this.#D.length-1]=Re;else{const Ue=Array.from(_.leaves);Ue.push(Re),this.#D=Ue,this.#K=_.leaves}this.#B=[{at:this.#D.length-1}]}else this.#K=null,this.#D=_.leaves,this.#B=V;return this.#H=V,this.#D}const se=[],oe=[],fe=[],pe=Re=>{if(se.push(Re),!ne)return;const Ue=this.#ee(Re);!Ue||!ne.isOpen(Ue.key)||(Ue.master=!0,Ue.expanded=!0,fe.push({at:se.length}),se.push(this.#s.detail(Ue,ne.heightOf(Ue))))};if(!_.roots){for(let Re=0;Re<_.leaves.length;Re++)pe(_.leaves[Re]);return J&&J.grand&&!this.#ge()&&(fe.push({at:se.length}),se.push(this.#s.grandTotal(J.grand,this.#nt(_.leaves.length)))),this.#K=null,this.#H=V,this.#B=fe.length?fe:V,this.#D=se,se}const he=(Re,Ue,Le)=>{if(Re.expanded=Re.hasChildren===!1?!1:this.#ut(Re.key,{key:Re.key,column:Re.groupColumn,value:Re.groupValue,level:Re.level,path:Re.groupPath}),Re.posinset=Ue+1,Re.setsize=Le,oe.push({at:se.length,row:Re}),fe.push({at:se.length}),se.push(Re),!!Re.expanded){if(Re.children&&Re.children.length)for(let ie=0;ie<Re.children.length;ie++)he(Re.children[ie],ie,Re.children.length);else{const ie=_.nodes.get(Re.key),ge=ie&&ie.leaves?ie.leaves:null;if(ge)for(let ke=0;ke<ge.length;ke++)pe(ge[ke])}ee&&Re.totals&&(fe.push({at:se.length}),se.push(this.#s.footer(Re)))}};for(let Re=0;Re<_.roots.length;Re++)he(_.roots[Re],Re,_.roots.length);return J&&J.grand&&!this.#ge()&&(fe.push({at:se.length}),se.push(this.#s.grandTotal(J.grand,this.#nt(_.leaves.length)))),this.#H=oe,this.#B=fe,this.#D=se,se}#Ke(){const _=this.#e.store;if(_&&K(_.liveIndices))return _.liveIndices();const J=new Uint32Array(this.#n.length);let ee=0;for(let ne=0;ne<this.#n.length;ne++)this.#n[ne]!==void 0&&(J[ee++]=ne);return J.subarray(0,ee)}#Fe(){const _=this.#e.store;return _&&typeof _.physical=="number"?_.physical:this.#n.length}#ue(_){const J=this.#e.store;return J&&K(J.source)?J.source(_):this.#n[_]}#Ne(_,J=_){const ee=this.#D[_];if(typeof ee!="number")return ee.index=J,ee;const ne=this.#ee(ee);return ne.index=J,ne}#ee(_){let J=this.#h.get(_);J||(J=this.#s.leaf(this.#ue(_),_),this.#h.set(_,J));const ee=this.#$?this.#$.get(_):null;if(ee){J.level=ee.level,J.posinset=ee.posinset,J.setsize=ee.setsize,J.hasChildren=ee.hasChildren,J.expanded=ee.hasChildren&&!ee.lazy&&this.#ut(J.key);const ne=this.#G?this.#G.byPhysical.get(_):void 0;ne?J.totals=ne:J.totals&&(J.totals=null)}else J.hasChildren&&(J.level=0,J.hasChildren=!1,J.expanded=!1,J.posinset=void 0,J.setsize=void 0);return J}#He(_,J,ee){const ne=[],se=[],oe=pe=>{if(pe.leafCount!==void 0)return pe.leafCount;let he=pe.physical>=0?1:0;for(const Re of pe.children)he+=oe(Re);return pe.leafCount=he,he},fe=pe=>{const he=this.#ut(pe.key);if(pe.physical>=0){if(ne.push(pe.physical),ee&&ee.isOpen(this.#ee(pe.physical).key)){const Re=this.#ee(pe.physical);se.push({at:ne.length}),ne.push(this.#s.detail(Re,ee.heightOf(Re)))}}else ne.push(this.#s.group({path:[pe.key],column:null,value:pe.value,level:pe.level,parent:null,expanded:he,hasChildren:pe.children.length>0,leafCount:oe(pe),totals:this.#G?this.#G.byKey.get(pe.key):void 0}));if(he)for(const Re of pe.children)fe(Re)};for(const pe of _.tree.roots)fe(pe);return J&&J.grand&&!this.#ge()&&(se.push({at:ne.length}),ne.push(this.#s.grandTotal(J.grand,this.#nt(_.leaves.length)))),this.#K=null,this.#H=V,this.#B=se.length?se:V,this.#D=ne,ne}#ct(){return r(()=>this.count(),_=>this.at(_))}#vt(_,J){let ee=this.#x.get(_);if(ee===void 0){const ne=this.#ue(_),se=this.#St(),oe=[],fe=this.#e.columnHidden;for(const pe of se){if(pe.quickFilter===!1||K(fe)&&fe(pe.id))continue;const he=pe.value&&K(pe.value.quickFilterText)?pe.value.quickFilterText({value:void 0,data:ne,row:null,column:pe,colId:pe.id,grid:null,context:this.#z("context",null)}):null,Re=he??(K(pe.formatValue)?pe.formatValue(K(pe.getValue)?pe.getValue(ne):void 0):"");Re!=null&&Re!==""&&oe.push(String(Re))}ee=oe.join(" ").toLowerCase(),this.#x.set(_,ee)}return J(ee)}#st(){const _=this.#z("totals",[]),J=_&&_.length?new Set(_):null;return this.#St().filter(ee=>J?J.has(ee.id):!!(ee.total||ee.groupTotal||ee.grandTotal))}#Ye(_,J,ee,ne="group"){const se={},oe=(this.#e.compute||{}).total;for(const fe of _){if(!$(fe))continue;const pe=this.#o.handle(fe.id);if(!pe)continue;const he=I(fe,ne);if(he)if(K(he)){const Re=new Array(J.length);for(let Ue=0;Ue<J.length;Ue++)Re[Ue]=pe.get(J[Ue]);se[fe.id]=he(Re,{row:ee,column:fe,grid:this.#e.grid||null,context:this.#z("context",null),valueAt:(Ue,Le)=>{const ie=this.#o.handle(Ue);return ie&&Le>=0&&Le<J.length?ie.get(J[Le]):null}})}else K(oe)&&(se[fe.id]=oe(pe,J,he))}return se}#kt(_){if(!_)return _;const J=this.#e.config||{},ee={tz:J.timeZone,weekStartsOn:J.weekStartsOn};return g(_,ne=>{const se=k(ne,ee),oe=this.#ze(se&&se.col),fe=oe&&oe.type==="datetime";if(se&&se.type)return se.type==="datetime"&&!se.timeZone&&oe?{...se,timeZone:J.timeZone||void 0}:se;if(fe)return{...se,type:"datetime",timeZone:J.timeZone||void 0};const pe=oe&&(oe.dataType?.base||oe.type);return pe?{...se,type:pe}:se})}#ut(_,J){const ee=this.#z("expanded",null);return ee?K(ee.has)?ee.has(_,J):Array.prototype.includes.call(ee,_):!0}#z(_,J){if(_==="context"||!K(this.#e.stateVersion))return this.#$t(_,J);const ee=this.#Ot(_),ne=this.#f.get(_);if(ne&&ne.version===ee)return ne.value;const se=this.#$t(_,J);return this.#f.set(_,{version:ee,value:se}),se}#$t(_,J){const ee=this.#e.state;if(ee&&K(ee[_])){const ne=ee[_]();return ne??J}return J}#Qe(){const _=this.#e.stateVersion;return K(_)?_():0}#It(){const _=this.#e.columnsVersion,J=this.#e.permissionsVersion;return`${K(_)?_():0}|${K(J)?J():0}`}#Ot(_){return _==="totals"?this.#It():`${this.#Qe()}`}#it(_,J,ee){if(!K(this.#e.stateVersion))return ee();const ne=this.#d.get(_);if(ne&&ne.version===J)return ne.key;const se=ee();return this.#d.set(_,{version:J,key:se}),se}#ot(_){const J=(this.#e.compute||{})[_];return K(J)||D(`ctx.compute.${_} is required by the memory source pipeline`),J}#St(){const _=this.#e.columns;return _&&K(_.all)?_.all():[]}#ze(_){const J=this.#e.columns;return J&&K(J.get)?J.get(_):void 0}#Je(_,J){const ee=this.#e.emit;K(ee)&&ee(_,J)}}}),Ie("packages/core/src/source/abort.js",function(e,U){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return D}});class te extends Error{constructor(K,x="superseded"){super(`[lattice] request ${K?`"${K}" `:""}${x}`),this.name="SupersededError",this.superseded=!0,this.key=K}}class N{#e;constructor(K,x,G,z){this.#e=K,this.key=x,this.controller=G,this.signal=G.signal,this.seq=z}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(K){this.signal.aborted||this.controller.abort(new te(this.key,K)),this.#e.settle(this)}}class X{#e=new Map;#t=0;begin(K="",x="superseded"){const G=this.#e.get(K);G&&!G.signal.aborted&&G.controller.abort(new te(K,x));const z=new N(this,K,new AbortController,++this.#t);return this.#e.set(K,z),z}tokenFor(K){return this.#e.get(K)}pending(K=""){const x=this.#e.get(K);return!!x&&!x.signal.aborted}get size(){return this.#e.size}settle(K){this.#e.get(K.key)===K&&this.#e.delete(K.key)}abort(K="",x="superseded"){const G=this.#e.get(K);G&&G.abort(x)}abortAll(K="superseded"){for(const x of[...this.#e.values()])x.abort(K);this.#e.clear()}}function B(){return new X}function D(q){if(!q||typeof q!="object")return!1;const K=q;return K.superseded===!0||K.name==="AbortError"||K.name==="SupersededError"}}),Ie("packages/core/src/source/blockcache.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return B}});const te=100,N=32;class X{constructor(q){this.id=q,this.rows=null,this.state="pending",this.token=null,this.error=null}}class B{#e=new Map;#t;#n;#r=0;#i=-1;constructor(q={}){this.#t=Math.max(1,Math.floor(Number(q.pageSize)||te)),this.#n=Math.max(1,Math.floor(Number(q.maxCachedPages)||N))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(q){return Math.floor(q/this.#t)}rangeOf(q){return{start:q*this.#t,end:(q+1)*this.#t}}has(q){return this.#e.has(q)}pending(q){const K=this.#e.get(q);return!!K&&K.state==="pending"}loaded(q){const K=this.#e.get(q);return!!K&&K.state==="loaded"}begin(q,K){let x=this.#e.get(q);return x||(x=new X(q)),x.state="pending",x.token=K,x.error=null,this.#s(q,x),x}fill(q,K){const x=this.#e.get(q)||new X(q);x.rows=K,x.state="loaded",x.token=null,this.#s(q,x)}failed(q,K){const x=this.#e.get(q)||new X(q);x.state="error",x.error=K,x.token=null,this.#s(q,x)}delete(q){return this.#e.delete(q)}rowAt(q){const K=this.blockOf(q),x=this.#e.get(K);if(!(!x||x.state!=="loaded"||!x.rows))return this.#s(K,x),x.rows[q-K*this.#t]}rowLoaded(q){const K=this.blockOf(q),x=this.#e.get(K);return!!x&&x.state==="loaded"&&!!x.rows&&q-K*this.#t<x.rows.length}erroredAt(q){const K=this.#e.get(this.blockOf(q));return!!K&&K.state==="error"}loadedExtent(){let q=0;for(const K of this.#e.values()){if(K.state!=="loaded"||!K.rows)continue;const x=K.id*this.#t+K.rows.length;x>q&&(q=x)}return q}fillOf(q){const K=this.#e.get(q);return K&&K.state==="loaded"&&K.rows?K.rows.length:null}protect(q,K){this.#r=this.blockOf(Math.max(0,q)),this.#i=this.blockOf(Math.max(0,K))}evict(){const q=[];if(this.#e.size<=this.#n)return q;for(const[K,x]of this.#e){if(this.#e.size-q.length<=this.#n)break;K>=this.#r&&K<=this.#i||x.state!=="pending"&&q.push(K)}for(const K of q)this.#e.delete(K);return q}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#s(q,K){this.#e.delete(q),this.#e.set(q,K)}}}),Ie("packages/core/src/source/pagewindow.js",function(e,U){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return te}});function te(N,X,B,D){const q=Math.floor(Number(N)||0);if(q<=0)return null;const K=Math.max(0,Math.floor(Number(X)||0)),x=Math.max(0,Math.floor(Number(B)||0));if(D){const G=Math.max(1,Math.ceil(x/q)),z=Math.min(K,G-1),j=z*q;return{page:z,pageSize:q,offset:j,length:Math.max(0,Math.min(q,x-j)),pageCount:G,total:x}}return{page:K,pageSize:q,offset:K*q,length:q,pageCount:Math.max(K+2,Math.ceil(x/q)),total:null}}}),Ie("packages/core/src/source/paged.js",function(e,U){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return w}});const N=U("packages/core/src/internal/lru.js").Lru,B=U("packages/core/src/internal/predicates.js").isFunction,q=U("packages/core/src/internal/warn.js").warnOnce,x=U("packages/core/src/internal/schedule.js").settleDebounce,G=U("packages/core/src/source/abort.js"),z=G.createAbortScope,j=G.isAbortError,O=U("packages/core/src/source/blockcache.js"),b=O.BlockCache,u=O.DEFAULT_PAGE_SIZE,f=O.DEFAULT_MAX_CACHED_PAGES,r=U("packages/core/src/source/rows.js").createRowFactory,t=U("packages/core/src/source/filterwire.js"),s=t.wireFilters,i=t.querySignature,n=t.warnHostFilterNotApplied,o=U("packages/core/src/source/pagewindow.js").pageWindow,l=120;function h(g,k){return new w(g,k)}class w{mode="paged";#e;#t;#n;#r=z();#i;#s;#o=new Map;#l=null;#a=null;#c=!1;#u=0;#f="";#d={start:0,end:0};#h;#p=!1;#m=0;#g="";constructor(k,d){this.#e=k||{mode:"paged"},this.#t=d||{},this.#n=new b({pageSize:this.#e.pageSize||u,maxCachedPages:this.#e.maxCachedPages||f}),this.#i=r(this.#t),this.#s=new N(this.#n.pageSize*4),this.#h=x((p,m)=>this.#w(p,m),l),this.#f=this.#E(),B(this.#e.fetch)||q("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),n(this.#t)}count(){const k=this.#y();return k?k.length:this.#b()}#b(){if(this.#T(),this.#l!==null)return this.#l;const k=Math.max(this.#u,this.#n.loadedExtent());return this.#c?k:k+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const k=this.#y();if(!k){const d=this.#b();return{page:0,pageSize:0,total:this.exact()?d:null,pageCount:1,counting:!1}}return{page:k.page,pageSize:k.pageSize,total:k.total,pageCount:k.pageCount,counting:k.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const k=this.#b(),d=o(this.#P("pageSize",0),this.#P("page",0),k,this.exact());if(!d)return this.#g="",null;const p=`${this.#m}:${d.offset}:${d.length}`;if(p!==this.#g&&!this.#p&&(this.#g=p,d.length>0)){const m=d.offset+d.length-1;this.#d={start:d.offset,end:m},this.#w(d.offset,m)}return d}at(k){const d=this.#y();if(d){if(k<0||k>=d.length)return;const p=this.#A(d.offset+k);return p&&(p.index=k),p}return this.#A(k)}#A(k){if(k<0||k>=this.#b())return;const d=this.#s.get(k);if(d&&(d.data!==null||!this.#n.rowLoaded(k)))return d;const p=this.#n.rowAt(k);if(p===void 0){const v=this.#i.skeleton(k,0,this.#n.erroredAt(k));return this.#s.set(k,v),v}const m=this.#i.leaf(p,k);return m.index=k,this.#s.set(k,m),this.#o.set(m.key,k),m}byKey(k){const d=this.#o.get(k);return d===void 0?void 0:this.#A(d)}loaded(k){const d=this.#y();return d?k>=0&&k<d.length&&this.#n.rowLoaded(d.offset+k):this.#n.rowLoaded(k)}loadedCount(){this.#T();let k=0;for(const d of this.#n.ids()){if(!this.#n.loaded(d))continue;const p=this.#n.fillOf(d);typeof p=="number"&&(k+=p)}return k}residentRows(){this.#T();const k=this.#y(),d=k?k.offset:0,p=k?k.offset+k.length:1/0,m=[],v=this.#n.ids().sort((y,E)=>y-E);for(const y of v){if(!this.#n.loaded(y))continue;const{start:E}=this.#n.rangeOf(y),M=this.#n.fillOf(y)||0;for(let F=E;F<E+M;F++){if(F<d||F>=p)continue;const V=this.#s.peek(F);if(V&&V.data!==null&&V.data!==void 0){m.push(V);continue}const I=this.#n.rowAt(F);if(I===void 0)continue;const $=this.#i.leaf(I,F);$.index=F,this.#s.set(F,$),this.#o.set($.key,F),m.push($)}}return m}hint(k,d){if(this.#p)return;const p=this.#T();let m=Math.max(0,Math.floor(k)),v=Math.max(m,Math.floor(d));const y=this.#y();if(y){if(y.length===0)return;m=y.offset,v=y.offset+y.length-1}this.#d={start:m,end:v},this.#n.protect(m,v);for(const E of this.#n.evict())this.#v(E);this.#h(m,v),p&&this.#h.flush()}#w(k,d){if(this.#p)return;this.#n.protect(k,d);const p=this.#n.blockOf(k),m=this.#n.blockOf(d);for(let v=p;v<=m&&!(this.#l!==null&&v*this.#n.pageSize>=this.#l);v++)this.#n.has(v)||this.#O(v)}apply(k){const d={added:[],updated:[],removed:[]};if(!k)return d;if(k.update)for(const p of k.update){const m=this.#i.keyOf(p,-1),v=this.#o.get(m);if(v===void 0)continue;const y=this.#i.leaf(p,v);y.index=v,this.#s.set(v,y),d.updated.push(y)}return(k.add&&k.add.length||k.remove&&k.remove.length)&&this.reload(),d}reload(k){this.#S("reload"),this.#h.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#p=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#s.clear(),this.#o.clear()}exact(){return this.#l!==null||this.#c}pending(){return this.#r.size}async#O(k){if(!B(this.#e.fetch))return;const d=this.#r.begin(`block:${k}`);this.#n.begin(k,d);const{start:p,end:m}=this.#n.rangeOf(k),v=this.#f;try{const y=await this.#e.fetch({range:{start:p,end:m},sort:this.#P("sort",[]),filters:s(this.#P("filters",null),this.#N()),quick:this.#P("quick","")||void 0,context:this.#P("context",null),signal:d.signal});if(!d.current||v!==this.#f||this.#p)return;d.settle();const E=y&&y.rows||[];this.#n.fill(k,E);for(let F=0;F<E.length;F++)this.#s.delete(p+F);const M=y&&typeof y.total=="number"?y.total:y&&typeof y.count=="number"?y.count:null;M!==null?(this.#l=M,this.#c=!0):E.length<this.#n.pageSize?(this.#c=!0,this.#l=p+E.length):this.#u=Math.max(this.#u,p+E.length),this.#M("model:changed",{reason:"page",block:k,from:p,to:p+E.length}),this.#M("rows:changed",{companion:!0,reason:"page",block:k,from:p,to:p+E.length}),this.#l!==null&&this.#l!==this.#a&&(this.#a=this.#l,this.#M("source:total",{total:this.#l,groupPath:[]}))}catch(y){if(d.settle(),j(y))return;this.#n.failed(k,y);for(let E=p;E<m;E++)this.#s.delete(E);this.#M("model:changed",{reason:"page-error",block:k,range:{start:p,end:m}}),this.#M("source:error",{error:y,block:k,range:{start:p,end:m}})}}#v(k){const{start:d,end:p}=this.#n.rangeOf(k);for(let m=d;m<p;m++){const v=this.#s.peek(m);v&&this.#o.delete(v.key),this.#s.delete(m)}}#T(){const k=this.#E();return k===this.#f?!1:(this.#f=k,this.#S("query"),!0)}#S(k){this.#r.abortAll(k),this.#n.clear(),this.#s.clear(),this.#o.clear(),this.#l=null,this.#a=null,this.#c=!1,this.#u=0,this.#m++,this.#M("model:changed",{reason:k})}#E(){return i({filters:this.#P("filters",null),sort:this.#P("sort",[]),quick:this.#P("quick",""),context:this.#P("context",null)})}#N(){const k=this.#t.config||{};return{tz:k.timeZone,weekStartsOn:k.weekStartsOn}}#P(k,d){const p=this.#t.state;if(p&&B(p[k])){const m=p[k]();return m??d}return d}#M(k,d){const p=this.#t.emit;B(p)&&p(k,d)}}}),Ie("packages/core/src/source/aggregates.js",function(e,U){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return G}});const te=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function N(){const z=new Set;for(const[j,O]of Object.entries(te))O.pushable&&z.add(j);return z}function X(z,j,O){let b=z.split("%c").join(j);return O!==void 0&&(b=b.split("%w").join(O)),b}function B(z){const j=z||{},O=j.default==="engine"||j.default==="engine-if-identical"?j.default:"client",b={};if(j.overrides&&typeof j.overrides=="object")for(const[u,f]of Object.entries(j.overrides))(f==="engine"||f==="client")&&(b[u]=f);return{default:O,overrides:b}}function D(z,j){const O=te[z];if(!O||!O.pushable)return"client";const b=j.overrides[z];return b==="engine"||b==="client"?b:j.default==="client"?"client":j.default==="engine-if-identical"?O.class==="identical"?"engine":"client":"engine"}function q(z,j){const O=B(j),b=[],u=[];for(const f of z||[]){const a=te[f.fn],r=D(f.fn,O),t={id:f.id,col:f.col,fn:f.fn,class:a?a.class:"fallback"};f.weight!==void 0&&(t.weight=f.weight),f.params!==void 0&&(t.params=f.params),r==="engine"?b.push(t):(t.reason=a&&!a.pushable?a.note||"the engine cannot express this stat":"client by config",u.push(t))}return{engine:b,client:u,config:O}}const K=/^[A-Za-z_][A-Za-z0-9_$]*$/;function x(z,j=[]){return(z||[]).every(b=>{if(typeof b=="string")return K.test(b);if(!b||typeof b!="object")return!1;const u=b;return Array.isArray(j)&&j.includes(u.bucket)&&typeof u.col=="string"&&K.test(u.col)&&typeof u.size=="number"&&Number.isFinite(u.size)&&u.size>0})}function G(){return Object.entries(te).map(([z,j])=>({stat:z,class:j.class,sql:j.sql?X(j.sql,"col",j.twoColumn?"weight":void 0):"",note:j.note||(j.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Ie("packages/core/src/source/pushdown.js",function(e,U){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return Z}});const N=U("packages/core/src/internal/compare.js").defaultCompare,B=U("packages/core/src/internal/predicates.js").isFunction,q=U("packages/core/src/internal/merge.js").toArray,x=U("packages/core/src/internal/warn.js").warnOnce,G=U("packages/core/src/source/filterwire.js"),z=G.isGroup,j=G.warnWherePageRelative,O=G.warnWhereOverThreshold,b=G.wireFilters,u=U("packages/core/src/source/aggregates.js"),f=u.resolveAggregatePlan,a=u.groupKeysPushable,r=u.STAT_PUSHDOWN,s=U("packages/core/src/source/abort.js").SupersededError,i=1e3;function n(_){const J=_&&_.signal;if(!J||!J.aborted)return;const ee=J.reason;throw ee instanceof Error?ee:new s("","superseded before it was sent")}const c=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function o(_){if(!_||typeof _!="object")return!1;const J=_.returning==="row"||_.returning==="key"?_.returning:"none";return{append:_.append===!0,update:_.update===!0,delete:_.delete===!0,returning:J}}function l(_,J){if(!_||typeof J!="string")return;if(!J.includes("."))return _[J];let ee=_;for(const ne of J.split(".")){if(ee===null||typeof ee!="object")return;ee=ee[ne]}return ee}function h(_){if(_===!0)return!0;if(!_||typeof _!="object")return!1;const J=_;return J.enabled===!1?!1:J.enabled===!0||B(J.commit)}function w(_){const J={...c,..._||{}};return J.operators=new Set(J.operators||[]),J.mutate=o(J.mutate),J}function g(_,J){return!_||!_.op||!J.operators.size?!1:J.operators.has(_.op)}function k(_,J){if(!_)return{pushed:null,residual:null};if(!J.filter)return{pushed:null,residual:_};if(J.filter==="term"){if(z(_)){const oe=_.conditions||[];if(String(_.op)!=="and")return{pushed:null,residual:_};const fe=oe.findIndex(he=>!z(he)&&g(he,J));if(fe<0)return{pushed:null,residual:_};const pe=oe.filter((he,Re)=>Re!==fe);return{pushed:oe[fe],residual:pe.length?{op:"and",conditions:pe}:null}}return g(_,J)?{pushed:_,residual:null}:{pushed:null,residual:_}}if(!z(_))return g(_,J)?{pushed:_,residual:null}:{pushed:null,residual:_};if(String(_.op)!=="and")return(_.conditions||[]).every(fe=>z(fe)?k(fe,J).residual===null:g(fe,J))?{pushed:_,residual:null}:{pushed:null,residual:_};const ee=[],ne=[];for(const oe of _.conditions||[]){if(z(oe)){if(J.filter==="flat"){ne.push(oe);continue}const fe=k(oe,J);fe.pushed&&ee.push(fe.pushed),fe.residual&&ne.push(fe.residual);continue}(g(oe,J)?ee:ne).push(oe)}const se=oe=>oe.length===0?null:oe.length===1?oe[0]:{op:"and",conditions:oe};return{pushed:se(ee),residual:se(ne)}}const d="__lattice_leaves";function p(_){return _.aggregates?_.aggregates instanceof Set?_.aggregates:new Set(q(_.aggregates)):new Set}function m(_){const J=p(_);return J.size?J.has("count")?_.filter!=="tree"||!_.operators||!_.operators.has("eq")?"the adapter does not declare the `group` capability, and cannot narrow a group's rows by its key (that needs a `tree` filter with the `eq` operator)":"":"the adapter does not declare the `group` capability, and its declared aggregates have no `count` to give each group its row count":"the adapter does not declare the `group` capability"}function v(_,J,ee,ne,se,oe,fe){const pe=Array.isArray(_.groupBy)?_.groupBy:[],he=Array.isArray(_.groupPath)?_.groupPath:[],Re=Array.isArray(_.groupValues)?_.groupValues:null;if(!J.group){const Ue=m(J);if(Ue)return Ue}return a(pe)?ee.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":ne?se?oe?"a host `where` predicate can only run in the browser, over rows the engine grouped":fe?"fullDataset holds the whole matching set, so the grid groups it itself":!Re||Re.length!==he.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",E="pushdown:group-unsupported",M=Symbol("lattice.remote.ungroupedLevel");function F(_,J,ee,ne,se,oe){const fe=Array.isArray(_.pivotBy)?_.pivotBy:[],pe=Array.isArray(_.groupBy)?_.groupBy:[],he=Array.isArray(_.groupPath)?_.groupPath:[],Re=Array.isArray(_.groupValues)?_.groupValues:null;return J.pivot?a(fe)?pe.length&&!a(pe)?"a grouping key is not a plain column the engine can name in a GROUP BY":ee.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":ne?se?oe?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!Re||Re.length!==he.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(_,J,ee=!1){const ne=k(_.filters||null,J),se=[];ne.residual&&se.push("filter");const oe=_.sort||[],fe=oe.length===0||J.sort==="multi"&&oe.length>=1||J.sort==="single"&&oe.length===1;!fe&&oe.length&&se.push("sort");const pe=_.quick?String(_.quick):"",he=!pe||!!J.quick;he||se.push("quick");const Re=_.where&&_.where.active?_.where:null;Re&&se.push("where");const Ue={filters:ne.residual,sort:fe?null:oe,quick:he?"":pe,where:Re},Le=!!ee,ie=Array.isArray(_.groupBy)&&_.groupBy.length>0,ge=ie?v(_,J,ne,fe,he,Re,Le):"",ke=_.pivotMode!==!1&&Array.isArray(_.pivotBy)&&_.pivotBy.length>0,Se=ke?F(_,J,ne,fe,he,Re):"",Ae=ke&&Se==="";ke&&!Ae&&se.push("pivot");const xe=ke?Ae&&ie:ie&&ge==="";ie&&!ke&&!xe&&se.push("group");const me=(xe||Ae)&&Array.isArray(_.groupValues)?_.groupValues.length:0,ye=xe||ke?!1:Le||!!(Ue.filters||Ue.sort||Ue.quick||Ue.where)||!J.range;return{pushed:{..._,filters:ne.pushed,sort:fe?oe:[],quick:he?pe:"",range:ye?null:_.range},residual:Ue,needsAll:ye,unpushed:se,full:Le,grouped:xe,groupLevel:me,groupReason:ke?"":ge,pivoted:Ae,pivotReason:Se}}function I(_){const J=Array.isArray(_.totals)?_.totals:[],ee=_.totalFns&&typeof _.totalFns=="object"?_.totalFns:{},ne=[],se=[];for(const oe of J){const fe=String(oe),pe=typeof ee[fe]=="string"?ee[fe]:null,he=pe?r[pe]:null;pe?!he||!he.pushable||!he.sql?se.push({id:fe,fn:pe,class:he?he.class:"fallback",reason:he&&he.note?he.note:`the pushdown map cannot express "${pe}"`}):he.twoColumn?se.push({id:fe,fn:pe,class:he.class,reason:`"${pe}" reduces two columns, and a grouped request carries no weight column`}):ne.push({id:fe,col:fe,fn:pe,class:he.class}):se.push({id:fe,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:ne,client:se}}const $=Object.freeze({items:_=>_==null?[]:Array.isArray(_)?_:[_]});function S(_,J,ee){if(!J)return _;let ne=_;if(J.filters&&B(ee.evaluateFilters)){const se=ne,oe={count:ne.length,handle:he=>({id:he,get:Re=>l(se[Re],he)}),itemwise:he=>se.some(Re=>Array.isArray(l(Re,he)))?$:null},fe=ee.evaluateFilters(J.filters,oe),pe=[];for(let he=0;he<ne.length;he++)fe[he]&&pe.push(ne[he]);ne=pe}if(J.where&&J.where.active&&(J.whole||j(J.where.names,"pushdown"),ne=ne.filter(se=>J.where.passes(se))),J.quick){const se=J.quick.toLowerCase();ne=ne.filter(oe=>{if(!oe||typeof oe!="object")return!1;for(const fe of Object.values(oe))if(fe!=null&&String(fe).toLowerCase().includes(se))return!0;return!1})}if(J.sort&&J.sort.length&&B(ee.sortMulti)){const se=[...new Set(J.sort.map(he=>he.col))],oe=ne,fe=se.map(he=>({id:he,get:Re=>l(oe[Re],he)})),pe=ee.sortMulti(fe,J.sort.map(he=>({col:he.col,dir:he.dir})),Uint32Array.from({length:ne.length},(he,Re)=>Re),{});ne=Array.from(pe,he=>oe[he])}return ne}function R(_){return JSON.stringify({filters:_.filters||null,sort:_.sort||[],quick:_.quick||"",groupBy:_.groupBy||[],groupPath:_.groupPath||[],context:_.context??null})}function L(_){if(!_||typeof _!="object")return 16;let J="";try{J=JSON.stringify(_)}catch{return 200}return J.length*2+64}function T(_){const J=_||{};return{enabled:!!J.enabled,maxRows:Number.isFinite(J.maxRows)?J.maxRows:1e6,maxBytesEstimate:Number.isFinite(J.maxBytesEstimate)?J.maxBytesEstimate:512*1024*1024}}const A=5e4;function C(_){return Number.isFinite(_)&&_>=0?_:A}function H(_){return!!_&&B(_.then)}async function Y(_){if(!_||_.total!==void 0||!H(_.pendingTotal))return _;const J=await _.pendingTotal,{pendingTotal:ee,...ne}=_;return typeof J=="number"?{...ne,total:J}:ne}function Z(_={}){const J=_.adapter;if(!J||!B(J.execute))return x("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{..._,mode:"remote",fetch:async()=>({rows:[],total:0})};const ee=w(J.capabilities),ne=J.capabilities&&Object.getOwnPropertyDescriptor(J.capabilities,"operators");ne&&B(ne.get)&&Object.defineProperty(ee,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(J.capabilities.operators||[]),set:()=>{}});const se=J.name||"adapter";let oe=null;const fe=()=>B(J.ready)?(oe||(oe=Promise.resolve(J.ready()).then(()=>{Object.assign(ee,w(J.capabilities))},ue=>{throw oe=null,ue})),oe):null,pe=T(_.fullDataset),he=!!_.allowPartialResults,Re=C(_.whereRowLimit);let Ue=null;const Le=_.aggregates;let ie=null,ge=null,ke=null,Se=null,Ae=null,xe,me=null,ye=0,Te=null;const Ye=()=>!pe.enabled||!ie?null:(Te!==ie.key&&(ye++,Te=ie.key),{rows:ie.rows,version:ye}),Oe=async ue=>{const ve=ue.where&&ue.where.active?ue.where:null;if(!ve)return{request:ue,probe:null};const{where:Ce,...Ee}=ue,Fe=V(Ee,ee,pe.enabled);if(Fe.needsAll)return{request:ue,probe:null};const Be=R(Fe.pushed);let Ve=null;return(!Ue||Ue.key!==Be)&&(ee.total?(n(ue),Ve=await Y(await J.execute(Fe.pushed,ue)),Ue={key:Be,size:Ve&&typeof Ve.total=="number"?Ve.total:null}):Ue={key:Be,size:null}),Ue.size!==null&&Ue.size<Re?{request:ue,probe:null}:(O(ve.names,se,Ue.size,Re),{request:Ee,probe:Ve})},_e=async(ue,ve)=>{me=null;const Ce=I(ue.pushed);ke={engine:Ce.engine,client:Ce.client,groupBy:ue.pushed.groupBy},Ce.client.length&&x(`source.pushdown.group.totals.${se}.${Ce.client.map(Be=>Be.id).join(".")}`,`the ${se} adapter cannot compute the group subtotal for ${Ce.client.map(Be=>`"${Be.id}" (${Be.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 Ee=await J.executeGroupLevel(ue.pushed,Ce.engine,ve)||{};let Fe=Ee.rows||[];return!ee.range&&ve.range&&(Fe=Fe.slice(ve.range.start,ve.range.end)),Ke(Ee),Ee.total===void 0?{rows:Fe}:{rows:Fe,total:Ee.total}},je=new Map,we=64,He=async(ue,ve)=>{me=null;const Ce=ue.pushed,Ee=Ce.groupBy,Fe=Array.isArray(Ce.groupValues)?Ce.groupValues:[],Be=Fe.length,Ve=[...Ce.filters?[Ce.filters]:[],...Ee.slice(0,Be).map((bt,mt)=>({col:bt,op:"eq",value:Fe[mt]===void 0?null:Fe[mt],caseSensitive:!0}))],Je=Ve.length===0?null:Ve.length===1?Ve[0]:{op:"and",conditions:Ve},$e=ve.range?ve.range.start:0;if(Be>=Ee.length){const bt={...Ce,filters:Je,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},mt=await Y(await J.execute(bt,ve))||{};let $t=mt.rows||[];return!ee.range&&ve.range&&($t=$t.slice(ve.range.start,ve.range.end)),typeof mt.total=="number"?{rows:$t,total:mt.total}:{rows:$t}}const ze=Ee[Be],Qe=I(Ce),tt=p(ee),et=Qe.engine.filter(bt=>tt.has(bt.fn)),dt=[...Qe.engine.filter(bt=>!tt.has(bt.fn)).map(bt=>({id:bt.id,fn:bt.fn,class:bt.class,reason:`the ${se} adapter does not compute "${bt.fn}"`})),...Qe.client];ke={engine:et,client:dt,groupBy:Ee},dt.length&&x(`source.pushdown.group.totals.${se}.${dt.map(bt=>bt.id).join(".")}`,`the ${se} adapter cannot compute the group subtotal for ${dt.map(bt=>`"${bt.id}" (${bt.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 ft=[...et.map(bt=>({id:bt.id,col:bt.col,fn:bt.fn})),{id:d,col:ze,fn:"count"}],lt={...Ce,filters:Je,range:null},jt=JSON.stringify([R(lt),Fe,ze,ft]);let Tt=$e>0?je.get(jt):void 0;if(!Tt){for(Tt=Promise.resolve(J.executeGroupedAggregates(lt,[ze],ft)),je.delete(jt),je.set(jt,Tt);je.size>we;)je.delete(je.keys().next().value);Tt.catch(()=>{je.get(jt)===Tt&&je.delete(jt)})}const xt=await Tt||[];n(ve);const Ge=bt=>{const mt={};for(const $t of et)mt[$t.id]=bt?bt[$t.id]:void 0;return mt},vt=(Ce.sort||[]).find(bt=>bt&&bt.col===ze),ht=vt&&vt.dir==="desc"?-1:1,kt=xt.filter(bt=>bt&&bt.level===1).map(bt=>({[ze]:bt.keys[0]===void 0?null:bt.keys[0],leafCount:Number(bt.values&&bt.values[d])||0,totals:Ge(bt.values)})).sort((bt,mt)=>ht*N(bt[ze],mt[ze]));if(Be===0){const bt=xt.find($t=>$t&&$t.level===0),mt=bt?Number(bt.values&&bt.values[d]):NaN;Ke({matchCount:Number.isFinite(mt)?mt:kt.reduce(($t,Ht)=>$t+Ht.leafCount,0),...bt?{grand:Ge(bt.values)}:{}})}const Nt=ve.range?ve.range.end:kt.length;return{rows:kt.slice($e,Nt),total:kt.length}},Ke=ue=>{typeof ue.matchCount=="number"&&(Se=ue.matchCount,Ae=ue.grand?{totals:ue.grand,leafCount:ue.matchCount}:null,xe===void 0&&B(J.unfilteredCount)&&(xe=null,Promise.resolve(J.unfilteredCount()).then(ve=>{xe=typeof ve=="number"?ve:null}).catch(ve=>{x(`source.pushdown.group.unfiltered.${se}`,`the ${se} adapter could not count the unfiltered set (${ve&&ve.message?ve.message:ve}), so "N of M" falls back to the display count for its denominator.`)})))},Xe=async(ue,ve)=>{me=null;const Ce=I(ue.pushed);ke={engine:Ce.engine,client:Ce.client,groupBy:ue.pushed.groupBy,pivotBy:ue.pushed.pivotBy},Ce.client.length&&x(`source.pushdown.pivot.totals.${se}.${Ce.client.map(Je=>Je.id).join(".")}`,`the ${se} adapter cannot compute the pivot cells for ${Ce.client.map(Je=>`"${Je.id}" (${Je.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 Ee=await J.executePivotLevel(ue.pushed,Ce.engine,ve)||{};let Fe=Ee.rows||[];!ee.range&&ve.range&&(Fe=Fe.slice(ve.range.start,ve.range.end)),Ke(Ee);const Be=Ee.pivot&&typeof Ee.pivot=="object"?Ee.pivot:{},Ve={cells:Array.isArray(Be.cells)?Be.cells:[],...Array.isArray(Be.axis)?{axis:Be.axis}:{}};return Ee.total===void 0?{rows:Fe,pivot:Ve}:{rows:Fe,total:Ee.total,pivot:Ve}},nt=ue=>{x(`source.pushdown.pivot.${se}.${ue}`,`pushdown:pivot-unsupported: the ${se} adapter cannot pivot this query because ${ue}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const ve=new Error(`[lattice] ${y}: the ${se} adapter cannot pivot this query because ${ue}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw ve.code=y,ve.reason=ue,ve},it=(ue,ve)=>{const Ce={key:ve,state:"pending",value:null};return me=Ce,ue.then(Ee=>(me===Ce&&(me={key:ve,state:"settled",value:typeof Ee=="number"?Ee:null}),Ee),Ee=>{throw me===Ce&&(me={key:ve,state:"failed",value:null}),Ee})};let wt=0,pt=[];const St=()=>wt===0?null:new Promise(ue=>{const ve=setTimeout(ue,i);pt.push(()=>{clearTimeout(ve),ue()})});let Ct;const Mt=async ue=>{const ve=fe();ve&&await ve;const Ee=ue&&ue.pivotMode!==!1&&Array.isArray(ue.pivotBy)&&ue.pivotBy.length>0?{request:ue,probe:null}:await Oe(ue);n(ue);let Fe=V(Ee.request,ee,pe.enabled);if(ee.group&&Fe.grouped&&!Fe.pivoted&&!B(J.executeGroupLevel)&&(x(`source.pushdown.group.method.${se}`,`the ${se} 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.`),Fe=V(Ee.request,{...ee,group:!1,aggregates:null},pe.enabled)),Fe.pivoted&&!B(J.executePivotLevel)&&(Fe=V(Ee.request,{...ee,pivot:!1},pe.enabled),Fe.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),Fe.grouped&&!Fe.pivoted&&!ee.group&&!B(J.executeGroupedAggregates)&&(x(`source.pushdown.group.aggregates.method.${se}`,`the ${se} 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\`.`),Fe=V(Ee.request,{...ee,aggregates:null},pe.enabled)),ge=Fe,Fe.pivoted)return Xe(Fe,ue);if(Fe.pivotReason&&nt(Fe.pivotReason),Fe.grouped)return ee.group?_e(Fe,ue):He(Fe,ue);const Ve=!!Fe.groupReason&&!Fe.full;Ve?x(`source.pushdown.group-unsupported.${se}.${Fe.groupReason}`,`pushdown:group-unsupported: the ${se} adapter was not asked to group this query because ${Fe.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.`):Fe.groupReason&&x(`source.pushdown.group.${se}.${Fe.groupReason}`,`the ${se} adapter was not asked to group this query because ${Fe.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 Je=ft=>Ve?{...ft,[M]:!0}:ft;if(!Fe.needsAll){const ft=Ee.probe||await J.execute(Fe.pushed,ue),lt=ft.rows||[];return H(ft.pendingTotal)&&ft.total===void 0?Je({rows:lt,pendingTotal:it(ft.pendingTotal,R(Fe.pushed))}):(me=null,!ee.total&&ft.total===void 0?Je({rows:lt}):Je({rows:lt,total:ft.total??lt.length}))}Fe.unpushed.length&&x(`source.pushdown.residual.${se}.${Fe.unpushed.join(".")}`,`the ${se} adapter cannot push ${Fe.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=R(Fe.pushed);if(!ie||ie.key!==$e){const ft=await Y(await J.execute(Fe.pushed,ue));me=null;const lt=ft.rows||[];if(Fe.full){const jt=typeof ft.total=="number"?Math.max(ft.total,lt.length):lt.length;if(jt>pe.maxRows)throw new Error(`[lattice] fullDataset refused: the ${se} adapter's matching set is ${jt.toLocaleString()} rows, past the configured maxRows of ${pe.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 Tt=lt.length*L(lt[0]);if(Tt>pe.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${se} adapter's matching set is an estimated ${Math.round(Tt/(1024*1024)).toLocaleString()} MB across ${lt.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(pe.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 ft.total=="number"&<.length<ft.total){const jt=!!(Fe.residual.filters||Fe.residual.quick||Fe.residual.sort&&Fe.residual.sort.length);if(jt&&!he)throw new Error(`[lattice] the ${se} adapter returned ${lt.length} of ${ft.total} matching rows when asked for the whole result, and the query has residual ${Fe.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.`);jt?x(`source.pushdown.partial.residual.${se}`,`the ${se} adapter returned ${lt.length} of ${ft.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.`):x(`source.pushdown.partial.${se}`,`the ${se} adapter returned ${lt.length} of ${ft.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}ie={key:$e,rows:lt,total:typeof ft.total=="number"?ft.total:null}}let ze=Fe;if(Fe.residual.where){const ft=ie.total??ie.rows.length;if(ft>=Re){O(Fe.residual.where.names,se,ft,Re);const{where:lt,...jt}=Ee.request;ze=V(jt,ee,pe.enabled),ge=ze}}const Qe=ie.total!==null&&ie.rows.length>=ie.total,tt=S(ie.rows,{...ze.residual,whole:Qe},_.compute||{}),et=ue.range?ue.range.start:0,dt=ue.range?ue.range.end:tt.length;return Je({rows:tt.slice(et,dt),total:tt.length})},at=async(ue,ve,Ce)=>{const Fe=Ce&&Ce.waitForPage&&Ct&&B(Ct.pageForegroundIdle)?Ct.pageForegroundIdle():St();Fe&&await Fe;const Be=fe();Be&&await Be;const Ve=V(ue,ee,pe.enabled);ge=Ve;const Je=f(ve,Le),$e=Array.isArray(ue.groupBy)?ue.groupBy:[],ze=$e.length>0,Qe=!Ve.residual.filters&&!Ve.residual.quick,tt=!ze||a($e,ee.buckets);let et=Je.engine,dt=Je.client;if(ee.aggregates&&et.length){const Tt=ee.aggregates instanceof Set?ee.aggregates:new Set(q(ee.aggregates)),xt=et.filter(Ge=>!Tt.has(Ge.fn));xt.length&&(et=et.filter(Ge=>Tt.has(Ge.fn)),dt=[...xt.map(Ge=>({...Ge,reason:`the ${se} adapter does not compute "${Ge.fn}"`})),...dt])}const ft=Tt=>{dt=[...et.map(xt=>({...xt,reason:Tt})),...dt],et=[]};et.length&&!Qe?ft(Ve.residual.quick&&!Ve.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):et.length&&!tt&&ft("a grouping key the engine cannot form forces all-client (no mixed provenance)");let lt={},jt;return et.length&&(B(ze?J.executeGroupedAggregates:J.executeAggregates)?ze?jt=await J.executeGroupedAggregates(Ve.pushed,$e,et)||[]:lt=await J.executeAggregates(Ve.pushed,et)||{}:(x(`source.pushdown.aggregates.${se}${ze?".grouped":""}`,`the ${se} adapter cannot compute ${ze?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),ft(`adapter cannot compute ${ze?"grouped ":""}aggregates`))),ke={engine:et,client:dt,...ze?{groupBy:$e}:{}},{values:lt,engine:et,client:dt,...jt!==void 0?{groups:jt}:{}}},ot=async ue=>{wt++;try{return await Mt(ue)}finally{if(wt--,wt===0&&pt.length){const ve=pt;pt=[];for(const Ce of ve)Ce()}}},gt=h(_.edit),Et=_.edit&&typeof _.edit=="object"&&B(_.edit.commit);let ut=_.edit;if(gt&&!Et)if(ee.mutate&&ee.mutate.update){const ue=ve=>{if(!ee.mutate||!ee.mutate.update)throw new Error(`[lattice] the ${se} adapter cannot update rows (mutate.update is not declared), so this edit cannot be persisted. The cell is reverted rather than left looking saved.`);const Ce={kind:"update",key:String(ve.key),patch:{[ve.colId]:ve.value}};return J.mutate(Ce,ve.request||{})};ut={..._.edit===!0?{}:_.edit,commit:ue}}else x(`source.pushdown.readonly.${se}`,`edit is enabled but the ${se} adapter declares mutate: ${ee.mutate?"without update":"false"} (read-only by declaration), so no commit is synthesised and the grid stays read-only. Declare \`mutate: { update: true }\` on the adapter to allow cell edits.`);const de=gt&&ee.mutate&&(ee.mutate.append||ee.mutate.delete)?{append:ee.mutate.append===!0,remove:ee.mutate.delete===!0,returning:ee.mutate.returning,mutate:(ue,ve)=>J.mutate(ue,ve||{})}:null,Pe=async ue=>{const ve=fe();ve&&await ve;const{range:Ce,signal:Ee,export:Fe,...Be}=ue||{},Ve={...Be,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:V(Ve,ee,pe.enabled),signal:Ee}};async function*le(ue,ve={}){const{plan:Ce,signal:Ee}=await Pe(ue),Fe=Math.max(1,Math.floor(Number(ve.pageSize))||5e3),Be={signal:Ee,stream:!0};if(!Ce.needsAll)for(let $e=0;;$e+=Fe){n(Be);const ze=await J.execute({...Ce.pushed,range:{start:$e,end:$e+Fe}},Be);ze&&H(ze.pendingTotal)&&ze.pendingTotal.then(null,()=>{});const Qe=ze&&ze.rows||[];if(Qe.length&&(yield Qe),Qe.length<Fe)return}n(Be);const Ve=await Y(await J.execute({...Ce.pushed,range:void 0},Be)),Je=S(Ve&&Ve.rows||[],{...Ce.residual,whole:!0},_.compute||{});for(let $e=0;$e<Je.length;$e+=Fe)yield Je.slice($e,$e+Fe)}return Ct={..._,edit:ut,rowMutate:de,mode:"remote",fetch:ot,foregroundIdle:St,aggregate:at,countMatching:async ue=>{const{plan:ve,signal:Ce}=await Pe(ue);if(!ve.needsAll&&ee.total){n({signal:Ce});const Fe=await Y(await J.execute({...ve.pushed,range:{start:0,end:0}},{signal:Ce}));if(Fe&&typeof Fe.total=="number")return Fe.total}let Ee=0;for await(const Fe of le(ue))Ee+=Fe.length;return Ee},streamMatching:le,capabilitiesOf:w,planQuery:V,wireFilters:b,resolveAggregatePlan:ue=>f(ue,Le),STAT_PUSHDOWN:r,lastPlan:()=>ge?{...ge,...ke?{aggregates:ke}:{},...me?{total:{deferred:!0,state:me.state,value:me.value}}:{}}:null,fullFrame:Ye,counts:()=>({match:Se,total:xe??null,pending:!!me&&me.state==="pending"}),grandTotals:()=>Ae},Ct}}),Ie("packages/core/src/source/remote.js",function(e,U){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return R}});const N=U("packages/core/src/internal/lru.js").Lru,B=U("packages/core/src/internal/predicates.js").isFunction,q=U("packages/core/src/internal/warn.js").warnOnce,x=U("packages/core/src/internal/schedule.js").settleDebounce,G=U("packages/core/src/source/abort.js"),z=G.createAbortScope,j=G.isAbortError,O=U("packages/core/src/source/blockcache.js"),b=O.BlockCache,u=O.DEFAULT_PAGE_SIZE,f=O.DEFAULT_MAX_CACHED_PAGES,a=U("packages/core/src/source/rows.js"),r=a.createRowFactory,t=a.groupKey,s=U("packages/core/src/source/filterwire.js"),i=s.wireFilters,n=s.querySignature,c=s.warnHostFilterNotApplied,l=U("packages/core/src/source/pagewindow.js").pageWindow,w=U("packages/core/src/source/memory.js").MemorySource,k=U("packages/core/src/compute/handle.js").valueComparator,d=U("packages/core/src/compute/pivot.js"),p=d.pivotKey,m=d.joinPath,v=d.DEFAULT_PATH_SEPARATOR,E=U("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,M=1,F=120,V=1e3;function I(L,T,A){for(let C=0;C<Math.max(L.length,T.length);C++){const H=L[C],Y=T[C],Z=H==null,_=Y==null;if(Z||_){if(Z&&_)continue;return Z?1:-1}const J=A(H,Y);if(J!==0)return J}return 0}function $(L,T){return new R(L,T)}class S{constructor(T,A,C,H){this.path=T,this.keyPath=H||T,this.values=[],this.level=A,this.key=t(this.keyPath),this.cache=new b(C),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 R{mode="remote";#e;#t;#n;#r;#i=new Map;#s=new Set;#o=z();#l;#a;#c=new Map;#u=[];#f=null;#d="";#h;#p=!1;#m=!1;#g=[];#b=!1;#y=0;#A="";#w=null;#O=-1;constructor(T,A){this.#e=T||{mode:"remote"},this.#t=A||{},B(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#G(),this.unfilteredIndices=()=>this.#V(),this.handleFor=_=>this.#F(_),this.display=()=>this.#x(),this.grandTotalRow=()=>this.#D(),this.unfilteredRows=()=>this.#B(),this.facetIndices=_=>this.#Y(_));const C=this.#e.counts;B(C)&&(this.matchCount=()=>this.#K("match"),this.totalCount=()=>this.#K("total"));const H=this.#e.grandTotals;B(H)&&(this.grandTotalRow=()=>this.#H());const Y=this.#e.foregroundIdle;B(Y)&&(this.foregroundIdle=()=>this.#be(Y),this.#e.pageForegroundIdle=()=>this.#b?this.#be(Y):null);const Z=this.#e;B(Z.countMatching)&&B(Z.streamMatching)&&(this.selectionQuery=()=>this.#fe(),this.countMatching=_=>Z.countMatching(_),this.streamMatching=(_,J)=>Z.streamMatching(_,J),this.loadedRows=()=>this.#pe(),this.resident=()=>this.#R()!==null),this.#n={pageSize:this.#e.pageSize||u,maxCachedPages:this.#e.maxCachedPages||f},this.#l=r(this.#t),this.#a=new N(this.#n.pageSize*4),this.#h=x((_,J)=>this.#P(_,J),F),this.#r=new S([],0,this.#n),this.#i.set(this.#r.key,this.#r),this.#d=this.#Oe(),B(this.#e.fetch)||q("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#$e()}count(){const T=this.#S();return T?T.length:this.#v()}#v(){const T=this.#R();return T?T.count():(this.#X(),this.#re(this.#r))}#T(){if(this.#R())return!0;const T=A=>{if(A.count===null&&!A.complete)return!1;for(const C of A.children.values())if(this.#we(C.key)&&!T(C))return!1;return!0};return T(this.#r)}pageInfo(){const T=this.#S(),A=this.totalPending();if(!T){const C=this.#v();return{page:0,pageSize:0,total:this.#T()?C:null,pageCount:1,counting:A}}return{page:T.page,pageSize:T.pageSize,total:T.total,pageCount:T.pageCount,counting:A||T.total===null&&this.#o.size>0&&this.#r.cache.loadedExtent()===0}}#S(){const T=this.#v(),A=l(this.#C("pageSize",0),this.#C("page",0),T,this.#T());if(!A)return this.#A="",null;const C=`${this.#y}:${A.offset}:${A.length}`;return C!==this.#A&&!this.#p&&(this.#A=C,A.length>0&&!this.#R()&&this.#P(A.offset,A.offset+A.length-1)),A}at(T){const A=this.#S();if(A){if(T<0||T>=A.length)return;const C=this.#E(A.offset+T);return C&&(C.index=T),C}return this.#E(T)}#E(T){const A=this.#R();if(A)return A.at(T);if(this.#X(),T<0||T>=this.#v())return;const C=this.#_(this.#r,T);if(!C)return;const H=this.#Z(C.node,C.local);return H&&(H.index=T),H||this.#l.skeleton(T,C.node.level,C.node.cache.erroredAt(C.local))}byKey(T){const A=this.#R();if(A)return A.byKey(T);const C=this.#c.get(T);if(!C)return;const H=C.lastIndexOf(":"),Y=this.#i.get(C.slice(0,H));return Y&&this.#Z(Y,Number(C.slice(H+1)))||void 0}loaded(T){const A=this.#S();if(A){if(T<0||T>=A.length)return!1;T+=A.offset}const C=this.#R();if(C)return C.loaded(T);if(T<0||T>=this.#v())return!1;const H=this.#_(this.#r,T);return!!H&&H.node.cache.rowLoaded(H.local)}hint(T,A){if(this.#p)return;this.#b=!0;const C=this.#X();let H=Math.max(0,Math.floor(T)),Y=Math.max(H,Math.floor(A));const Z=this.#S();if(Z){if(Z.length===0)return;H=Z.offset,Y=Z.offset+Z.length-1}for(const[_,J]of this.#N(H,Y)){_.cache.protect(J.min,J.max);for(const ee of _.cache.evict())this.#Te(_,ee)}this.#h(H,Y),C&&this.#h.flush()}#N(T,A){const C=this.#v(),H=new Map;for(let Y=T;Y<=A&&Y<C;Y++){const Z=this.#_(this.#r,Y);if(!Z)continue;const _=H.get(Z.node);_?(_.min=Math.min(_.min,Z.local),_.max=Math.max(_.max,Z.local)):H.set(Z.node,{min:Z.local,max:Z.local})}return H.size||H.set(this.#r,{min:T,max:T}),H}#P(T,A){if(!this.#p)for(const[C,H]of this.#N(T,A)){C.cache.protect(H.min,H.max);const Y=C.cache.blockOf(H.min),Z=C.cache.blockOf(H.max);for(let _=Y;_<=Z&&!(C.count!==null&&_*C.cache.pageSize>=C.count);_++)C.cache.has(_)||this.#Be(C,_)}}apply(T){const A={added:[],updated:[],removed:[]};if(!T)return A;if(T.update)for(const C of T.update){const H=this.#c.get(this.#l.keyOf(C,-1));if(!H)continue;this.#a.delete(H);const Y=H.lastIndexOf(":"),Z=this.#i.get(H.slice(0,Y));if(!Z)continue;const _=Number(H.slice(Y+1)),J=Z.cache.blockOf(_);if(!Z.cache.loaded(J))continue;const{start:ee}=Z.cache.rangeOf(J),ne=[];for(let oe=ee;oe<ee+Z.cache.pageSize;oe++){const fe=Z.cache.rowAt(oe);if(fe===void 0)break;ne.push(oe===_?C:fe)}Z.cache.fill(J,ne);const se=this.#Z(Z,_);se&&A.updated.push(se)}return(T.add&&T.add.length||T.remove&&T.remove.length)&&this.reload({keepExpanded:!0}),A}reload(T){this.#o.abortAll("reload"),this.#h.cancel(),T&&T.keepExpanded===!1&&this.#s.clear(),this.#oe(),this.#W("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#o.abortAll("destroyed"),this.#oe(),this.#i.clear(),this.#s.clear(),this.#w&&B(this.#w.destroy)&&this.#w.destroy(),this.#w=null}expand(T){this.#s.has(T)||(this.#s.add(T),this.#W("group:toggled",{key:T,expanded:!0}),this.#W("model:changed",{reason:"expand",key:T}))}collapse(T){this.#s.delete(T)&&(this.#W("group:toggled",{key:T,expanded:!1}),this.#W("model:changed",{reason:"collapse",key:T}))}expandedKeys(){return[...this.#s]}pivotFields(){return this.#u}pivot(){this.#X();const T=this.#f;if(!T||!T.keys.size||!this.#C("pivotBy",[]).length)return null;if(!T.result){const A=k((this.#t.config||{}).locale),C=[...T.keys.entries()].sort((Y,Z)=>I(Y[1],Z[1],A)),H=C.map(([Y])=>Y);T.result={keys:C.map(([,Y])=>Y),paths:H,fields:this.#ne(H),groupPaths:[],columns:H.length*Math.max(1,this.#Ee().length),values:T.cells,cells:T.cells,error:null}}return T.result}invalidateHandles(){this.#w&&(B(this.#w.invalidateHandles)&&this.#w.invalidateHandles(),B(this.#w.invalidate)&&this.#w.invalidate("filter"))}#M(){const T=this.#e.fullFrame;return B(T)?T():null}#R(){const T=this.#M();return T?(this.#w||(this.#w=new w({mode:"memory"},this.#$())),T.version!==this.#O&&(this.#w.setRows(T.rows),this.#O=T.version),this.#w):null}#$(){const T=this.#t,A=T.state||{};return{...T,state:{...A,page:()=>0,pageSize:()=>0}}}#G(){const T=this.#R();return T?T.filteredIndices():new Uint32Array(0)}#V(){const T=this.#R();return T?T.unfilteredIndices():new Uint32Array(0)}#F(T){const A=this.#R();return A?A.handleFor(T):void 0}#x(){const T=this.#R();return T?T.display():[]}#Y(T){const A=this.#R();return A&&B(A.facetIndices)?A.facetIndices(T):new Uint32Array(0)}#D(){const T=this.#R();return T&&B(T.grandTotalRow)?T.grandTotalRow():null}#K(T){const A=this.#R();if(A){const Z=T==="match"?A.matchCount:A.totalCount;if(B(Z))return Z.call(A)}const C=this.#e.counts,H=B(C)?C():null,Y=H?H[T]:null;return typeof Y=="number"?Y:this.#v()}#H(){const T=this.#R();if(T&&B(T.grandTotalRow))return T.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const C=this.#e.grandTotals,H=B(C)?C():null;return!H||!H.totals?null:this.#l.grandTotal(H.totals,H.leafCount||0)}#B(){const T=this.#R();if(T&&B(T.unfilteredRows))return T.unfilteredRows();const A=[],C=this.count();for(let H=0;H<C;H++){const Y=this.at(H);Y&&A.push(Y)}return A}#fe(){const T=this.#C("quick",""),A={protocol:M,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:i(this.#C("filters",null),this.#U()),sort:this.#C("sort",[]),context:this.#C("context",null)};T&&(A.quick=T);const C=this.#C("where",null);return C&&C.active&&(A.where=C),A}#pe(){const T=this.#C("groupBy",[]).length,A=[];for(const C of this.#i.values())if(!(C.level!==T&&!C.flat))for(const H of C.cache.ids()){if(!C.cache.loaded(H))continue;const{start:Y,end:Z}=C.cache.rangeOf(H);for(let _=Y;_<Z&&C.cache.rowLoaded(_);_++){const J=this.#Z(C,_);J&&!J.group&&A.push(J)}}return A}loadedCount(){const T=this.#R();if(T){const H=T.matchCount();return typeof H=="number"?H:T.count()}this.#X();const A=this.#C("groupBy",[]).length;let C=0;for(const H of this.#i.values())if(!(H.level!==A&&!H.flat))for(const Y of H.cache.ids()){if(!H.cache.loaded(Y))continue;const Z=H.cache.fillOf(Y);typeof Z=="number"&&(C+=Z)}return C}residentRows(){const T=this.#R();return T?T.display():this.#C("groupBy",[]).length>0?null:(this.#X(),this.#pe())}#se(T,A,C){const{start:H,end:Y}=T.cache.rangeOf(A),Z=this.#C("groupBy",[]),_=this.#C("pivotBy",[]),J=this.#C("quick",""),ee=this.#Ee(),ne={protocol:M,range:{start:H,end:Y},groupPath:T.path,groupValues:T.values,groupBy:Z,totals:ee,totalFns:this.#ae(ee),pivotBy:_,pivotMode:_.length>0,filters:i(this.#C("filters",null),this.#U()),sort:this.#C("sort",[]),context:this.#C("context",null),signal:C};J&&(ne.quick=J);const se=this.#C("where",null);return se&&se.active&&(ne.where=se),ne}async#Be(T,A){if(!B(this.#e.fetch))return;if(!this.#m){this.#m=!0;const Z=this.#g;this.#g=[],queueMicrotask(()=>{for(const _ of Z)_()})}const C=this.#o.begin(`${T.key}:${A}`);T.cache.begin(A,C);const H=this.#d,{start:Y}=T.cache.rangeOf(A);try{const Z=await this.#e.fetch(this.#se(T,A,C.signal));if(!C.current||H!==this.#d||this.#p)return;C.settle();const _=Z&&Z.rows||[];if(!!(Z&&Z[E])&&!T.flat){T.flat=!0,T.children.clear();for(const[se,oe]of[...this.#c])oe.startsWith(`${T.key}:`)&&(this.#a.delete(oe),this.#c.delete(se))}T.cache.fill(A,_),T.failed=!1;for(let se=0;se<_.length;se++)this.#a.delete(`${T.key}:${Y+se}`);const ee=Z&&typeof Z.count=="number"?Z.count:Z&&typeof Z.total=="number"?Z.total:null,ne=Z&&B(Z.pendingTotal?.then)?Z.pendingTotal:null;ee!==null?(T.count=ee,T.complete=!0):_.length<T.cache.pageSize?(T.count=Y+_.length,T.complete=!0):ne&&(T.counting=!0,T.announced=null),Z&&Array.isArray(Z.pivotFields)&&this.#je(Z.pivotFields),Z&&Z.pivot&&typeof Z.pivot=="object"&&this.#Ce(Z.pivot),this.#W("model:changed",{reason:"page",groupPath:T.path,block:A}),this.#W("rows:changed",{companion:!0,reason:"page",groupPath:T.path,block:A}),this.#ge(T),ne&&this.#Se(T,ne,H)}catch(Z){if(C.settle(),j(Z))return;T.cache.failed(A,Z),T.failed=!0;const{end:_}=T.cache.rangeOf(A);for(let J=Y;J<_;J++)this.#a.delete(`${T.key}:${J}`);this.#W("model:changed",{reason:"page-error",groupPath:T.path,block:A}),this.#W("source:error",{error:Z,groupPath:T.path,block:A})}}async#Se(T,A,C){let H;try{H=await A}catch(Y){if(C!==this.#d||this.#p)return;T.counting=!1,j(Y)||(T.failed=!0),j(Y)||this.#W("source:error",{error:Y,groupPath:T.path});return}C!==this.#d||this.#p||(T.counting=!1,typeof H=="number"&&(T.count=H,T.complete=!0,this.#ge(T),this.#W("model:changed",{reason:"total",count:H,groupPath:T.path})))}#ge(T){typeof T.count!="number"||!T.complete||T.announced!==T.count&&(T.announced=T.count,this.#W("source:total",{total:T.count,groupPath:T.path}))}#be(T){if(this.#p)return null;this.#X();const A=this.#m?null:new Promise(_=>{this.#g.push(_),setTimeout(_,V)}),C=T();if(!A&&!C)return null;const H=(async()=>{A&&await A;for(let _=T();_;_=T())await _})();let Y;const Z=new Promise(_=>{Y=setTimeout(_,V)});return Promise.race([H,Z]).then(()=>clearTimeout(Y))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#R())return!1;this.#X();const T=this.#r;return T.count===null&&!T.complete&&T.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#je(T){T.length===this.#u.length&&T.every((A,C)=>A===this.#u[C])||(this.#u=T,this.#W("column:pivoted",{pivotFields:T,remote:!0}))}#Pe(){const T=this.#t.config||{};return T.pivot&&T.pivot.separator||v}#ne(T){const A=this.#Pe(),C=this.#Ee();if(!C.length)return T.slice();const H=[];for(const Y of T)for(const Z of C)H.push(`${Y}${A}${Z}`);return H}#Ce(T){const A=this.#Pe();this.#f||(this.#f={keys:new Map,cells:new Map,result:null});const C=this.#f;let H=!1;const Y=_=>{const J=Array.isArray(_)?_:[_],ee=m(J,A);return C.keys.has(ee)||(C.keys.set(ee,J),H=!0),ee},Z=this.#C("groupBy",[]).length>0;for(const _ of Array.isArray(T.axis)?T.axis:[])Y(_);for(const _ of Array.isArray(T.cells)?T.cells:[]){if(!_||typeof _!="object")continue;const J=Y(_.pivot);if(Z&&!(Array.isArray(_.group)&&_.group.length))continue;const ee=m(Array.isArray(_.group)?_.group:[],A);for(const[ne,se]of Object.entries(_.values||{}))C.cells.set(p(ee,J,ne),se)}C.result=null,H&&this.#je((this.pivot()||{fields:[]}).fields)}#re(T){let A=this.#J(T);for(const C of T.children.values())this.#we(C.key)&&(A+=this.#re(C));return A}#J(T){if(T.count!==null)return T.count;const A=T.cache.loadedExtent();return T.complete?A:T.row&&T.row.leafCount>0?T.level>=this.#C("groupBy",[]).length?Math.max(A,T.row.leafCount):A===0?1:Math.min(A+T.cache.pageSize,Math.max(A,T.row.leafCount)):A+T.cache.pageSize}#_(T,A){let C=A,H=0;const Y=[...T.children.entries()].filter(([,_])=>this.#we(_.key)).sort((_,J)=>_[0]-J[0]);for(const[_,J]of Y){const ee=_-H+1;if(C<ee)return{node:T,local:H+C};C-=ee,H=_+1;const ne=this.#re(J);if(C<ne)return this.#_(J,C);C-=ne}const Z=this.#J(T);return H+C<Z?{node:T,local:H+C}:null}#Z(T,A){const C=`${T.key}:${A}`,H=this.#a.get(C);if(H)return H;const Y=T.cache.rowAt(A);if(Y===void 0)return null;const Z=this.#C("groupBy",[]);let _;if(T.level<Z.length&&!T.flat){const J=Z[T.level],ee=this.#f!==null&&T.level===Z.length-1&&this.#C("pivotBy",[]).length>0,ne=this.#ce(Y,J),se=ne==null,oe=[...T.path,se?"":String(ne)],fe=[...T.keyPath,se?null:String(ne)];if(_=this.#l.group({path:oe,keyPath:fe,column:J,value:ne,level:T.level,parent:T.row,leafCount:Number(Y.leafCount)||0,expanded:ee?!1:this.#we(t(fe)),...ee?{hasChildren:!1}:{}}),_.totals=this.#I(Y),_.data=Y,!ee){let pe=this.#i.get(_.key);pe?pe.row=_:(pe=new S(oe,T.level+1,this.#n,fe),pe.row=_,this.#i.set(pe.key,pe)),pe.values=[...T.values,ne],T.children.set(A,pe)}}else _=this.#l.leaf(Y,A,T.level,T.row);return this.#a.set(C,_),this.#c.set(_.key,C),_}#I(T){const A=T||{};if(A.totals&&typeof A.totals=="object")return A.totals;const C={};for(const H of this.#Ee())Object.hasOwn(A,H)&&(C[H]=A[H]);return C}#Te(T,A){const{start:C,end:H}=T.cache.rangeOf(A);for(let Y=C;Y<H;Y++){const Z=`${T.key}:${Y}`,_=this.#a.peek(Z);_&&this.#c.delete(_.key),this.#a.delete(Z)}}#X(){const T=this.#Oe();return T===this.#d?!1:(this.#d=T,this.#o.abortAll("query"),this.#oe(),this.#m=!1,this.#W("model:changed",{reason:"query"}),!0)}#oe(){for(const T of this.#i.values())T.cache.clear(),T.count=null,T.complete=!1,T.announced=null,T.counting=!1,T.failed=!1,T.children.clear(),T.flat=!1;this.#a.clear(),this.#c.clear(),this.#y++,this.#f=null}#Oe(){const T=this.#C("where",null);return`${n({filters:this.#C("filters",null),sort:this.#C("sort",[]),quick:this.#C("quick",""),groupBy:this.#C("groupBy",[]),pivotBy:this.#C("pivotBy",[]),context:this.#C("context",null)})}|${T?T.version:0}`}#we(T){const A=this.#C("expanded",null);return A?B(A.has)?A.has(T):Array.prototype.includes.call(A,T):this.#s.has(T)}#Ee(){const T=this.#C("totals",[]);if(T&&T.length)return[...T];const A=this.#t.columns;return!A||!B(A.all)?[]:A.all().filter(C=>!!C.total).map(C=>C.id)}#ae(T){const A=this.#t.columns,C={};if(!A||!B(A.get))return C;for(const H of T){const Y=A.get(H);if(!Y)continue;const Z=Y.groupTotal!=null?Y.groupTotal:Y.total;typeof Z=="string"&&(C[H]=Z)}return C}#ce(T,A){const C=this.#t.columns,H=C&&B(C.get)?C.get(A):void 0;return H&&B(H.getValue)?H.getValue(T):T?.[A]}#$e(){c(this.#t)}#U(){const T=this.#t.config||{};return{tz:T.timeZone,weekStartsOn:T.weekStartsOn}}#C(T,A){const C=this.#t.state;if(C&&B(C[T])){const H=C[T]();return H??A}return A}#W(T,A){const C=this.#t.emit;B(C)&&C(T,A)}}}),Ie("packages/core/src/source/gapbuffer.js",function(e,U){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return N}});const te=64;class N{#e;#t=0;#n=0;constructor(B=te){this.#e=new Uint32Array(Math.max(1,B)),this.#n=this.#e.length}static from(B,D=te){const q=new N(B.length+Math.max(1,D));return q.#e.set(B,0),q.#t=B.length,q.#n=q.#e.length,q}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(B){return B<0||B>=this.length?0:B<this.#t?this.#e[B]:this.#e[B+(this.#n-this.#t)]}insert(B,D){const q=B<0?0:B>this.length?this.length:B;this.#r(q),this.#t===this.#n&&this.#i(),this.#e[this.#t++]=D}push(B){this.insert(this.length,B)}removeAt(B){return!Number.isInteger(B)||B<0||B>=this.length?!1:(this.#r(B),this.#n++,!0)}toArray(){const B=new Uint32Array(this.length);return B.set(this.#e.subarray(0,this.#t),0),B.set(this.#e.subarray(this.#n),this.#t),B}clear(){this.#t=0,this.#n=this.#e.length}#r(B){if(B!==this.#t)if(B<this.#t){const D=this.#t-B;this.#e.copyWithin(this.#n-D,B,this.#t),this.#t=B,this.#n-=D}else{const D=B-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+D),this.#t=B,this.#n+=D}}#i(){const B=this.#e.length-this.#n,D=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+te));D.set(this.#e.subarray(0,this.#t),0),D.set(this.#e.subarray(this.#n),D.length-B),this.#e=D,this.#n=D.length-B}}}),Ie("packages/core/src/store/ingest.js",function(e,U){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return i}});const te=U("packages/core/src/internal/schedule.js"),N=te.now,X=te.nextFrame,B=U("packages/core/src/internal/warn.js"),D=B.infoOnce,q=B.warnOnce,x=U("packages/core/src/internal/predicates.js").isFunction,z=U("packages/core/src/internal/paths.js").pathGetter,O=U("packages/core/src/store/columnstore.js").ColumnStore,b=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function u(n,c={}){if(c.multi)return"multi";if(n.length===0)return"object";let o=0,l=0,h=0,w=0,g=0;for(let d=0;d<n.length;d++){const p=n[d];typeof p=="number"?o++:typeof p=="boolean"?l++:typeof p=="string"?h++:p instanceof Date?w++:Array.isArray(p)&&g++}const k=n.length;return o===k?"float64":l===k?"bitset":w===k?"float64":h===k?"text":g===k?"multi":"object"}function f(n,c,o){return c<=0||n<o*c?"dictionary":"object"}function a(n,c,o){const l=new Map,h=new Map;for(const M of n){if(M.computed)continue;const F=x(M.read)?M.read:z(M.field||M.id);h.set(M.id,F),l.set(M.id,F)}const w=c?.order??[],g=c?.fns??{},k=c?.deps??{},d=c?.wrapDeps??null,p=w.filter(M=>x(g[M])),m=p.some(M=>k[M]==="*");let v=new WeakMap;const y=M=>{const F={};if(m)for(const[V,I]of h)F[V]=I(M);for(const V of p){const I=k[V];let $;if(I==="*")$=F;else{$={};const S=I||[];for(let R=0;R<S.length;R++){const L=S[R];$[L]=L in F?F[L]:h.get(L)?.(M)}}F[V]=g[V](d?d($,V):$,{data:M,row:null,column:null,grid:null,context:o})}return F},E=M=>{if(M===null||typeof M!="object"&&typeof M!="function")return y(M);let F=v.get(M);return F===void 0&&(F=y(M),v.set(M,F)),F};for(const M of p)l.set(M,F=>E(F)[M]);return{readers:l,reset(){v=new WeakMap}}}class r{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(c,o){this.spec=c,this.read=o,this.kind="object",this.inferred=!1,this.nullable=c.nullable!==!1}}class t{#e;#t=[];#n=null;#r;#i=0;#s;#o=!1;#l=!1;#a=0;#c;constructor(c,o={},l={}){this.#e=Array.isArray(c)?c:Array.from(c||[]),this.#s={...b,...l};const h=o.columns??[];this.#r=a(h,o.computed??null,o.context),this.#c=this.#e.length>=this.#s.columnarBelow,this.#u(h,o.computed??null),this.#n=new O(this.#t.map(w=>({id:w.spec.id,kind:w.kind,nullable:w.nullable,read:w.read,dictionary:w.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#o||this.#l}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#l=!0,!1;const c=N(),{chunkMs:o,chunkRows:l}=this.#s,h=this.#e.length;do{const w=Math.min(this.#i+l,h);this.#n.append(this.#e.slice(this.#i,w)),this.#f(this.#i,w),this.#i=w,this.#r.reset(),this.#h(!1)}while(this.#i<h&&N()-c<o);return this.#a+=N()-c,this.#s.onProgress?.({loaded:this.#i,total:h}),this.#i>=h?(this.#h(!0),this.#o=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(c=>({id:c.spec.id,kind:c.kind,nullable:c.nullable,read:c.read,dictionary:c.spec.dictionary})),decisions:this.#t.map(c=>({id:c.spec.id,kind:c.kind,nullable:c.nullable,inferred:c.inferred,distinct:c.candidate||c.change?this.#d(c):null,change:c.change,reason:c.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#u(c,o){const l=this.#e,h=Math.min(this.#s.sampleSize,l.length),w=this.#s.dictionaryRatio,g=o?.pure instanceof Set?o.pure:new Set(o?.pure??o?.order??[]);for(const k of c){if(!k||!k.id)continue;if(k.computed&&(k.pure===!1||o&&!g.has(k.id))){q(`ingest.impure.${k.id}`,`column "${k.id}" is an impure computed column and is not materialised into the store`);continue}const d=this.#r.readers.get(k.id)??(x(k.read)?k.read:z(k.field||k.id)),p=new r(k,d);if(k.kind)p.kind=k.kind,p.reason="declared by the caller";else if(k.dictionary)p.kind=k.multi?"multi":"dictionary",p.reason="value table supplied (lookup column)";else{const m=[];for(let y=0;y<h&&m.length<this.#s.sampleSize;y++){const E=d(l[y]);E!=null&&m.push(E)}p.inferred=!0;const v=u(m,{multi:k.multi});if(v==="text"){const y=new Set(m).size;p.kind=f(y,m.length,w),p.candidate=this.#c,p.reason=`sampled ${y} distinct in ${m.length}`}else p.kind=v,p.reason=`inferred from ${m.length} sampled values`,v==="object"&&m.length&&D(`ingest.mixed.${k.id}`,`column "${k.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);p.kind==="object"&&p.candidate&&(p.distinct=new Set(m))}this.#t.push(p)}}#f(c,o){const l=this.#e;for(const h of this.#t){if(!h.candidate||!h.distinct)continue;const w=h.distinct;for(let g=c;g<o;g++){const k=h.read(l[g]);k!=null&&w.add(k)}}}#d(c){if(c.distinct)return c.distinct.size;const o=this.#n.column(c.spec.id);return o?.dict?o.dict.size:0}#h(c){const o=this.#s.dictionaryRatio,l=this.#e.length;for(const h of this.#t){if(!h.candidate)continue;const w=this.#d(h);if(h.kind==="dictionary"&&w>=o*l){const g=this.#n.column(h.spec.id);h.distinct=new Set(g?.dict?g.dict.values():[]),this.#n.convert(h.spec.id,"object"),h.kind="object",h.change="demoted",h.reason=`${w} distinct values is at or above ${o*100}% of ${l} rows`;continue}if(h.kind==="object"&&w>=o*l){h.candidate=!1,h.distinct=null,h.reason=`${w} distinct values is at or above ${o*100}% of ${l} rows`;continue}c&&h.kind==="object"&&w<o*l&&(this.#n.convert(h.spec.id,"dictionary"),h.kind="dictionary",h.change=h.change==="demoted"?null:"promoted",h.reason=`${w} distinct values is below ${o*100}% of ${l} rows`,h.distinct=null),c&&(h.candidate=!1)}}}async function s(n,c={},o={}){const l=new t(n,c,o),h=o.scheduler?.frame??X;for(;l.slice();)await new Promise(w=>{h(w)});return l.result()}function i(n,c={},o={}){const l=new t(n,c,{...o,chunkMs:1/0});for(;l.slice(););return l.result()}}),Ie("packages/core/src/store/columnpack.js",function(e,U){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return f}});const N=U("packages/core/src/internal/paths.js").pathGetter,X=U("packages/core/src/store/ingest.js"),B=X.inferKind,D=X.decideText,q=X.INGEST_DEFAULTS,x=U("packages/core/src/store/columnstore.js").toFloat,G=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&&!G.has(r.kind))return!1;return!0}function j(a){const r=x(a);return Number.isFinite(r)?r|0:0}function O(a){return a==null?[]:Array.isArray(a)?a:[a]}function b(a,r,t,s){if(a.kind)return a.kind;const i=[];for(let o=0;o<r.length&&i.length<q.sampleSize;o++){const l=r[o];l!=null&&i.push(l)}const n=B(i,{multi:a.multi});if(n!=="text")return n;const c=new Set(i).size;return D(c,i.length,s)}function u(a,r,t={}){const s=r.length|0,i=t.dictionaryRatio??q.dictionaryRatio,n=[];for(const c of a){const o=N(c.field||c.id),l=c.nullable!==!1,h=new Array(s);for(let p=0;p<s;p++){const m=o(r[p]);h[p]=m===void 0?null:m}const w=b(c,h,s,i),g=l?new Uint8Array(s+7>>3):null,k=p=>{g&&(g[p>>3]|=1<<(p&7))};let d;switch(w){case"float64":{const p=new Float64Array(s);for(let m=0;m<s;m++){const v=h[m],y=v===null;y||k(m),p[m]=y?NaN:x(v)}d={id:c.id,kind:w,nullable:l,values:p,presence:g,offsets:null,table:null};break}case"int32":{const p=new Int32Array(s);for(let m=0;m<s;m++){const v=h[m],y=v===null;y||k(m),p[m]=y?0:j(v)}d={id:c.id,kind:w,nullable:l,values:p,presence:g,offsets:null,table:null};break}case"bitset":{const p=new Uint8Array(s+7>>3);for(let m=0;m<s;m++){const v=h[m],y=v===null;y||k(m),!y&&v&&(p[m>>3]|=1<<(m&7))}d={id:c.id,kind:w,nullable:l,values:p,presence:g,offsets:null,table:null};break}case"dictionary":{const p=new Uint32Array(s),m=[],v=new Map;for(let y=0;y<s;y++){const E=h[y];if(E===null){p[y]=0;continue}k(y);let M=v.get(E);M===void 0&&(M=m.length,m.push(E),v.set(E,M)),p[y]=M}d={id:c.id,kind:w,nullable:l,values:p,presence:g,offsets:null,table:m};break}case"multi":{const p=[],m=new Map,v=new Uint32Array(s+1),y=[];for(let E=0;E<s;E++){const M=h[E];v[E]=y.length,M===null||k(E);const V=O(M);for(let I=0;I<V.length;I++){const $=V[I];let S=m.get($);S===void 0&&(S=p.length,p.push($),m.set($,S)),y.push(S)}}v[s]=y.length,d={id:c.id,kind:w,nullable:l,values:Int32Array.from(y),presence:g,offsets:v,table:p};break}default:{const p=new Array(s);for(let m=0;m<s;m++){const v=h[m];v!==null&&k(m),p[m]=v}d={id:c.id,kind:"object",nullable:l,values:p,presence:g,offsets:null,table:null};break}}n.push(d)}return{count:s,columns:n}}function f(a){const r=[];if(!a||!Array.isArray(a.columns))return r;const t=s=>{ArrayBuffer.isView(s)&&s.buffer&&!r.includes(s.buffer)&&r.push(s.buffer)};for(const s of a.columns)t(s.values),t(s.presence),t(s.offsets);return r}}),Ie("packages/core/src/source/stream.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return S}});const N=U("packages/core/src/internal/lru.js").Lru,B=U("packages/core/src/internal/predicates.js").isFunction,D=U("packages/core/src/internal/schedule.js"),q=D.now,K=D.nextFrame,x=D.cancelFrame,G=D.whenIdle,j=U("packages/core/src/internal/compare.js").defaultCompare,O=U("packages/core/src/internal/warn.js"),b=O.warnOnce,u=O.infoOnce,a=U("packages/core/src/internal/paths.js").getPath,r=U("packages/core/src/source/abort.js"),t=r.createAbortScope,s=r.isAbortError,i=U("packages/core/src/source/rows.js"),n=i.createRowFactory,c=i.lazyRowView,l=U("packages/core/src/source/gapbuffer.js").GapBuffer,w=U("packages/core/src/source/memory.js").createMemorySource,k=U("packages/core/src/source/filterwire.js").querySignature,p=U("packages/core/src/store/columnpack.js").isPortableSchema,m=25e4,v=Symbol("lattice.stream.storeBacked"),y=8,E=.1,M=1e3,F=50;function V(R){return Math.min(M,Math.max(F,Math.floor(R/4)))}function I(R){if(R instanceof Date)return R.getTime();if(typeof R=="number")return Number.isFinite(R)?R:NaN;if(typeof R=="string"){const L=R.trim();if(!L)return NaN;const T=Date.parse(L);return Number.isNaN(T)?Number(L):T}return NaN}function $(R,L){return new S(R,L)}class S{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#i=[];#s=null;#o;#l;#a=new Map;#c=t();#u={loaded:0,estimated:void 0};#f=null;#d=0;#h=0;#p=0;#m=0;#g=null;#b=null;#y=null;#A=!1;#w=!1;#O=!1;#v=!1;#T="";#S=0;#E=0;#N=0;#P=null;#M=1/0;#R=!1;#$=null;#G=null;#V=null;#F=null;#x=!1;#Y=0;#D=0;#K=!1;constructor(L,T){this.#e=L||{mode:"stream"},this.#t=T||{},this.#o=n(this.#t),this.#l=new N(4096),this.#T=this.#Xe();const A=(this.#t.config||{}).ingest;this.#x=!!A&&A.retainSource===!1,B(this.#e.open)||b("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const C=Number(this.#e.poll);Number.isFinite(C)&&C>0&&(this.#F=setInterval(()=>{this.#v||this.reload()},C),this.#F&&B(this.#F.unref)&&this.#F.unref()),this.#B()}#H(){const L=Number(this.#e.maxAge);return Number.isFinite(L)&&L>0?L:0}#B(){const L=this.#H();if(!L)return;const T=this.#e.ageBy;B(T)?this.#G=T:typeof T=="string"&&T?this.#G=A=>a(A,T):this.#G=null,this.#P=[],this.#$=setInterval(()=>{this.#v||this.#fe()&&(this.#X(),this.#me())},V(L)),this.#$&&B(this.#$.unref)&&this.#$.unref()}#fe(){const L=this.#H();return!L||!this.#P?!1:this.#R?!0:this.#M<Date.now()-L*(1+E)}#pe(L,T){if(!this.#P)return;const A=this.#G?I(this.#G(T)):Date.now();this.#P[L]=A,Number.isNaN(A)||(A<this.#M&&(this.#M=A),A<Date.now()-this.#H()&&(this.#R=!0))}#se(){return this.#ye("groupBy",[]).length>0?!0:!!this.#ye("pivotMode",!1)&&this.#ye("pivotBy",[]).length>0}#Be(){if(this.#g||this.#v)return;const L=this.#se();if(L&&!this.#b){this.#b=w({mode:"memory",rows:this.#n},this.#Se()),this.#A=!1;return}!L&&this.#b&&(this.#b.destroy(),this.#b=null)}#Se(){if(this.#y)return this.#y;const L=this,T={liveIndices:()=>L.#ge(),live:A=>L.#n[A]!==void 0,source:A=>L.#xe(A),get physical(){return L.#n.length}};return this.#x&&(T.column=A=>{const C=L.#t.store;return C&&B(C.column)?C.column(A):void 0}),this.#y=Object.create(this.#t,{store:{value:T,enumerable:!0,configurable:!0}}),this.#y}#ge(){const L=new Uint32Array(this.#n.length);let T=0;for(let A=0;A<this.#n.length;A++)this.#n[A]!==void 0&&(L[T++]=A);return L.subarray(0,T)}#be(){return this.#g?this.#g:this.#b?(this.#A&&(this.#A=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(L="filter"){if(this.#g){this.#g.invalidate(L);return}this.#Be(),this.#b&&this.#b.invalidate(L),(L==="filter"||L==="sort")&&this.#Ee()}count(){const L=this.#be();return L?L.count():this.#r?this.#r.length:this.#S}matchCount(){const L=this.#be();return L&&B(L.matchCount)?L.matchCount():this.#r?this.#r.length:this.#S}totalCount(){const L=this.#be();return L&&B(L.totalCount)?L.totalCount():this.#S}unfilteredRows(){const L=this.#be();if(L&&B(L.unfilteredRows))return L.unfilteredRows();const T=[];for(let A=0;A<this.#n.length;A++){if(!this.#n[A])continue;const C=this.#ve(A);C&&T.push(C)}return T}at(L){const T=this.#be();if(T)return T.at(L);if(L<0||L>=this.count())return;const A=this.#r?this.#r.at(L):L,C=this.#ve(A);return C.index=L,C}byKey(L){const T=this.#be();if(T)return T.byKey(L);const A=this.#a.get(L);return A===void 0?void 0:this.#ve(A)}leavesOf(L){const T=this.#be();return T&&B(T.leavesOf)?T.leavesOf(L):[]}loaded(L){return L>=0&&L<this.count()}hint(L,T){if(this.#g){this.#g.hint(L,T);return}this.#je(),this.#p=Math.max(0,Math.floor(L))}#je(){this.#v||this.#Xe()===this.#T||this.reload()}display(){const L=this.#be();return L?L.display():c(()=>this.count(),T=>this.at(T))}apply(L){if(this.#g)return this.#g.apply(L);const T={added:[],updated:[],removed:[]};if(!L)return T;if(L.update){let A=!1;for(const C of L.update){const H=this.#a.get(this.#o.keyOf(C,-1));if(H===void 0)continue;const Y=this.#$e(H);this.#x?this.#k(H,C):this.#n[H]=C,this.#l.delete(H),this.#U(H,Y),this.#P&&(this.#pe(H,C),A=!0),this.#A=!0,T.updated.push(this.#ve(H))}A&&this.#X()}if(L.add&&L.add.length){const A=this.#I(L.add);for(const C of A)T.added.push(this.#ve(C))}return L.remove&&L.remove.length&&b("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#me(),T}reload(L){this.#c.abortAll("reload"),this.#Ue(),this.#b&&(this.#b.destroy(),this.#b=null),this.#A=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#S=0,this.#E=0,this.#N=0,this.#P&&(this.#P=[]),this.#M=1/0,this.#R=!1,this.#w=!1,this.#O=!1,this.#u={loaded:0,estimated:void 0},this.#T=this.#Xe(),this.#ke("model:changed",{reason:"reload"}),this.start()}destroy(){this.#v=!0,this.#F!==null&&(clearInterval(this.#F),this.#F=null),this.#$!==null&&(clearInterval(this.#$),this.#$=null),this.#P=null,this.#c.abortAll("destroyed"),this.#Ue(),this.#f!==null&&(this.#Le(this.#f),this.#f=null),this.#b&&(this.#b.destroy(),this.#b=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#O||this.#v||!B(this.#e.open))return;this.#O=!0;const L=this.#c.begin("stream");this.#Ee(),this.#Be();let T;try{T=this.#e.open({sort:this.#ye("sort",[]),filters:this.#ye("filters",null),quick:this.#ye("quick","")||void 0,context:this.#ye("context",null),signal:L.signal})}catch(C){this.#ke("source:error",{error:C});return}const A=B(T[Symbol.asyncIterator])?T[Symbol.asyncIterator]():T[Symbol.iterator]();this.#V=A;try{for(;;){const C=await A.next();if(!L.current||this.#v)return;if(C.done){this.#ie();return}if(await this.#Pe(C.value,L),!L.current||this.#v)return;if(C.value&&C.value.done){this.#ie();return}if(await this.#le(),!L.current||this.#v)return}}catch(C){if(s(C))return;this.#ke("source:error",{error:C})}finally{L.settle()}}progress(){return{loaded:this.#u.loaded,estimated:this.#u.estimated,done:this.#w,live:this.#S,evicted:this.#E}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const L=this.#be();L&&(B(L.invalidateHandles)&&L.invalidateHandles(),B(L.invalidate)&&L.invalidate("sort"))}renderCount(){return this.#d}ingestStats(){return{worker:this.#Y,inline:this.#D,storeBacked:this.#x}}#Pe(L,T){if(!L)return;const A=L.rows;if(A&&A.length&&this.#Ce(A))return this.#J(L,T);const C=q();A&&A.length&&(this.#I(A),this.#D++),this.#ne(L),this.#h+=q()-C,this.#me()}#ne(L){this.#u.loaded=L.progress&&typeof L.progress.loaded=="number"?L.progress.loaded:this.#n.length,L.progress&&typeof L.progress.estimated=="number"&&(this.#u.estimated=L.progress.estimated)}#Ce(L){if(this.#K||this.#g)return!1;const T=this.#_();if(!T)return!1;const A=this.#t.store;if(!A||!B(A.appendPacked))return!1;const C=this.#Z();return!C||!p(C)?(this.#K=!0,u("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):L.length<T.threshold?!1:!this.#re(L)}#re(L){if(!this.#o.keyed)return!1;const T=new Set;for(let A=0;A<L.length;A++){const C=this.#o.keyOf(L[A],this.#n.length+A);if(C!=null){if(T.has(C)||this.#a.has(C))return!0;T.add(C)}}return!1}async#J(L,T){const A=L.rows,C=this.#_(),H=this.#Z();let Y;try{Y=await C.columnize(H,A,{key:"ingest:stream",signal:T&&T.signal})}catch(ne){if(s(ne)||(b("source.stream.columnize","worker columnization failed; columnizing on the main thread",ne),this.#K=!0,T&&(!T.current||this.#v)))return;this.#I(A),this.#D++,this.#ne(L),this.#me();return}if(T&&(!T.current||this.#v))return;const Z=this.#t.store,_=this.#x?void 0:A,{from:J}=Z.appendPacked(Y,_),ee=Y.count|0;for(let ne=0;ne<ee;ne++){const se=J+ne,oe=A[ne],fe=this.#o.keyed?this.#o.keyOf(oe,se):null;if(this.#n[se]=this.#x?v:oe,this.#S++,this.#pe(se,oe),fe!==null&&this.#a.set(fe,se),!this.#r||!this.#ae(se))continue;const pe=this.#C(se);this.#r.insert(pe,se),pe<=this.#p&&this.#m++}this.#A=!0,this.#X(),this.#Y++,this.#ne(L),this.#me()}#_(){const L=this.#t.ingestWorker;return B(L)?L():null}#Z(){const L=this.#t.storeSchema;return B(L)?L():null}#I(L){const T=[],A=this.#t.store,C=new Array(L.length),H=[],Y=new Set;for(let _=0;_<L.length;_++){const J=this.#o.keyed?this.#o.keyOf(L[_],this.#n.length+H.length):null;C[_]=J,!(J!==null&&(this.#a.has(J)||Y.has(J)))&&(J!==null&&Y.add(J),H.push(L[_]))}let Z=H.length&&A&&B(A.append)?A.append(H).from:this.#n.length;for(let _=0;_<L.length;_++){const J=L[_],ee=C[_];if(ee!==null&&this.#a.has(ee)){const oe=this.#a.get(ee),fe=this.#$e(oe);this.#x||(this.#n[oe]=J,A&&B(A.setSource)&&A.setSource(oe,J)),this.#k(oe,J),this.#l.delete(oe),this.#pe(oe,J),this.#U(oe,fe);continue}const ne=Z++;if(this.#n[ne]=this.#x?v:J,this.#S++,this.#pe(ne,J),ee!==null&&this.#a.set(ee,ne),T.push(ne),!this.#r||!this.#ae(ne))continue;const se=this.#C(ne);this.#r.insert(se,ne),se<=this.#p&&this.#m++}return this.#A=!0,this.#X(),T}#Te(L){const T=this.#n[L];let A=!1;if(this.#r){const Z=this.#we(L);Z>=0&&Z<=this.#p&&(A=!0)}else L<=this.#p&&(A=!0);const C=T===v?this.#xe(L):T,H=this.#o.keyed?this.#o.keyOf(C,L):null;H!==null&&this.#a.get(H)===L&&this.#a.delete(H),this.#n[L]=void 0,this.#P&&(this.#P[L]=NaN),this.#l.delete(L);const Y=this.#t.store;return Y&&B(Y.remove)&&Y.remove(L),this.#S--,A}#X(){let L=0,T=0;const A=this.#Oe();L+=A.dropped,T+=A.aboveAnchor;const C=this.#oe();L+=C.dropped,T+=C.aboveAnchor,L&&(this.#A=!0,this.#E+=L,this.#Ee(),this.#m-=T,this.#ke("stream:evicted",{evicted:L,total:this.#E,live:this.#S}))}#oe(){const L=this.#e.maxRows;if(!Number.isFinite(L)||L<=0||this.#S<=L)return{dropped:0,aboveAnchor:0};const T=Math.max(1,Math.floor(L*(1-E)));let A=0,C=0;for(;this.#S>T&&this.#N<this.#n.length;){const H=this.#N++;this.#n[H]!==void 0&&(this.#Te(H)&&C++,A++)}return{dropped:A,aboveAnchor:C}}#Oe(){const L=this.#H();if(!L||!this.#P||!this.#fe())return{dropped:0,aboveAnchor:0};const T=Date.now()-L;let A=0,C=0,H=1/0;for(let Y=this.#N;Y<this.#n.length;Y++){if(this.#n[Y]===void 0)continue;const Z=this.#P[Y];if(!(Number.isNaN(Z)||Z===void 0)){if(Z>=T){Z<H&&(H=Z);continue}this.#Te(Y)&&C++,A++}}for(this.#M=H,this.#R=!1;this.#N<this.#n.length&&this.#n[this.#N]===void 0;)this.#N++;return{dropped:A,aboveAnchor:C}}#we(L){if(!this.#r)return L;for(let T=0;T<this.#r.length;T++)if(this.#r.at(T)===L)return T;return-1}#Ee(){this.#i=this.#ye("sort",[]),this.#s=this.#ye("filters",null);const L=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#H()>0,T=this.#ye("where",null),A=(this.#t.config||{}).hostFilter,C=!!(T&&T.active)||!!(A&&B(A.active)&&A.active());if(!(L||this.#i.length>0||!!this.#s||!!this.#ye("quick","")||C)){this.#r=null;return}this.#r=new l(Math.max(64,this.#n.length+64));for(let Y=0;Y<this.#n.length;Y++)this.#n[Y]!==void 0&&this.#ae(Y)&&this.#r.insert(this.#C(Y),Y)}#ae(L){const T=this.#xe(L);if(this.#s&&!this.#ce(this.#s,T))return!1;const A=String(this.#ye("quick","")||"").toLowerCase();if(A&&!this.#at(T).includes(A))return!1;const C=(this.#t.config||{}).hostFilter;if(C&&B(C.active)&&C.active()&&!C.passes(this.#ve(L)))return!1;const H=this.#ye("where",null);if(H&&H.active){const Y=this.#ve(L);if(!H.passes(Y.data,Y.key))return!1}return!0}#ce(L,T){if(!L)return!0;const A=L;if(Array.isArray(A.conditions))return A.op==="or"?A.conditions.some(Y=>this.#ce(Y,T)):A.op==="not"?!A.conditions.some(Y=>this.#ce(Y,T)):A.conditions.every(Y=>this.#ce(Y,T));const C=L,H=(this.#t.compute||{}).testValue;return B(H)?!!H(this.#Me(T,C.col),C,(this.#t.config||{}).locale):(b("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#$e(L){if(!this.#r)return-1;if(!this.#i.length)return this.#we(L);let T=0,A=this.#r.length;for(;T<A;){const C=T+A>>>1;this.#W(this.#r.at(C),L)<0?T=C+1:A=C}for(let C=T;C<this.#r.length;C++){const H=this.#r.at(C);if(H===L)return C;if(this.#W(H,L)>0)break}return this.#we(L)}#U(L,T){if(!this.#r||!this.#i.length)return;const A=this.#ae(L);if(T>=0&&this.#r.at(T)===L)this.#r.removeAt(T),T<=this.#p&&this.#m--;else if(T>=0)return;if(!A)return;const C=this.#C(L);this.#r.insert(C,L),C<=this.#p&&this.#m++}#C(L){if(!this.#r||!this.#i.length)return this.#r?this.#r.length:0;let T=0,A=this.#r.length;for(;T<A;){const C=T+A>>>1;this.#W(L,this.#r.at(C))<0?A=C:T=C+1}return T}#W(L,T){const A=this.#xe(L),C=this.#xe(T);for(const H of this.#i){const Y=this.#_e(H.col),Z=this.#Me(A,H.col),_=this.#Me(C,H.col),ee=(Y&&Y.value&&B(Y.value.compare)?Y.value.compare:j)(Z,_);if(ee!==0)return H.dir==="desc"?-ee:ee}return 0}#ie(){this.#w=!0,this.#u.loaded=this.#u.loaded||this.#n.length;const L=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:m;!this.#x&&this.#n.length<L&&(this.#g=w({mode:"memory",rows:this.#n},this.#t),this.#$!==null&&(clearInterval(this.#$),this.#$=null),this.#b&&(this.#b.destroy(),this.#b=null)),this.#me(),this.#ke("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:L})}#me(){this.#f!==null||this.#v||(this.#f=this.#he(()=>{this.#f=null,this.#d++;const L=this.#m;this.#m=0,this.#h=0,this.#ke("stream:chunk",{loaded:this.#u.loaded,estimated:this.#u.estimated,count:this.count(),renders:this.#d}),this.#ke("model:changed",{reason:"stream",shiftAboveViewport:L,anchor:this.#p}),this.#ke("rows:changed",{companion:!0,reason:"stream"})}))}#le(){return this.#d===0||this.#h<this.#de()?Promise.resolve():(this.#h=0,new Promise(L=>{const T=(this.#t.scheduler||{}).idle;B(T)?T(()=>L()):G(()=>L())}))}#de(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:y}#he(L){const T=this.#t.scheduler||{};return B(T.frame)?T.frame(L):K(L)}#Le(L){const T=this.#t.scheduler||{};B(T.cancel)?T.cancel(L):x(L)}#xe(L){const T=this.#n[L];if(T!==void 0&&T!==v)return T;if(T===void 0)return;const A=this.#t.store;return A&&B(A.source)?A.source(L):void 0}#k(L,T){const A=this.#t.store;if(!A||!B(A.set))return;const C=this.#Z();if(Array.isArray(C))for(const H of C){if(!H||!H.id)continue;const Y=B(H.read)?H.read:Z=>a(Z,H.field||H.id);A.set(H.id,L,Y(T))}}#ve(L){let T=this.#l.get(L);return T||(T=this.#o.leaf(this.#xe(L),L),this.#l.set(L,T)),T}#Me(L,T){const A=this.#_e(T);return A&&B(A.getValue)?A.getValue(L):L?.[T]}#at(L){const T=this.#t.columns,A=T&&B(T.all)?T.all():[],C=[];for(const H of A){const Y=B(H.getValue)?H.getValue(L):void 0;Y!=null&&Y!==""&&C.push(String(Y))}return C.join(" ").toLowerCase()}#_e(L){const T=this.#t.columns;return T&&B(T.get)?T.get(L):void 0}#Ue(){const L=this.#V;if(this.#V=null,L&&B(L.return))try{L.return()}catch{}}#Xe(){return k({context:this.#ye("context",null)})}#ye(L,T){const A=this.#t.state;if(A&&B(A[L])){const C=A[L]();return C??T}return T}#ke(L,T){const A=this.#t.emit;B(A)&&A(L,T)}}}),Ie("packages/core/src/source/url.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return b}});const N=U("packages/core/src/internal/warn.js").warnOnce,X=U("packages/core/src/internal/predicates.js"),B=X.isObject,D=X.isFunction,K=U("packages/core/src/internal/paths.js").getPath,G=U("packages/core/src/source/abort.js").isAbortError,z=500,j=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),O=Symbol("lattice.url.skip");function b(g,k={}){const d=B(k)?k:{},p=D(d.fetch)?d.fetch:typeof globalThis<"u"&&D(globalThis.fetch)?globalThis.fetch:null,m=d.format==="json"||d.format==="ndjson"?d.format:void 0,v=typeof d.rowsPath=="string"&&d.rowsPath?d.rowsPath:void 0,y=D(d.map)?d.map:void 0,E=B(d.headers)?d.headers:void 0,M=Number.isFinite(d.batchSize)&&d.batchSize>0?Math.floor(d.batchSize):z,F=d.lenient===!0,V=Number.isFinite(d.poll)&&d.poll>0?Math.floor(d.poll):void 0,I=typeof g=="string"&&g.length>0;I||N("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*$(R={}){if(!I)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const L=R&&R.signal;let T;try{T=await p(g,E?{signal:L,headers:E}:{signal:L})}catch(H){throw G(H)?H:new Error(`[lattice] createUrlSource: request to ${g} failed — ${H&&H.message||H}`)}if(!T||!T.ok){const H=T?T.status:"no response";throw new Error(`[lattice] createUrlSource: ${H} for ${g}`)}const A=u(g,m,T),C=T.body&&D(T.body.getReader)?T.body.getReader():null;try{if(!C){const Z=await T.text();(A||r(Z,g))==="ndjson"?yield*o(null,null,Z,0,T,g,M,F):yield*c(Z,g,v,y);return}const H=new TextDecoder("utf-8");if(A==="json"){yield*c(await n(C,H,""),g,v,y);return}if(A==="ndjson"){yield*o(C,H,"",0,T,g,M,F);return}const Y=await t(C,H,g);Y.format==="json"?yield*c(await n(C,H,Y.seed),g,v,y):yield*o(C,H,Y.seed,Y.bytes,T,g,M,F)}finally{if(C&&D(C.cancel))try{await C.cancel()}catch{}}}const S={mode:"stream",open:$,autoStart:d.autoStart!==!1};return V!==void 0&&(S.poll=V),Number.isFinite(d.maxRows)&&(S.maxRows=d.maxRows),Number.isFinite(d.maxAge)&&(S.maxAge=d.maxAge),(typeof d.ageBy=="string"||D(d.ageBy))&&(S.ageBy=d.ageBy),Number.isFinite(d.coalesceMs)&&(S.coalesceMs=d.coalesceMs),Number.isFinite(d.promoteToMemoryBelow)&&(S.promoteToMemoryBelow=d.promoteToMemoryBelow),S}function u(g,k,d){if(k)return k;const p=f(g);if(p)return p;const m=d&&d.headers&&D(d.headers.get)?d.headers.get("content-type"):null;return a(m)}function f(g){const k=String(g).split(/[?#]/)[0].toLowerCase();if(k.endsWith(".ndjson")||k.endsWith(".jsonl"))return"ndjson";if(k.endsWith(".json"))return"json"}function a(g){if(!g)return;const k=g.split(";")[0].trim().toLowerCase();if(j.has(k))return"ndjson";if(k==="application/json"||k==="text/json"||k.endsWith("+json"))return"json"}function r(g,k){const d=g.replace(/^\s+/,""),p=s(d);if(p==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${k} — pass opts.format: 'json' | 'ndjson'.`);return p}async function t(g,k,d){let p="",m=0;for(;;){const{value:y,done:E}=await g.read();if(y&&(m+=y.byteLength,p+=k.decode(y,{stream:!0})),E){p+=k.decode();break}const M=p.replace(/^\s+/,"");if(M){if(M[0]==="[")return{format:"json",seed:p,bytes:m};if(M[0]!=="{"||p.indexOf(`
|
|
8
8
|
`)!==-1)break}}const v=s(p.replace(/^\s+/,""));if(v==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${d} — pass opts.format: 'json' | 'ndjson'.`);return{format:v,seed:p,bytes:m}}function s(g){if(!g||g[0]==="[")return"json";if(g[0]!=="{")return"error";const k=g.indexOf(`
|
|
9
9
|
`);if(k===-1)return"json";let d=g.slice(0,k);return d.endsWith("\r")&&(d=d.slice(0,-1)),i(d)?"ndjson":"json"}function i(g){try{return JSON.parse(g),!0}catch{return!1}}async function n(g,k,d){let p=d;for(;;){const{value:m,done:v}=await g.read();if(m&&(p+=k.decode(m,{stream:!0})),v)break}return p+=k.decode(),p}function*c(g,k,d,p){let m;try{m=JSON.parse(g)}catch(y){throw new Error(`[lattice] createUrlSource: ${k} is not valid JSON — ${y.message}`)}let v=d!==void 0?K(m,d):m;if(p&&(v=p(v)),!Array.isArray(v)){const y=d!==void 0||p?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${k} did not resolve to an array${y}.`)}yield{rows:v,progress:{loaded:v.length,estimated:v.length}}}async function*o(g,k,d,p,m,v,y,E){const M=w(m);let F=d||"",V=p||0,I=0,$=0,S=[];function*R(){let T;for(;(T=F.indexOf(`
|
|
10
10
|
`))!==-1;){const A=F.slice(0,T);F=F.slice(T+1),$++;const C=l(A,$,v,E);C!==O&&(S.push(C),S.length>=y&&(I+=S.length,yield h(S,I,M,V),S=[]))}}if(g){for(;;){const{value:T,done:A}=await g.read();if(T&&(V+=T.byteLength,F+=k.decode(T,{stream:!0}),yield*R()),A)break}F+=k.decode()}yield*R(),$++;const L=l(F,$,v,E);L!==O&&S.push(L),S.length&&(I+=S.length,yield h(S,I,M,V))}function l(g,k,d,p){let m=g;if(m.endsWith("\r")&&(m=m.slice(0,-1)),!m.trim())return O;try{return JSON.parse(m)}catch(v){if(p)return N(`source.url.badline.${d}`,`skipping a malformed NDJSON line (line ${k}) from ${d} — ${v.message}`),O;throw new Error(`[lattice] createUrlSource: malformed NDJSON at line ${k} of ${d} — ${v.message}`)}}function h(g,k,d,p){const m=d&&p>0&&k>0?Math.max(k,Math.round(d/(p/k))):void 0;return{rows:g,progress:{loaded:k,estimated:m}}}function w(g){const k=g&&g.headers&&D(g.headers.get)?g.headers.get("content-length"):null,d=k!=null?Number(k):NaN;return Number.isFinite(d)&&d>0?d:void 0}}),Ie("packages/core/src/source/derive.js",function(e,U){"use strict";Object.defineProperty(e,"FOLLOW_MODES",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"BUCKETS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"DERIVED_ROW_KEY",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"DERIVED_SOURCE_KEY",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"UNION_KEY_SEP",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"readPath",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"unnest",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"reduceValues",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"applyLimit",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"applyCumulative",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"groupRows",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"finishGroups",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"derive",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"normalizeUnionSource",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"namespaceUnionKeys",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"joinRows",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"preGroup",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"buildJoinIndex",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"joinOne",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"joinKeyOf",{enumerable:!0,get:function(){return m}});const te=U("packages/core/src/internal/predicates.js"),N=te.isFunction,X=te.isObject,D=U("packages/core/src/compute/total.js").TOTAL_FNS,q=Object.freeze(["filtered","all","selected","grouped"]),K=Object.freeze(["day","week","month","quarter","year"]),x="__key",G="__source",z="";function j(v,y){if(!X(v)||typeof y!="string")return;if(!y.includes("."))return v[y];let E=v;for(const M of y.split(".")){if(!X(E))return;E=E[M]}return E}function O(v,y){const E=[];for(const M of v){const F=j(M,y);if(!(!Array.isArray(F)||!F.length))for(const V of F)E.push({...M,[y]:V})}return E}function b(v,y){const E=v instanceof Date?v:new Date(v),M=E.getTime();if(!Number.isFinite(M))return null;const F=E.getUTCFullYear(),V=E.getUTCMonth(),I=E.getUTCDate(),$=S=>S.toISOString().slice(0,10);switch(y){case"year":return $(new Date(Date.UTC(F,0,1)));case"quarter":return $(new Date(Date.UTC(F,Math.floor(V/3)*3,1)));case"month":return $(new Date(Date.UTC(F,V,1)));case"week":{const S=(E.getUTCDay()+6)%7;return $(new Date(Date.UTC(F,V,I-S)))}default:return $(new Date(Date.UTC(F,V,I)))}}function u(v,y,E){const M=y.map(F=>E&&E.of===F?b(j(v,F),E.by):j(v,F));return{key:M.map(F=>F==null?"\0":String(F)).join(""),values:M}}function f(v,y){const E=D[y];return E?E({get:M=>v[M]},t(v.length)):null}function a(v,y){return!y||typeof y.of!="string"||y.of===""||v&&v.includes(y.of)?v:[y.of,...v||[]]}function r(v,y){const E={},M=t(v.length);for(const[F,V]of Object.entries(y)){const I=V.fn||"count",$=D[I];if(!$){E[F]=null;continue}const S=V.of?v.map(R=>j(R,V.of)):[];E[F]=$({get:R=>S[R]},M)}return E}const t=(()=>{const v=new Map;return y=>{let E=v.get(y);if(!E){E=new Uint32Array(y);for(let M=0;M<y;M++)E[M]=M;v.size<512&&v.set(y,E)}return E}})();function s(v,y,E){if(!Number.isFinite(y)||y<=0)return v;if(!E)return v.slice(0,y);const M=new Map,F=[];for(const V of v){const I=String(j(V,E)),$=M.get(I)||0;$>=y||(M.set(I,$+1),F.push(V))}return F}function i(v,y){const E=v.reduce((I,$)=>I+(Number(j($,y.of))||0),0);if(!E)return v;const M=E*y.upTo;let F=0;const V=[];for(const I of v)if(V.push(I),F+=Number(j(I,y.of))||0,F>=M)break;return V}function n(v,y){return!Array.isArray(y)||!y.length?v:[...v].sort((E,M)=>{for(const F of y){const V=j(E,F.col),I=j(M,F.col);if(V===I)continue;return V==null?1:I==null?-1:((typeof V=="number"&&typeof I=="number"?V<I:String(V)<String(I))?-1:1)*(F.dir==="desc"?-1:1)}return 0})}function c(v,y,E){const M=y.groupBy?Array.isArray(y.groupBy)?y.groupBy:[y.groupBy]:null,F=X(y.bucket)?y.bucket:null,V=a(M,F),I=new Map,$=new Map;if(!V)return{groups:I,rowGroup:$};for(const S of v){const{key:R,values:L}=u(S,V,F);let T=I.get(R);T||(T={values:L,rows:new Map},I.set(R,T));const A=E(S);T.rows.set(A,S),$.set(A,R)}return{groups:I,rowGroup:$}}function o(v,y,E=null,M=null){const F=y.groupBy?Array.isArray(y.groupBy)?y.groupBy:[y.groupBy]:null,V=X(y.bucket)?y.bucket:null,I=a(F,V);let $=[...v.entries()].map(([S,R])=>{if(E&&M&&!M.has(S)){const T=E.get(S);if(T)return T}const L={[x]:S};return I.forEach((T,A)=>{L[T.includes(".")?T.split(".").pop():T]=R.values[A]}),Object.assign(L,r([...R.rows.values()],y.select||{})),E&&E.set(S,L),L});return $=n($,y.sort),X(y.cumulative)&&($=i($,y.cumulative)),s($,y.limit,y.limitPer||null)}function l(v,y){const E=k(v,y),M=y.groupBy?Array.isArray(y.groupBy)?y.groupBy:[y.groupBy]:null,F=X(y.bucket)?y.bucket:null,V=a(M,F);let I;if(!V)I=E.map(($,S)=>({...$,[x]:String(j($,y.rowKey||"id")??S)}));else{const $=new Map;for(const S of E){const{key:R,values:L}=u(S,V,F);let T=$.get(R);T||(T={values:L,rows:[]},$.set(R,T)),T.rows.push(S)}I=[...$.entries()].map(([S,R])=>{const L={[x]:S};return V.forEach((T,A)=>{L[T.includes(".")?T.split(".").pop():T]=R.values[A]}),Object.assign(L,r(R.rows,y.select||{})),L})}return I=n(I,y.sort),X(y.cumulative)&&(I=i(I,y.cumulative)),s(I,y.limit,y.limitPer||null)}function h(v,y){const M=X(v)&&X(v.grid)?v:{grid:v};return{grid:X(M.grid)?M.grid:null,label:M.label!=null&&M.label!==""?String(M.label):String(y),follow:typeof M.follow=="string"?M.follow:void 0,map:N(M.map)?M.map:null}}function w(v){for(const y of v){const E=y[G];E!==void 0&&(y[x]=`${E}${z}${y[x]}`)}return v}function g(v,y){const E=y.on,M=X(E)?String(E.left||E.right||""):String(E||""),F=X(E)?String(E.right||E.left||""):String(E||"");if(!M||!F)return v;const V=y.index instanceof Map?y.index:d(Array.isArray(y.rows)?y.rows:[],F),I=Array.isArray(y.select)?y.select.map(String):null,$=y.prefix?String(y.prefix):"",S=String(y.type||"inner")==="left",R=[];for(const L of v){const T=j(L,M),A=T==null?void 0:V.get(String(T));if(!A){S&&R.push(L);continue}const C={...L},H=I||Object.keys(A);for(const Y of H)!$&&Y===M||(C[$?$+Y:Y]=j(A,Y));R.push(C)}return R}function k(v,y){let E=Array.isArray(v)?v:[];return y.unnest&&(E=O(E,y.unnest)),X(y.join)&&(Array.isArray(y.join.rows)||y.join.index instanceof Map)&&(E=g(E,y.join)),N(y.where)&&(E=E.filter(M=>!!y.where(M))),E}function d(v,y){const E=new Map;for(const M of v){const F=j(M,y);if(F==null)continue;const V=String(F);E.has(V)||E.set(V,M)}return E}function p(v,y){const E=y.on,M=X(E)?String(E.left||E.right||""):String(E||""),F=X(E)?String(E.right||E.left||""):String(E||"");if(!M||!F)return v;const V=y.index instanceof Map?y.index:new Map,I=j(v,M),$=I==null?void 0:V.get(String(I));if(!$)return String(y.type||"inner")==="left"?v:null;const S=Array.isArray(y.select)?y.select.map(String):null,R=y.prefix?String(y.prefix):"",L={...v};for(const T of S||Object.keys($))!R&&T===M||(L[R?R+T:T]=j($,T));return L}function m(v,y){const E=j(v,y);return E==null?null:String(E)}}),Ie("packages/core/src/source/derived.js",function(e,U){"use strict";Object.defineProperty(e,"IDLE_REFRESH_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"PROFILE_FIELDS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ALERT_THRESHOLDS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"STATISTICS_FNS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"SERIES_METRICS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"PRODUCER_IGNORED_KEYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"profileAlerts",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"DerivedSource",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"createDerivedSource",{enumerable:!0,get:function(){return F}});const te=U("packages/core/src/internal/predicates.js"),N=te.isFunction,X=te.isObject,D=U("packages/core/src/internal/warn.js").warnOnce,K=U("packages/core/src/source/memory.js").MemorySource,G=U("packages/core/src/source/settle.js").isPipelineSettle,z=U("packages/core/src/source/derive.js"),j=z.derive,O=z.preGroup,b=z.groupRows,u=z.finishGroups,f=z.readPath,a=z.buildJoinIndex,r=z.joinOne,t=z.joinKeyOf,s=z.FOLLOW_MODES,i=z.DERIVED_ROW_KEY,n=z.DERIVED_SOURCE_KEY,c=z.normalizeUnionSource,o=z.namespaceUnionKeys,l=16,h=Object.freeze(["column","rows","present","missing","numeric","distinct","min","max","mean","median","q1","q3","iqr","stddev","outliers","alerts","alertCount"]),w=Object.freeze({missing:.2,cardinality:.9,skew:1,outliers:.05}),g=Object.freeze(["correlation","series","datasetVsDataset"]),k=Object.freeze(["n","first","last","change","changePercent","volatility","annualisedVolatility","growth","maxDrawdown","maxDrawdownFrom","maxDrawdownTo","autocorrelation","upDays","downDays"]),d=Object.freeze(["unnest","join","where","bucket","groupBy","select","sort","limit","limitPer","cumulative"]);function p(V,I={}){const $={...w,...X(I)?I:{}},S=ee=>typeof ee=="number"&&Number.isFinite(ee)?ee:null,R=S(V.rows)??0,L=S(V.numeric)??0,T=S(V.missing)??0,A=S(V.distinct),C=S(V.mean),H=S(V.median),Y=S(V.stddev),Z=S(Array.isArray(V.outliers)?V.outliers.length:V.outliers),_=L>0,J=[];return A===0?["empty"]:(A===1&&J.push("constant"),R>0&&T/R>=$.missing&&J.push("high-missing"),!_&&A!==null&&R>1&&A===R&&T===0?J.push("unique"):A!==null&&R>0&&A/R>=$.cardinality&&J.push("high-cardinality"),_&&C!==null&&H!==null&&Y!==null&&Y>0&&Math.abs(3*(C-H)/Y)>=$.skew&&J.push("skewed"),_&&Z!==null&&Z/L>=$.outliers&&J.push("outliers"),J)}class m extends K{#e=null;#t={};#n=[];#r=null;#i=!1;#s={};#o=!1;#l=null;#a=null;#c=!1;#u=null;#f=!1;#d=null;constructor(I,$){super({mode:"memory",rows:[]},$),this.#s=$||{},this.#t=X(I)?I:{};const S=this.#t.from;if(Array.isArray(S)){if(this.#e=null,this.#d=this.#g(S),!this.#d.length){D("source.derived.from",'source.mode "derived" needs `from`: at least one grid to derive from.');return}this.#t.follow!==void 0&&D("source.derived.union.follow",'source.mode "derived": `follow` is ignored when `from` is a union of several grids (BACKLOG-0001045) — each entry carries its own `follow` instead.'),this.#t.crossFilter&&D("source.derived.union.crossfilter",'source.mode "derived": `crossFilter` is not supported when `from` is a union of several grids (BACKLOG-0001045) — it has no single target once there is more than one parent. Push a filter onto the individual source grid you mean instead.'),this.#t.statistics!==void 0&&(D("source.derived.union.statistics",'source.mode "derived": `statistics` is not supported when `from` is a union of several grids (BACKLOG-0001046) — a relational statistic reduces one grid\'s own columns, and a union has no single set of them. Derive the statistics of a single grid instead.'),this.#f=!0),this.#m(),this.#b(),this.refresh();return}if(this.#e=S||null,!this.#e){D("source.derived.from",'source.mode "derived" needs `from`: the grid to derive from.');return}this.#t.follow&&!s.includes(String(this.#t.follow))&&D(`source.derived.follow.${this.#t.follow}`,`unknown follow "${this.#t.follow}"; using "filtered". Known: ${s.join(", ")}.`),this.#h()||(this.#f=!0),this.#m(),this.#b(),this.refresh()}#h(){const I=this.#t.statistics;if(I===void 0)return!0;if(this.#t.profile!==void 0)return D("source.derived.producer.conflict",'source.mode "derived": `profile` and `statistics` are both terminal producers and cannot be used together — each replaces the pipeline with its own output builder. Declare one, or chain a second derived grid whose `from` is the first.'),!1;if(!X(I))return D("source.derived.statistics.shape",`source.mode "derived": \`statistics\` needs an object naming the statistic, e.g. \`{ fn: 'correlation', columns: ['a', 'b'] }\`. Known fn: ${g.join(", ")}.`),!1;const $=String(I.fn||"");return g.includes($)?this.#p($,I):(D(`source.derived.statistics.fn.${$}`,`source.mode "derived": unknown \`statistics.fn\` "${$}". Known: ${g.join(", ")}. Every *single-column* statistic is reached through \`select\` instead, e.g. \`select: { p95: { of: 'amount', fn: 'p95' } }\`.`),!1)}#p(I,$){if(I==="correlation"){if((Array.isArray($.columns)?$.columns.filter(Boolean):[]).length<2)return D("source.derived.statistics.columns","source.mode \"derived\": `statistics: { fn: 'correlation' }` needs `columns`: at least two column ids to correlate pairwise."),!1;const R=$.orient===void 0?"pairs":String($.orient);return R!=="pairs"&&R!=="matrix"&&D(`source.derived.statistics.orient.${R}`,`source.mode "derived": unknown \`statistics.orient\` "${R}" for \`fn: 'correlation'\`; using "pairs". Known: pairs, matrix.`),!0}return I==="series"?!$.of||!$.by?(D("source.derived.statistics.series","source.mode \"derived\": `statistics: { fn: 'series' }` needs both `of` (the column to summarise) and `by` (the column that orders it). `by` is never guessed — kernels see rows in arrival order, which is not the grid's sort."),!1):!0:X($.with)?!0:(D("source.derived.statistics.with","source.mode \"derived\": `statistics: { fn: 'datasetVsDataset' }` needs `with`: the second grid to compare this one against."),!1)}#m(){const I=this.#t.statistics!==void 0?"statistics":this.#t.profile!==void 0?"profile":null;if(!I)return;const $=d.filter(S=>this.#t[S]!==void 0);$.length&&D(`source.derived.producer.ignored.${I}`,`source.mode "derived": \`${I}\` is a terminal producer and replaces the pipeline, so ${$.map(S=>`\`${S}\``).join(", ")} ${$.length>1?"are":"is"} ignored. Sort, filter or limit the derived grid itself, or chain a second derived grid whose \`from\` is this one.`)}#g(I){const $=this.#s&&this.#s.grid,S=new Set,R=[];return I.forEach((L,T)=>{const A=c(L,T);if(S.has(A.label)&&D(`source.derived.union.label.${A.label}`,`source.mode "derived": two union sources share the label "${A.label}"; give each a distinct \`label\` or __source/__key will not distinguish them.`),S.add(A.label),!A.grid){D(`source.derived.union.missing.${A.label}`,`source.mode "derived": union source "${A.label}" has no grid and was skipped.`),R.push(A);return}if($&&N(A.grid.on)){const C=y($,A.grid,[A.label]);if(C){D(`source.derived.union.cycle.${A.label}`,`source.mode "derived": union source "${A.label}" was refused — it derives from the grid being derived, directly or through a chain (${C.join(" → ")}). Remove it from \`from\`.`),R.push({...A,grid:null});return}}R.push(A)}),R}#b(){if(this.#d){this.#A(),this.#w();return}const I=this.#e;if(!I||!N(I.on))return;const $=String(this.#t.follow||"filtered"),S=["rows:changed"];($==="filtered"||$==="grouped")&&S.push("filter:changed","model:changed"),$==="selected"&&S.push("selection:changed"),$==="grouped"&&S.push("column:grouped");for(const R of S){const L=T=>{R==="rows:changed"&&v(T)||R==="model:changed"&&!G(T)||this.schedule(R==="rows:changed"?T:null)};I.on(R,L),this.#n.push(()=>N(I.off)&&I.off(R,L))}this.#w(),this.#y()}#y(){const I=this.#t.statistics,$=X(I)?I.with:null;if(!X($)||!N($.on))return;const S=$;for(const R of["rows:changed","filter:changed","model:changed"]){const L=T=>{R==="rows:changed"&&v(T)||R==="model:changed"&&!G(T)||this.schedule(null)};S.on(R,L),this.#n.push(()=>N(S.off)&&S.off(R,L))}}#A(){for(const I of this.#d){const $=I.grid;if(!$||!N($.on))continue;const S=s.includes(String(I.follow))?String(I.follow):"filtered",R=["rows:changed"];(S==="filtered"||S==="grouped")&&R.push("filter:changed","model:changed"),S==="selected"&&R.push("selection:changed"),S==="grouped"&&R.push("column:grouped");for(const L of R){const T=A=>{L==="rows:changed"&&v(A)||L==="model:changed"&&!G(A)||this.schedule(null)};$.on(L,T),this.#n.push(()=>N($.off)&&$.off(L,T))}}}#w(){const I=this.#t.join,$=I&&I.with;if(!$||!N($.on))return;const R=String(I.follow||"all")==="all"?["rows:changed"]:["rows:changed","filter:changed","model:changed"];for(const L of R){const T=A=>{L==="rows:changed"&&v(A)||L==="model:changed"&&!G(A)||this.schedule({partner:!0})};$.on(L,T),this.#n.push(()=>N($.off)&&$.off(L,T))}}#O(){const I=this.#t.join;if(!I||!I.with)return null;const $=I.on,S=X($)?String($.left||$.right||""):String($||""),R=X($)?String($.right||$.left||""):String($||"");return S&&R?{left:S,right:R}:null}#v(){const I=this.#O();if(!I)return this.#u=null,null;const $=this.#u;if(this.#u=a(this.#E(),I.right),!$)return null;const S=this.#t.join||{},R=Array.isArray(S.select)?S.select.map(String):null,L=C=>C?(R||Object.keys(C)).map(Y=>String(f(C,Y))).join(""):null,T=new Set,A=new Set;for(const[C,H]of this.#u)L(H)!==L($.get(C))&&(T.add(C),$.has(C)||A.add(C));for(const C of $.keys())this.#u.has(C)||T.add(C);return{affected:T,gained:A}}#T(I,$){const S=this.#l;if(!S||!S.leftByJoinKey)return null;const R=[];for(const L of I){const T=S.leftByJoinKey.get(L);if(T)for(const A of T){const C=S.rowData.get(A);C!==void 0&&R.push({key:A,data:C})}}return this.#M({updated:R,added:[],removed:[]},$)}#S(I,$){if(!this.#l||!this.#l.leftByJoinKey||I.unnest||I.where||String(I.follow||"filtered")==="grouped")return!1;const S=I.join||{};return String(S.type||"inner")==="left"?!0:$.size===0}#E(){const I=this.#t.join,$=I&&I.with;if(!$||!$.rows)return[];const S=[],R=L=>{L.group||S.push(E(L))};return String(I.follow||"all")==="filtered"&&N($.rows.forEach)?$.rows.forEach(R):N($.rows.forEachAll)&&$.rows.forEachAll(R),S}schedule(I){const $=this.#t.refresh===void 0?"idle":this.#t.refresh;if($==="manual")return;if($==="live"){this.refresh(I);return}const S=typeof $=="number"&&Number.isFinite($)?$:l;if(this.#r){this.#c=!0;return}this.#c=!1,this.#r=setTimeout(()=>{this.#r=null,this.refresh(this.#c?null:I)},S)}refresh(I){if(!(this.#i||!this.#e&&!this.#d)){if(this.#o){D("source.derived.cycle","a derived grid is deriving from itself, directly or through a chain. The cycle was refused; check the `from` of each grid in the chain.");return}this.#o=!0;try{const $=this.#f?[]:this.#d?this.#t.profile?this.#Y():this.#x():this.#t.statistics!==void 0?this.#pe():this.#t.profile?this.#ge():this.#N(I);this.setRows($),this.invalidate("filter"),N(this.#s.emit)&&this.#s.emit("rows:changed",{derived:!0},"derived")}finally{this.#o=!1}}}#N(I){const S=X(I)&&I.partner===!0?this.#v():null,R=this.#G();if(S&&this.#l){if(!S.affected.size)return u(this.#l.groups,R,this.#l.reduced,new Set);if(this.#S(R,S.gained)){const ne=this.#T(S.affected,R);if(ne)return u(this.#l.groups,R,this.#l.reduced,ne)}}const L=this.#P(R,I);if(L&&this.#l){const ne=this.#M(L,R);return u(this.#l.groups,R,this.#l.reduced,ne)}const T=O(this.#D(),R);if(this.#a=this.#$(),!R.groupBy)return this.#l=null,j(T,R);const A=this.#R(),{groups:C,rowGroup:H}=b(T,R,A),Y=new Map;for(const[ne,se]of H){const oe=C.get(se);oe&&Y.set(ne,oe.rows.get(ne))}const Z=new Map,_=this.#O(),J=new Map,ee=new Map;if(_)for(const[ne,se]of Y){const oe=t(se,_.left);if(oe===null)continue;J.set(ne,oe);let fe=ee.get(oe);fe||(fe=new Set,ee.set(oe,fe)),fe.add(ne)}return this.#l={groups:C,rowGroup:H,rowData:Y,reduced:Z,leftJoinKey:J,leftByJoinKey:ee},u(C,R,Z,null)}#P(I,$){if(!this.#l||!I.groupBy||I.unnest||I.where||String(I.follow||"filtered")==="grouped"||X(I.join)&&I.join.with&&!(I.join.index instanceof Map)||!X($))return null;const S=Array.isArray($.updated)?$.updated:null,R=Array.isArray($.added)?$.added:null,L=Array.isArray($.removed)?$.removed:null;if(!S&&!R&&!L)return null;const T=this.#a;if(T&&T.size&&String(I.follow||"filtered")!=="all"){if($.edit===!0&&Array.isArray($.columns)){for(const A of $.columns)if(T.has(String(A)))return null}for(const A of S||[]){const C=A&&A.key,H=C===void 0?void 0:this.#l.rowData.get(String(C)),Y=E(A);for(const Z of T)if(f(H,Z)!==f(Y,Z))return null}}return{updated:S||[],added:R||[],removed:L||[]}}#M(I,$){const S=this.#l,R=this.#R(),L=new Set,T=X($.join)&&$.join.index instanceof Map?$.join:null,A=this.#O(),C=Y=>{const Z=S.rowGroup.get(Y);if(Z===void 0)return;L.add(Z);const _=S.groups.get(Z);if(_&&(_.rows.delete(Y),_.rows.size||S.groups.delete(Z)),S.rowGroup.delete(Y),S.rowData.delete(Y),S.leftJoinKey){const J=S.leftJoinKey.get(Y);if(J!==void 0){const ee=S.leftByJoinKey.get(J);ee&&(ee.delete(Y),ee.size||S.leftByJoinKey.delete(J)),S.leftJoinKey.delete(Y)}}},H=Y=>{const Z=T?r(Y,T):Y;if(!Z)return;const _=R(Z),J=b([Z],$,R);for(const[ee,ne]of J.groups){let se=S.groups.get(ee);se||(se={values:ne.values,rows:new Map},S.groups.set(ee,se)),se.rows.set(_,Z),S.rowGroup.set(_,ee),L.add(ee)}if(S.rowData.set(_,Z),A&&S.leftByJoinKey){const ee=t(Z,A.left);if(ee!==null){S.leftJoinKey.set(_,ee);let ne=S.leftByJoinKey.get(ee);ne||(ne=new Set,S.leftByJoinKey.set(ee,ne)),ne.add(_)}}};for(const Y of I.removed)C(String(Y));for(const Y of I.updated)C(String(Y.key)),H(E(Y));for(const Y of I.added)H(E(Y));return L}#R(){const I=this.#e,$=I&&I.config&&I.config.rowKey||"id";return S=>String(f(S,typeof $=="string"?$:"id")??"")}#$(){const I=this.#e,$=I&&I.state&&N(I.state.get)?I.state.get():null,S=new Set,R=L=>{if(L){if(Array.isArray(L.conditions)){L.conditions.forEach(R);return}L.col&&S.add(String(L.col))}};return $&&R($.filters),S}#G(){let I=this.#t;if(I.join&&I.join.with&&(this.#u||this.#v(),I={...I,join:{...I.join,index:this.#u}}),this.#d||String(I.follow||"filtered")!=="grouped")return I;const $=this.#e,S=$&&$.state&&N($.state.get)?$.state.get():null,R=S&&Array.isArray(S.group)?S.group:[];return R.length?{...I,groupBy:[...R]}:I}#V(){const I=[];for(const $ of this.#d)if($.grid)try{const S=s.includes(String($.follow))?String($.follow):"filtered",R=this.#F($.grid,S);for(const L of R){const T=$.map?$.map(L):L;X(T)&&I.push({...T,[n]:$.label})}}catch(S){D(`source.derived.union.failed.${$.label}`,`source.mode "derived": union source "${$.label}" failed to read (${S&&S.message?S.message:S}) and was skipped this pass.`)}return I}#F(I,$){if(!I||!I.rows)return[];if($==="all"){const R=[];return N(I.rows.forEachAll)&&I.rows.forEachAll(L=>{L.group||R.push(E(L))}),R}if($==="selected")return(I.selection&&N(I.selection.rows)?I.selection.rows():[]).filter(Boolean).map(E);const S=[];return N(I.rows.forEach)&&I.rows.forEach(R=>{R.group||S.push(E(R))}),S}#x(){const I=this.#G(),$=this.#V(),S=j($,I);return I.groupBy?S:o(S)}#Y(){return D("source.derived.union.profile",'source.mode "derived": `profile` is not supported when `from` is a union of several grids (BACKLOG-0001045); profile a single grid instead.'),[]}#D(){const I=this.#e,$=String(this.#t.follow||"filtered");if(!I||!I.rows)return[];if($==="all"){const L=[];return N(I.rows.forEachAll)&&I.rows.forEachAll(T=>{T.group||L.push(E(T))}),L}if($==="selected")return(I.selection&&N(I.selection.rows)?I.selection.rows():[]).filter(Boolean).map(E);const S=this.#K(),R=[];return S&&this.#H().length&&N(I.rows.forEachExcept)?(I.rows.forEachExcept(S,L=>{L.group||R.push(E(L))}),R):(N(I.rows.forEach)&&I.rows.forEach(L=>{L.group||R.push(E(L))}),R)}#K(){const I=this.#t.crossFilter;if(!I||this.#d)return null;if(typeof I=="string")return I;if(I.col)return String(I.col);const $=this.#t.groupBy,S=Array.isArray($)?$[0]:$;return S?String(S):null}#H(){const I=this.#K(),$=this.#e;if(!I||!$||!$.filters||!N($.filters.get))return[];const S=M($.filters.get(),I);return S?S.op==="in"&&Array.isArray(S.value)?S.value.map(String):S.op==="eq"&&S.value!==void 0?[String(S.value)]:[]:[]}#B(I){const $=this.#K(),S=this.#e;if(!$||!S||!S.filters||!N(S.filters.set))return;const R=this.#s.compute||{},L=N(S.filters.get)?S.filters.get():null,T=N(R.pruneColumn)?R.pruneColumn(L,$):null;if(!I.length){S.filters.set(T||null);return}const A=I.length===1?{col:$,op:"eq",value:I[0]}:{col:$,op:"in",value:I.slice()},C=T?T.conditions&&T.op?T.conditions:[T]:[];S.filters.set(C.length?{op:"and",conditions:[...C,A]}:A)}crossFilter(){const I=this;return{enabled(){return!!I.#K()},column(){return I.#K()},get(){return I.#H()},set($){const S=$==null?[]:(Array.isArray($)?$:[$]).map(R=>String(R));I.#B(S)},toggle($){const S=String($),R=I.#H(),T=R.indexOf(S)>=0?R.filter(A=>A!==S):[...R,S];I.#B(T)},clear(){I.#B([])}}}#fe(I){const $=I&&I.rows;if($&&N($.matchCount)){const S=$.matchCount(),R=Number(S);if(S!==null&&Number.isFinite(R))return R}if($&&N($.count)){const S=Number($.count());if(Number.isFinite(S))return S}return 0}#pe(){const I=this.#e,$=this.#t.statistics;if(!I||!I.statistics||!X($))return[];switch(String($.fn)){case"correlation":return this.#se(I,$);case"series":return this.#Be(I,$);case"datasetVsDataset":return this.#Se(I,$);default:return[]}}#se(I,$){const S=$.columns.filter(Boolean).map(String),R=this.#fe(I),L=(T,A)=>{const C=I.statistics.correlation(T,A);return typeof C=="number"&&Number.isFinite(C)?C:null};if(String($.orient||"pairs")!=="matrix"){const T=[];for(let A=0;A<S.length;A++)for(let C=A+1;C<S.length;C++)T.push({[i]:`${S[A]}${S[C]}`,a:S[A],b:S[C],coefficient:L(S[A],S[C]),n:R});return T}return S.map(T=>{const A={[i]:T,column:T};for(const C of S)A[C]=T===C?1:L(T,C);return A.n=R,A})}#Be(I,$){const S=this.#fe(I),R={by:String($.by)};$.periodsPerYear!==void 0&&(R.periodsPerYear=Number($.periodsPerYear));const L=I.statistics.series(String($.of),R)||{};return k.map(T=>({[i]:T,metric:T,value:L[T]??null,n:S}))}#Se(I,$){const S=$.with,R=Array.isArray($.columns)?{columns:$.columns.map(String)}:void 0,L=I.statistics.datasetVsDataset(S,R);if(!X(L))return[];const A=(Array.isArray(L.ranked)?L.ranked:[]).map(Y=>({[i]:String(Y.column),column:Y.column,measure:Y.measure??null,magnitude:Y.magnitude??null,distance:Y.distance??null,direction:Y.direction??null,nA:Y.nA??null,nB:Y.nB??null,reliable:Y.reliable??null,unmatched:""})),C=L.unmatched,H=[["A",C&&C.onlyA],["B",C&&C.onlyB]];for(const[Y,Z]of H)for(const _ of Z||[])A.push({[i]:`${Y}${_}`,column:_,measure:null,magnitude:null,distance:null,direction:null,nA:null,nB:null,reliable:!1,unmatched:Y});return A}#ge(){const I=this.#e;if(!I||!I.statistics||!N(I.statistics.profile))return[];const S=(Array.isArray(this.#t.profile)?this.#t.profile:[this.#t.profile]).filter(Boolean).map(L=>{const T=I.statistics.profile(String(L))||{},A={[i]:String(L)};for(const H of h)A[H]=H==="column"?String(L):T[H]??null;A.outliers=Array.isArray(T.outliers)?T.outliers.length:T.outliers??null;const C=p({...T,rows:A.rows,outliers:A.outliers,numeric:T.numeric},this.#t.alerts);return A.alerts=C.join(", "),A.alertCount=C.length,A});if(this.#t.orient!=="metrics")return S;const R=S[0];return R?h.filter(L=>L!=="column").map(L=>({[i]:L,metric:L,value:R[L]})):[]}apply(I){const $=["add","update","remove"],S=[];for(const R of $)for(const L of I&&I[R]||[])S.push({operation:R,id:L&&L.id,reason:"derived-read-only"});return S.length&&D("source.derived.readonly","a derived grid is read-only: its rows are computed from another grid. Write to the source grid instead, and the derived one follows."),{added:[],updated:[],removed:[],rejected:S}}destroy(){this.#i=!0,this.#r&&(clearTimeout(this.#r),this.#r=null),this.#K()&&this.#H().length&&this.#B([]);for(const I of this.#n)try{I()}catch{}this.#n=[],this.#e=null,this.#d=null,super.destroy()}}function v(V){return X(V)&&V.companion===!0}function y(V,I,$,S=new Set){if(I===V)return $;if(S.has(I))return null;S.add(I);let R=null;try{R=N(I.config)?I.config():null}catch{R=null}const L=R&&X(R.source)?R.source:null;if(!L||L.mode!=="derived")return null;const T=L.from;if(Array.isArray(T)){for(let A=0;A<T.length;A++){const C=c(T[A],A);if(!C.grid||!N(C.grid.on))continue;const H=y(V,C.grid,[...$,C.label],S);if(H)return H}return null}return X(T)&&N(T.on)?y(V,T,[...$,"(from)"],S):null}function E(V){return X(V)&&"data"in V?V.data:V}function M(V,I){if(!V||typeof V!="object")return null;if(Array.isArray(V.conditions)){for(const S of V.conditions){const R=M(S,I);if(R)return R}return null}return V.col===I?V:null}function F(V,I){return new m(V,I)}}),Ie("packages/core/src/source/adapters/odata.js",function(e,U){"use strict";Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return h}});const N=U("packages/core/src/internal/warn.js").warnOnce,B=U("packages/core/src/source/filterwire.js").isGroup,D=Object.freeze(["eq","ne","gt","gte","lt","lte","contains","startsWith","endsWith","blank","notBlank","between","notBetween"]),q=/^\d{4}-\d{2}-\d{2}$/,K=/^\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/,x=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;function G(w){const g=w instanceof Date?w:typeof w=="number"&&Number.isFinite(w)?new Date(w):typeof w=="string"&&x.test(w)?new Date(w):null;return g&&!Number.isNaN(g.getTime())?g:null}const z=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function j(w,g){throw typeof g=="string"&&z.test(g)?new Error(`odataAdapter: "${g}" needs a zone designator to be used as a ${w} value — add "Z" for UTC or a "+HH:MM"/"-HH:MM" offset. A date-time with no zone is ambiguous (whose local time?) and would otherwise silently become the wrong instant rather than the one intended.`):new Error(`odataAdapter: "${String(g)}" is not a usable ${w} value`)}function O(w){const g=G(w);return g||j("DateTimeOffset",w),g.toISOString()}function b(w){if(typeof w=="string"&&q.test(w))return w;const g=G(w);return g||j("Date",w),g.toISOString().slice(0,10)}function u(w){if(typeof w=="string"&&K.test(w))return w.length===5?`${w}:00`:w;if(typeof w=="number"&&Number.isFinite(w)&&w>=0&&w<864e5){const g=Math.floor(w),k=d=>String(d).padStart(2,"0");return`${k(Math.floor(g/36e5))}:${k(Math.floor(g%36e5/6e4))}:${k(Math.floor(g%6e4/1e3))}`}throw new Error(`odataAdapter: "${String(w)}" is not a usable TimeOfDay value`)}const f=Object.freeze({timestamp:O,datetime:O,date:b,dateString:b,time:u}),a=200,r=1e3,t=Object.freeze({eq:"eq",ne:"ne",gt:"gt",gte:"ge",lt:"lt",lte:"le"});function s(w,g){if(w==null)return"null";const k=g&&f[String(g)];return k?k(w):typeof w=="number"||typeof w=="boolean"?String(w):w instanceof Date?w.toISOString():`'${String(w).replace(/'/g,"''")}'`}function i(w){const g=String(w),k=/^[A-Za-z_][A-Za-z0-9_]*$/;if(!g||!g.split("/").every(d=>k.test(d)))throw new Error(`odataAdapter: "${g}" is not a usable column name`);return g}const n=Object.freeze({lo:{incl:"ge",excl:"gt"},hi:{incl:"le",excl:"lt"}});function c(w){const g=i(w.col),k=String(w.op),d=w.type;if(t[k])return`${g} ${t[k]} ${s(w.value,d)}`;if(k==="contains")return`contains(${g},${s(w.value,d)})`;if(k==="startsWith")return`startswith(${g},${s(w.value,d)})`;if(k==="endsWith")return`endswith(${g},${s(w.value,d)})`;if(k==="blank")return`(${g} eq null)`;if(k==="notBlank")return`(${g} ne null)`;if(k==="between"||k==="notBetween"){const p=Array.isArray(w.value)?w.value:[w.value,w.value],m=String(w.bounds||"[]"),v=m.charAt(0)==="("?n.lo.excl:n.lo.incl,y=m.charAt(1)===")"?n.hi.excl:n.hi.incl,E=`(${g} ${v} ${s(p[0],d)} and ${g} ${y} ${s(p[1],d)})`;return k==="between"?E:`(${g} eq null or not ${E})`}return null}function o(w){const g=String(w&&w.op);throw N(`source.odata.filter.refuse.${g}`,`a "${g}" filter condition cannot be written as an OData $filter expression, so the request was refused rather than sent without it — silently dropping it would have matched more or fewer rows than the filter asked for. Route this condition through a source that can pushdown-split it as residual (source.filter capability), or drop it from the tree before building the URL.`),new Error(`odataAdapter: a "${g}" filter condition cannot be expressed in OData and was refused`)}function l(w){if(!w)return"";if(!B(w)){const d=c(w);return d===null?o(w):d}const g=String(w.op)==="or"?" or ":" and ",k=(w.conditions||[]).map(d=>{if(B(d))return l(d);const p=c(d);return p===null?o(d):p}).filter(Boolean);return k.length?k.length===1?k[0]:`(${k.join(g)})`:""}function h(w={}){const g=String(w.url||""),k=w.fetch||(typeof fetch=="function"?fetch:null),d=w.count!==!1,p=i(w.key||"id"),m=w.edit===!0;return{name:"odata",capabilities:{filter:"tree",operators:D,sort:"multi",quick:w.search===!0,range:!0,total:d,mutate:m?{update:!0,delete:!0,append:!0,returning:"row"}:!1},urlFor(v){const y=[],E=(F,V)=>y.push(`${F}=${encodeURIComponent(V)}`),M=l(v.filters);return M&&E("$filter",M),v.sort&&v.sort.length&&E("$orderby",v.sort.map(F=>`${i(F.col)}${F.dir==="desc"?" desc":" asc"}`).join(",")),v.range&&(E("$skip",String(v.range.start)),E("$top",String(v.range.end-v.range.start))),v.quick&&E("$search",`"${String(v.quick).replace(/"/g,"")}"`),d&&E("$count","true"),y.length?`${g}?${y.join("&")}`:g},async execute(v,y){if(!k)throw new Error("odataAdapter needs a fetch implementation");const E={Accept:"application/json",...w.headers||{}},M=y&&y.signal,F=async S=>{const R=await k(S,{headers:E,signal:M});if(!R.ok)throw new Error(`OData request failed: ${R.status}`);return R.json()};let V=await F(this.urlFor(v)),I=V.value||V.rows||[];const $=V["@odata.count"]??V.count;if(!v.range){let S=V["@odata.nextLink"];for(;S&&I.length<a*r;)V=await F(S),I=I.concat(V.value||V.rows||[]),S=V["@odata.nextLink"]}return $==null?(d&&N("source.odata.nocount",`${g} was asked for $count=true and answered without an @odata.count, so the grid has no total for this query and will scroll open-ended rather than present the page size as the whole. The endpoint does not support $count, or filters it out.`),{rows:I}):{rows:I,total:Number($)}},urlForKey(v){return`${g}(${s(v)})`},async mutate(v,y){if(!k)throw new Error("odataAdapter needs a fetch implementation");if(!v||v.kind!=="update"&&v.kind!=="delete"&&v.kind!=="append")throw new Error(`odataAdapter: mutation kind "${v&&v.kind}" is not supported (update, delete and append are wired)`);const E={Accept:"application/json","Content-Type":"application/json",...w.headers||{}},M=y&&y.signal;if(v.kind==="delete"){const S=Array.isArray(v.keys)&&v.keys.length?v.keys[0]:v.key;if(S==null)throw new Error("odataAdapter: a delete needs a row key");const R=await k(this.urlForKey(S),{method:"DELETE",headers:E,signal:M});if(!R.ok)throw new Error(`OData delete failed: ${R.status}`);return{ok:!0}}if(v.kind==="append"){const S=Array.isArray(v.rows)?v.rows.filter(C=>C&&typeof C=="object"):[];if(S.length!==1)throw new Error("odataAdapter: an append needs exactly one row object (OData creates one entity per POST)");const R=await k(g,{method:"POST",headers:E,signal:M,body:JSON.stringify(S[0])});if(!R.ok)throw new Error(`OData add-row failed: ${R.status}`);const L=R.status===204?null:await R.json().catch(()=>null),T=L&&typeof L=="object"&&"value"in L?L.value:L;if(!T||typeof T!="object")throw new Error("odataAdapter: the POST returned no created entity to rekey the appended row by. Have the service return the created entity (Prefer: return=representation).");const A=T[p];if(A==null)throw new Error(`odataAdapter: the created entity carried no ${p} to rekey the appended row by.`);return{ok:!0,keys:[String(A)],rows:[T]}}const F=this.urlForKey(v.key),V=await k(F,{method:"PATCH",headers:E,signal:M,body:JSON.stringify(v.patch||{})});if(!V.ok)throw new Error(`OData update failed: ${V.status}`);if(V.status===204)return{ok:!0};const I=await V.json(),$=I&&typeof I=="object"&&"value"in I?I.value:I;return $==null?{ok:!0}:{ok:!0,rows:[$]}}}}}),Ie("packages/core/src/source/adapters/rest.js",function(e,U){"use strict";Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"DEFAULT_VERBS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return X}});const te=Object.freeze({offset:"offset",limit:"limit",sort:"sort",order:"order",filter:"filter",search:"q"}),N=Object.freeze({update:"PATCH",delete:"DELETE",append:"POST"});function X(B={}){const D=String(B.url||""),q=B.fetch||(typeof fetch=="function"?fetch:null),K={...te,...B.params||{}},x=B.encodeFilter||(r=>JSON.stringify(r)),G=B.rows||(r=>Array.isArray(r)?r:r.rows||r.data||[]),z=B.total||((r,t)=>Array.isArray(r)?t.length:r.total??r.count??t.length),j=B.edit===!0,O=B.returning==="row"?"row":B.returning==="key"?"key":"none",b=B.keyField||"id",u=B.writeUrlFor||(r=>`${D}/${encodeURIComponent(String(r.key??(r.keys&&r.keys[0])))}`),f=B.encodeMutation||(r=>{const t=N[r.kind];if(r.kind==="update")return{method:t,url:u(r),headers:{"Content-Type":"application/json"},body:JSON.stringify(r.patch||{})};if(r.kind==="append"){const s=Array.isArray(r.rows)?r.rows:r.rows?[r.rows]:[];return{method:t,url:D,headers:{"Content-Type":"application/json"},body:JSON.stringify(s.length===1?s[0]:s)}}return{method:t,url:u(r)}}),a=B.writeRow||(r=>{if(r===null||typeof r!="object")return null;if(Array.isArray(r))return r.length?r[0]:null;const t=r;return t.row??t.data??r});return{name:"rest",capabilities:{range:!0,total:!0,sort:"multi",filter:!1,quick:!1,mutate:j?{update:!0,delete:!0,append:!0,returning:O}:!1,...B.capabilities||{},...B.operators?{filter:"tree",operators:B.operators}:{}},urlFor(r){const t=new URLSearchParams;r.range&&(t.set(K.offset,String(r.range.start)),t.set(K.limit,String(r.range.end-r.range.start))),r.sort&&r.sort.length&&(t.set(K.sort,r.sort.map(i=>i.col).join(",")),t.set(K.order,r.sort.map(i=>i.dir||"asc").join(","))),r.filters&&t.set(K.filter,x(r.filters)),r.quick&&t.set(K.search,String(r.quick));const s=t.toString();return s?`${D}?${s}`:D},async execute(r,t){if(!q)throw new Error("restAdapter needs a fetch implementation");const s=await q(this.urlFor(r),{headers:{Accept:"application/json",...B.headers||{}},signal:t&&t.signal});if(!s.ok)throw new Error(`request failed: ${s.status}`);const i=await s.json(),n=G(i);return{rows:n,total:z(i,n)}},writeUrlFor(r){return u(r)},encodeMutation(r){return f(r)},async mutate(r,t){if(!q)throw new Error("restAdapter needs a fetch implementation");if(!r||r.kind!=="update"&&r.kind!=="delete"&&r.kind!=="append")throw new Error(`restAdapter: mutation kind "${r&&r.kind}" is not supported (update, delete and append are wired)`);const s=f(r);if(!s||!s.url||!s.method)throw new Error("restAdapter: encodeMutation must return { method, url }");const i={Accept:"application/json",...B.headers||{},...s.headers||{}},n=await q(s.url,{method:s.method,headers:i,signal:t&&t.signal,...s.body!==void 0?{body:s.body}:{}});if(!n.ok)throw new Error(`REST ${r.kind} failed: ${n.status}`);if(r.kind==="append"){if(O==="none")return{ok:!0};if(n.status===204)throw new Error("restAdapter: the add-row POST returned 204 with no body, so the appended row has no server key to rekey by. Declare returning: 'row'/'key' and have the endpoint return the created row.");const l=await n.json(),h=a(l),w=h&&typeof h=="object"?h[b]:void 0;if(w==null)throw new Error(`restAdapter: the add-row response carried no ${b} to rekey the appended row by. Point \`keyField\` at the primary key the endpoint returns, or override \`writeRow\`.`);return O==="row"?{ok:!0,keys:[String(w)],rows:[h]}:{ok:!0,keys:[String(w)]}}if(O!=="row"||n.status===204)return{ok:!0};const c=await n.json(),o=a(c);return o==null?{ok:!0}:{ok:!0,rows:[o]}}}}}),Ie("packages/core/src/source/adapters/dfql.js",function(e,U){"use strict";Object.defineProperty(e,"DFQL_BASE",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"DFQL_WRITE_URL",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return j}});const N=U("packages/core/src/internal/predicates.js").isFunction,B=U("packages/core/src/internal/warn.js").warnOnce,D="https://rest.demandflow.com",q="https://stream.demandflow.com/dfql",K=Object.freeze(["id","created","updated","ownerId","entity"]);function x(O){const b={},u=[];for(const[f,a]of Object.entries(O||{})){if(K.includes(f)){u.push(f);continue}b[f]=a}return u.length&&B("source.dfql.protected",`a DFQL update tried to write protected field(s) ${u.join(", ")}; they are server-assigned and immutable, so they were dropped from the PATCH.`),b}function G(O){if(!O||typeof O!="object"||Array.isArray(O))return["fields (must be an object)"];const b=O,u=[];return(typeof b.entity!="string"||!b.entity)&&u.push("entity (uppercase code)"),Number.isFinite(Number(b.level))||u.push("level (numeric)"),(typeof b.comboKey!="string"||!b.comboKey.endsWith("|ENT:"))&&u.push("comboKey (a string ending '|ENT:')"),u}async function z(O){const b=[],u=t=>{const s=t.trim();if(s)try{b.push(JSON.parse(s))}catch{}};if(!O.body||typeof O.body.getReader!="function")return(await O.text()).split(`
|