@toclocoinc/lattice-grid 1.111.4 → 1.111.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/angular/package.json +1 -1
- package/docs/API.html +27 -5
- 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/dataview.html +1 -1
- package/docs/api/deckgl.html +1 -1
- package/docs/api/designer.html +1 -1
- package/docs/api/form.html +1 -1
- 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 +25 -2
- 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/listview.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/tree.html +1 -1
- package/docs/api/types.html +1 -1
- package/docs/api-detail.html +31 -5
- package/docs/warnings.json +12 -2
- 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/contextmenu.d.ts +1 -1
- package/modules/contextmenu.esm.min.js +1 -1
- package/modules/contextmenu.min.cjs +1 -1
- package/modules/contextmenu.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/dataview.d.ts +1 -1
- package/modules/dataview.esm.min.js +1 -1
- package/modules/dataview.min.cjs +1 -1
- package/modules/dataview.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 +1 -1
- package/modules/form.esm.min.js +1 -1
- package/modules/form.min.cjs +1 -1
- package/modules/form.min.js +1 -1
- 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/htmx.shared.esm.min.js +1 -1
- package/modules/htmx.shared.min.cjs +1 -1
- package/modules/htmx.shared.min.js +1 -1
- package/modules/kanban.d.ts +29 -2
- package/modules/kanban.esm.min.js +16 -14
- package/modules/kanban.esm.min.js.map +2 -2
- package/modules/kanban.min.cjs +15 -13
- package/modules/kanban.min.js +15 -13
- package/modules/kanban.min.js.map +2 -2
- 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/listview.d.ts +1 -1
- package/modules/listview.esm.min.js +1 -1
- package/modules/listview.min.cjs +1 -1
- package/modules/listview.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/recordeditor.d.ts +1 -1
- package/modules/recordeditor.esm.min.js +1 -1
- package/modules/recordeditor.min.cjs +1 -1
- package/modules/recordeditor.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/sidebar.d.ts +1 -1
- package/modules/sidebar.esm.min.js +1 -1
- package/modules/sidebar.min.cjs +1 -1
- package/modules/sidebar.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/toolbar.d.ts +1 -1
- package/modules/toolbar.esm.min.js +1 -1
- package/modules/toolbar.min.cjs +1 -1
- package/modules/toolbar.min.js +1 -1
- package/modules/tree.d.ts +1 -1
- package/modules/tree.esm.min.js +1 -1
- package/modules/tree.min.cjs +1 -1
- package/modules/tree.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/modules/htmx.min.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.111.
|
|
2
|
+
* Lattice Grid 1.111.5, htmx module
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
6
|
(function(xr){"use strict";var gs=!0,ar=Object.create(null),lr=Object.create(null);function We(e,D){ar[e]=D}function Kn(e){var D=lr[e];if(D)return D;var ne=Object.create(null);lr[e]=ne;var P=ar[e];if(!P)throw new Error("[lattice] missing module: "+e);return P(ne,Kn),ne}We("packages/core/src/internal/predicates.js",function(e,D){"use strict";Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return L}});function ne(Z){return Z!==null&&typeof Z=="object"&&!Array.isArray(Z)}function P(Z){return typeof Z=="function"}function Y(Z){return Z==null}function _(Z){return Z==null||Z===""}function L(Z){return typeof Z!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(Z))?!0:!!(Z.prototype&&Object.getOwnPropertyNames(Z.prototype).length>1)}}),We("packages/core/src/internal/warn.js",function(e,D){"use strict";Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return h}});const ne=new Set,P=2e3;function Y(r){if(ne.add(r),ne.size>P){const t=ne.values().next().value;t!==void 0&&ne.delete(t)}}const _=[],L=500;function Z(r,t,o){_.push({key:r,level:t,message:o.map(u=>typeof u=="string"?u:H(u)).join(" "),at:Date.now()}),_.length>L&&_.shift()}function H(r){if(r instanceof Error)return r.message;try{return JSON.stringify(r)}catch{return String(r)}}function x(){return _.map(r=>({...r}))}function X(r){if(r.length===0||typeof r[0]!="string")return r;const t=r[0].replace(/^\[lattice\]\s*/,"");return t===r[0]?r:[t,...r.slice(1)]}function U(r,...t){if(ne.has(r))return;Y(r);const o=X(t);Z(r,"warn",o),console.warn("[lattice]",...o)}function j(r,...t){if(ne.has(r))return;Y(r);const o=X(t);Z(r,"info",o),console.info("[lattice]",...o)}function k(){ne.clear(),_.length=0}function b(r,t){const o=new Error(`[lattice] ${r}`);throw t!==void 0&&(o.cause=t),o}function a(r,t){r||b(t)}const h=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})()}),We("packages/core/src/formatting/rules.js",function(e,D){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return V}});const P=D("packages/core/src/internal/predicates.js").isFunction,_=D("packages/core/src/internal/warn.js").warnOnce,L=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),Z=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),H=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(T,A){const N=Number(T),C=Number(A);if(T!==null&&T!==""&&A!==null&&A!==""&&Number.isFinite(N)&&Number.isFinite(C))return N<C?-1:N>C?1:0;const F=String(T??"").toLowerCase(),$=String(A??"").toLowerCase();return F<$?-1:F>$?1:0}function X(T){return T==null||T===""}function U(T,A){if(!A||typeof A!="object")return!1;const{op:N}=A,C=A.value,S=A.value2;switch(N){case"blank":return X(T);case"notBlank":return!X(T);case"true":return T===!0;case"false":return T===!1;default:break}if(X(T))return!1;switch(N){case"eq":return x(T,C)===0;case"ne":return x(T,C)!==0;case"gt":return x(T,C)>0;case"gte":return x(T,C)>=0;case"lt":return x(T,C)<0;case"lte":return x(T,C)<=0;case"between":return x(T,C)>=0&&x(T,S)<=0;case"outside":return x(T,C)<0||x(T,S)>0;case"contains":return String(T).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(T).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(T).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(T).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function j(T,A,N){const C=te=>{const Q=String(te).replace("#",""),re=Q.length===3?Q.split("").map(ie=>ie+ie).join(""):Q;return[0,2,4].map(ie=>parseInt(re.slice(ie,ie+2),16)||0)},[S,F,$]=C(T),[W,K,I]=C(A),B=Math.max(0,Math.min(1,N)),J=(te,Q)=>Math.round(te+(Q-te)*B);return`#${[J(S,W),J(F,K),J($,I)].map(te=>te.toString(16).padStart(2,"0")).join("")}`}function k(T){const A=[];for(const W of T||[]){if(W==null||W==="")continue;const K=W instanceof Date?W.getTime():Number(W);Number.isFinite(K)&&A.push(K)}if(!A.length)return null;A.sort((W,K)=>W-K);let N=0,C=0,S=0;for(const W of A){N++;const K=W-C;C+=K/N,S+=K*(W-C)}const F=b(A,.25),$=b(A,.75);return{n:A.length,min:A[0],max:A[A.length-1],mean:C,stddev:A.length>1?Math.sqrt(S/(A.length-1)):0,median:b(A,.5),q1:F,q3:$,iqr:$-F,sorted:A}}function b(T,A){if(!T.length)return 0;const N=(T.length-1)*Math.max(0,Math.min(1,A)),C=Math.floor(N),S=Math.ceil(N);return C===S?T[C]:T[C]+(N-C)*(T[S]-T[C])}function a(T){for(const A of Array.isArray(T)?T:[])if(!(!A||typeof A!="object")&&(A.when&&Z.includes(A.when.op)||A.scale&&A.scale.from||A.dataBar&&!(Number.isFinite(Number(A.dataBar.min))&&Number.isFinite(Number(A.dataBar.max)))||A.iconSet&&!Array.isArray(A.iconSet.thresholds)))return!0;return!1}function h(T,A){const N=Number(T.value),C=S=>b(A.sorted,S);switch(T.op){case"topPercent":{const S=r(N,10);return{op:"gte",value:C(1-S)}}case"bottomPercent":{const S=r(N,10);return{op:"lte",value:C(S)}}case"topN":{const S=Math.max(1,Math.floor(N)||1),F=Math.max(0,A.sorted.length-S);return{op:"gte",value:A.sorted[F]}}case"bottomN":{const S=Math.max(1,Math.floor(N)||1),F=Math.min(A.sorted.length-1,S-1);return{op:"lte",value:A.sorted[F]}}case"aboveMean":return{op:"gt",value:A.mean};case"belowMean":return{op:"lt",value:A.mean};case"aboveMedian":return{op:"gt",value:A.median};case"belowMedian":return{op:"lt",value:A.median};case"zAbove":return A.stddev?{op:"gte",value:A.mean+(Number.isFinite(N)?N:2)*A.stddev}:null;case"zBelow":return A.stddev?{op:"lte",value:A.mean-(Number.isFinite(N)?N:2)*A.stddev}:null;case"outlier":{const S=(Number.isFinite(N)&&N>0?N:1.5)*A.iqr;return A.iqr?{op:"outside",value:A.q1-S,value2:A.q3+S}:null}default:return null}}function r(T,A){const N=Number.isFinite(T)?T:A,C=N>1?N/100:N;return Math.max(0,Math.min(1,C))}function t(T,A){if(T.from==="minmax")return{...T,min:A.min,max:A.max};if(T.from==="quantile")return{...T,min:b(A.sorted,r(Number(T.low),5)),max:b(A.sorted,r(Number(T.high),95))};if(T.from==="stddev"){const N=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:A.mean-N*A.stddev,max:A.mean+N*A.stddev}}return T}function o(T,A){const N=Array.isArray(T)?T:[];return!A||!A.n?N.map(C=>C&&a([C])?{...C,enabled:!1}:C):N.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:t(C.scale,A)};if(C.dataBar)return{...C,dataBar:u(C.dataBar,A)};if(C.iconSet)return{...C,iconSet:d(C.iconSet,A)};if(!C.when||!Z.includes(C.when.op))return C;const S=h(C.when,A);return S?{...C,when:S}:{...C,enabled:!1}})}function u(T,A){const N=Number.isFinite(Number(T.min))?Number(T.min):void 0,C=Number.isFinite(Number(T.max))?Number(T.max):void 0;if(N!==void 0&&C!==void 0)return{...T,min:N,max:C};if(T.from==="quantile")return{...T,min:N??b(A.sorted,r(Number(T.low),5)),max:C??b(A.sorted,r(Number(T.high),95))};if(T.from==="stddev"){const S=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:N??A.mean-S*A.stddev,max:C??A.mean+S*A.stddev}}return{...T,min:N??A.min,max:C??A.max}}function d(T,A){if(Array.isArray(T.thresholds))return T;const N=s(T),C=[];for(let S=1;S<N;S++)C.push(b(A.sorted,S/N));return{...T,thresholds:C}}function s(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.length;if(Number.isFinite(Number(T.count))&&Number(T.count)>=2)return Math.floor(Number(T.count));const A=y[T.set];return A?A.length:3}function g(T){return`url("data:image/svg+xml,${encodeURIComponent(T)}")`}function i(T){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${T}"/></svg>`}function n(T,A){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${A==="up"?"8,2 14,13 2,13":A==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${T}"/></svg>`}function f(T,A){const N="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${A*16} 16">`;for(let S=0;S<A;S++){const F=S<T?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${S*16},0)" d="${N}" fill="${F}"/>`}return`${C}</svg>`}const p=Object.freeze([n("#c0392b","down"),n("#e0a800","right"),n("#2e7d32","up")]),l=Object.freeze([i("#d13438"),i("#f5a623"),i("#2e9e44")]),y=Object.freeze({arrows:p,trafficLights:l,ratings:Object.freeze([1,2,3,4,5].map(T=>f(T,5)))}),c=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function m(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?g(String(C)):String(C));const A=T.set||"arrows";if(A==="ratings"){const C=s(T),S=[];for(let F=1;F<=C;F++)S.push(g(f(F,C)));return S}const N=y[A];return N?N.map(g):(_(`iconSet:${A}`,`unknown icon set '${A}'; falling back to arrows.`),p.map(g))}function w(T){const A=Number(T.min),C=Number(T.max)-A,S=T.colour||T.color||"#5b9bd5",F=T.negativeColour||T.negativeColor||"#d13438",$=T.direction==="rtl"?"left":"right",W=I=>Math.max(0,Math.min(1,(I-A)/C))*100,K=C?Math.max(0,Math.min(100,(0-A)/C*100)):0;return I=>{if(X(I))return null;const B=Number(I);if(!Number.isFinite(B)||!C)return null;const J=W(B),te=Math.min(J,K),Q=Math.max(J,K),re=B>=0?S:F;return{backgroundImage:`linear-gradient(to ${$}, transparent ${te}%, ${re} ${te}%, ${re} ${Q}%, transparent ${Q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function v(T){const A=m(T),N=T.reverse?[...A].reverse():A,C=(Array.isArray(T.thresholds)?T.thresholds:[]).map(Number).filter(Number.isFinite),S=Number.isFinite(Number(T.size))?Number(T.size):16,F=T.set==="ratings"?S*s(T):S;return $=>{if(X($))return null;const W=Number($);if(!Number.isFinite(W))return null;let K=0;for(const B of C)W>=B&&K++;const I=N[Math.min(K,N.length-1)];return I?{backgroundImage:I,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${F}px ${S}px`,paddingLeft:`${F+4}px`}:null}}function E(T){const A=Array.isArray(T.colours)&&T.colours.length>=2?T.colours:["#f8f9fa","#1a6bc7"],N=Number(T.min),C=Number(T.max),S=C-N,F=A.length-1,$=[];for(let K=0;K<=F;K++)$.push(F?K/F:0);const W=Number(T.mid);if(T.mid!==void 0&&T.mid!==null)if(A.length%2===0)_("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${A.length} were given, so "mid" was ignored.`);else if(Number.isFinite(W)&&S&&W>Math.min(N,C)&&W<Math.max(N,C)){const K=F/2,I=Math.max(0,Math.min(1,(W-N)/S));for(let B=0;B<=F;B++)$[B]=B<=K?K?B/K*I:I:I+(B-K)/(F-K)*(1-I)}else Number.isFinite(W)&&_("formatting.scale.mid.range",`a scale's "mid" (${W}) is outside its min..max range, so it was ignored.`);return K=>{const I=Number(K);if(!Number.isFinite(I)||!S)return null;const B=Math.max(0,Math.min(1,(I-N)/S));let J=0;for(;J<F-1&&B>$[J+1];)J++;const te=$[J+1]-$[J],Q=te>0?(B-$[J])/te:0;return{background:j(A[J],A[J+1],Math.max(0,Math.min(1,Q)))}}}function V(T,A=null){const N=a(T)?o(T,A):T,C=(Array.isArray(N)?N:[]).filter($=>$&&typeof $=="object");if(!C.length)return()=>null;const S=C.map($=>$.scale?{scale:E($.scale),enabled:$.enabled!==!1}:$.dataBar?{scale:w($.dataBar),enabled:$.enabled!==!1}:$.iconSet?{scale:v($.iconSet),enabled:$.enabled!==!1}:{when:$.when,style:$.style,stop:$.stopIfTrue!==!1,enabled:$.enabled!==!1}),F=G(S)?O():null;return($,W)=>{const K=$?$.value:void 0;let I=null;W&&(W.mode=0);for(const B of S){if(!B.enabled)continue;if(B.scale){const Q=B.scale(K);Q&&(I={...I||{},...Q});continue}if(!U(K,B.when))continue;let J;const te=P(B.style);if(te?W&&F?(J=B.style(F.enter($)),F.mode>W.mode&&(W.mode=F.mode)):J=B.style($):J=B.style,J&&(I=I?{...I,...J}:te?J:{...J}),B.stop)break}return I}}function G(T){return T.some(A=>A.enabled&&!A.scale&&P(A.style))}const q=new Set(["value","colId","column"]),M=new Set(["row","data","index"]);function O(){let T={};const A={mode:0,enter(S){return T=S||{},A.mode=0,C}},N=S=>{if(q.has(S))return;const F=M.has(S)?1:2;F>A.mode&&(A.mode=F)},C=new Proxy({},{get(S,F){return N(F),T[F]},has(S,F){return N(F),F in T},set(S,F,$){return A.mode=2,T[F]=$,!0},ownKeys(){return A.mode=2,Reflect.ownKeys(T)},getOwnPropertyDescriptor(S,F){A.mode=2;const $=Object.getOwnPropertyDescriptor(T,F);return $?{value:T[F],enumerable:$.enumerable,configurable:!0,writable:!0}:void 0}});return A}}),We("packages/core/src/formula/parse.js",function(e,D){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return o}});const ne="num",P="str",Y="ref",_="name",L="op",Z="end",H=["<=",">=","<>","!="],x="+-*/^%(),<>=";class X extends Error{constructor(d,s){super(d),this.name="FormulaError",this.at=s}}function U(u){const d=[];let s=0;for(;s<u.length;){const g=u[s];if(g===" "||g===" "||g===`
|
|
7
|
-
`||g==="\r"){s++;continue}if(g>="0"&&g<="9"){s=k(u,s,d);continue}if(g==="."&&u[s+1]>="0"&&u[s+1]<="9"){s=k(u,s,d);continue}if(g==='"'||g==="'"){s=b(u,s,d);continue}if(g==="["){const n=u.indexOf("]",s+1);if(n<0)throw new X("a [column reference] was opened and never closed",s);d.push({kind:Y,value:u.slice(s+1,n).trim(),at:s}),s=n+1;continue}if(j(g)){s=a(u,s,d);continue}const i=u.slice(s,s+2);if(H.includes(i)){d.push({kind:L,value:i==="!="?"<>":i,at:s}),s+=2;continue}if(x.includes(g)){d.push({kind:L,value:g,at:s}),s++;continue}throw new X(`unexpected character ${JSON.stringify(g)}`,s)}return d.push({kind:Z,value:null,at:u.length}),d}function j(u){return/[A-Za-z_À-]/.test(u)}function k(u,d,s){let g=d,i=!1;for(;g<u.length;){const n=u[g];if(n>="0"&&n<="9"){g++;continue}if(n==="."&&!i){i=!0,g++;continue}if((n==="e"||n==="E")&&/[0-9+-]/.test(u[g+1]||"")){for(g+=2;g<u.length&&u[g]>="0"&&u[g]<="9";)g++;break}break}return s.push({kind:ne,value:Number(u.slice(d,g)),at:d}),g}function b(u,d,s){const g=u[d];let i=d+1,n="";for(;i<u.length;){if(u[i]===g){if(u[i+1]===g){n+=g,i+=2;continue}return s.push({kind:P,value:n,at:d}),i+1}n+=u[i],i++}throw new X("a string was opened and never closed",d)}function a(u,d,s){let g=d;for(;g<u.length&&/[A-Za-z0-9_.À-]/.test(u[g]);)g++;const i=u.slice(d,g);let n=g;for(;n<u.length&&u[n]===" ";)n++;return s.push({kind:u[n]==="("?_:Y,value:i,at:d}),g}const h={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function r(u){const d=String(u??"").replace(/^\s*=/,"");if(!d.trim())throw new X("the formula is empty");const s=U(d);let g=0;const i=()=>s[g],n=()=>s[g++],f=v=>{const E=i();if(E.kind!==L||E.value!==v)throw new X(`expected ${JSON.stringify(v)}`,E.at);g++},p=v=>{let E=l();for(;;){const V=i();if(V.kind!==L)break;const G=h[V.value];if(!G||G<v)break;g++;const q=p(V.value==="^"?G:G+1);E={kind:"bin",op:V.value,left:E,right:q}}return E},l=()=>{const v=i();return v.kind===L&&(v.value==="-"||v.value==="+")?(g++,{kind:"unary",op:v.value,arg:l()}):y()},y=()=>{let v=c();for(;i().kind===L&&i().value==="%";)g++,v={kind:"unary",op:"%",arg:v};return v},c=()=>{const v=n();if(v.kind===ne)return{kind:"num",value:v.value};if(v.kind===P)return{kind:"str",value:v.value};if(v.kind===Y)return{kind:"ref",name:v.value};if(v.kind===_){f("(");const E=[];if(!(i().kind===L&&i().value===")"))for(;;){if(E.push(p(1)),i().kind===L&&i().value===","){g++;continue}break}return f(")"),{kind:"call",name:String(v.value).toUpperCase(),args:E}}if(v.kind===L&&v.value==="("){const E=p(1);return f(")"),E}throw v.kind===Z?new X("the formula ends unexpectedly",v.at):new X(`unexpected ${JSON.stringify(v.value)}`,v.at)},m=p(1),w=i();if(w.kind!==Z)throw new X(`unexpected ${JSON.stringify(w.value)}: is an operator missing?`,w.at);return m}function t(u){const d=new Set,s=g=>{if(!(!g||typeof g!="object")){if(g.kind==="ref"){d.add(String(g.name));return}if(g.kind==="bin"){s(g.left),s(g.right);return}if(g.kind==="unary"){s(g.arg);return}if(g.kind==="call")for(const i of g.args)s(i)}};return s(u),[...d]}function o(u){return typeof u=="string"&&/^\s*=/.test(u)&&u.trim()!=="="}}),We("packages/core/src/formula/evaluate.js",function(e,D){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return k}});const P=D("packages/core/src/formula/parse.js").FormulaError;function Y(b){if(b==null||b==="")return 0;if(typeof b=="boolean")return b?1:0;if(b instanceof Date)return b.getTime();const a=typeof b=="number"?b:Number(String(b).replace(/[,\s]/g,""));if(!Number.isFinite(a))throw new P(`${JSON.stringify(b)} is not a number`);return a}function _(b){return b==null?"":String(b)}function L(b){if(typeof b=="boolean")return b;if(b==null||b==="")return!1;if(typeof b=="number")return b!==0;const a=String(b).trim().toLowerCase();return a==="false"||a==="no"||a==="0"?!1:a!==""}function Z(b){const a=[];for(const h of b){if(Array.isArray(h)){for(const r of h)r!=null&&r!==""&&a.push(Y(r));continue}h==null||h===""||a.push(Y(h))}return a}function H(b,a){const h=10**a,r=b*h;return Math.sign(r)*Math.round(Math.abs(r)+Number.EPSILON*Math.abs(r))/h}function x(b,a){if(!b.length)return 0;const h=b.slice().sort((u,d)=>u-d),r=(h.length-1)*Math.min(1,Math.max(0,a)),t=Math.floor(r),o=Math.ceil(r);return t===o?h[t]:h[t]+(r-t)*(h[o]-h[t])}function X(b,a){let h=0,r=0,t=0;for(const u of b){h++;const d=u-r;r+=d/h,t+=d*(u-r)}const o=a?h-1:h;return o>0?Math.sqrt(t/o):0}const U={SUM:b=>Z(b).reduce((a,h)=>a+h,0),AVERAGE:b=>{const a=Z(b);return a.length?a.reduce((h,r)=>h+r,0)/a.length:0},MIN:b=>{const a=Z(b);return a.length?Math.min(...a):0},MAX:b=>{const a=Z(b);return a.length?Math.max(...a):0},COUNT:b=>Z(b).length,PRODUCT:b=>Z(b).reduce((a,h)=>a*h,1),ROUND:b=>H(Y(b[0]),b.length>1?Y(b[1]):0),ROUNDDOWN:b=>{const a=10**(b.length>1?Y(b[1]):0),h=Y(b[0])*a;return(h<0?Math.ceil(h):Math.floor(h))/a},ROUNDUP:b=>{const a=10**(b.length>1?Y(b[1]):0),h=Y(b[0])*a;return(h<0?Math.floor(h):Math.ceil(h))/a},ABS:b=>Math.abs(Y(b[0])),FLOOR:b=>Math.floor(Y(b[0])),CEILING:b=>Math.ceil(Y(b[0])),SQRT:b=>Math.sqrt(Y(b[0])),POWER:b=>Y(b[0])**Y(b[1]),MOD:b=>{const a=Y(b[1]);if(a===0)throw new P("MOD by zero");return(Y(b[0])%a+a)%a},IF:b=>L(b[0])?b[1]:b.length>2?b[2]:!1,AND:b=>b.every(L),OR:b=>b.some(L),NOT:b=>!L(b[0]),COALESCE:b=>b.find(a=>a!=null&&a!=="")??null,CONCAT:b=>b.map(_).join(""),LEN:b=>_(b[0]).length,UPPER:b=>_(b[0]).toUpperCase(),LOWER:b=>_(b[0]).toLowerCase(),TRIM:b=>_(b[0]).trim(),LEFT:b=>_(b[0]).slice(0,b.length>1?Y(b[1]):1),RIGHT:b=>{const a=b.length>1?Y(b[1]):1;return a<=0?"":_(b[0]).slice(-a)},MEDIAN:b=>x(Z(b),.5),PERCENTILE:b=>{const a=Y(b[b.length-1]);return x(Z(b.slice(0,-1)),a>1?a/100:a)},QUARTILE1:b=>x(Z(b),.25),QUARTILE3:b=>x(Z(b),.75),STDEV:b=>X(Z(b),!0),STDEVP:b=>X(Z(b),!1),VAR:b=>{const a=X(Z(b),!0);return a*a},VARP:b=>{const a=X(Z(b),!1);return a*a},COUNTDISTINCT:b=>{const a=new Set;for(const h of b){const r=Array.isArray(h)?h:[h];for(const t of r)t!=null&&t!==""&&a.add(t)}return a.size},IQR:b=>{const a=Z(b);return x(a,.75)-x(a,.25)}};U.AVG=U.AVERAGE,U.CEIL=U.CEILING,U.POW=U.POWER,U.STDEVS=U.STDEV,U.PERCENTILEINC=U.PERCENTILE;function j(b,a){const h=Number(b),r=Number(a);if(b!==null&&b!==""&&a!==null&&a!==""&&Number.isFinite(h)&&Number.isFinite(r))return h<r?-1:h>r?1:0;const o=_(b).toLowerCase(),u=_(a).toLowerCase();return o<u?-1:o>u?1:0}function k(b,a={}){const h=typeof a.lookup=="function"?a.lookup:null,r=a.functions?{...U,...a.functions}:U,t=o=>{switch(o.kind){case"num":return o.value;case"str":return o.value;case"ref":{if(!h)throw new P(`there is no column called ${JSON.stringify(o.name)} here`);const u=h(String(o.name));if(u===void 0)throw new P(`there is no column called ${JSON.stringify(o.name)}`);return u}case"unary":{if(o.op==="%")return Y(t(o.arg))/100;const u=Y(t(o.arg));return o.op==="-"?-u:u}case"bin":{const u=o.op;if(u==="=")return j(t(o.left),t(o.right))===0;if(u==="<>")return j(t(o.left),t(o.right))!==0;if(u==="<")return j(t(o.left),t(o.right))<0;if(u==="<=")return j(t(o.left),t(o.right))<=0;if(u===">")return j(t(o.left),t(o.right))>0;if(u===">=")return j(t(o.left),t(o.right))>=0;const d=Y(t(o.left)),s=Y(t(o.right));if(u==="+")return d+s;if(u==="-")return d-s;if(u==="*")return d*s;if(u==="^")return d**s;if(u==="/"){if(s===0)throw new P("division by zero");return d/s}throw new P(`unknown operator ${JSON.stringify(u)}`)}case"call":{const u=a.lazy&&a.lazy[o.name];if(typeof u=="function")return u(o.args,t,a);const d=r[o.name];if(typeof d!="function")throw new P(`there is no function called ${o.name}`);return d(o.args.map(t),a)}default:throw new P("the formula could not be read")}};return t(b)}}),We("packages/core/src/formula/index.js",function(e,D){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return j}});const ne=D("packages/core/src/formula/parse.js"),P=ne.parseFormula,Y=ne.referencesOf,_=ne.looksLikeFormula,L=ne.FormulaError,Z=ne.tokenise,H=D("packages/core/src/formula/evaluate.js"),x=H.evaluateAst,X=H.FUNCTIONS;function U(k){const{grid:b,row:a,data:h}=k||{},r=s=>String(s).toLowerCase().replace(/[\s_-]/g,""),t=b&&b.columns&&typeof b.columns.all=="function"?b.columns.all():[],o=b&&b.permissions,u=o&&typeof o.isReadable=="function"?s=>o.isReadable(s):()=>!0,d=new Set;for(const s of t)u(s)||(d.add(r(s.id)),s.field&&d.add(r(s.field)),s.title&&d.add(r(s.title)));return s=>{const g=r(s);if(d.has(g))throw new L(`"${s}" cannot be read`);for(const i of t)if(r(i.id)===g||i.field&&r(i.field)===g||i.title&&r(i.title)===g)return a&&b.rows&&typeof b.rows.value=="function"?b.rows.value(a.key,i.id):h?h[i.field||i.id]:void 0;if(h&&typeof h=="object"){for(const i of Object.keys(h))if(r(i)===g){if(!u(i))throw new L(`"${s}" cannot be read`);return h[i]}}}}function j(k,b={}){try{const a=P(k);return{ok:!0,value:x(a,{lookup:U(b),functions:b.formulaFunctions}),references:Y(a)}}catch(a){return{ok:!1,error:a instanceof L?a.message:"the formula could not be read",at:a instanceof L?a.at:void 0}}}}),We("packages/core/src/internal/version.js",function(e,D){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return Y}});const ne="1.111.4";async function P(){return ne}const Y="1.111.4"}),We("packages/core/src/internal/merge.js",function(e,D){"use strict";Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return H}});const P=D("packages/core/src/internal/predicates.js").isObject;function Y(x,X,U){if(x!==void 0)return x===!0?{enabled:!0,...U}:x===!1?{enabled:!1}:P(x)?x:{[X]:x,enabled:!0}}function _(x){return x==null?[]:Array.isArray(x)?x:[x]}const L=Object.freeze(new Set(["__proto__","constructor","prototype"]));function Z(x,X){if(!P(x))return P(X)?{...X}:X;if(!P(X))return X===void 0?x:X;const U={...x};for(const j of Object.keys(X)){if(L.has(j))continue;const k=X[j];k!==void 0&&(U[j]=P(k)&&P(U[j])?Z(U[j],k):k)}return U}function H(x,X){if(!P(x)||!P(X)||x===X)return X;const U=Object.create(Object.getPrototypeOf(x));return Object.assign(U,x,X),U}}),We("packages/core/src/internal/schedule.js",function(e,D){"use strict";Object.defineProperty(e,"now",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return H}});function ne(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const P=typeof requestAnimationFrame=="function";function Y(x){return P?requestAnimationFrame(x):setTimeout(()=>x(ne()),16)}function _(x){x!=null&&(P?cancelAnimationFrame(x):clearTimeout(x))}function L(x){let X=null,U=null;const j=()=>{X=null;const b=U;U=null,x(...b||[])},k=(...b)=>{U=b,X===null&&(X=Y(j))};return k.cancel=()=>{_(X),X=null,U=null},k.flush=()=>{X!==null&&(_(X),j())},k}function Z(x,X){let U=null,j=null;const k=()=>{if(U=null,j===null)return;const h=j;j=null,x(...h),b()},b=()=>{U=setTimeout(k,X),typeof U?.unref=="function"&&U.unref()},a=(...h)=>{U===null?(x(...h),b()):(j=h,clearTimeout(U),b())};return a.flush=()=>{if(U!==null&&clearTimeout(U),U=null,j===null)return;const h=j;j=null,x(...h)},a.cancel=()=>{U!==null&&clearTimeout(U),U=null,j=null},a.pending=()=>U!==null||j!==null,a}function H(x,X=50){return typeof requestIdleCallback=="function"?requestIdleCallback(x,{timeout:X}):setTimeout(()=>x({timeRemaining:()=>0,didTimeout:!0}),1)}}),We("packages/core/src/internal/paths.js",function(e,D){"use strict";Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return Z}});const ne=new Map;function P(H){let x=ne.get(H);if(x)return x;if(!H.includes("."))x=X=>X?.[H];else{const X=H.split("."),U=X.length;x=j=>{let k=j;for(let b=0;b<U;b++){if(k==null)return;k=k[X[b]]}return k}}return ne.set(H,x),x}const Y=new Map;function _(H){let x=Y.get(H);if(x)return x;if(!H.includes("."))x=(X,U)=>{X!=null&&(X[H]=U)};else{const X=H.split("."),U=X.length-1;x=(j,k)=>{let b=j;for(let a=0;a<U;a++){if(b==null)return;const h=X[a];b[h]==null&&(b[h]={}),b=b[h]}b!=null&&(b[X[U]]=k)}}return Y.set(H,x),x}function L(H,x){return P(x)(H)}function Z(H,x,X){_(x)(H,X)}}),We("packages/core/src/internal/compare.js",function(e,D){"use strict";Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return Y}});const ne=new Map;function P(_,L){const Z=`${_||""}|${L?JSON.stringify(L):""}`;let H=ne.get(Z);return H||(H=new Intl.Collator(_||void 0,{numeric:!0,sensitivity:"variant",...L}),ne.set(Z,H)),H}function Y(_,L){if(_===L)return 0;if(_==null)return 1;if(L==null)return-1;if(typeof _=="number"&&typeof L=="number")return Number.isNaN(_)?Number.isNaN(L)?0:1:Number.isNaN(L)||_<L?-1:_>L?1:0;const Z=String(_),H=String(L);return Z<H?-1:Z>H?1:0}}),We("packages/core/src/defaults.js",function(e,D){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return j}});const P=D("packages/core/src/internal/predicates.js").isObject,_=D("packages/core/src/internal/merge.js").merge,Z=D("packages/core/src/internal/warn.js").warnOnce;let H=null;class x extends Error{}function X(k,b=new Set){if(Array.isArray(k)){if(b.has(k))throw new x;b.add(k);const h=k.map(r=>X(r,b));return b.delete(k),h}if(!P(k)||Object.getPrototypeOf(k)!==Object.prototype&&Object.getPrototypeOf(k)!==null)return k;if(b.has(k))throw new x;b.add(k);const a={};for(const[h,r]of Object.entries(k))a[h]=X(r,b);return b.delete(k),a}function U(k){if(k===void 0)return X(H??{});if(k===null)return H=null,{};if(!P(k))return Z("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(k)?"an array":typeof k}. The call was ignored and the defaults are unchanged.`),X(H??{});try{H=X(k)}catch(b){if(!(b instanceof x))throw b;return Z("defaults:cyclic","defaults() expects a configuration object with no circular references, but the object passed refers back to itself. The call was ignored and the defaults are unchanged."),X(H??{})}return X(H)}function j(k){return H===null?k:_(X(H),k)}}),We("packages/core/src/internal/uid.js",function(e,D){"use strict";Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return P}});let ne=0;function P(Y="l"){return`${Y}${(++ne).toString(36)}`}}),We("packages/core/src/events/names.js",function(e,D){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return Y}});const ne=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","beforeRowDrop","rowDrop:cancelled","rowDrop","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:compareGroups:open","column:menu:open","explain:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","totals: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"]),P=new Set(ne);function Y(_){return _==="*"||P.has(_)}}),We("packages/core/src/events/bus.js",function(e,D){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return h}});const ne=D("packages/core/src/internal/warn.js"),P=ne.warnOnce,Y=ne.DEV,L=D("packages/core/src/internal/uid.js").uid,H=D("packages/core/src/events/names.js").isKnownEvent,x="*";function X(r,t){!Y||H(t)||P(`bus.unknown:${t}`,`${r}('${t}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const U=new Set(["api","user","init","ai"]),j=new WeakMap;function k(r){let t=j.get(r);return t||(t=L("h"),j.set(r,t)),t}function b(){return typeof performance=="object"&&performance?performance.now():Date.now()}function a(r){if(!r||typeof r!="object")return{};const t={};for(const[o,u]of Object.entries(r))o!=="grid"&&(u==null?t[o]=String(u):Array.isArray(u)?t[o]=`[${u.length}]`:typeof u=="object"?t[o]=u.key?`row ${u.key}`:"{…}":typeof u=="function"?t[o]="[function]":t[o]=String(u).slice(0,60));return t}class h{#e=new Map;#t=!1;#n=[];#r=200;#s=new Map;#i=null;#o=!1;#l=0;constructor(t=null){this.#i=t}attach(t){this.#i=t}get grid(){return this.#i}get destroyed(){return this.#o}on(t,o){if(typeof o!="function")return P(`bus.handler:${t}`,`on('${t}') needs a function; ignored.`),()=>{};X("on",t);let u=this.#e.get(t);return u||(u=[],this.#e.set(t,u)),u.push(o),()=>this.off(t,o)}once(t,o){if(typeof o!="function")return P(`bus.handler:${t}`,`once('${t}') needs a function; ignored.`),()=>{};X("once",t);const u=d=>{this.off(t,o),o(d)};return this.#s.set(o,u),this.on(t,u)}off(t,o){if(o===void 0){this.#e.delete(t);return}const u=this.#e.get(t);if(!u)return;const d=this.#s.get(o),s=d&&u.includes(d)?d:o,g=u.indexOf(s);g>=0&&u.splice(g,1),d&&s===d&&this.#s.delete(o),u.length===0&&this.#e.delete(t)}count(t){const o=this.#e.get(t),u=t===x?null:this.#e.get(x);return(o?o.length:0)+(u?u.length:0)}#a(t,o,u,d,s){this.#n.push({type:t,origin:o,listeners:(d?d.length:0)+(s?s.length:0),payload:a(u),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(t,o){this.#t=!!t,Number.isFinite(o)&&o>0&&(this.#r=Math.floor(o)),t||(this.#n=[])}eventLog(){return this.#n.map(t=>({...t}))}clearEventLog(){this.#n=[]}counts(){const t={};for(const[o,u]of this.#e)t[o]=u.length;return t}emit(t,o,u){const d=u??(o&&o.origin),s=U.has(d)?d:"api",g={...o||null,type:t,origin:s,grid:this.#i};if(this.#o)return g;const i=this.#e.get(t),n=t===x?void 0:this.#e.get(x);if(this.#t&&this.#a(t,s,o,i,n),!i&&!n)return g;const f=this.#t?b():0;this.#l++;try{i&&this.#c(i.slice(),g,t),n&&this.#c(n.slice(),g,x)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=b()-f)}return g}emitBefore(t,o,u){const d=u??(o&&o.origin),s=U.has(d)?d:"user";let g=!1,i=null;const n=m=>{g=!0,m!=null&&i===null&&(i=String(m))},f={...o||null,type:t,origin:s,grid:this.#i,get defaultPrevented(){return g},get reason(){return i},preventDefault(m){n(m)}};if(this.#o)return!0;const p=this.#e.get(t);this.#t&&this.#a(t,s,o,p,void 0);const l=p?p.slice():[];if(l.length===0)return!0;const y=()=>(g&&i===null&&(i="prevented"),g&&o&&typeof o=="object"&&(o.reason=i),!g),c=[];for(const m of l)try{const w=m(f);w&&typeof w.then=="function"?c.push(w):w===!1&&n("prevented")}catch(w){n("error"),P(`bus.beforeThrow:${t}:${k(m)}`,`a '${t}' before-handler threw; the action was cancelled.`,w)}return c.length===0?y():Promise.allSettled(c).then(m=>{for(const w of m)w.status==="rejected"?(n("error"),P(`bus.beforeReject:${t}`,`a '${t}' before-handler rejected; the action was cancelled.`,w.reason)):w.value===!1&&n("prevented");return y()})}#c(t,o,u){for(let d=0;d<t.length;d++)try{t[d](o)}catch(s){P(`bus.throw:${u}:${k(t[d])}`,`a '${u}' handler threw; other handlers were unaffected.`,s)}}clear(){this.#e.clear(),this.#s.clear()}destroy(){this.clear(),this.#o=!0,this.#i=null}}}),We("packages/core/src/registry/free-tier-notice.js",function(e,D){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"WATERMARK_TEXT",{enumerable:!0,get:function(){return P}});const ne="Free for non-commercial use: latticegrid.dev/free",P="Unlicensed: Lattice Grid trial"}),We("packages/core/src/registry/licence.js",function(e,D){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return O}});const P=D("packages/core/src/internal/warn.js").warnOnce,Y=D("packages/core/src/registry/free-tier-notice.js"),_=Y.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return Y.FREE_TIER_NOTICE}});const L="lattice-grid",Z=1,H="LG1",x=64,X="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",U="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",j=(()=>{const T=new Int16Array(128).fill(-1);for(let A=0;A<U.length;A++)T[U.charCodeAt(A)]=A;return T[43]=62,T[47]=63,T})();function k(T){if(typeof T!="string")return null;let A="";for(let W=0;W<T.length;W++){const K=T.charCodeAt(W);if(K!==61){if(K>127||j[K]<0)return null;A+=T[W]}}const N=A.length;if(N%4===1)return null;const C=new Uint8Array(Math.floor(N*3/4));let S=0,F=0,$=0;for(let W=0;W<N;W++)S=S<<6|j[A.charCodeAt(W)],F+=6,F>=8&&(F-=8,C[$++]=S>>F&255);return $===C.length?C:C.subarray(0,$)}function b(T){let A="",N=0;for(;N+2<T.length;N+=3){const S=T[N]<<16|T[N+1]<<8|T[N+2];A+=U[S>>18&63]+U[S>>12&63]+U[S>>6&63]+U[S&63]}const C=T.length-N;if(C===1){const S=T[N]<<16;A+=U[S>>18&63]+U[S>>12&63]}else if(C===2){const S=T[N]<<16|T[N+1]<<8;A+=U[S>>18&63]+U[S>>12&63]+U[S>>6&63]}return A}function a(T){const A=new Uint8Array(T.length);for(let N=0;N<T.length;N++)A[N]=T.charCodeAt(N)&127;return A}function h(T){if(typeof TextDecoder=="function")return new TextDecoder().decode(T);let A="";for(let N=0;N<T.length;N++)A+=String.fromCharCode(T[N]);return A}function r(T){const A={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof T=="string"?T:""};if(typeof T!="string"||T.length===0)return{...A,reason:"missing"};const N=T.trim(),C=N.split(".");if(C.length!==3)return A;const[S,F,$]=C;if(S!==H)return{...A,reason:"prefix"};const W=k(F),K=k($);if(!W||!K)return A;let I;try{I=JSON.parse(h(W))}catch{return A}return I===null||typeof I!="object"?A:{ok:!0,reason:null,product:typeof I.p=="string"?I.p:null,issuedTo:typeof I.t=="string"?I.t:null,expires:typeof I.e=="string"?I.e:null,terms:typeof I.terms=="string"?I.terms:null,features:Array.isArray(I.f)?I.f.slice():[],deployments:Array.isArray(I.d)?I.d.slice():[],version:typeof I.v=="number"?I.v:0,message:a(F),signature:K,raw:N}}function t(T,A){if(!T)return!1;const N=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(T)?`${T}T23:59:59.999Z`:T);return Number.isNaN(N)?!0:A>N}function o(T){return T==="non-commercial"?"non-commercial":"commercial"}let u=null,d=null,s=null;function g(){const T=globalThis.crypto;return T&&T.subtle?T.subtle:null}async function i(T){if(u&&d===T)return u;const A=g();if(!A)return null;const N=k(T);if(!N)return null;try{const C=await A.importKey("raw",N,{name:"Ed25519"},!1,["verify"]);return u=C,d=T,C}catch{return null}}async function n(){return s!==null||(s=await i(X)!==null),s}async function f(T,A={}){const N=A.warn!==!1,C=A.product||L,S=A.publicKey||X,F=A.now??Date.now(),$=A.host??l(),W=p($)?"":` ${_}`,K=r(T);if(!K.ok){const Q=K.reason==="missing"?"missing":"malformed";return N&&P(`licence.${Q}`,Q==="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.${W}`:`licence key could not be read. The grid will render with a watermark.${W}`),{valid:!1,reason:Q,terms:"commercial"}}const I={product:K.product||void 0,issuedTo:K.issuedTo||void 0,expires:K.expires||void 0,terms:o(K.terms)};if(K.product!==C)return N&&P("licence.product",`licence key is for '${K.product}', not '${C}'. The grid will render with a watermark.`),{valid:!1,...I,reason:"product"};if(t(K.expires,F))return N&&P("licence.expired",`licence expired on ${K.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...I,reason:"expired"};const B=K.deployments||[];if(B.length&&$&&!p($)&&!y($,B))return N&&P("licence.domain",`licence key is not valid for ${$}; it covers ${B.join(", ")}. The grid will render with a watermark.`),{valid:!1,...I,reason:"domain"};const J=await i(S);if(!J){const Q=!!K.signature&&K.signature.length===x;return N&&P("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),Q?{valid:!0,...I,reason:"unverified"}:{valid:!1,...I,reason:"signature"}}let te=!1;try{te=await g().verify({name:"Ed25519"},J,K.signature,K.message)}catch{te=!1}return te?{valid:!0,...I}:(N&&P("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...I,reason:"signature"})}function p(T){const A=String(T??l()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!A||A==="localhost"||A.endsWith(".localhost")||A==="::1"||A==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(A)}function l(){const T=globalThis.location;return T&&typeof T.hostname=="string"?T.hostname:null}function y(T,A){const N=c(T);return!N||!Array.isArray(A)?!1:A.some(C=>{const S=c(C);if(!S)return!1;if(S==="*")return!0;if(S.startsWith("*.")){const F=S.slice(2);return N===F||N.endsWith(`.${F}`)}return N===S})}function c(T){return String(T??"").trim().toLowerCase().replace(/\.$/,"")}class m{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#s;#i=new Set;constructor(A={}){this.#s=A}set(A){this.#e=typeof A=="string"?A.trim():"";const N=r(this.#e);return this.#t=N.ok?{valid:!t(N.expires,Date.now())&&N.product===(this.#s.product||L),product:N.product||void 0,issuedTo:N.issuedTo||void 0,expires:N.expires||void 0,terms:o(N.terms),reason:"pending"}:{valid:!1,reason:N.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const A=this.#e;return this.#n=f(A,this.#s).then(N=>{if(this.#e===A){this.#t=N;for(const C of this.#i)C(N)}return N}),this.#n}onSettled(A){return this.#i.add(A),()=>this.#i.delete(A)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!p(this.#r)}setHost(A){this.#r=A}state(){return this.#t.valid?"licensed":p(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#i.clear()}}const w=Symbol.for("lattice-grid/licence/holder");function v(){const T=globalThis,A=T&&T[w];if(A&&typeof A.set=="function"&&typeof A.watermark=="function")return A;const N=new m;if(T)try{T[w]=N}catch{}return N}const E=v();function V(T){return E.set(T)}function G(){return E.info()}function q(){return E.watermark()}function M(){return E.state()}function O(){return E}}),We("packages/core/src/registry/registry.js",function(e,D){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return u}});const ne=D("packages/core/src/internal/warn.js"),P=ne.warnOnce,Y=ne.DEV,L=D("packages/core/src/internal/predicates.js").isFunction,Z=D("packages/core/src/registry/licence.js"),H=Z.LicenceHolder,x=Z.sharedLicence,X=["renderer","editor","filter","dataType","totalFn","pipe","component"],U=["all","header","body","totals","panels"];class j{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#s;#i=null;#o=null;#l=new Set;#a=new Map;constructor(s={}){for(const g of X)this.#t.set(g,new Map);this.#s=s.holder||x(),this.#o=s.grid??null,this.#i=this.#s.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),s.licence&&this.setLicence(s.licence)}registerModules(s,g={}){g.licence&&this.setLicence(g.licence),g.grid!==void 0&&(this.#o=g.grid);const i=Array.isArray(s)?s:[s],n=[];for(const f of i){if(!f||typeof f!="object"||typeof f.name!="string"||!f.name){P("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(f.name)){Y&&this.#u(this.#e.get(f.name),f);continue}if(!L(f.install)){P(`registry.module.install:${f.name}`,`module '${f.name}' has no install() and was ignored.`);continue}const p={registry:this,grid:this.#o};try{f.install(p)}catch(l){P(`registry.module.throw:${f.name}`,`module '${f.name}' threw during install; it was not registered.`,l);continue}this.#e.set(f.name,f);for(const l of k(f))this.#n.add(l);n.push(f.name),this.#d({reason:"module",name:f.name,capabilities:this.capabilities(),regions:h(f)})}return n}unregisterModule(s){const g=this.#e.get(s);if(!g)return!1;if(L(g.uninstall))try{g.uninstall({registry:this,grid:this.#o})}catch(i){P(`registry.module.uninstall:${s}`,`module '${s}' threw during uninstall.`,i)}return this.#e.delete(s),this.#c(),this.#d({reason:"unmodule",name:s,capabilities:this.capabilities(),regions:h(g)}),!0}modules(){return[...this.#e.values()]}has(s){return this.#e.has(s)}#c(){this.#n.clear();for(const s of this.#e.values())for(const g of k(s))this.#n.add(g)}#u(s,g){!s||s===g||b(s,g)||P(`registry.module.reconfigure:${g.name}`,`module '${g.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(s){return this.#n.has(s)}onChange(s){return L(s)?(this.#r.add(s),this.#a.set(s,this.#o),()=>{this.#r.delete(s),this.#a.delete(s)}):()=>{}}#d(s){for(const g of[...this.#r])try{g(s)}catch(i){P("registry.onChange.throw","a registry change handler threw.",i)}}register(s,g,i){const n=this.#t.get(s);if(!n){P(`registry.kind:${s}`,`unknown registry kind '${s}'; expected one of ${X.join(", ")}.`);return}if(!g||typeof g!="string"){P(`registry.name:${s}`,`register('${s}', ...) needs a name.`);return}n.has(g)&&n.get(g)!==i&&P(`registry.replace:${s}:${g}`,`'${g}' was already registered as a ${s} and has been replaced.`),n.set(g,i),this.#d({reason:"register",name:g,kind:s,capabilities:this.capabilities(),regions:r(s)})}registerAll(s,g){if(g)for(const i of Object.keys(g))this.register(s,i,g[i])}get(s,g){const i=this.#t.get(s);return i?i.get(g):void 0}names(s){const g=this.#t.get(s);return g?[...g.keys()]:[]}#f(s,g){const i=this.#t.get(s).get(g);return i!==void 0?i:this.#t.get("component").get(g)}renderer(s){return this.#f("renderer",s)}editor(s){return this.#f("editor",s)}filter(s){return this.#f("filter",s)}dataType(s){return this.get("dataType",s)}totalFn(s){return this.get("totalFn",s)}pipe(s){return this.get("pipe",s)}setLicence(s){return this.#s.set(s)}licence(){return this.#s.info()}licenceVerified(){return this.#s.verify()}watermark(){return this.#s.watermark()}attach(s){s!=null&&(this.#l.add(s),this.#o=s)}detach(s){if(s!=null){this.#l.delete(s);for(const[g,i]of[...this.#a])i===s&&(this.#r.delete(g),this.#a.delete(g));if(this.#o===s){const g=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#o=g}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(s){if(s!=null){this.detach(s);return}for(const g of[...this.#e.keys()])this.unregisterModule(g);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#o=null}}function k(d){const s=d.capabilities,g=Array.isArray(s)?s.filter(i=>typeof i=="string"):[];return[d.name,...g]}function b(d,s){return d.install!==s.install||d.uninstall!==s.uninstall||(d.version||"")!==(s.version||"")?!1:a(k(d),k(s))&&a(h(d),h(s))}function a(d,s){const g=new Set(d),i=new Set(s);if(g.size!==i.size)return!1;for(const n of g)if(!i.has(n))return!1;return!0}function h(d){const s=d.regions;return!Array.isArray(s)||s.length===0?["all"]:s.filter(g=>U.includes(g))}function r(d){switch(d){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const t=new j;function o(){return t}function u(d,s={}){return t.registerModules(d,s)}}),We("packages/core/src/internal/text.js",function(e,D){"use strict";Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return _}});function ne(L){return L?(L.includes(".")?L.slice(L.lastIndexOf(".")+1):L).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(/^./,H=>H.toUpperCase()):""}const P={"&":"&","<":"<",">":">",'"':""","'":"'"};function Y(L){const Z=L==null?"":String(L);return/[&<>"']/.test(Z)?Z.replace(/[&<>"']/g,H=>P[H]):Z}function _(L){return String(L).replace(/\w\S*/g,Z=>Z[0].toUpperCase()+Z.slice(1).toLowerCase())}}),We("packages/core/src/format/mask.js",function(e,D){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return Z}});const ne=new Set(["0","#","?",",","."]),P="\0";function Y(x){const X=[];let U="",j=!1;for(let k=0;k<x.length;k++){const b=x[k];if(b==="\\"){U+=b+(x[k+1]??""),k+=1;continue}if(b==='"'){j=!j,U+=b;continue}if(b===";"&&!j){X.push(U),U="";continue}U+=b}return X.push(U),X}function _(x){let X="",U="",j="",k=1,b=!1,a=!1;const h=n=>{a?U+=n:X+=n};for(let n=0;n<x.length;n++){const f=x[n];if(f==="\\"){h(x[n+1]??""),n+=1;continue}if(f==='"'){const p=x.indexOf('"',n+1);h(p===-1?x.slice(n+1):x.slice(n+1,p)),n=p===-1?x.length:p;continue}if(f==="%"){k*=100,h("%");continue}if(f==="@"){b=!0,h("\0");continue}if(ne.has(f)){j+=f,a=!0;continue}h(f)}let r=-1;for(let n=j.length-1;n>=0;n--){const f=j[n];if(f==="0"||f==="#"||f==="?"){r=n;break}}let t=!1,o="";for(let n=0;n<j.length;n++){const f=j[n];if(f===","){n>r?k/=1e3:t=!0;continue}o+=f}const u=o.indexOf("."),d=u===-1?o:o.slice(0,u),s=u===-1?"":o.slice(u+1);let g=0;for(const n of d)n==="0"&&(g+=1);let i=0;for(const n of s)n==="0"&&(i+=1);return{prefix:X,suffix:U,minInt:g,minDec:i,maxDec:s.length,grouping:t,scale:k,hasNumber:r!==-1,isText:b}}function L(x,X){const U=new Intl.NumberFormat(X,{minimumIntegerDigits:Math.max(x.minInt,1),minimumFractionDigits:x.minDec,maximumFractionDigits:Math.max(x.maxDec,x.minDec),useGrouping:x.grouping}),{prefix:j,suffix:k,scale:b,hasNumber:a}=x;return h=>{if(!a)return j+k;const r=b===1?h:h*b;return j+U.format(r)+k}}function Z(x,X){const j=Y(String(x)).map(_),k=j.map(o=>L(o,X)),b=0,a=j.length>1?1:-1,h=j.length>2?2:-1,r=j.length>3?3:-1,t=o=>{if(o==null||o==="")return"";if(typeof o!="number"||Number.isNaN(o)){const u=Number(o);if(Number.isNaN(u))return r===-1?String(o):(j[r].prefix+j[r].suffix).split("\0").join(String(o));o=u}return o===0&&h!==-1?k[h](0):o<0&&a!==-1?k[a](-o):k[b](o)};return t.spec={mask:x},{format:t,ooxml:H(String(x))}}function H(x){return x.trim()}}),We("packages/core/src/format/pattern.js",function(e,D){"use strict";Object.defineProperty(e,"parseNumberPattern",{enumerable:!0,get:function(){return L}});const P=D("packages/core/src/format/mask.js").splitSections;function Y(Z){let H="",x="",X="",U="",j=!1,k=!1,b=!1,a=!1;const h=t=>{b?x+=t:H+=t};for(let t=0;t<Z.length;t++){const o=Z[t];if(o==="\\"){h(Z[t+1]??""),t+=1;continue}if(o==='"'){const u=Z.indexOf('"',t+1);h(u===-1?Z.slice(t+1):Z.slice(t+1,u)),t=u===-1?Z.length:u;continue}if(o==="%"){k=!0;continue}if(o==="0"||o==="#"){b=!0,a?U+=o:X+=o;continue}if(o===","){a||(j=!0);continue}if(o==="."&&!a){a=!0;continue}h(o)}if(!b)return{hasDigit:!1,prefix:H,suffix:x,minDec:0,maxDec:0,grouping:!1,percent:k};let r=0;for(const t of U)t==="0"&&(r+=1);return{hasDigit:!0,prefix:H,suffix:x,minDec:r,maxDec:U.length,grouping:j,percent:k}}function _(Z,H){const x=H.trim(),X=Z.trim();return x.startsWith("(")&&x.endsWith(")")&&x.slice(1,-1).trim()===X?"parentheses":x.endsWith("-")?"suffix":"minus"}function L(Z){if(typeof Z!="string")return null;const H=P(Z);if(H.length===0)return null;const x=Y(H[0]);if(!x.hasDigit)return null;const X={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(H.length>1&&(X.negative=_(H[0],H[1])),H.length>2){const U=Y(H[2]);U.hasDigit||(X.zeroDisplay=U.prefix+U.suffix)}return X}}),We("packages/core/src/format/number.js",function(e,D){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return H}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/internal/warn.js").warnOnce,Z=D("packages/core/src/format/pattern.js").parseNumberPattern;function H(x,X){const U=typeof x=="string"?{pattern:x}:x||{};let j=U;if(typeof U.pattern=="string"){const v=Z(U.pattern);if(v){const{pattern:E,...V}=U;j={...v,...V}}else _(`format:pattern:${U.pattern}`,`invalid number format pattern "${U.pattern}"; the value will use the default number format`)}const k=j.locale||X||void 0,b=j.style||"decimal",a=typeof j.scale=="number"?j.scale:1,h=j.nullDisplay??"",r=j.zeroDisplay,t=j.prefix||"",o=j.suffix||"",u=j.negative||"minus",d=j.signed===!0,s={style:b,notation:j.notation||"standard"};b==="currency"&&(s.currency=j.currency||"USD",j.currencyDisplay&&(s.currencyDisplay=j.currencyDisplay)),typeof j.decimals=="number"?(s.minimumFractionDigits=j.decimals,s.maximumFractionDigits=j.decimals):(typeof j.minDecimals=="number"&&(s.minimumFractionDigits=j.minDecimals),typeof j.maxDecimals=="number"&&(s.maximumFractionDigits=j.maxDecimals),s.minimumFractionDigits>(s.maximumFractionDigits??20)&&(s.maximumFractionDigits=s.minimumFractionDigits)),j.thousandsSeparator===!1&&(s.useGrouping=!1),s.notation==="compact"&&(s.compactDisplay=j.compactDisplay||"short");const g=new Intl.NumberFormat(k,s),i=typeof j.thousandsSeparator=="string"?j.thousandsSeparator:null,n=typeof j.decimalSeparator=="string"?j.decimalSeparator:null;let f=",",p=".";if(i||n)for(const v of g.formatToParts(12345.6))v.type==="group"?f=v.value:v.type==="decimal"&&(p=v.value);const l=v=>{let E=v;return i&&(E=E.split(f).join("")),n&&(E=E.split(p).join("")),i&&(E=E.split("").join(i)),n&&(E=E.split("").join(n)),E},y=!!(i||n),c=t!==""&&b==="currency",m=v=>{let E;if(c){const V=g.formatToParts(v);let G=!1;E="";for(const q of V)E+=q.value,!G&&q.type==="currency"&&(E+=t,G=!0);G||(E=t+E)}else E=t+g.format(v);return y&&(E=l(E)),E+o},w=v=>{if(P(v)||v==="")return h;const E=typeof v=="number"?v:Number(v);if(Number.isNaN(E))return h;const V=a===1?E:E*a;return V===0&&r!==void 0?r:V<0?u==="parentheses"?`(${m(-V)})`:u==="suffix"?`${m(-V)}-`:m(V):d&&V>0?`+${m(V)}`:m(V)};return w.negativeClass=j.negativeClass||null,w.spec=j,w}}),We("packages/core/src/format/date.js",function(e,D){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return Z}}),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 a}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return o}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/internal/warn.js").warnOnce,L=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function Z(u){const d=[];let s=0,g="";const i=()=>{g&&(d.push({token:null,text:g}),g="")};for(;s<u.length;){const n=u[s];if(n==="'"){if(u[s+1]==="'"){g+="'",s+=2;continue}const p=u.indexOf("'",s+1);if(p===-1){g+=u.slice(s+1),s=u.length;continue}g+=u.slice(s+1,p),s=p+1;continue}const f=L.find(p=>u.startsWith(p,s));if(f){i(),d.push({token:f,text:f}),s+=f.length;continue}/[A-Za-z]/.test(n)&&_(`date.pattern.token:${n}`,`the date pattern "${u}" contains '${n}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${L.join(" ")}.`),g+=n,s+=1}return i(),d}const H=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function x(u){if(P(u)||u==="")return null;if(u instanceof Date)return Number.isNaN(u.getTime())?null:u;if(typeof u=="number")return Number.isNaN(u)?null:new Date(u);if(typeof u=="string"){const d=H.exec(u.trim());if(d){const[,g,i,n,f="0",p="0",l="0"]=d;return new Date(+g,+i-1,+n,+f,+p,+l)}const s=new Date(u);return Number.isNaN(s.getTime())?null:s}return null}function X(u,d){return String(u).padStart(d,"0")}function U(u){if(!u)return g=>({year:g.getFullYear(),month:g.getMonth()+1,day:g.getDate(),hour:g.getHours(),minute:g.getMinutes(),second:g.getSeconds(),ms:g.getMilliseconds(),weekday:g.getDay()});const d=new Intl.DateTimeFormat("en-US",{timeZone:u,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),s={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return g=>{const i={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:g.getMilliseconds(),weekday:0};for(const n of d.formatToParts(g))switch(n.type){case"year":i.year=Number(n.value);break;case"month":i.month=Number(n.value);break;case"day":i.day=Number(n.value);break;case"hour":i.hour=Number(n.value)%24;break;case"minute":i.minute=Number(n.value);break;case"second":i.second=Number(n.value);break;case"weekday":i.weekday=s[n.value]??0;break;default:break}return i}}function j(u,d,s){const g=Z(u),i=U(s),n=new Set(g.filter(c=>c.token).map(c=>c.token)),f=n.has("MMM")?new Intl.DateTimeFormat(d,{month:"short",timeZone:s}):null,p=n.has("MMMM")?new Intl.DateTimeFormat(d,{month:"long",timeZone:s}):null,l=n.has("EEE")?new Intl.DateTimeFormat(d,{weekday:"short",timeZone:s}):null,y=n.has("EEEE")?new Intl.DateTimeFormat(d,{weekday:"long",timeZone:s}):null;return c=>{const m=i(c);let w="";for(const v of g){if(!v.token){w+=v.text;continue}switch(v.token){case"yyyy":w+=X(m.year,4);break;case"yy":w+=X(m.year%100,2);break;case"MMMM":w+=p.format(c);break;case"MMM":w+=f.format(c);break;case"MM":w+=X(m.month,2);break;case"M":w+=String(m.month);break;case"dd":w+=X(m.day,2);break;case"d":w+=String(m.day);break;case"EEEE":w+=y.format(c);break;case"EEE":w+=l.format(c);break;case"HH":w+=X(m.hour,2);break;case"H":w+=String(m.hour);break;case"hh":w+=X(m.hour%12===0?12:m.hour%12,2);break;case"h":w+=String(m.hour%12===0?12:m.hour%12);break;case"mm":w+=X(m.minute,2);break;case"m":w+=String(m.minute);break;case"ss":w+=X(m.second,2);break;case"s":w+=String(m.second);break;case"SSS":w+=X(m.ms,3);break;case"a":w+=m.hour<12?"AM":"PM";break;default:w+=v.text;break}}return w}}const k=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function b(u,d){const s=u||{},g=s.locale||d||void 0,i=s.nullDisplay??"",n=s.timeZone;let f;if(s.pattern)f=j(s.pattern,g,n);else if(s.dateStyle||s.timeStyle){const m={timeZone:n};s.dateStyle&&(m.dateStyle=s.dateStyle),s.timeStyle&&(m.timeStyle=s.timeStyle);const w=new Intl.DateTimeFormat(g,m);f=v=>w.format(v)}else{const m=new Intl.DateTimeFormat(g,{dateStyle:"medium",timeZone:n});f=w=>m.format(w)}const p=s.relative?new Intl.RelativeTimeFormat(g,{numeric:"auto"}):null,y=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,c=(m,w)=>{const v=x(m);if(!v)return i;if(p){const E=w&&typeof w.now=="number"?w.now:Date.now(),V=v.getTime()-E;if(Math.abs(V)<y){for(const[G,q]of k)if(Math.abs(V)>=q||G==="second")return p.format(Math.round(V/q),G)}}return f(v)};return c.spec=s,c}function a(u){if(P(u)||u==="")return null;if(typeof u=="string"){const g=/^(\d{4}-\d{2}-\d{2})/.exec(u.trim());if(g)return g[1];const i=x(u);return i?a(i):null}const d=x(u);if(!d)return null;const s=g=>String(g).padStart(2,"0");return`${d.getFullYear()}-${s(d.getMonth()+1)}-${s(d.getDate())}`}function h(u,d){if(P(u)||u==="")return null;if(typeof u=="string"){const g=u.trim();if(r.test(g)){const f=x(g);return f?t(f,d):null}const i=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(g);if(i){const[,f,p,l,y]=i;return`${f}T${p}:${l}${y&&y!=="00"?`:${y}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(g))return`${g}T00:00`;const n=x(g);return n?h(n):null}const s=x(u);return s?t(s,d):null}const r=/(?:Z|[+-]\d{2}:?\d{2})$/i;function t(u,d){const s=f=>String(f).padStart(2,"0");if(d)try{const f=new Intl.DateTimeFormat("en-CA",{timeZone:d,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(u).reduce((y,c)=>(c.type!=="literal"&&(y[c.type]=c.value),y),{}),p=f.hour==="24"?"00":f.hour,l=Number(f.second);return`${f.year}-${f.month}-${f.day}T${p}:${f.minute}`+(l?`:${f.second}`:"")}catch{}const g=`${u.getFullYear()}-${s(u.getMonth()+1)}-${s(u.getDate())}`,i=u.getSeconds(),n=`${s(u.getHours())}:${s(u.getMinutes())}${i?`:${s(i)}`:""}`;return`${g}T${n}`}function o(u,d){const s=P(u)||u===""?null:String(u),g=P(d)||d===""?null:String(d);return s===null?g===null?0:1:g===null||s<g?-1:s>g?1:0}}),We("packages/core/src/format/boolean.js",function(e,D){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return Z}});const P=D("packages/core/src/internal/predicates.js").isNil,Y={true:"☑",false:"☐",null:""},_={true:"◉",false:"◯",null:""};function L(H){if(P(H)||H==="")return null;if(typeof H=="boolean")return H;if(typeof H=="number")return H!==0;const x=String(H).trim().toLowerCase();return x==="true"||x==="yes"||x==="y"||x==="1"?!0:x==="false"||x==="no"||x==="n"||x==="0"?!1:null}function Z(H,x){const X=H||{},U=X.display||"text",j=X.trueLabel??"Yes",k=X.falseLabel??"No",b=X.nullLabel??"";let a=j,h=k;const r=b;U==="checkbox"?(a=Y.true,h=Y.false):U==="switch"?(a=_.true,h=_.false):U==="icon"&&(a=X.trueIcon??j,h=X.falseIcon??k);const t=o=>{const u=L(o);return u===null?r:u?a:h};return t.display=U,t.labels={true:j,false:k,null:b},t.locale=x,t.spec=X,t}}),We("packages/core/src/format/text.js",function(e,D){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return L}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/internal/text.js").titleCase;function L(Z,H){const x=Z||{},X=x.locale||H||void 0,U=x.nullDisplay??"",j=x.emptyDisplay??"",k=x.transform||"none",b=typeof x.truncate=="number"?{chars:x.truncate}:x.truncate||null,a=b?b.chars:0,h=b?b.ellipsis??"…":"",r=o=>{switch(k){case"upper":return X?o.toLocaleUpperCase(X):o.toUpperCase();case"lower":return X?o.toLocaleLowerCase(X):o.toLowerCase();case"title":return _(o);default:return o}},t=o=>{if(P(o))return U;let u=typeof o=="string"?o:String(o);return u===""?j:(k!=="none"&&(u=r(u)),a>0&&u.length>a&&(u=u.slice(0,a)+h),u)};return t.spec=x,t}}),We("packages/core/src/format/shorthand.js",function(e,D){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return H}});const ne=["currency","number","percent","date","boolean","text","relative"],P=/[#0?@;"\\]/,Y=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function _(x){return typeof x!="string"||x===""||Z(x)?!1:P.test(x)}function L(x){return typeof x!="string"||x===""||Z(x)?!1:Y.test(x)}function Z(x){const X=x.indexOf(":"),U=X===-1?x:x.slice(0,X);return ne.includes(U)?U:null}function H(x){const X=Z(x);if(!X)return null;const U=x.indexOf(":"),j=U===-1?"":x.slice(U+1),k=j===""?[]:j.split(":");switch(X){case"currency":{const b={type:"number",style:"currency",currency:k[0]||"USD"};return k[1]!==void 0&&k[1]!==""&&(b.decimals=Number(k[1])),b}case"number":{const b={type:"number",style:"decimal"};return k[0]!==void 0&&k[0]!==""&&(b.decimals=Number(k[0])),b}case"percent":{const b={type:"number",style:"percent"};return k[0]!==void 0&&k[0]!==""&&(b.decimals=Number(k[0])),b}case"date":return{type:"date",pattern:j||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const b=j.split("/"),a={type:"boolean",display:"text"};return b[0]!==void 0&&b[0]!==""&&(a.trueLabel=b[0]),b[1]!==void 0&&b[1]!==""&&(a.falseLabel=b[1]),b[2]!==void 0&&(a.nullLabel=b[2]),a}case"text":{const b={type:"text"};return k[0]&&(b.transform=k[0]),k[1]!==void 0&&k[1]!==""&&(b.truncate=Number(k[1])),b}default:return null}}}),We("packages/core/src/format/index.js",function(e,D){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return E}});const ne=D("packages/core/src/internal/predicates.js"),P=ne.isFunction,Y=ne.isObject,L=D("packages/core/src/internal/warn.js").warnOnce,Z=D("packages/core/src/format/number.js"),H=Z.compileNumber,x=D("packages/core/src/format/date.js"),X=x.compileDate,U=x.scanPattern,j=D("packages/core/src/format/boolean.js"),k=j.compileBoolean,b=D("packages/core/src/format/text.js"),a=b.compileText,h=D("packages/core/src/format/mask.js"),r=h.compileMask,t=D("packages/core/src/format/shorthand.js"),o=t.parseShorthand,u=t.looksLikeMask,d=t.looksLikeDatePattern,g=D("packages/core/src/format/pattern.js").parseNumberPattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return Z.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 h.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return h.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return h.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return t.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return t.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return t.looksLikeDatePattern}});const i=new Set(["decimal","currency","percent","unit"]),n=new Set(["type","locale"]),f={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"])},p=new Set(["number","date","boolean","text"]);function l(M,O){const T=M.type;if(T===void 0||p.has(T)||!i.has(String(T)))return;const A=O?`"${O}"`:"with no id";L(`format:unknown-style-key:${O||""}:${T}`,`column ${A} has format: { type: "${T}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${T}" instead?`)}function y(M,O,T){const A=f[O],N=T?`"${T}"`:"with no id";for(const C of M){if(n.has(C)||A.has(C))continue;const S=Object.keys(f).find(F=>F!==O&&f[F].has(C));S?L(`format:inapplicable:${T||""}:${C}`,`column ${N} has format key "${C}", which applies to a ${S} column, not the ${O} column it was applied to; it is ignored.`):L(`format:unknown:${T||""}:${C}`,`column ${N} has an unrecognised format key "${C}" for its ${O} format; it is ignored.`)}}function c(M){if(M.type==="number"||M.type==="date"||M.type==="boolean"||M.type==="text")return!0;const O=i.has(String(M.style));return!!(M.pattern||M.dateStyle||M.timeStyle||M.relative||M.timeZone||M.trueLabel||M.falseLabel||M.display||M.trueIcon||M.falseIcon||M.transform||M.truncate||M.emptyDisplay||O||M.currency||M.decimals!==void 0||M.minDecimals!==void 0||M.maxDecimals!==void 0||M.notation||M.negative||M.scale!==void 0||M.prefix||M.suffix||M.zeroDisplay!==void 0)}function m(M,O){if(M.type==="number"||M.type==="date"||M.type==="boolean"||M.type==="text")return M.type;if(M.pattern){if(u(M.pattern))return"number";if(d(M.pattern))return"date"}if(M.dateStyle||M.timeStyle||M.relative||M.timeZone)return"date";if(M.trueLabel||M.falseLabel||M.display||M.trueIcon||M.falseIcon)return"boolean";if(M.transform||M.truncate||M.emptyDisplay)return"text";if(M.style||M.currency||M.decimals!==void 0||M.minDecimals!==void 0||M.maxDecimals!==void 0||M.notation||M.negative||M.scale!==void 0||M.prefix||M.suffix||M.zeroDisplay!==void 0)return"number";const T=O&&O.base;return T==="number"?"number":T==="date"||T==="dateString"?"date":T==="boolean"?"boolean":"text"}function w(M,O=null,T=void 0,A=void 0,N=void 0){if(M==null||M==="")return null;const C=Y(M)?Object.keys(M):null;if(typeof M=="function"){const $=(W,K)=>String(M({...K||{},value:W,locale:T})??"");return $.ooxml=O&&O.excel||"General",$}if(typeof M=="string"){if(u(M)){const{format:W,ooxml:K}=r(M,T);return W.ooxml=K,W}const $=o(M)||(d(M)?{type:"date",pattern:M}:null);return $?w($,O,T,A,N):(L(`format:${M}`,`unrecognised format string "${M}"; the value will be stringified`),null)}if(!Y(M))return L("format:shape","format must be a spec object or a string; ignoring",M),null;if(O&&P(O.format)&&!c(M)||O&&P(O.format)&&Array.isArray(O.formatPatterns)&&M.type===void 0)return null;const S=m(M,O);S==="date"&&A&&M.timeZone===void 0&&(M={...M,timeZone:A}),l(M,N),y(C||Object.keys(M),S,N);let F;switch(S){case"number":F=H(M,T);break;case"date":F=X(M,T);break;case"boolean":F=k(M,T);break;default:F=a(M,T);break}return F.ooxml=E(M,S,T,O),F.kind=S,F}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 E(M,O,T=void 0,A=null){if(O==="date"){if(M.pattern){let $="";for(const W of U(M.pattern))$+=W.token?v[W.token]??W.text:W.text;return $}return A&&A.excel||"yyyy-mm-dd"}if(O==="boolean")return"General";if(O==="text")return"@";if(typeof M.pattern=="string"&&g(M.pattern))return String(M.pattern).trim();if(M.notation==="compact"||M.notation==="scientific")return"General";const N=typeof M.decimals=="number"?M.decimals:typeof M.minDecimals=="number"?M.minDecimals:M.style==="currency"?2:0;let S=`${M.thousandsSeparator===!1?"":"#,#"}#0${N>0?`.${"0".repeat(N)}`:""}`,F="";return M.style==="currency"&&(F+=V(q(M.currency||"USD",T))),M.prefix&&(F+=V(M.prefix)),S=F+S,M.style==="percent"&&(S=`${S}%`),M.suffix&&(S+=V(M.suffix)),M.negative==="parentheses"?`${S};(${S})`:M.negative==="suffix"?`${S};${S}-`:S}function V(M){return`"${String(M).split('"').join("")}"`}const G=new Map;function q(M,O){const T=`${M}|${O||""}`;let A=G.get(T);if(A!==void 0)return A;A=M;try{const C=new Intl.NumberFormat(O,{style:"currency",currency:M}).formatToParts(0).find(S=>S.type==="currency");C&&(A=C.value)}catch{}return G.set(T,A),A}}),We("packages/core/src/columns/types/temporal.js",function(e,D){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Re}});const ne=D("packages/core/src/internal/predicates.js"),P=ne.isNil,Y=ne.isFunction,_=D("packages/core/src/format/date.js"),L=_.toDate,Z=_.compilePattern,H=_.compileDate,x=_.toIsoDateTime,X=_.compareIso,U=864e5,j=Object.freeze({}),k=1e3,b=60*k,a=60*b,h=24*a,r=7*h,t=new WeakMap;function o(Se,Ve){const Fe=Se&&Se.locale||"",Ce=Se&&Se.column;if(!Ce)return Fe?{locale:Fe}:j;const Ee=t.get(Ce);if(Ee&&Ee.locale===Fe)return Ee.bag;const Ie=Ce.typeOptions||Ce[Ve]||(u(Ce.format)?Ce.format:null),Be={...Ie||j,locale:Ie&&Ie.locale||Fe||void 0};return t.set(Ce,{locale:Fe,bag:Be}),Be}function u(Se){return Se!==null&&typeof Se=="object"&&!Array.isArray(Se)&&!(Se instanceof Date)}function d(Se,Ve){const Fe=Se===null||Number.isNaN(Se)?null:Se,Ce=Ve===null||Number.isNaN(Ve)?null:Ve;return Fe===null?Ce===null?0:1:Ce===null||Fe<Ce?-1:Fe>Ce?1:0}const s=/^(\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,g=/^(\d{3,6})$/;function i(Se,Ve,Fe,Ce){return!(Se>=0&&Se<=23)||!(Ve>=0&&Ve<=59)||!(Fe>=0&&Fe<=59)||!(Ce>=0&&Ce<=999)?null:Se*a+Ve*b+Fe*k+Ce}function n(Se){if(P(Se))return null;const Ve=String(Se).trim();if(Ve==="")return null;const Fe=g.exec(Ve);if(Fe){const rt=Fe[1];if(rt.length===5)return null;const nt=rt.length===3?1:2;return i(Number(rt.slice(0,nt)),Number(rt.slice(nt,nt+2)),Number(rt.slice(nt+2,nt+4)||0),0)}const Ce=s.exec(Ve);if(!Ce)return null;let Ee=Number(Ce[1]);const Ie=Number(Ce[2]||0),Be=Number(Ce[3]||0),Ke=Ce[4]?Number(Ce[4].padEnd(3,"0")):0,qe=Ce[5]?Ce[5][0].toLowerCase():null;if(qe){if(Ee<1||Ee>12)return null;Ee=Ee%12,qe==="p"&&(Ee+=12)}return i(Ee,Ie,Be,Ke)}function f(Se){return P(Se)||Se===""?null:typeof Se=="number"?Number.isFinite(Se)?(Se%h+h)%h:null:Se instanceof Date?Number.isNaN(Se.getTime())?null:Se.getHours()*a+Se.getMinutes()*b+Se.getSeconds()*k+Se.getMilliseconds():n(Se)}const p=new Map;function l(Se){const Ve=Se.pattern||"",Fe=Se.timeStyle||(Se.seconds?"medium":"short"),Ce=`${Se.locale||""}|${Ve}|${Fe}`;let Ee=p.get(Ce);if(Ee)return Ee;if(Ve)Ee=Z(Ve,Se.locale||void 0,"UTC");else{const Ie=new Intl.DateTimeFormat(Se.locale||void 0,{timeStyle:Fe,timeZone:"UTC"});Ee=Be=>Ie.format(Be)}return p.set(Ce,Ee),Ee}function y(Se,Ve){const Fe=Ve||j;if(Se==null||typeof Se!="number"||!Number.isFinite(Se))return Fe.nullDisplay??"";const Ce=(Se%h+h)%h;return l(Fe)(new Date(Ce))}function c(Se){return Se instanceof Date?!Number.isNaN(Se.getTime()):typeof Se=="number"?Number.isFinite(Se)&&Se>=0&&Se<h:typeof Se!="string"||!Se.includes(":")?!1:n(Se)!==null}function m(Se){const Ve=f(Se);return Ve==null?"":y(Ve,{pattern:Ve%k===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const w=new Map;function v(Se){const Ve=Se||"";let Fe=w.get(Ve);return Fe||(Fe=new Intl.DateTimeFormat("en-GB",{timeZone:Se||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),w.set(Ve,Fe)),Fe}function E(Se,Ve){const Fe={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Ce of v(Ve).formatToParts(new Date(Se)))Ce.type==="year"?Fe.year=Number(Ce.value):Ce.type==="month"?Fe.month=Number(Ce.value):Ce.type==="day"?Fe.day=Number(Ce.value):Ce.type==="hour"?Fe.hour=Number(Ce.value)%24:Ce.type==="minute"?Fe.minute=Number(Ce.value):Ce.type==="second"&&(Fe.second=Number(Ce.value));return Fe}function V(Se,Ve){const Fe=E(Se,Ve);return Date.UTC(Fe.year,Fe.month-1,Fe.day,Fe.hour,Fe.minute,Fe.second,0)-Math.floor(Se/1e3)*1e3}function G(Se,Ve){const Fe=Se.hour||0,Ce=Se.minute||0,Ee=Se.second||0,Ie=Se.ms||0;if(!Ve)return new Date(Se.year,Se.month-1,Se.day,Fe,Ce,Ee,Ie).getTime();const Be=Date.UTC(Se.year,Se.month-1,Se.day,Fe,Ce,Ee,Ie);let Ke=Be-V(Be,Ve);return Ke=Be-V(Ke,Ve),Ke}const q=/(?:Z|[+-]\d{2}:?\d{2})$/i,M=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function O(Se,Ve){if(P(Se))return null;const Fe=String(Se).trim();if(Fe==="")return null;const Ce=Ve&&Ve.timeZone||void 0;if(!q.test(Fe)){const Ee=M.exec(Fe);if(Ee){const Ie=(Ee[4]||"").trim(),Be=Ie===""?0:n(Ie);if(Be===null)return null;const Ke=G({year:Number(Ee[1]),month:Number(Ee[2]),day:Number(Ee[3]),hour:Math.floor(Be/a),minute:Math.floor(Be/b)%60,second:Math.floor(Be/k)%60,ms:Be%k},Ce);return Number.isNaN(Ke)?null:new Date(Ke)}}return L(Fe)}function T(Se){if(typeof Se=="number")return Number.isFinite(Se)?Se:null;const Ve=L(Se);return Ve?Ve.getTime():null}const A=new Map;function N(Se){const Ve=[Se.locale||"",Se.pattern||"",Se.dateStyle||"",Se.timeStyle||"",Se.timeZone||"",Se.seconds?"1":""].join("|");let Fe=A.get(Ve);if(Fe)return Fe;const Ce=Se.pattern?{type:"date",pattern:Se.pattern,timeZone:Se.timeZone}:{type:"date",dateStyle:Se.dateStyle||"medium",timeStyle:Se.timeStyle||(Se.seconds?"medium":"short"),timeZone:Se.timeZone};return Fe=H(Ce,Se.locale||void 0),A.set(Ve,Fe),Fe}function C(Se,Ve){const Fe=Ve||j,Ce=T(Se);return Ce==null?Fe.nullDisplay??"":N(Fe)(Ce)}function S(Se){return Se instanceof Date?!Number.isNaN(Se.getTime()):typeof Se!="string"||!M.test(Se.trim())?!1:O(Se)!==null}const F=Object.freeze([{key:"w",ms:r,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:h,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:a,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:k,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),$=new Map;for(const Se of F)for(const Ve of Se.names)$.set(Ve,Se);const W=Object.freeze(F.filter(Se=>Se.key!=="w")),K=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,I=/^\d+(?:\.\d+)?$/,B=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function J(Se){const Ve=Se&&Se.defaultUnit?$.get(String(Se.defaultUnit).toLowerCase()):null;return Ve?Ve.ms:b}function te(Se){return(Se&&Se.defaultUnit?$.get(String(Se.defaultUnit).toLowerCase()):null)||$.get("m")}function Q(Se,Ve){if(P(Se))return null;let Fe=String(Se).trim().toLowerCase();if(Fe==="")return null;let Ce=1;if(Fe[0]==="-"?(Ce=-1,Fe=Fe.slice(1).trim()):Fe[0]==="+"&&(Fe=Fe.slice(1).trim()),Fe==="")return null;const Ee=B.exec(Fe);if(Ee){const qe=Ee[3]!==void 0,rt=Number(Ee[1])*a+Number(Ee[2])*b+(qe?Number(Ee[3])*k:0)+(Ee[4]?Number(Ee[4].padEnd(3,"0")):0);return Ce*rt}if(I.test(Fe))return Math.round(Ce*Number(Fe)*J(Ve||j));let Ie=Fe,Be=0,Ke=0;for(;Ie!=="";){const qe=K.exec(Ie);if(!qe)return null;const rt=$.get(qe[2]);if(!rt)return null;Be+=Number(qe[1])*rt.ms,Ie=Ie.slice(qe[0].length),Ke++}return Ke===0?null:Math.round(Ce*Be)}function re(Se){return P(Se)||Se===""?null:typeof Se=="number"?Number.isFinite(Se)?Se:null:Q(Se)}const ie=new Map;function ue(Se,Ve,Fe){const Ce=`${Fe||""}|${Ve.intl}`;let Ee=ie.get(Ce);if(Ee===void 0){try{Ee=new Intl.NumberFormat(Fe||void 0,{style:"unit",unit:Ve.intl,unitDisplay:"long"})}catch{Ee=null}ie.set(Ce,Ee)}return Ee?Ee.format(Se):`${Se} ${Se===1?Ve.long[0]:Ve.long[1]}`}function ke(Se,Ve){return String(Se).padStart(Ve,"0")}function de(Se,Ve){const Fe=Ve||j;if(Se==null||typeof Se!="number"||!Number.isFinite(Se))return Fe.nullDisplay??"";const Ce=Fe.style||"short",Ee=Se<0;let Ie=Math.round(Math.abs(Se));const Be=Ee?"-":"";if(Ie===0&&Fe.zeroDisplay!=null)return Fe.zeroDisplay;if(Ce==="clock"){const nt=Math.floor(Ie/a),dt=Math.floor(Ie/b)%60,Pt=Math.floor(Ie/k)%60;return`${Be}${ke(nt,2)}:${ke(dt,2)}:${ke(Pt,2)}`}if(Ie===0){const nt=te(Fe);return Ce==="long"?ue(0,nt,Fe.locale):`0${nt.key}`}const Ke=Fe.weeks===!0?F:W,qe=typeof Fe.maxUnits=="number"&&Fe.maxUnits>0?Fe.maxUnits:Fe.maxUnits===void 0?2:1/0,rt=[];for(const nt of Ke){if(rt.length>=qe)break;const dt=Math.floor(Ie/nt.ms);dt!==0&&(Ie-=dt*nt.ms,rt.push(Ce==="long"?ue(dt,nt,Fe.locale):`${dt}${nt.key}`))}return Be+rt.join(" ")}function we(Se){if(typeof Se!="string")return!1;const Ve=Se.trim();return Ve===""||B.test(Ve)||!/[a-z]/i.test(Ve)?!1:Q(Ve)!==null}const ve=Date.UTC(1899,11,30),De=new Map;function pe(Se,Ve){const Fe=Se||"";let Ce=De.get(Fe);Ce||(Ce=new Intl.DateTimeFormat("en-GB",{timeZone:Se||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),De.set(Fe,Ce));const Ee=typeof Ve=="number"?Ve:Date.now();for(const Ie of Ce.formatToParts(new Date(Ee)))if(Ie.type==="timeZoneName")return Ie.value;return""}function oe(Se){if(Se)return Se;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function be(Se,Ve){const Fe=oe(Se),Ce=pe(Se,Ve);return Ce?`${Fe} (${Ce})`:Fe}function fe(Se,Ve){if(Se&&Se.timeZone)return Se.timeZone;const Fe=Ve&&Ve.grid;return(Fe&&Y(Fe.get)?Fe.get("timeZone"):void 0)||void 0}function le(Se,Ve){const Fe=Ve||j,Ce=T(Se);if(Ce==null)return Fe.nullDisplay??"";const Ee=N(Fe)(Ce);if(!Fe.showOrigin)return Ee;const Ie=Fe.originZone;return Ie?Ie===(Fe.timeZone||oe(Fe.timeZone))?Ee:`${Ee} (${be(Ie,Ce)})`:`${Ee} (no origin recorded)`}function ye(Se,Ve,Fe,Ce){if(Ve==="instant"||!Ve)return Se;const Ee=E(Se,Fe);if(Ve==="month")return G({year:Ee.year,month:Ee.month,day:1},Fe);if(Ve==="week"){const Ie=Ce>=1&&Ce<=7?Ce:1,Ke=((new Date(Date.UTC(Ee.year,Ee.month-1,Ee.day)).getUTCDay()+6)%7+1-Ie+7)%7,qe=new Date(Date.UTC(Ee.year,Ee.month-1,Ee.day-Ke));return G({year:qe.getUTCFullYear(),month:qe.getUTCMonth()+1,day:qe.getUTCDate()},Fe)}return G({year:Ee.year,month:Ee.month,day:Ee.day},Fe)}function Ne(Se,Ve){const Fe=Se&&Se.group,Ce=Fe&&Fe.granularity||"day";if(Ce==="instant")return null;const Ee=Fe&&Fe.weekStart;return Ie=>typeof Ie=="number"?ye(Ie,Ce,Ve,Ee):Ie}const je={time:{base:"number",storage:"float64",matches:c,format:Se=>y(f(Se.value),o(Se,"time")),parse:Se=>n(Se.text),compare:(Se,Ve)=>d(f(Se),f(Ve)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Se=>{const Ve=f(Se);return Ve===null?null:Ve/U},toStorage:Se=>f(Se),toClipboard:m,fromClipboard:n},datetime:{base:"dateString",storage:"dictionary",matches:S,format:Se=>C(Se.value,o(Se,"datetime")),parse:Se=>x(O(Se.text,o(Se,"datetime"))??Se.text),compare:X,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Se,Ve)=>x(Se,Ve&&Ve.timeZone),toClipboard:Se=>P(Se)?"":String(Se),fromClipboard:Se=>x(Se)},duration:{base:"number",storage:"float64",matches:we,format:Se=>de(re(Se.value),o(Se,"duration")),parse:Se=>Q(Se.text,o(Se,"duration")),compare:(Se,Ve)=>d(re(Se),re(Ve)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Se=>{const Ve=re(Se);return Ve===null?null:Ve/U},toStorage:Se=>re(Se),toClipboard:Se=>de(re(Se),{style:"short",maxUnits:-1}),fromClipboard:Se=>Q(Se)},timestamp:{base:"number",storage:"float64",format:Se=>{const Ve=o(Se,"timestamp");return le(Se.value,{...Ve,timeZone:fe(Ve,Se)})},parse:Se=>{const Ve=o(Se,"timestamp"),Fe=O(Se.text,{timeZone:fe(Ve,Se)});return Fe?Fe.getTime():null},compare:(Se,Ve)=>d(T(Se),T(Ve)),groupProjector:(Se,Ve)=>Ne(Se,Ve),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Se,Ve)=>{const Fe=T(Se);if(Fe==null)return null;const Ce=E(Fe,Ve&&Ve.timeZone||void 0);return(Date.UTC(Ce.year,Ce.month-1,Ce.day,Ce.hour,Ce.minute,Ce.second)-ve)/U},toStorage:Se=>T(Se),toClipboard:Se=>{const Ve=T(Se);return Ve==null?"":new Date(Ve).toISOString()},fromClipboard:Se=>T(Se)}},$e=["datetime","time","duration"],Re=je}),We("packages/core/src/internal/lru.js",function(e,D){"use strict";Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return ne}});class ne{#e;#t=new Map;#n;constructor(Y=256,_=null){this.#e=Y,this.#n=_}get size(){return this.#t.size}get max(){return this.#e}set max(Y){this.#e=Y,this.#r()}has(Y){return this.#t.has(Y)}get(Y){const _=this.#t;if(!_.has(Y))return;const L=_.get(Y);return _.delete(Y),_.set(Y,L),L}peek(Y){return this.#t.get(Y)}set(Y,_){const L=this.#t;return L.has(Y)&&L.delete(Y),L.set(Y,_),this.#r(),_}delete(Y){const _=this.#t.get(Y);return this.#t.delete(Y)&&this.#n&&this.#n(_,Y),_}clear(){if(this.#n)for(const[Y,_]of this.#t)this.#n(_,Y);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const Y=this.#t;for(;Y.size>this.#e;){const _=Y.keys().next().value,L=Y.get(_);Y.delete(_),this.#n&&this.#n(L,_)}}}}),We("packages/core/src/columns/types/network.js",function(e,D){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/internal/lru.js").Lru,L=4294967295,Z=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function H(A){if(P(A))return null;if(typeof A=="string")return x(A);const N=Number(A);return Number.isFinite(N)?N<0?N<-2147483648?null:N>>>0:N>L?null:Math.trunc(N)>>>0:null}function x(A){if(P(A))return null;const N=String(A).trim();if(N==="")return null;const C=Z.exec(N);if(!C)return null;let S=0;for(let F=1;F<=4;F++){const $=C[F];if($.length>1&&$.charCodeAt(0)===48)return null;const W=Number($);if(W>255)return null;S=S*256+W}return S}function X(A){const N=H(A);return N===null?"":`${N>>>24&255}.${N>>>16&255}.${N>>>8&255}.${N&255}`}function U(A){return typeof A=="string"&&x(A)!==null}function j(A,N){const C=H(A),S=H(N);return C===null?S===null?0:1:S===null||C<S?-1:C>S?1:0}const k=64,b=L*k+32,a=/^(?:0|[1-9]\d?)$/;function h(A,N){return A*k+N}function r(A){if(P(A))return null;if(typeof A=="string"){const S=t(A);return S===null?null:r(S)}if(typeof A=="object"){const S=H(A.address),F=Number(A.prefix);return S===null||!Number.isInteger(F)||F<0||F>32?null:{address:S,prefix:F}}const N=Number(A);if(!Number.isInteger(N)||N<0||N>b)return null;const C=N%k;return C>32?null:{address:(N-C)/k,prefix:C}}function t(A){if(P(A))return null;const N=String(A).trim();if(N==="")return null;const C=N.indexOf("/");if(C<0)return null;const S=x(N.slice(0,C));if(S===null)return null;const F=N.slice(C+1).trim();if(!a.test(F))return null;const $=Number(F);return $>32?null:h(S,$)}function o(A){const N=r(A);return N?`${X(N.address)}/${N.prefix}`:""}function u(A){return typeof A=="string"&&t(A)!==null}function d(A,N){const C=r(A),S=r(N);return C?S?C.address!==S.address?C.address<S.address?-1:1:C.prefix-S.prefix:-1:S?1:0}function s(A){return A===0?0:4294967295<<32-A>>>0}function g(A){const N=r(A);return N?(N.address&s(N.prefix))>>>0:null}function i(A){const N=r(A);return N?(N.address&s(N.prefix)|~s(N.prefix)>>>0)>>>0:null}function n(A){const N=r(A);return N?2**(32-N.prefix):null}function f(A){const N=r(A);return N?N.prefix===32?1:N.prefix===31?2:2**(32-N.prefix)-2:null}function p(A,N){const C=r(A);if(!C)return!1;const S=H(N);if(S===null)return!1;const F=s(C.prefix);return(S&F)>>>0===(C.address&F)>>>0}function l(A,N){const C=g(A),S=g(N);return C===null||S===null?!1:C<=i(N)&&S<=i(A)}const y=/^[0-9a-fA-F]{1,4}$/,c=new _(512);function m(A){if(P(A))return null;let N=String(A).trim();if(N==="")return null;const C=N.indexOf("%");if(C>=0&&(N=N.slice(0,C)),N==="")return null;if(N.indexOf(".")>=0){const I=N.lastIndexOf(":");if(I<0)return null;const B=x(N.slice(I+1));if(B===null)return null;N=`${N.slice(0,I+1)}${(B>>>16&65535).toString(16)}:${(B&65535).toString(16)}`}const S=N.split("::");if(S.length>2)return null;const F=w(S[0]);if(F===null)return null;if(S.length===1)return F.length===8?F:null;const $=w(S[1]);if($===null)return null;const W=8-F.length-$.length;if(W<1)return null;const K=F.slice();for(let I=0;I<W;I++)K.push(0);for(const I of $)K.push(I);return K}function w(A){if(A==="")return[];const N=[];for(const C of A.split(":")){if(!y.test(C))return null;N.push(parseInt(C,16))}return N}function v(A){if(typeof A!="string")return m(A);if(c.has(A))return c.get(A);const N=m(A);return c.set(A,N),N}function E(A){if(A[0]===0&&A[1]===0&&A[2]===0&&A[3]===0&&A[4]===0&&A[5]===65535)return`::ffff:${X((A[6]<<16|A[7])>>>0)}`;let N=-1,C=0,S=-1,F=0;for(let K=0;K<8;K++)A[K]===0?(S<0?(S=K,F=1):F++,F>C&&(C=F,N=S)):(S=-1,F=0);if(C<2)return A.map(K=>K.toString(16)).join(":");const $=A.slice(0,N).map(K=>K.toString(16)).join(":"),W=A.slice(N+C).map(K=>K.toString(16)).join(":");return`${$}::${W}`}function V(A){const N=m(A);return N===null?null:E(N)}function G(A){return V(A)??""}function q(A){return typeof A=="string"&&A.indexOf(":")>=0&&m(A)!==null}function M(A,N){const C=v(A),S=v(N);if(!C)return S?1:0;if(!S)return-1;for(let F=0;F<8;F++)if(C[F]!==S[F])return C[F]<S[F]?-1:1;return 0}const O=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:U,parse:A=>x(A.text),compare:j,format:A=>X(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:A=>H(A),toClipboard:A=>X(A),fromClipboard:A=>x(A)},cidr:{base:"number",storage:"float64",matches:u,parse:A=>t(A.text),compare:d,format:A=>o(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:A=>{const N=r(A);return N===null?null:h(N.address,N.prefix)},toClipboard:A=>o(A),fromClipboard:A=>t(A)},ipv6:{base:"text",storage:"dictionary",matches:q,parse:A=>V(A.text),compare:M,format:A=>G(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:A=>V(A),toClipboard:A=>G(A),fromClipboard:A=>V(A)}}),T=O}),We("packages/core/src/i18n/catalogue.js",function(e,D){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return L}});const ne=D("packages/core/src/registry/free-tier-notice.js"),P=ne.FREE_TIER_NOTICE,Y=ne.WATERMARK_TEXT,_=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","rowCap.more":"+ {count} more","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","stat.target":"target {target}","meter.target":"target {value}","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","panel.compareGroups":"Compare groups","panel.explain":"Explain","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.","compareGroups.noTest":"Not enough readings, or no variation, in at least one group.","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","explain.column":"Value","explain.by":"Break down by","explain.byRow":"Each row","explain.noColumns":"No numeric columns to explain","explain.unavailable":"Nothing to explain in this column","explain.total":"{fn}: {total}","explain.weighted":"weighted effects","explain.single":"one contributor","explain.delta":"was {before}, now {after} (Δ {delta})","explain.breakdown":"Contributors","explain.contributor":"Contributor","explain.count":"Rows","explain.value":"Value","explain.contribution":"Contribution","explain.share":"Share","explain.change":"Change","explain.before":"Before","explain.after":"After","explain.effect":"Effect","explain.kind.new":"New","explain.kind.dropped":"Dropped","explain.kind.changed":"Changed","explain.narrative":"Explanation","explain.narrative.lead":"{top} accounts for {share}; the {fn} is {total}.","explain.narrative.next":"{next} follows at {share}.","explain.narrative.driver":"The change of {delta} was driven most by {top} ({effect}).","explain.narrative.driverNext":"{next} ({kind}) moved it {effect}.","explain.narrative.none":"Nothing contributed to this total.","explain.narrative.noChange":"Nothing changed between the two states.","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.compareGroups":"Compare groups","menu.explain":"Explain this number","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","listview.pullToRefresh.pull":"Pull to refresh","listview.pullToRefresh.release":"Release to refresh","listview.pullToRefresh.refreshing":"Refreshing…","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","dataview.label":"Items","dataview.empty":"No items","dataview.reorder.sorted":"Items cannot be reordered while the view is sorted","dataview.reorder.filtered":"Items cannot be reordered while a filter is applied","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.tree.dropRefusedDescendant":"A row cannot be dropped into one of its own descendants; the row stays where it was","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.explain":"Explain the focused column","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.","form.grid.cellInvalid":"Row {row}, {column}: {message}","form.grid.required":"Add at least one row.","form.grid.addRow":"Add row","form.grid.deleteRow":"Delete row","form.grid.total":"Total","form.grid.rowControls":"Row controls","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","panel.tabActiveCount":{one:"{title}, {count} active",other:"{title}, {count} active"},"panel.tabActive":"{title}, active","views.default":"Default","views.namePlaceholder":"Name this view…","views.nameLabel":"Name for the current layout","views.save":"Save view","licence.watermark":Y,"licence.watermark.free":P,"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.suppressed.unavailable":"Histogram unavailable","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}","views.shared":"View copied to the clipboard","views.sharedDownload":"Clipboard unavailable; the view was downloaded as {name}","views.sharedFailed":"The view could not be copied or downloaded","views.rename":"Rename","views.ownedBy":"Owned by {name}","views.ownerOnlyReason":"Only {name} or an admin can do that","views.noOwnerReason":"Only an admin can do that — this view has no recorded owner","views.unshare":"Unshare","views.unshareTitle":"Stop sharing {name}","views.duplicate":"Duplicate","views.duplicateTitle":"Duplicate {name}","views.copyName":"{name} (copy)","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","sidebar.nav":"Main navigation","sidebar.search":"Search","sidebar.collapse":"Collapse sidebar","sidebar.expand":"Expand sidebar","toolbar.more":"More"}),L=Object.freeze(Object.keys(_))}),We("packages/core/src/i18n/format.js",function(e,D){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return k}});const P=D("packages/core/src/internal/predicates.js").isFunction,Y=/\{(\w+)\}/g,_=new Map,L=new Map;function Z(b){const a=b||"";if(_.has(a))return _.get(a);let h=null;try{h=new Intl.PluralRules(b||void 0)}catch{h=null}return _.set(a,h),h}function H(b,a,h="conjunction"){const r=Array.isArray(b)?b.filter(u=>u!=null&&u!==""):[];if(r.length===0)return"";if(r.length===1)return String(r[0]);const t=`${a||""}|${h}`;let o=L.get(t);if(o===void 0){try{o=new Intl.ListFormat(a||void 0,{style:"long",type:h})}catch{o=null}L.set(t,o)}return o?o.format(r.map(String)):r.map(String).join(", ")}function x(b,a){return b==null?"":typeof b=="number"?Number.isFinite(b)?b.toLocaleString(a||void 0,{maximumFractionDigits:20}):"":String(b)}function X(b,a,h){if(typeof b=="string")return b;if(!b||typeof b!="object")return"";const r=a&&typeof a.count=="number"?a.count:null;if(r===null)return b.other??"";const t=Z(h),o=t?t.select(r):r===1?"one":"other";return b[o]??b.other??""}function U(b,a={},h){const r=X(b,a,h);return r?r.replace(Y,(t,o)=>Object.prototype.hasOwnProperty.call(a,o)?x(a[o],h):t):""}function j(b,a,h="en-GB"){return typeof b=="string"&&b?b:typeof a=="string"&&a?a:h}function k(b,a){const h=b?b[a]:void 0;return h==null||P(h)?a:h}}),We("packages/core/src/i18n/registry.js",function(e,D){"use strict";Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"localeCatalogue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"registeredTags",{enumerable:!0,get:function(){return Z}});const P=D("packages/core/src/i18n/catalogue.js").EN_GB,Y=new Map([["en-gb",P]]);function _(H,x){const X=typeof H=="string"?H.toLowerCase():"";return!X||!x||typeof x!="object"?!1:(Y.set(X,x),!0)}function L(H){if(typeof H!="string"||!H)return null;const x=H.toLowerCase(),X=Y.get(x);if(X)return X;const U=x.split("-")[0],j=Y.get(U);if(j)return j;for(const[k,b]of Y)if(k.split("-")[0]===U)return b;return null}function Z(){return[...Y.keys()]}}),We("packages/core/src/i18n/index.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return d}});const ne=D("packages/core/src/i18n/catalogue.js"),P=ne.EN_GB,Y=ne.MESSAGE_KEYS,_=D("packages/core/src/i18n/format.js"),L=_.formatMessage,Z=_.formatList,H=_.lookup,x=_.resolveLocale,U=D("packages/core/src/internal/predicates.js").isFunction,k=D("packages/core/src/internal/warn.js").warnOnce,b=D("packages/core/src/i18n/registry.js"),a=b.registerLocale,h=b.localeCatalogue;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return ne.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return ne.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return _.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return _.resolveLocale}}),Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return b.registerLocale}});const r="en-GB";class t{#e=r;#t=P;constructor(g={}){this.configure(g)}configure(g={}){this.#e=x(g.locale,g.declared,r);const i=g.messages,n=h(this.#e);if(!n&&this.#e.toLowerCase()!=="en-gb"&&(!i||typeof i!="object")&&k(`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.`),!i||typeof i!="object"){this.#t=n?{...P,...n}:P;return}const p=Object.keys(i).filter(l=>!(l in P));p.length&&k(`i18n:unknown:${p[0]}`,`message keys not in the catalogue and so ignored: ${p.slice(0,5).join(", ")}${p.length>5?`, and ${p.length-5} more`:""}`),this.#t={...P,...n||{},...i}}get locale(){return this.#e}t(g,i){return L(H(this.#t,g),i||{},this.#e)}list(g,i){return Z(g,this.#e,i)}number(g,i){const n=Number(g);return Number.isFinite(n)?n.toLocaleString(this.#e,i||{maximumFractionDigits:20}):""}}const o=new t;function u(s){return s instanceof t?s:new t(s||{})}function d(s){const g=s&&typeof s=="object"?s:{},i=Y.filter(f=>{const p=g[f];return p==null||p===""||U(p)}),n=Object.keys(g).filter(f=>!(f in P));return{missing:i,unknown:n}}}),We("packages/core/src/columns/types/structured.js",function(e,D){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return U}}),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 h}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const ne=D("packages/core/src/internal/predicates.js"),P=ne.isNil,Y=ne.isObject,L=D("packages/core/src/i18n/index.js").defaultMessages,Z=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function H(t,o){const u=o||{},d=u.emptyDisplay??Z.emptyDisplay;if(P(t)||t==="")return d;const g=[...typeof u.char=="string"&&u.char!==""?u.char:Z.char][0]||Z.char,i=u.fixedLength??Z.fixedLength,n=Number.isFinite(u.length)&&Number(u.length)>0?Math.floor(Number(u.length)):Z.length,f=typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):null;let p=0;if(f!==null){const l=Number.isFinite(u.lastVisible)?Math.floor(Number(u.lastVisible)):Z.lastVisible,y=[...f];if(p=l>0&&l<y.length?l:0,p>0){const c=y.slice(y.length-p).join(""),m=Math.max(1,(i?n:y.length)-p);return g.repeat(m)+c}return g.repeat(i?n:Math.max(1,y.length))}return g.repeat(n)}const x=48;function X(t){try{const o=JSON.stringify(t);return o===void 0?null:o}catch{return null}}function U(t,o){if(P(t))return"";const u=Number.isFinite(o&&o.inlineLimit)?Number(o.inlineLimit):x;if(typeof t=="string")return t.length>u?`${t.slice(0,u-1)}…`:t;if(typeof t!="object")return String(t);const d=X(t);if(d!==null&&d.length<=u)return d;if(Array.isArray(t)){const g=t.length;return`[${L.t("count.items",{count:g})}]`}const s=Object.keys(t).length;return`{${L.t("count.keys",{count:s})}}`}function j(t,o){if(t==null)return"null";const u=typeof t;if(u==="number"||u==="boolean"||u==="bigint")return String(t);if(u==="string")return JSON.stringify(t);if(u!=="object")return JSON.stringify(String(t));const d=o||new WeakSet;return d.has(t)?'"[circular]"':(d.add(t),t instanceof Date?JSON.stringify(t.toISOString()):Array.isArray(t)?`[${t.map(i=>j(i,d)).join(",")}]`:`{${Object.keys(t).sort().map(i=>`${JSON.stringify(i)}:${j(t[i],d)}`).join(",")}}`)}function k(t,o){if(P(t))return P(o)?0:1;if(P(o))return-1;const u=j(t),d=j(o);return u<d?-1:u>d?1:0}function b(t){if(P(t))return null;const o=String(t);if(o.trim()==="")return null;try{return JSON.parse(o)}catch{return o}}function a(t){const o=t&&t.cell&&t.cell.props;return Y(o)?o:{}}const h=Object.freeze({json:{base:"object",storage:"object",format:t=>U(t&&t.value,a(t&&t.column)),parse:t=>b(t&&t.text),compare:k,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:t=>{if(P(t))return"";if(typeof t=="string")return t;try{const o=JSON.stringify(t,null,2);return o===void 0?String(t):o}catch{return String(t)}},fromClipboard:t=>b(t)},secret:{base:"text",storage:"object",format:t=>H(t&&t.value,a(t&&t.column)),parse:t=>{const o=t&&t.text;return P(o)||String(o)===""?null:String(o)},compare:(t,o)=>{const u=P(t)||t==="",d=P(o)||o==="";return u===d?0:u?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:t=>H(t),fromClipboard:t=>P(t)||String(t)===""?null:String(t)}}),r=h}),We("packages/core/src/columns/types/unit.js",function(e,D){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/internal/warn.js").warnOnce;function L(F,$,W,K){return Object.freeze({symbol:F,factor:$,aliases:Object.freeze(W||[]),binary:!!(K&&K.binary),prefix:K&&K.prefix||null,auto:!(K&&K.auto===!1)})}function Z(F,$,W,K){return L(F,$,W,K)}const H=Object.freeze({data:Object.freeze([L("B",1,["byte","bytes"]),L("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),L("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),L("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),L("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),L("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),L("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),L("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),L("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),L("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([L("bps",1,["bit","bits","bit/s","b/s"]),L("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),L("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),L("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),L("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([L("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),L("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),L("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),L("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),L("in",.0254,["inch","inches"],{auto:!1}),L("ft",.3048,["foot","feet"],{auto:!1}),L("yd",.9144,["yard","yards"],{auto:!1}),L("m",1,["metre","metres","meter","meters"]),L("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),L("mi",1609.344,["mile","miles"],{auto:!1}),L("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([L("mg",.001,["milligram","milligrams"]),L("g",1,["gram","grams"]),L("oz",28.349523125,["ounce","ounces"],{auto:!1}),L("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),L("kg",1e3,["kilogram","kilograms"]),L("st",6350.29318,["stone"],{auto:!1}),L("t",1e6,["tonne","tonnes","ton"],{auto:!1}),L("ton (US)",907184.74,["ton","shortton"],{auto:!1}),L("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([L("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),L("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),L("ms",.001,["msec","msecs","millisecond","milliseconds"]),L("s",1,["sec","secs","second","seconds"]),L("m",60,["min","mins","minute","minutes"]),L("h",3600,["hr","hrs","hour","hours"]),L("d",86400,["day","days"])]),speed:Object.freeze([L("mm/s",.001,["millimetre/s","millimeter/s"]),L("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),L("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),L("mph",.44704,["mile/h","miles/h"],{auto:!1}),L("kn",1852/3600,["knot","knots"],{auto:!1}),L("m/s",1,["metre/s","meter/s","mps"]),L("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([L("mm/s²",.001,["mm/s2"]),L("ft/s²",.3048,["ft/s2"],{auto:!1}),L("m/s²",1,["m/s2","metre/s2","meter/s2"]),L("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([L("mm²",1e-6,["mm2"]),L("cm²",1e-4,["cm2"]),L("in²",64516e-8,["in2","sqin"],{auto:!1}),L("ft²",.09290304,["ft2","sqft"],{auto:!1}),L("yd²",.83612736,["yd2","sqyd"],{auto:!1}),L("m²",1,["m2","sqm"]),L("ha",1e4,["hectare","hectares"],{auto:!1}),L("ac",4046.8564224,["acre","acres"],{auto:!1}),L("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([L("µL",1e-6,["ul","microlitre","microliter"]),L("mL",.001,["millilitre","milliliter"]),L("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),L("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),L("L",1,["litre","litres","liter","liters"]),L("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),L("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),L("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),L("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([L("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),L("J",1,["joule","joules"]),L("cal",4.184,["calorie","calories"],{auto:!1}),L("kJ",1e3,["kilojoule","kilojoules"]),L("BTU",1055.05585262,["btu"],{auto:!1}),L("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),L("MJ",1e6,["megajoule","megajoules"]),L("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),L("GJ",1e9,["gigajoule","gigajoules"]),L("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([L("mW",.001,["milliwatt","milliwatts"]),L("W",1,["watt","watts"]),L("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),L("kW",1e3,["kilowatt","kilowatts"]),L("hp",745.6998715822702,["horsepower"],{auto:!1}),L("MW",1e6,["megawatt","megawatts"]),L("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([L("mN",.001,["millinewton","millinewtons"]),L("N",1,["newton","newtons"]),L("lbf",4.4482216152605,["poundforce"],{auto:!1}),L("kgf",9.80665,["kilogramforce"],{auto:!1}),L("kN",1e3,["kilonewton","kilonewtons"]),L("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([L("Pa",1,["pascal","pascals"]),L("mbar",100,["millibar"],{auto:!1}),L("inH₂O",249.0889,["inh2o"],{auto:!1}),L("mmHg",133.322387415,["torr"],{auto:!1}),L("kPa",1e3,["kilopascal","kilopascals"]),L("inHg",3386.388640341,["inhg"],{auto:!1}),L("psi",6894.757293168361,["lbf/in2"],{auto:!1}),L("bar",1e5,[],{auto:!1}),L("atm",101325,["atmosphere","atmospheres"],{auto:!1}),L("MPa",1e6,["megapascal","megapascals"]),L("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([L("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),L("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),L("kN·m",1e3,["knm","kn.m"],{auto:!1}),L("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([L("kg/m³",1,["kg/m3"]),L("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),L("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),L("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([L("L/min",1/6e4,["lpm","l/min"],{auto:!1}),L("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),L("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),L("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),L("cfm",.0004719474432,["ft3/min"],{auto:!1}),L("L/s",.001,["lps","l/s"],{auto:!1}),L("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([L("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),L("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),L("mrad",.001,["milliradian","milliradians"],{auto:!1}),L("mil",Math.PI/3200,["nato-mil"],{auto:!1}),L("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),L("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),L("rad",1,["radian","radians"]),L("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([L("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),L("rad/s",1,["radps","radians/s"]),L("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),L("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([L("ppt",1e-12,["partspertrillion"],{auto:!1}),L("ppb",1e-9,["partsperbillion"]),L("ppm",1e-6,["partspermillion"]),L("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),L("‰",.001,["permille","permil"],{auto:!1}),L("%",.01,["pct","percent"]),L("×",1,["x","ratio","times"])]),molarity:Object.freeze([L("pM",1e-12,["picomolar","picomolarity"]),L("nM",1e-9,["nanomolar","nanomolarity"]),L("µM",1e-6,["um-molar","micromolar","micromolarity"]),L("mM",.001,["millimolar","millimolarity"]),L("M",1,["molar","mol/l","mol/L","molarity"]),L("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([L("mg/s",1e-6,["milligrams/s"]),L("g/s",.001,["grams/s"]),L("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),L("kg/s",1,["kilograms/s","kgps"]),L("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),L("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),L("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([L("µPa·s",1e-6,["upas","micropascalsecond"]),L("cP",.001,["centipoise"],{auto:!1}),L("mPa·s",.001,["mpas","millipascalsecond"]),L("P",.1,["poise"],{auto:!1}),L("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([L("cSt",1e-6,["centistokes","centistoke"]),L("mm²/s",1e-6,["mm2/s"],{auto:!1}),L("St",1e-4,["stokes","stoke"],{auto:!1}),L("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([L("mW/(m·K)",.001,["mw/mk"]),L("W/(m·K)",1,["w/mk","wmk"]),L("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),L("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([L("J/(kg·K)",1,["j/kgk","jkgk"]),L("kJ/(kg·K)",1e3,["kj/kgk"]),L("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([L("nSv/h",1e-9,["nsvh"]),L("µSv/h",1e-6,["usv/h","usvh"]),L("mSv/h",.001,["msvh"]),L("Sv/h",1,["svh"]),L("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),x=Symbol("ambiguous"),X=new Map,U=new Map;function j(F,$){const W=String(F||"").trim();if(!W)throw new Error("[lattice] a unit system needs a name");if(H[W]||U.has(W))throw new Error(`[lattice] unit system "${W}" already exists`);const K=[...$||[]];if(!K.length)throw new Error(`[lattice] unit system "${W}" has no units`);if(!K.some(B=>B.factor===1))throw new Error(`[lattice] unit system "${W}" has no base unit (none with factor 1)`);const I=new Set;for(const B of K){if(I.has(B.symbol))throw new Error(`[lattice] unit system "${W}" declares "${B.symbol}" twice`);I.add(B.symbol)}return U.set(W,Object.freeze(K)),X.delete(W),W}function k(){return[...Object.keys(H),...U.keys()]}function b(F){const $=a(F);return $?$.units:[]}function a(F){const $=String(F||""),W=X.get($);if(W!==void 0)return W;const K=H[$]||U.get($);if(!K)return X.set($,null),null;const I=Object.freeze([...K].sort((re,ie)=>re.factor-ie.factor)),B=new Map,J=new Map,te=(re,ie)=>{const ue=B.get(re);ue===void 0?B.set(re,ie):ue!==ie&&B.set(re,x)};for(const re of I){te(re.symbol.toLowerCase(),re);for(const ie of re.aliases)te(ie.toLowerCase(),re);if(re.prefix){const ie=J.get(re.prefix)||[];ie.push(re),J.set(re.prefix,ie)}}const Q={units:I,byToken:B,byPrefix:J,decimal:I.filter(re=>!re.binary&&re.auto),binary:I.some(re=>re.binary)?I.filter(re=>(re.binary||re.factor===1)&&re.auto):null};return X.set($,Q),Q}function h(F,$){return $&&F.binary||F.decimal}function r(F,$){const W=a(F);if(!W||P($))return null;const K=W.units.find(B=>B.symbol===String($));if(K)return K;const I=W.byToken.get(String($).trim().toLowerCase());return I&&I!==x?I:null}const t=new WeakMap;function o(F){const $=F||{};if(typeof $=="object"&&$!==null){const B=t.get($);if(B!==void 0)return B}const W=$.system||"data",K=a(W);let I=null;if(!K)_(`unit:system:${W}`,`unknown unit system "${W}"; known systems are ${k().join(", ")}`);else{let B=$.unit?r(W,$.unit):null;B||($.unit&&_(`unit:unit:${W}:${$.unit}`,`unknown unit "${$.unit}" in system "${W}"; falling back to ${K.units[0].symbol}`),B=K.units.find(J=>J.factor===1)||K.units[0]),I={index:K,base:B,binary:$.binary===!0}}return typeof $=="object"&&$!==null&&t.set($,I),I}const u=new WeakMap;function d(F,$){if(!F||!$||!Array.isArray(F.compound)||F.compound.length===0)return null;const W=u.get(F);if(W!==void 0)return W;const K=new Set,I=[];for(const J of F.compound){const te=r(F.system||"data",J);if(!te){_(`unit:compound:${F.system}:${J}`,`unknown compound unit "${J}" in system "${F.system||"data"}"; ignoring it`);continue}K.has(te.symbol)||(K.add(te.symbol),I.push(te))}I.sort((J,te)=>te.factor-J.factor);const B=I.length>=2?I:null;return u.set(F,B),B}function s(F,$,W){return $===W||$.factor===W.factor?F:F*$.factor/W.factor}const g=new Map;function i(F){const $=F||"",W=g.get($);if(W)return W;const K={group:",",decimal:"."};try{for(const I of new Intl.NumberFormat(F||void 0).formatToParts(12345.6))I.type==="group"?K.group=I.value:I.type==="decimal"&&(K.decimal=I.value)}catch{}return g.set($,K),K}const n=/[\s ]/g,f=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,p=/^[^\d+\-(.,\s]+\s*/,l=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function y(F,$){const{group:W,decimal:K}=i($);let I=String(F).replace(n,"");if(I==="")return null;const B=K?I.indexOf(K):-1;if(W&&W!==K){if(B>=0&&I.indexOf(W,B+K.length)>=0)return null;I=I.split(W).join("")}if(K&&K!=="."&&(I=I.split(K).join(".")),!l.test(I))return null;const J=Number(I);return Number.isFinite(J)?J:null}function c(F,$,W){const K=String(F).trim().replace(/\.$/,"");if(K==="")return null;const I=$.units.find(ie=>ie.symbol===K);if(I)return I;const B=K.toLowerCase(),J=$.byToken.get(B);if(J===x)return null;if(J)return J;const te=$.byPrefix.get(B);if(!te||!te.length)return null;const Q=h($,W),re=te.filter(ie=>Q.includes(ie));return re.length===1?re[0]:null}function m(F,$,W,K){let I=F,B=0,J=!1,te=!1;for(;I!=="";){const Q=f.exec(I)[0];if(Q==="")return null;const re=y(Q,K&&K.locale);if(re===null)return null;I=I.slice(Q.length).trim();const ie=I.search(/[+-]?[\d]/),ue=(ie>=0?I.slice(0,ie):I).trim();if(I=ie>=0?I.slice(ie).trim():"",ue===""){if(J)return null;te=!0,B+=s(re,W[0],$.base)}else{const ke=c(ue,$.index,$.binary);if(!ke)return null;B+=s(re,ke,$.base)}if(J=!0,te&&I!=="")return null}return J?B:null}function w(F,$){if(P(F))return null;if(typeof F=="number")return Number.isFinite(F)?F:null;const W=o($);if(!W)return null;let K=String(F).trim();if(K==="")return null;let I=!1;K.startsWith("(")&&K.endsWith(")")&&(I=!0,K=K.slice(1,-1).trim());const B=d($,W);if(B){K.startsWith("-")&&(I=!0,K=K.slice(1).trim());const de=m(K,W,B,$);return de===null?null:I?-de:de}let J=null;const te=p.exec(K);if(te&&te[0]){const de=c(te[0].trim(),W.index,W.binary);de&&(J=de,K=K.slice(te[0].length).trim())}const Q=f.exec(K)[0],re=y(Q,$&&$.locale);if(re===null)return null;const ie=K.slice(Q.length).trim();if(J&&ie!=="")return null;const ue=J||(ie===""?W.base:c(ie,W.index,W.binary));if(!ue)return null;const ke=s(re,ue,W.base);return I?-ke:ke}const v=new Map;function E(F,$,W,K){const I=`${F||""}|${$}|${W}|${K?1:0}`;let B=v.get(I);return B||(B=new Intl.NumberFormat(F||void 0,{minimumFractionDigits:$,maximumFractionDigits:W,useGrouping:K}),v.set(I,B)),B}function V(F,$){if(!Number.isFinite(F)||F===0)return Math.max(0,$-1);const W=Math.floor(Math.log10(Math.abs(F)));return Math.min(20,Math.max(0,$-1-W))}function G(F,$){if(!Number.isFinite(F)||F===0)return F;const W=Math.ceil(Math.log10(Math.abs(F))),K=10**($-W);return Math.round(F*K)/K}function q(F,$,W){if(!W||W===$.base.symbol)return $.base;if(W!=="auto")return M($,W);if(F===0||!Number.isFinite(F))return $.base;const K=Math.abs(F)*$.base.factor,I=h($.index,$.binary);let B=I[0];for(const Q of I)K>=Q.factor&&(B=Q);if(K>=B.factor)return B;let J=B;for(const Q of $.index.units)Q.binary!==$.binary&&Q.factor!==1||Q.factor<=K&&Q.factor>(J===B?0:J.factor)&&(J=Q);if(J!==B)return J;let te=B;for(const Q of $.index.units)Q.binary!==$.binary&&Q.factor!==1||Q.factor<te.factor&&(te=Q);return te.factor<$.base.factor?te:$.base}function M(F,$){const W=F.index.units.find(I=>I.symbol===$);if(W)return W;const K=F.index.byToken.get(String($).toLowerCase());return K&&K!==x?K:(_(`unit:display:${$}`,`unknown display unit "${$}"; rendering in ${F.base.symbol}`),F.base)}function O(F,$,W,K){const I=F<0;let B=Math.abs(F)*$.base.factor;const J=typeof K.decimals=="number"?K.decimals:K.minDecimals??0,te=typeof K.decimals=="number"?K.decimals:K.maxDecimals??Math.max(J,2),Q=K.space??" ",re=[];for(let ue=0;ue<W.length;ue++){const ke=W[ue],de=ue===W.length-1;let we=de?B/ke.factor:Math.floor(B/ke.factor);if(B-=we*ke.factor,de){const De=10**te;we=Math.round(we*De)/De+0}const ve=de?E(K.locale,J,te,K.group!==!1):E(K.locale,0,0,K.group!==!1);re.push(`${ve.format(we)}${Q}${ke.symbol}`)}const ie=re.join(" ");return I?`-${ie}`:ie}function T(F,$){const W=$||{},K=W.nullDisplay??"";if(P(F)||F==="")return K;const I=typeof F=="number"?F:Number(F);if(!Number.isFinite(I))return K;const B=o(W);if(!B)return String(I);const J=d(W,B);if(J)return O(I,B,J,W);const te=typeof W.significantFigures=="number"&&W.significantFigures>0?W.significantFigures:0,Q=te?G(I,te):I,re=q(Q,B,W.display),ie=s(Q,B.base,re);let ue=typeof W.decimals=="number"?W.decimals:W.minDecimals??0,ke=typeof W.decimals=="number"?W.decimals:W.maxDecimals??Math.max(ue,2);te&&(ue=V(ie,te),ke=ue);const de=E(W.locale,ue,ke,W.group!==!1).format(ie),we=W.space??" ";return W.placement==="prefix"?`${re.symbol}${W.space??""}${de}`:`${de}${we}${re.symbol}`}function A(F,$){const W=P(F)||Number.isNaN(F)?null:Number(F),K=P($)||Number.isNaN($)?null:Number($);return W===null||Number.isNaN(W)?K===null||Number.isNaN(K)?0:1:K===null||Number.isNaN(K)||W<K?-1:W>K?1:0}function N(F){const $=typeof F.decimals=="number"&&F.decimals>0?`.${"0".repeat(F.decimals)}`:"";return`${typeof F.decimals=="number"?`#,##0${$}`:"#,##0.##"}" ${F.symbol}"`}function C(F){const $={system:"data",...F||{}},W=o($),K=W?W.base.symbol:String($.unit||""),I=Object.freeze({...$,unit:K}),B=Object.freeze({...I,display:K,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[I.locale||"",I]]),te=Q=>{const re=Q||"";let ie=J.get(re);return ie||(ie=Object.freeze({...I,locale:Q||void 0}),J.set(re,ie)),ie};return{base:"number",extends:"number",storage:"float64",unitConfig:I,format:Q=>T(Q.value,Q.locale?te(Q.locale):I),parse:Q=>w(Q.text,Q.locale?te(Q.locale):I),compare:A,defaults:{filter:"number",editor:"unit",align:"end",total:$.total||"sum"},...$.totals?{totals:$.totals}:{},excel:$.excel||N({decimals:$.decimals,symbol:K}),toStorage:Q=>typeof Q=="number"?Number.isFinite(Q)?Q:null:typeof Q=="string"?w(Q,I):P(Q)?null:w(String(Q),I),toClipboard:Q=>T(Q,B),fromClipboard:Q=>w(Q,I)}}const S=C}),We("packages/core/src/columns/types/engineering.js",function(e,D){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return L}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/columns/types/unit.js").createUnitType;function L(x){const X=2*Math.PI/x;return U=>{let j=0,k=0,b=0;for(const h of U||[]){if(P(h))continue;const r=Number(h);Number.isFinite(r)&&(j+=Math.cos(r*X),k+=Math.sin(r*X),b+=1)}return!b||Math.hypot(j,k)/b<1e-12?null:(Math.atan2(k,j)/X%x+x)%x}}function Z(x){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:L(x)}}}const H=Object.freeze({metres:_({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:_({system:"length",unit:"mm",maxDecimals:2}),kilometres:_({system:"length",unit:"km",maxDecimals:3}),grams:_({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:_({system:"mass",unit:"kg",maxDecimals:3}),tonnes:_({system:"mass",unit:"t",maxDecimals:3}),seconds:_({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:_({system:"duration",unit:"ms",maxDecimals:3}),hours:_({system:"duration",unit:"h",maxDecimals:2}),speed:_({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:_({system:"speed",unit:"km/h",maxDecimals:1}),mph:_({system:"speed",unit:"mph",maxDecimals:1}),knots:_({system:"speed",unit:"kn",maxDecimals:1}),acceleration:_({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:_({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:_({system:"area",unit:"ha",maxDecimals:4}),volume:_({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:_({system:"volume",unit:"m³",maxDecimals:3}),energy:_({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:_({system:"energy",unit:"kWh",maxDecimals:2}),power:_({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:_({system:"power",unit:"kW",maxDecimals:2}),force:_({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:_({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:_({system:"pressure",unit:"bar",maxDecimals:3}),psi:_({system:"pressure",unit:"psi",maxDecimals:1}),torque:_({system:"torque",unit:"N·m",maxDecimals:2}),density:_({system:"density",unit:"kg/m³",maxDecimals:2}),flow:_({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:_({system:"flow",unit:"L/min",maxDecimals:1}),radians:_({system:"angle",unit:"rad",maxDecimals:4,totals:Z(2*Math.PI)}),degrees:_({system:"angle",unit:"°",maxDecimals:2,totals:Z(360)}),rpm:_({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:_({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:_({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:_({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:_({system:"fraction",unit:"bp",maxDecimals:1}),molarity:_({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:_({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:_({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:_({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:_({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:_({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:_({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:_({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),We("packages/core/src/columns/types/si.js",function(e,D){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return j}});const ne=D("packages/core/src/columns/types/unit.js"),P=ne.defineUnit,Y=ne.registerUnitSystem,_=ne.createUnitType,L=Object.freeze([Object.freeze({symbol:"f",name:"femto",factor:1e-15}),Object.freeze({symbol:"p",name:"pico",factor:1e-12}),Object.freeze({symbol:"n",name:"nano",factor:1e-9}),Object.freeze({symbol:"µ",name:"micro",factor:1e-6}),Object.freeze({symbol:"m",name:"milli",factor:.001}),Object.freeze({symbol:"c",name:"centi",factor:.01}),Object.freeze({symbol:"",name:"",factor:1}),Object.freeze({symbol:"k",name:"kilo",factor:1e3}),Object.freeze({symbol:"M",name:"mega",factor:1e6}),Object.freeze({symbol:"G",name:"giga",factor:1e9}),Object.freeze({symbol:"T",name:"tera",factor:1e12}),Object.freeze({symbol:"P",name:"peta",factor:1e15})]),Z=Object.freeze(["p","n","µ","m","","k","M","G"]);function H(k){const b=String(k.base),a=new Set([...k.prefixes||Z,""]),h=[];for(const r of L){if(!a.has(r.symbol))continue;const t=`${r.symbol}${b}`,o=[];if(k.name){o.push(`${r.name}${k.name}`,`${r.name}${k.name}s`);const u=r.name.slice(-1);if(u&&k.name.startsWith(u)){const d=`${r.name.slice(0,-1)}${k.name}`;o.push(d,`${d}s`)}}r.symbol==="µ"&&o.push(`u${b}`),r.factor===1&&k.aliases&&o.push(...k.aliases),h.push(P(t,r.factor,o))}for(const r of k.extra||[])h.push(r);return h}function x(k,b){const a=H(b);return Y(k,a)}function X(k,b,a){return x(k,b),_({system:k,unit:b.base,display:"auto",maxDecimals:3,...a||{}})}const U=Object.freeze({voltage:X("voltage",{base:"V",name:"volt"}),current:X("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:X("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:X("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:X("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:X("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[P("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),P("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:X("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:X("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[P("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:X("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:X("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:X("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:X("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:X("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:X("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:X("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[P("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:X("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),j=X}),We("packages/core/src/columns/types/temperature.js",function(e,D){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return L}}),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 k}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const P=D("packages/core/src/internal/predicates.js").isNil,Y=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:h=>h+273.15,fromKelvin:h=>h-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:h=>(h+459.67)*(5/9),fromKelvin:h=>h*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:h=>h,fromKelvin:h=>h}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:h=>h*(5/9),fromKelvin:h=>h*(9/5)})});function _(h){if(P(h))return null;const r=String(h).trim();if(r==="")return null;for(const[o,u]of Object.entries(Y))if(r===o||r===u.symbol)return{key:o,scale:u};const t=r.toLowerCase();for(const[o,u]of Object.entries(Y))if(u.aliases.includes(t))return{key:o,scale:u};return null}function L(h,r,t){const o=_(r),u=_(t);return!o||!u||!Number.isFinite(Number(h))?null:o.key===u.key?Number(h):u.scale.fromKelvin(o.scale.toKelvin(Number(h)))}const Z=new Map;function H(h,r,t){const o=`${h||""}|${r}|${t}`;let u=Z.get(o);return u||(u=new Intl.NumberFormat(h||void 0,{minimumFractionDigits:r,maximumFractionDigits:t}),Z.set(o,u)),u}function x(h,r){const t=r||{},o=t.nullDisplay??"";if(P(h)||h==="")return o;const u=Number(h);if(!Number.isFinite(u))return o;const d=_(t.scale||"C");if(!d)return String(u);const s=_(t.display||t.scale||"C")||d,g=s.key===d.key?u:s.scale.fromKelvin(d.scale.toKelvin(u)),i=typeof t.decimals=="number"?t.decimals:null,n=i??t.minDecimals??0,f=i??t.maxDecimals??1;return`${H(t.locale,n,f).format(g)}${t.space??" "}${s.scale.symbol}`}const X=/^[+-]?[\d\s., ]*\d/;function U(h,r){const t=String(h).trim();if(t==="")return null;const o=new Intl.NumberFormat(r||void 0).formatToParts(1.1).find(g=>g.type==="decimal")?.value||".",u=o===","?".":",",d=t.split(u).join("").split(/[\s ]/).join("").replace(o,"."),s=Number(d);return Number.isFinite(s)?s:null}function j(h,r){if(P(h))return null;const t=r||{},o=_(t.scale||"C");if(!o)return null;if(typeof h=="number")return Number.isFinite(h)?h:null;let u=String(h).trim();if(u==="")return null;let d=!1;u.startsWith("(")&&u.endsWith(")")&&(d=!0,u=u.slice(1,-1).trim());const s=X.exec(u);if(!s)return null;const g=U(s[0],t.locale);if(g===null)return null;const i=u.slice(s[0].length).trim();if(i==="")return d?-g:g;const n=_(i);if(!n)return null;const f=n.key===o.key?g:o.scale.fromKelvin(n.scale.toKelvin(g));return d?-f:f}function k(h){const r=Object.freeze({scale:"C",...h||{}}),o=(_(r.scale)||_("C")).scale.symbol,u=Object.freeze({...r,display:r.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),d=new Map([[r.locale||"",r]]),s=g=>{const i=g||"";let n=d.get(i);return n||(n=Object.freeze({...r,locale:g||void 0}),d.set(i,n)),n};return{base:"number",extends:"number",storage:"float64",temperatureConfig:r,format:g=>x(g.value,g.locale?s(g.locale):r),parse:g=>j(g.text,g.locale?s(g.locale):r),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:r.excel||`#,##0${typeof r.decimals=="number"&&r.decimals>0?`.${"0".repeat(r.decimals)}`:".#"}" ${o}"`,toStorage:g=>typeof g=="number"?Number.isFinite(g)?g:null:typeof g=="string"?j(g,r):P(g)?null:j(String(g),r),toClipboard:g=>x(g,u),fromClipboard:g=>j(g,r)}}const b=Object.freeze({celsius:k({scale:"C"}),fahrenheit:k({scale:"F"}),kelvin:k({scale:"K"})}),a=k}),We("packages/core/src/columns/types/radix.js",function(e,D){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/internal/warn.js").warnOnce,L=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),Z=Object.freeze({2:1,8:3,16:4}),H=Object.freeze({2:"0b",8:"0o",16:"0x"}),x=Object.freeze({2:4,8:3,16:2}),X=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),U=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),j=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),k=/[\s\u00a0\u202f_,']/g,b=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,a=Object.freeze([8,16,32,53]),h=new WeakSet,r=new WeakMap,t=new Map,o=new WeakMap,u=new WeakMap,d=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 s(T){if(T==null)return 16;const A=typeof T=="string"?T.toLowerCase():T,N=L[A];return N||(_(`radix:base:${String(T)}`,`unsupported radix ${String(T)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function g(T,A){return Math.ceil(T/Z[A])}function i(T,A){if(!T)return A?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!A)return{min:0,max:2**T-1};const N=2**(T-1);return{min:-N,max:N-1}}function n(T){return U[T]||"hexadecimal"}function f(T){if(typeof T=="string"){const A=d[T];return A||_(`radix:preset:${T}`,`unknown radix preset "${T}"; known presets are ${Object.keys(d).join(", ")}`),{...A||{}}}if(T&&typeof T.preset=="string"){const A=d[T.preset];return A||_(`radix:preset:${T.preset}`,`unknown radix preset "${T.preset}"; known presets are ${Object.keys(d).join(", ")}`),{...A||{},...T}}return T||{}}function p(T){const A=f(T),N=s(A.radix),C=Z[N];let S=null;if(A.bitWidth!==void 0&&A.bitWidth!==null&&A.bitWidth!==!1){const Q=Number(A.bitWidth);a.includes(Q)?S=Q:_(`radix:width:${String(A.bitWidth)}`,`unsupported bitWidth ${String(A.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let F=A.signed!==!1;!F&&S===null&&(_("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),S=32);const $=A.prefix===void 0||A.prefix===!0?H[N]:A.prefix===!1?"":String(A.prefix);let W=0;A.pad===!0?W=S?g(S,N):0:typeof A.pad=="number"&&A.pad>0&&(W=Math.floor(A.pad));let K=0;A.group===!0?K=x[N]:typeof A.group=="number"&&A.group>0&&(K=Math.floor(A.group));const I=i(S,F),B=typeof A.min=="number"?Math.max(I.min,A.min):I.min,J=typeof A.max=="number"?Math.min(I.max,A.max):I.max,te=Object.freeze({radix:N,bits:C,prefix:$,uppercase:A.uppercase!==!1,pad:W,group:K,groupSeparator:typeof A.groupSeparator=="string"?A.groupSeparator:" ",bitWidth:S,signed:F,min:B,max:J<B?B:J,nullDisplay:typeof A.nullDisplay=="string"?A.nullDisplay:"",name:n(N)});return h.add(te),te}function l(T){if(T&&h.has(T))return T;if(typeof T=="string"){let A=t.get(T);return A||(A=p(T),t.set(T,A)),A}if(T&&typeof T=="object"){let A=r.get(T);return A||(A=p(T),r.set(T,A)),A}return l("hex")}function y(T){return T<0?-Math.round(-T):Math.round(T)}function c(T,A,N){if(A<=0||T.length<=A)return T;const C=T.length%A||A,S=[T.slice(0,C)];for(let F=C;F<T.length;F+=A)S.push(T.slice(F,F+A));return S.join(N)}function m(T){const A=l(T),{radix:N,prefix:C,uppercase:S,pad:F,group:$,groupSeparator:W,signed:K,bitWidth:I,nullDisplay:B}=A,J=I?2**I:0,te=Q=>{if(P(Q)||Q==="")return B;const re=typeof Q=="number"?Q:Number(Q);if(!Number.isFinite(re))return B;const ie=y(re);let ue="",ke=ie;ie<0&&(K?(ue="-",ke=-ie):ke=(ie%J+J)%J);let de=ke.toString(N);return de=S?de.toUpperCase():de.toLowerCase(),F>0&&de.length<F&&(de=de.padStart(F,"0")),$>0&&(de=c(de,$,W)),ue+C+de};return te.options=A,te}function w(T,A){const N=l(A);let C=o.get(N);return C||(C=m(N),o.set(N,C)),C(T)}function v(T){const A=l(T),{radix:N,groupSeparator:C,signed:S,min:F,max:$}=A,W=X[N],K=I=>{if(P(I))return{ok:!0,value:null,reason:"blank"};let B=String(I);if(C&&C!==""&&(B=B.split(C).join("")),B=B.replace(k,""),B==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((B[0]==="-"||B[0]==="+")&&(J=B[0]==="-",B=B.slice(1)),B==="")return{ok:!1,value:null,reason:"digits"};let te=null;for(const[re,ie]of j){const ue=re.exec(B);if(!ue)continue;const ke=B.slice(ue[0].length);if(ke==="")break;if(!X[ie].test(ke))return{ok:!1,value:null,reason:"digits"};te=parseInt(ke,ie);break}if(te===null)if(W.test(B))te=parseInt(B,N);else if(b.test(B))te=Number(B);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(te))return{ok:!1,value:null,reason:"digits"};const Q=y(J?-te:te);return!S&&Q<0?{ok:!1,value:Q,reason:"negative"}:Q<F||Q>$?{ok:!1,value:Q,reason:"range"}:{ok:!0,value:Q,reason:"ok"}};return K.options=A,K}function E(T,A){const N=l(A);let C=u.get(N);return C||(C=v(N),u.set(N,C)),C(T)}function V(T,A){const N=E(T,A);return N.ok?N.value:null}function G(T,A){const N=P(T)||Number.isNaN(T)?null:Number(T),C=P(A)||Number.isNaN(A)?null:Number(A);return N===null?C===null?0:1:C===null||N<C?-1:N>C?1:0}function q(T){const A=T.min>=-2147483648&&T.max<=2147483647;return T.bitWidth&&A?"int32":"float64"}function M(T){const A=p(T),N=m(A),C=v(A);return{base:"number",extends:"number",storage:q(A),matches:null,format:S=>N(S.value),parse:S=>{const F=C(S.text);return F.ok?F.value:null},compare:G,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:S=>N(S),fromClipboard:S=>{const F=C(S);return F.ok?F.value:null},radix:A,formatValue:N,parseText:C}}const O=M}),We("packages/core/src/columns/types/aggregable.js",function(e,D){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return L}});const P=D("packages/core/src/internal/predicates.js").isNil;function Y(U){const j=[];for(const k of U||[]){if(P(k))continue;const b=Number(k);Number.isFinite(b)&&j.push(b)}return j}function _(U){return j=>{const k=Y(j);if(!k.length)return null;let b=0;for(const a of k)b+=10**(a/U);return U*Math.log10(b)}}function L(U){return j=>{const k=Y(j);if(!k.length)return null;let b=0;for(const a of k)b+=10**(a/U);return U*Math.log10(b/k.length)}}function Z(U,j){const k=j&&j.column,a=(k&&k.typeOptions||{}).weight,h=j&&j.valueAt;if(!a||typeof h!="function")return null;let r=0,t=0;for(let o=0;o<U.length;o++){if(P(U[o]))continue;const u=Number(U[o]);if(!Number.isFinite(u))continue;const d=h(a,o);if(P(d))continue;const s=Number(d);!Number.isFinite(s)||s<=0||(r+=u*s,t+=s)}return t===0?null:r/t}function H(U={}){const j=U.factor===20?20:10,k=typeof U.suffix=="string"?U.suffix:"",b=Number.isInteger(U.decimals)?U.decimals:1;return{base:"number",storage:"float64",name:U.name||"logarithmic",format:a=>{const h=a&&a.value;return P(h)||!Number.isFinite(Number(h))?"":`${Number(h).toFixed(b)}${k}`},parse:a=>{const h=String((a&&a.text)??"").replace(k,"").trim();if(!h)return null;const r=Number(h);return Number.isFinite(r)?r:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:_(j),avg:L(j)}}}}function x(U={}){const j=Number.isInteger(U.decimals)?U.decimals:1,k=U.percent===!0;return{base:"number",storage:"float64",name:U.name||"ratio",format:b=>{const a=b&&b.value;return P(a)||!Number.isFinite(Number(a))?"":k?`${Number(a).toFixed(j)}%`:Number(a).toFixed(j)},parse:b=>{const a=String((b&&b.text)??"").replace("%","").trim();if(!a)return null;const h=Number(a);return Number.isFinite(h)?h:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:Z}}}}const X=Object.freeze({decibel:H({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:H({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:x({name:"ratio"}),percentRate:x({name:"percentRate",percent:!0})})}),We("packages/core/src/columns/types/currency.js",function(e,D){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const P=D("packages/core/src/internal/predicates.js").isNil,Y="⚠ no rate";function _(g){if(P(g))return null;const i=String(g).trim().toUpperCase();return i===""?null:i}function L(g){if(P(g))return null;if(typeof g=="object"&&!Array.isArray(g)){const i=Number(g.amount),n=_(g.code);return!n||!Number.isFinite(i)?null:{amount:i,code:n}}if(Array.isArray(g)&&g.length===2){const i=Number(g[0]),n=_(g[1]);return!n||!Number.isFinite(i)?null:{amount:i,code:n}}return null}const Z=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),H=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),x=/[+-]?[\d\s., ]*\d/;function X(g,i){const n=String(g).trim();if(n==="")return null;const f=new Intl.NumberFormat(i||void 0).formatToParts(1.1).find(c=>c.type==="decimal")?.value||".",p=f===","?".":",",l=n.split(p).join("").split(/[\s ]/).join("").replace(f,"."),y=Number(l);return Number.isFinite(y)?y:null}function U(g,i){const n=i||{},f=_(n.code);if(P(g))return null;const p=L(g);if(p)return p;if(typeof g=="number")return Number.isFinite(g)&&f?{amount:g,code:f}:null;let l=String(g).trim();if(l==="")return null;let y=!1;l.startsWith("(")&&l.endsWith(")")&&(y=!0,l=l.slice(1,-1).trim());let c=null;for(const[G,q]of Object.entries(Z)){if(l.startsWith(G)){c=q,l=l.slice(G.length).trim();break}if(l.endsWith(G)){c=q,l=l.slice(0,-G.length).trim();break}}const m=x.exec(l);if(!m)return null;const w=X(m[0],n.locale);if(w===null)return null;const v=(l.slice(0,m.index)+" "+l.slice(m.index+m[0].length)).trim();!c&&v!==""&&(c=_(v));const E=c||f;return E?{amount:y?-w:w,code:E}:null}function j(g,i){if(typeof g=="function")return(n,f)=>{if(n===f)return 1;const p=g(n,f);return typeof p=="number"&&Number.isFinite(p)&&p>0?p:null};if(g&&typeof g=="object"){const n=g;return(f,p)=>{if(f===p)return 1;const l=Number(n[f]),y=Number(n[p]);return!Number.isFinite(l)||!Number.isFinite(y)||l<=0||y<=0?null:y/l}}return(n,f)=>n===f?1:null}function k(g,i,n){if(!g)return null;if(g.code===i)return g.amount;const f=n(g.code,i);return f===null?null:g.amount*f}const b=new Map;function a(g,i,n){const f=`${g||""}|${i}|${n??""}`;let p=b.get(f);if(!p){const l={style:"currency",currency:i};typeof n=="number"&&(l.minimumFractionDigits=n,l.maximumFractionDigits=n);try{p={fmt:new Intl.NumberFormat(g||void 0,l),currency:!0}}catch{p={fmt:new Intl.NumberFormat(g||void 0,typeof n=="number"?{minimumFractionDigits:n,maximumFractionDigits:n}:{}),currency:!1}}b.set(f,p)}return p}function h(g,i){const n=i||{},f=n.nullDisplay??"",p=L(g);if(!p)return f;const l=_(n.display)||p.code;let y=p.amount,c=p.code;if(l!==p.code){const v=n.rateFn||j(n.rates,n.rateBase),E=k(p,l,v);if(E===null)return`${n.missingRate??Y} ${p.code}→${l}`;y=E,c=l}const{fmt:m,currency:w}=a(n.locale,c,n.decimals);return w?m.format(y):`${m.format(y)} ${c}`}function r(g){const i=L(g);return i?`${i.amount} ${i.code}`:""}function t(g){const i=g||{},n=_(i.display),f=i.rateFn||j(i.rates,i.rateBase);return(p,l)=>{const y=L(p),c=L(l);if(!y&&!c)return 0;if(!y)return 1;if(!c)return-1;if(n){const m=k(y,n,f),w=k(c,n,f);if(m!==null&&w!==null)return m===w?0:m<w?-1:1}return y.code===c.code?y.amount===c.amount?0:y.amount<c.amount?-1:1:y.code<c.code?-1:1}}function o(g){const i=g||{},n=(p,l)=>{const y=[];for(const E of p||[]){const V=L(E);V&&y.push(V)}if(!y.length)return null;if(new Set(y.map(E=>E.code)).size===1){const E=y[0].code;return{amount:l(y.map(V=>V.amount)),code:E}}const m=_(i.display);if(!m)return`${i.missingRate??Y}: mixed currencies, no display currency set`;const w=i.rateFn||j(i.rates,i.rateBase),v=[];for(const E of y){const V=k(E,m,w);if(V===null)return`${i.missingRate??Y}: ${E.code}→${m}`;v.push(V)}return{amount:l(v),code:m}},f=p=>p.reduce((l,y)=>l+y,0);return{sum:p=>n(p,f),avg:p=>n(p,l=>f(l)/l.length),min:p=>n(p,l=>Math.min(...l)),max:p=>n(p,l=>Math.max(...l))}}function u(g){const i=Object.freeze({code:"USD",...g||{}}),n=j(i.rates,i.rateBase),f=Object.freeze({...i,rateFn:n}),p=o(f),l=t(f),y=new Map([[i.locale||"",f]]),c=v=>{const E=v||"";let V=y.get(E);return V||(V=Object.freeze({...f,locale:v||void 0}),y.set(E,V)),V},m=H[_(i.display||i.code)]||"",w=typeof i.decimals=="number"&&i.decimals>0?`.${"0".repeat(i.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:f,format:v=>h(v.value,v.locale?c(v.locale):f),parse:v=>U(v.text,v.locale?c(v.locale):f),compare:l,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:p},excel:i.excel||(m?`"${m}"#,##0${w}`:`#,##0${w}`),toStorage:v=>{const E=L(v);return E||(typeof v=="string"||typeof v=="number"?U(v,f):null)},toClipboard:v=>r(v),fromClipboard:v=>U(v,f)}}const d=Object.freeze({currency:u({code:"USD"}),usd:u({code:"USD"}),eur:u({code:"EUR"}),gbp:u({code:"GBP"}),jpy:u({code:"JPY",decimals:0})}),s=u}),We("packages/core/src/columns/types/index.js",function(e,D){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return G}});const ne=D("packages/core/src/columns/types/temporal.js"),P=ne.TEMPORAL_TYPES,Y=D("packages/core/src/columns/types/network.js"),_=Y.NETWORK_TYPES,L=D("packages/core/src/columns/types/structured.js"),Z=L.STRUCTURED_TYPES,H=D("packages/core/src/columns/types/unit.js"),x=H.createUnitType,X=H.UNIT_SYSTEMS,U=H.parseUnit,j=H.formatUnit,k=H.registerUnitSystem,b=H.unitSystemNames,a=H.unitsOf,h=H.defineUnit,r=D("packages/core/src/columns/types/engineering.js"),t=r.ENGINEERING_TYPES,o=D("packages/core/src/columns/types/si.js"),u=o.SI_TYPES,d=o.createSiType,s=o.createSiSystem,g=o.siUnits,i=o.SI_PREFIXES,n=D("packages/core/src/columns/types/temperature.js"),f=n.TEMPERATURE_TYPES,p=n.createTemperatureType,l=n.convertTemperature,y=n.formatTemperature,c=n.parseTemperature,m=n.TEMPERATURE_SCALES,w=D("packages/core/src/columns/types/radix.js"),v=w.createRadixType,E=w.RADIX_PRESETS,V=w.parseRadix,G=w.formatRadix,q=D("packages/core/src/columns/types/aggregable.js"),M=q.AGGREGABLE_TYPES,O=D("packages/core/src/columns/types/currency.js"),T=O.CURRENCY_TYPES,A=O.createCurrencyType,N=O.parseMoney,C=O.formatMoney,S=O.convertMoney,F=O.toMoney,$=O.rateFunction,W=O.moneyComparator,K=O.normaliseCode,I=O.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return H.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return r.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return r.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return n.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return n.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return n.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return n.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return n.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return n.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return n.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return O.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return O.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return O.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return O.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return O.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return O.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return O.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return O.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return O.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return O.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return ne.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return Y.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return L.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return q.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return q.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return q.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return ne.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return ne.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return ne.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return ne.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ne.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ne.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return Y.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return Y.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return Y.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return Y.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return Y.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return Y.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return Y.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return Y.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return Y.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return Y.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return Y.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return L.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return L.summariseJson}});const B=Object.freeze({...P,..._,...Z,...M,hex:v(E.hex),hex8:v(E.hex8),hex16:v(E.hex16),hex32:v(E.hex32),binary:v(E.binary),binary8:v(E.binary8),octal:v(E.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"}),...t,...u,...f,...T});{const J=new Set;for(const te of[P,_,Z,M,t,u,f,T])for(const Q of Object.keys(te)){if(J.has(Q))throw new Error(`[lattice] data type "${Q}" is declared twice`);J.add(Q)}}}),We("packages/core/src/compute/handle.js",function(e,D){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return u}});const ne=D("packages/core/src/internal/compare.js"),P=ne.collator,Y=ne.defaultCompare,L=D("packages/core/src/internal/warn.js").warnOnce;function Z(d){const s=new Uint32Array(d);for(let g=0;g<d;g++)s[g]=g;return s}function H(d,s){if(s&&typeof s.count=="number")return s.count;if(!d)return 0;if(typeof d.count=="number")return d.count;if(typeof d.length=="number")return d.length;const g=d.values;return d.kind==="multi"&&d.offsets?Math.max(0,d.offsets.length-1):g?d.kind==="bitset"?typeof g.size=="number"?g.size:d.presence&&typeof d.presence.size=="number"?d.presence.size:(L(`count:${d.id}`,`column "${d.id}" is bitset-backed with no declared row count; assuming ${g.length*8}`),g.length*8):g.length:d.presence&&typeof d.presence.size=="number"?d.presence.size:0}const x=new WeakMap;function X(d){const s=d.constructor;if(!s)return"unknown";const g=x.get(s);if(g)return g;let i="unknown";try{let n=null;typeof s.from=="function"?n=s.from([!1,!0]):(n=new s(8),n.set(1));const f=n&&n.words;f&&f.length&&(f[0]===2?i="lsb":f[0]===64&&(i="msb"))}catch{i="unknown"}return x.set(s,i),i}function U(d){if(!d)return()=>0;const s=d instanceof Uint8Array?d:d.words;if(s instanceof Uint8Array){const g=d instanceof Uint8Array?"lsb":X(d);if(g==="lsb")return i=>s[i>>>3]>>>(i&7)&1;if(g==="msb")return i=>s[i>>>3]>>>7-(i&7)&1}return typeof d.get=="function"?g=>d.get(g)?1:0:()=>0}function j(d){return!d||!d.presence?null:U(d.presence)}function k(d){return d?typeof d.size=="number"?d.size:typeof d.values=="function"?d.values().length:0:0}function b(d,s){return d?typeof d.valueOf=="function"?d.valueOf(s):typeof d.values=="function"?d.values()[s]:null:null}function a(d,s){const g=d.offsets,i=d.values;if(!g||!i)return[];const n=g[s],f=g[s+1];if(!(f>n))return[];const p=d.dict,l=new Array(f-n);for(let y=n;y<f;y++)l[y-n]=p?b(p,i[y]):i[y];return l}function h(d){if(!d)return()=>{};const s=d.values,g=j(d),i=d.kind;if(i==="dictionary"){const n=d.dict;return g?f=>g(f)?b(n,s[f]):null:f=>b(n,s[f])}if(i==="bitset"){const n=U(s);return g?f=>g(f)?n(f)===1:null:f=>n(f)===1}if(i==="multi")return g?n=>g(n)?a(d,n):null:n=>a(d,n);if(!s&&typeof d.get=="function"){const n=d.get.bind(d);return f=>{const p=n(f);return p===void 0?null:p}}return g?n=>{if(!g(n))return null;const f=s[n];return f===void 0?null:f}:n=>{const f=s[n];return f===void 0?null:f}}function r(d,s){if(d<s)return-1;if(d>s)return 1;if(d===s){const n=Object.is(d,-0),f=Object.is(s,-0);return n===f?0:n?-1:1}const g=Number.isNaN(d),i=Number.isNaN(s);return g&&i?0:g?1:-1}function t(d){const s=P(d);return(g,i)=>{if(g===i)return 0;const n=typeof g,f=typeof i;if(n==="string"&&f==="string")return s.compare(g,i);if(n==="number"&&f==="number")return r(g,i);if(n==="boolean"&&f==="boolean")return g===i?0:g?1:-1;if(g instanceof Date||i instanceof Date){const p=g instanceof Date?g.getTime():Number(g),l=i instanceof Date?i.getTime():Number(i);return r(p,l)}return Y(g,i)}}function o(d,s){if(d&&typeof d.ranks=="function")return d.ranks(s);const g=d&&typeof d.values=="function"?d.values():[],i=g.length,n=t(s),f=new Array(i);for(let l=0;l<i;l++)f[l]=l;f.sort((l,y)=>n(g[l],g[y])||l-y);const p=new Uint32Array(i);for(let l=0;l<i;l++)p[f[l]]=l;return p}function u(d){return d==null||typeof d=="number"&&Number.isNaN(d)}}),We("packages/core/src/compute/filter.js",function(e,D){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return ke}});const P=D("packages/core/src/internal/predicates.js").isBlank,_=D("packages/core/src/internal/merge.js").toArray,Z=D("packages/core/src/internal/warn.js").warnOnce,H=D("packages/core/src/format/date.js"),x=H.toDate,X=H.toIsoDate,U=D("packages/core/src/compute/handle.js"),j=U.bitReader,k=U.dictSize,b=U.dictValue,a=U.presenceReader,h=U.valueComparator,r=U.valueReader,t=/^\d{4}-\d{2}-\d{2}$/,o="\0null\0";function u(de,we){const ve=de&&de.pool;if(ve){const De=ve.mask||ve.acquireMask||ve.acquire||ve.take;if(typeof De=="function"){const pe=De.call(ve,we);if(pe&&pe.length>=we)return pe}}return new Uint8Array(we)}function d(de,we){const ve=de&&de.pool;if(!ve||!we)return;const De=ve.release||ve.releaseMask||ve.free||ve.recycle;typeof De=="function"&&De.call(ve,we)}function s(de,we,ve){return de.fill(ve,0,we),de}function g(de){return de==null||typeof de=="number"&&Number.isNaN(de)}function i(de,we){if(de==null)return de;if(we==="number")return typeof de=="number"?de:Number(de);if(we==="date"||we==="dateString"){const ve=X(de);return ve===null?n(de):ve}return we==="boolean"?typeof de=="boolean"?de:de==="true"||de===1?!0:de==="false"||de===0?!1:!!de:de}function n(de){return de instanceof Date?de.getTime():typeof de=="number"?de:Date.parse(String(de))}function f(de){return typeof de=="number"?de:de instanceof Date?de.getTime():de==null||de===""?NaN:Number(de)}function p(de,we){const ve=typeof de=="string"?de:String(de);return we?ve:ve.toLowerCase()}function l(de,we){return de==null?o:typeof de=="string"?we?de:de.toLowerCase():de instanceof Date?de.getTime():de}function y(de,we,ve){const De=new Set;for(const pe of _(de)){const oe=i(pe,ve);De.add(l(oe,we)),typeof oe=="string"&&oe!==""&&Number.isFinite(Number(oe))?De.add(Number(oe)):typeof oe=="number"&&Number.isFinite(oe)&&De.add(l(String(oe),we))}return De}function c(de,we,ve){if(de==null||we===null||we===void 0)return de==null&&we==null;const De=typeof de,pe=typeof we;return De==="string"&&pe==="string"?ve?de===we:de.toLowerCase()===we.toLowerCase():de instanceof Date||we instanceof Date?n(de)===n(we):De==="number"&&pe==="number"?de===we||Number.isNaN(de)&&Number.isNaN(we):De==="number"&&pe==="string"?de===Number(we):De==="string"&&pe==="number"?Number(de)===we:De==="boolean"||pe==="boolean"?de===we:Array.isArray(de)&&Array.isArray(we)?de.length===we.length&&de.every((oe,be)=>c(oe,we[be],ve)):de===we}function m(de,we){try{if(de instanceof RegExp){const ve=de.flags.replace(/[gy]/g,"");return new RegExp(de.source,we||ve.includes("i")?ve:`${ve}i`)}return new RegExp(String(de),we?"":"i")}catch(ve){return Z(`regex:${String(de)}`,`filter operator "matches" received an invalid pattern: ${String(de)}`,ve),null}}function w(de,we){if(de&&de.type==="datetime"&&v.has(de.op))return M(de,we);const ve=O(de,we),De=de&&de.type;return De!=="date"&&De!=="dateString"?ve:pe=>ve(typeof pe=="string"&&t.test(pe)?pe:X(pe)??pe)}const v=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),E=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,V=new Map;function G(de,we){let ve=V.get(we);if(ve===void 0){try{ve=new Intl.DateTimeFormat("en-CA",{timeZone:we,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{ve=null}V.set(we,ve)}if(!ve)return null;const De={};for(const pe of ve.formatToParts(de))pe.type!=="literal"&&(De[pe.type]=pe.value);return De}function q(de,we){if(de==null||de==="")return null;if(typeof de=="string"){const oe=E.exec(de.trim());if(oe)return Date.UTC(+oe[1],+oe[2]-1,+oe[3],+(oe[4]||0),+(oe[5]||0),+(oe[6]||0),+(oe[7]||"0").padEnd(3,"0"))}const ve=x(de);if(!ve)return null;const De=ve.getUTCMilliseconds(),pe=we?G(ve,we):null;return pe?Date.UTC(+pe.year,+pe.month-1,+pe.day,pe.hour==="24"?0:+pe.hour,+pe.minute,+pe.second,De):Date.UTC(ve.getFullYear(),ve.getMonth(),ve.getDate(),ve.getHours(),ve.getMinutes(),ve.getSeconds(),De)}function M(de,we){const ve=typeof de.timeZone=="string"&&de.timeZone?de.timeZone:void 0,De=be=>q(be,ve),pe=Array.isArray(de.value)?de.value.map(De):De(de.value),oe=O({...de,type:"number",value:pe},we);return be=>oe(q(be))}function O(de,we){const ve=de&&de.op,De=!!(de&&de.caseSensitive),pe=de&&de.type,oe=h(we),be=fe=>le=>!fe(le);switch(ve){case"eq":{const fe=i(de.value,pe);return le=>c(le,fe,De)}case"ne":{const fe=i(de.value,pe);return le=>!c(le,fe,De)}case"lt":case"lte":case"gt":case"gte":{const fe=i(de.value,pe);if(g(fe))return()=>!1;const le=ve==="lt"?-1:ve==="lte"?0:ve==="gt"?1:2;return ye=>{if(g(ye))return!1;const Ne=oe(ye,fe);return le===-1?Ne<0:le===0?Ne<=0:le===1?Ne>0:Ne>=0}}case"between":case"notBetween":{const fe=_(de.value),le=i(fe[0],pe),ye=i(fe[1],pe),Ne=de.bounds||"[]",je=Ne.charAt(0)!=="(",$e=Ne.charAt(1)!==")";if(g(le)||g(ye))return ve==="between"?()=>!1:()=>!0;const Re=Se=>{if(g(Se))return!1;const Ve=oe(Se,le),Fe=oe(Se,ye);return(je?Ve>=0:Ve>0)&&($e?Fe<=0:Fe<0)};return ve==="between"?Re:be(Re)}case"in":case"notIn":{const fe=y(de.value,De,pe),le=ye=>fe.has(l(ye,De));return ve==="in"?le:be(le)}case"contains":case"notContains":{const fe=p(i(de.value,pe),De),le=ye=>ye==null?!1:p(ye,De).includes(fe);return ve==="contains"?le:be(le)}case"startsWith":{const fe=p(i(de.value,pe),De);return le=>le==null?!1:p(le,De).startsWith(fe)}case"endsWith":{const fe=p(i(de.value,pe),De);return le=>le==null?!1:p(le,De).endsWith(fe)}case"matches":{const fe=m(de.value,De);return fe?le=>le==null?!1:fe.test(String(le)):()=>!1}case"blank":case"notBlank":{const fe=de.trim===!0,le=ye=>P(ye)||Array.isArray(ye)&&ye.length===0||fe&&typeof ye=="string"&&ye.trim()==="";return ve==="blank"?le:ye=>!le(ye)}case"containsAny":case"containsNone":{const fe=y(de.value,De,pe),le=ye=>{const Ne=ye==null?[]:_(ye);for(let je=0;je<Ne.length;je++)if(fe.has(l(Ne[je],De)))return!0;return!1};return ve==="containsAny"?le:be(le)}case"containsAll":{const fe=_(de.value).map(le=>l(i(le,pe),De));return le=>{const ye=le==null?[]:_(le);if(fe.length===0)return!0;const Ne=new Set(ye.map(je=>l(je,De)));for(let je=0;je<fe.length;je++)if(!Ne.has(fe[je]))return!1;return!0}}default:{const fe=ke(ve);return fe?fe.compile(de.value):(Z(`op:${String(ve)}`,`unknown filter operator "${String(ve)}"; the condition is refused rather than matching every row`),()=>!1)}}}function T(de,we,ve){return w(we,ve)(de)}const A=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),N=new Set(["containsAny","containsAll","containsNone"]);function C(de,we,ve){const De=de&&de.op,pe=A[De]||De,oe=w({...de,op:pe,type:we.type},ve),be=we.items,fe=le=>{const ye=be(le);if(!ye)return!1;for(let Ne=0;Ne<ye.length;Ne++)if(oe(ye[Ne]))return!0;return!1};return A[De]?le=>!fe(le):fe}function S(de,we,ve,De,pe){const oe=pe?null:a(de);if(oe){const le=we?1:0;for(let ye=0;ye<De;ye++)ve[ye]=oe(ye)===le?1:0;return ve}const be=de.kind;if(be==="float64"||be==="int32"||be==="bitset")return s(ve,De,we?1:0);const fe=r(de);for(let le=0;le<De;le++){const ye=fe(le),Ne=P(ye)||Array.isArray(ye)&&ye.length===0||pe&&typeof ye=="string"&&ye.trim()==="";ve[le]=Ne===we?0:1}return ve}function F(de,we,ve,De){const pe=de.dict,oe=k(pe),be=new Uint8Array(oe);for(let Ne=0;Ne<oe;Ne++)be[Ne]=we(b(pe,Ne))?1:0;const fe=de.values,le=a(de);if(!le){for(let Ne=0;Ne<De;Ne++)ve[Ne]=be[fe[Ne]];return ve}const ye=we(null)?1:0;for(let Ne=0;Ne<De;Ne++)ve[Ne]=le(Ne)===1?be[fe[Ne]]:ye;return ve}function $(de,we,ve,De){const pe=j(de.values),oe=we(!0)?1:0,be=we(!1)?1:0,fe=a(de);if(!fe){for(let ye=0;ye<De;ye++)ve[ye]=pe(ye)===1?oe:be;return ve}const le=we(null)?1:0;for(let ye=0;ye<De;ye++)ve[ye]=fe(ye)===0?le:pe(ye)===1?oe:be;return ve}function W(de,we,ve,De,pe){const oe=de.values,be=we.type,fe=we.op;let le=!0;switch(fe){case"eq":case"ne":{const Ne=f(i(we.value,be)),je=typeof we.value=="number"&&Number.isNaN(we.value),$e=fe==="ne"?1:0;if(je)for(let Re=0;Re<pe;Re++)De[Re]=(Number.isNaN(oe[Re])?1:0)^$e;else for(let Re=0;Re<pe;Re++)De[Re]=(oe[Re]===Ne?1:0)^$e;break}case"lt":{const Ne=f(i(we.value,be));for(let je=0;je<pe;je++)De[je]=oe[je]<Ne?1:0;break}case"lte":{const Ne=f(i(we.value,be));for(let je=0;je<pe;je++)De[je]=oe[je]<=Ne?1:0;break}case"gt":{const Ne=f(i(we.value,be));for(let je=0;je<pe;je++)De[je]=oe[je]>Ne?1:0;break}case"gte":{const Ne=f(i(we.value,be));for(let je=0;je<pe;je++)De[je]=oe[je]>=Ne?1:0;break}case"between":case"notBetween":{const Ne=_(we.value),je=f(i(Ne[0],be)),$e=f(i(Ne[1],be)),Re=we.bounds||"[]",Se=Re.charAt(0)!=="(",Ve=Re.charAt(1)!==")",Fe=fe==="notBetween"?1:0;if(Se&&Ve)for(let Ce=0;Ce<pe;Ce++)De[Ce]=(oe[Ce]>=je&oe[Ce]<=$e?1:0)^Fe;else if(Se)for(let Ce=0;Ce<pe;Ce++)De[Ce]=(oe[Ce]>=je&oe[Ce]<$e?1:0)^Fe;else if(Ve)for(let Ce=0;Ce<pe;Ce++)De[Ce]=(oe[Ce]>je&oe[Ce]<=$e?1:0)^Fe;else for(let Ce=0;Ce<pe;Ce++)De[Ce]=(oe[Ce]>je&oe[Ce]<$e?1:0)^Fe;break}case"in":case"notIn":{const Ne=new Set;for(const $e of _(we.value)){const Re=f(i($e,be));Number.isNaN(Re)||Ne.add(Re)}const je=fe==="notIn"?1:0;for(let $e=0;$e<pe;$e++)De[$e]=(Ne.has(oe[$e])?1:0)^je;break}default:le=!1;break}if(!le)return!1;const ye=a(de);if(ye){const Ne=ve(null)?1:0;for(let je=0;je<pe;je++)ye(je)===0&&(De[je]=Ne)}return!0}function K(de,we,ve,De){const pe=r(de);for(let oe=0;oe<De;oe++)ve[oe]=we(pe(oe))?1:0;return ve}function I(de,we,ve){const De=we.count|0,pe=ve||u(we,De);if(!de)return s(pe,De,1);const oe=typeof we.handle=="function"?we.handle(de.col):void 0,be=typeof we.custom=="function"?we.custom:null;if(!oe){if(be){for(let Ne=0;Ne<De;Ne++)pe[Ne]=be(de,Ne)?1:0;return pe}return Z(`filter:col:${String(de.col)}`,`filter references unknown column "${String(de.col)}"; the condition is refused rather than matching every row`),s(pe,De,0)}const fe=de.op;if(fe==="blank"||fe==="notBlank")return S(oe,fe==="notBlank",pe,De,de.trim===!0);const le=typeof we.itemwise=="function"?we.itemwise(de.col):null;if(le&&!ke(fe)&&!N.has(fe))return K(oe,C(de,le,we.locale),pe,De);const ye=w(de,we.locale);switch(oe.kind){case"dictionary":return F(oe,ye,pe,De);case"bitset":return $(oe,ye,pe,De);case"float64":case"int32":return W(oe,de,ye,pe,De)?pe:K(oe,ye,pe,De);default:return K(oe,ye,pe,De)}}function B(de,we,ve){if(!de)return s(u(we,ve),ve,1);if(Array.isArray(de.conditions)){const De=de.conditions.filter(be=>be!=null),pe=de.op==="or"?"or":de.op==="not"?"not":"and";if(De.length===0)return s(u(we,ve),ve,1);const oe=B(De[0],we,ve);for(let be=1;be<De.length;be++){const fe=B(De[be],we,ve);if(pe==="or")for(let le=0;le<ve;le++)oe[le]|=fe[le];else for(let le=0;le<ve;le++)oe[le]&=fe[le];d(we,fe)}if(pe==="not")for(let be=0;be<ve;be++)oe[be]^=1;return oe}return I(de,we,u(we,ve))}function J(de,we){return B(de,we,we.count|0)}function te(de,we){if(!de||!we)return de||null;const ve=de;if(Array.isArray(ve.conditions)){if((ve.op==="or"?"or":ve.op==="not"?"not":"and")!=="and")return Q(ve,we)?null:de;const pe=[];for(const oe of ve.conditions){const be=te(oe,we);be&&pe.push(be)}return pe.length?{...ve,op:"and",conditions:pe}:null}return ve.col===we?null:de}function Q(de,we){if(!de||typeof de!="object")return!1;const ve=de;if(ve.col===we)return!0;if(Array.isArray(ve.conditions)){for(const De of ve.conditions)if(Q(De,we))return!0}return!1}function re(de,we,ve){if(ve&&ve.length>=we){let be=0;for(let fe=0;fe<we;fe++)de[fe]&&(ve[be++]=fe);return ve.subarray(0,be)}let De=0;for(let be=0;be<we;be++)De+=de[be]?1:0;const pe=new Uint32Array(De);let oe=0;for(let be=0;be<we;be++)de[be]&&(pe[oe++]=be);return pe}const ie=new Map;function ue(de){if(!(!de||typeof de!="object"))for(const[we,ve]of Object.entries(de))ve&&typeof ve.compile=="function"&&ie.set(we,ve)}function ke(de){return typeof de=="string"?ie.get(de):void 0}}),We("packages/core/src/columns/datatypes.js",function(e,D){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return C}});const ne=D("packages/core/src/internal/compare.js"),P=ne.collator,Y=ne.defaultCompare,_=D("packages/core/src/internal/predicates.js"),L=_.isNil,Z=_.isObject,H=_.isFunction,X=D("packages/core/src/internal/warn.js").fail,j=D("packages/core/src/internal/text.js").titleCase,k=D("packages/core/src/format/date.js"),b=k.toDate,a=k.toIsoDate,h=k.compareIso,t=D("packages/core/src/format/boolean.js").toTriState,u=D("packages/core/src/columns/types/index.js").EXTENDED_TYPES,d=D("packages/core/src/formula/index.js"),s=d.evaluateFormula,g=d.looksLikeFormula,n=D("packages/core/src/compute/filter.js").declareOperators,f=/^\d{4}-\d{2}-\d{2}$/;function p(S){return S.getHours()===0&&S.getMinutes()===0&&S.getSeconds()===0&&S.getMilliseconds()===0}const l=new Map;function y(S){const F=S||"",$=l.get(F);if($)return $;const W={group:",",decimal:"."};try{for(const K of new Intl.NumberFormat(S||void 0).formatToParts(12345.6))K.type==="group"?W.group=K.value:K.type==="decimal"&&(W.decimal=K.value)}catch{}return l.set(F,W),W}const c=/\d\s*[*/^]\s*[\d.(]/;function m(S,F){if(L(S))return null;let $=String(S).trim();if($===""||$.startsWith("=")||c.test($))return null;let W=1;$.startsWith("(")&&$.endsWith(")")&&(W=-1,$=$.slice(1,-1));const K=$.endsWith("%"),{group:I,decimal:B}=y(F);if($=$.replace(/[\s\u00a0\u202f\u2009']/g,""),I&&I!=="."&&I!==","&&($=$.split(I).join("")),$=$.replace(/[^0-9eE+\-.,]/g,""),B===","?$=$.split(".").join("").replace(",","."):$=$.split(",").join(""),$===""||$==="-"||$==="+")return null;const J=Number($);return Number.isNaN(J)?null:W*(K?J/100:J)}function w(S,F){const $=L(S)||Number.isNaN(S)?null:Number(S),W=L(F)||Number.isNaN(F)?null:Number(F);return $===null?W===null?0:1:W===null||$<W?-1:$>W?1:0}function v(S,F){const $=t(S),W=t(F);return $===null?W===null?0:1:W===null?-1:$===W?0:$?1:-1}function E(S,F){const $=b(S),W=b(F);if(!$)return W?1:0;if(!W)return-1;const K=$.getTime(),I=W.getTime();return K<I?-1:K>I?1:0}const V=new Map;function G(S){const F=b(S.value);if(!F)return"";const $=S.locale||"";let W=V.get($);return W||(W=new Intl.DateTimeFormat(S.locale||void 0,{dateStyle:"medium"}),V.set($,W)),W.format(F)}const q={boolean:{base:"boolean",storage:"bitset",matches:S=>typeof S=="boolean",parse:S=>t(S.text),compare:v,format:S=>t(S.value)===null?"":t(S.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:S=>t(S)===null?"":String(t(S)),fromClipboard:S=>t(S)},number:{base:"number",storage:"float64",matches:S=>typeof S=="number"&&!Number.isNaN(S),parse:S=>{if(g(S.text)){const F=s(S.text,S);if(!F.ok)return null;const $=Number(F.value);return Number.isFinite($)?$:null}return m(S.text,S.locale)},compare:w,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:S=>L(S)?"":String(S),fromClipboard:(S,F)=>m(S,F&&F.locale)},date:{base:"dateString",storage:"dictionary",matches:S=>typeof S=="string"&&f.test(S)&&!Number.isNaN(Date.parse(S))||S instanceof Date&&!Number.isNaN(S.getTime())&&p(S),parse:S=>a(S.text),compare:h,format:G,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:S=>a(S),toClipboard:S=>L(S)?"":String(S),fromClipboard:S=>a(S)},dateString:{base:"dateString",storage:"dictionary",matches:S=>typeof S=="string"&&f.test(S)&&!Number.isNaN(Date.parse(S)),parse:S=>a(S.text),compare:h,format:G,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:S=>a(S),toClipboard:S=>L(S)?"":String(S),fromClipboard:S=>a(S)},text:{base:"text",storage:"dictionary",matches:S=>typeof S=="string",parse:S=>S.text===""?null:String(S.text),compare:(S,F)=>L(S)?L(F)?0:1:L(F)?-1:P().compare(String(S),String(F)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:S=>L(S)?"":String(S),fromClipboard:S=>S},image:{base:"text",storage:"dictionary",parse:S=>S.text===""||S.text==null?null:String(S.text).trim(),compare:(S,F)=>L(S)?L(F)?0:1:L(F)?-1:P().compare(String(S),String(F)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:S=>L(S)?"":String(S),fromClipboard:S=>S},lookup:{base:"text",storage:"dictionary",parse:S=>{if(S.text===""||S.text==null)return null;const F=S.column&&S.column.lookup,$=F&&H(F.options)?F.options():null;if(!$)return S.text;const W=String(S.text),K=$.find(J=>String(J.id)===W);if(K)return K.id;const I=W.trim().toLowerCase(),B=$.find(J=>String(J.label).toLowerCase()===I);return B?B.id:S.text},compare:Y,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:S=>L(S)?"":String(S),fromClipboard:S=>S},object:{base:"object",storage:"object",matches:S=>S!==null&&typeof S=="object"&&!(S instanceof Date),parse:S=>{try{return S.text===""?null:JSON.parse(S.text)}catch{return S.text}},compare:(S,F)=>Y(S,F),format:S=>{const F=S.value;if(L(F))return"";if(typeof F=="string")return F;try{return JSON.stringify(F)}catch{return String(F)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:S=>L(S)?"":typeof S=="string"?S:JSON.stringify(S),fromClipboard:S=>S}},M=["boolean","number","date","dateString","datetime","text","object"];function O(S,F,$,W){const K=$.get(S);if(K)return K;W.includes(S)&&X(`circular data type extends chain: ${[...W,S].join(" → ")}`);const I=F[S];I||X(`unknown data type "${S}"`);let B=null;I.extends&&(B=O(I.extends,F,$,[...W,S]));const J={...B||{},...I,name:S,defaults:{...B&&B.defaults||{},...I.defaults||{}}};return J.base||(J.base=B&&B.base||"text"),J.storage||(J.storage=B&&B.storage||"object"),$.set(S,J),J}function T(S,F){const $={...q,...u};if(F&&typeof F.dataType=="function"&&typeof F.names=="function")for(const K of F.names("dataType")){const I=F.dataType(K);I&&($[K]=I)}if(Z(S))for(const[K,I]of Object.entries(S))$[K]=I;const W=new Map;for(const K of M)O(K,$,W,[]);O("lookup",$,W,[]);for(const K of Object.keys($))O(K,$,W,[]);for(const K of W.values())n(K.operators);return W}function A(S,F){if(S.base==="text"&&(!S.compare||S.compare===q.text.compare)){const $=P(F);return(W,K)=>L(W)?L(K)?0:1:L(K)?-1:$.compare(String(W),String(K))}return S.compare||Y}function N(S,F){return F?S.multiStorage||"multi":S.storage||"object"}function C(S){return j(String(S).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),We("packages/core/src/columns/infer.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return H}});const P=D("packages/core/src/internal/warn.js").infoOnce,_=D("packages/core/src/internal/predicates.js").isNil,L=100;function Z(x,X,U={}){const j=U.sampleSize??L,k=[];for(let b=0;b<x.length&&k.length<j;b++){const a=x[b];_(a)||typeof a=="number"&&Number.isNaN(a)||k.push(a)}if(k.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[b,a]of X){if(typeof a.matches!="function")continue;let h=!0;for(let r=0;r<k.length;r++)if(!a.matches(k[r])){h=!1;break}if(h)return{type:b,unanimous:!0,sampled:k.length}}return U.quiet||P(`infer:${U.colId||"?"}`,`column "${U.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:k.length}}function H(x,X,U,j,k={}){const b=k.sampleSize??L,a=[];for(let h=0;h<X.length&&a.length<b;h++){const r=U(X[h]);_(r)||typeof r=="number"&&Number.isNaN(r)||a.push(r)}return Z(a,j,{...k,colId:x}).type}}),We("packages/core/src/columns/graph.js",function(e,D){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return j}});const ne=D("packages/core/src/internal/warn.js"),P=ne.DEV,Y=ne.fail,_=ne.warnOnce,Z=D("packages/core/src/internal/predicates.js").isFunction,H="*";function x(k){const b=k.value||{};if(!Z(b.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const h=b.pure!==!1;return b.deps===H?{computed:!0,wholeRow:!0,deps:[],pure:h}:Array.isArray(b.deps)?{computed:!0,wholeRow:!1,deps:b.deps.slice(),pure:h}:(_(`deps:missing:${k.id}`,`computed column "${k.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:h})}function X(k){const b=new Map;for(const f of k)b.set(f.id,f);const a=new Map,h=new Map,r=new Set,t=new Set,o=new Set,u=new Set;for(const f of k){const p=x(f);if(!p.computed){a.set(f.id,[]);continue}t.add(f.id),(p.pure?o:u).add(f.id),p.wholeRow&&r.add(f.id);const l=[],y=[];for(const c of p.deps)(b.has(c)?l:y).push(c);a.set(f.id,l),y.length&&h.set(f.id,y)}for(const f of o)for(const p of a.get(f))u.has(p)&&Y(`pure computed column "${f}" depends on impure column "${p}". Mark it \`value.pure: false\` or make the dependency pure.`);const d=[],s=new Map,g=[],i=f=>{const p=s.get(f);if(p!=="done"){if(p==="open"){const l=g.indexOf(f);Y(`circular column dependency: ${[...g.slice(l),f].join(" → ")}`)}s.set(f,"open"),g.push(f);for(const l of a.get(f)||[])b.has(l)&&i(l);g.pop(),s.set(f,"done"),d.push(f)}};for(const f of k)i(f.id);const n=new Map;for(const f of k)n.set(f.id,[]);for(const f of k)for(const p of a.get(f.id)||[]){const l=n.get(p);l&&!l.includes(f.id)&&l.push(f.id)}if(r.size)for(const f of k){if(t.has(f.id))continue;const p=n.get(f.id);for(const l of r)p.includes(l)||p.push(l)}return{order:d,dependents:n,pure:o,impure:u,computed:t,deps:a,wholeRow:r,external:h,index:b}}function U(k,b){const a=Array.isArray(b)?b:[b],h=new Set,r=[...a];for(;r.length;){const t=r.shift();for(const o of k.dependents.get(t)||[])h.has(o)||(h.add(o),r.push(o))}for(const t of a)h.delete(t);return k.order.filter(t=>h.has(t))}function j(k,b,a){if(!P)return k;const h=b instanceof Set?b:new Set(b);return new Proxy(k,{get(r,t){return typeof t=="string"&&!h.has(t)&&!Object.hasOwn(r,t)&&_(`undeclared:${a}:${t}`,`computed column "${a}" read undeclared dependency "${t}". Add it to \`value.deps\` or the value will go stale.`),r[t]}})}}),We("packages/core/src/model/rowkey.js",function(e,D){"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 k}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return t}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/internal/paths.js").pathGetter,L=D("packages/core/src/internal/predicates.js"),Z=L.isFunction,H=L.isBlank,x=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],X="";function U(o){if(o===null)return"\0n";if(o===void 0)return"\0u";const u=typeof o;if(u==="string")return o;if(u==="number"||u==="bigint"||u==="boolean")return String(o);if(o instanceof Date)return`\0d${o.getTime()}`;try{return`\0o${JSON.stringify(o)}`}catch{return"\0o?"}}function j(o){if(o.length===1)return U(o[0]);let u="";for(let d=0;d<o.length;d++)d&&(u+=X),u+=U(o[d]);return u}function k(o,u={}){const d=u.warn!==!1;if(Z(o)){const s=o;return{stable:!0,fields:[],disabled:[],key(g,i){try{const n=s(g);return Array.isArray(n)?j(n):U(n)}catch(n){return P("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",n),`#${i??-1}`}},keyEmpty(g){try{const i=s(g);return Array.isArray(i)?i.length===0||i.some(H):H(i)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(o)&&o.length>0){const s=o.filter(n=>typeof n=="string"),g=s.map(n=>_(n)),i=g.length;return{stable:!0,fields:s,disabled:[],key(n){const f=new Array(i);for(let p=0;p<i;p++)f[p]=g[p](n);return j(f)},keyEmpty(n){for(let f=0;f<i;f++)if(H(g[f](n)))return!0;return!1},missingFields(n){const f=[];for(let p=0;p<i;p++)H(g[p](n))&&f.push(s[p]);return f}}}if(typeof o=="string"&&o.length>0){const s=_(o);return{stable:!0,fields:[o],disabled:[],key(g){return U(s(g))},keyEmpty(g){return H(s(g))},missingFields(g){return H(s(g))?[o]:[]}}}return d&&P("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(s,g){if(s===null||typeof s!="object")return`#${g??0}:${String(s)}`;let i=b.get(s);return i===void 0&&(i=`#${a++}`,b.set(s,i)),i}}}const b=new WeakMap;let a=0;function h(o,u){if(!o||o.stable===!1||!Z(o.keyEmpty)||!Array.isArray(u)||u.length===0)return;let d=0,s=null,g;for(let p=0;p<u.length;p++){const l=u[p];o.keyEmpty(l)&&(d++,s===null&&(s=Z(o.missingFields)?o.missingFields(l):[],g=l))}if(d===0)return;const i=o.fields.length?o.fields.join(","):"(function)",n=s&&s.length?s.join(", "):o.fields.length?o.fields.join(", "):"the rowKey function",f=g!==null&&typeof g=="object"?Object.keys(g).join(", ")||"(no fields)":String(g);P(`rowKey.emptyValue:${i}`,`rowKey ${n} is missing on ${d} of ${u.length} rows; the first such row has: ${f}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function r(o){return j(o)}function t(o){return o.split(X)}}),We("packages/core/src/columns/lookup.js",function(e,D){"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 a}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return o}});const ne=D("packages/core/src/internal/compare.js"),P=ne.collator,Y=ne.defaultCompare,_=D("packages/core/src/internal/predicates.js"),L=_.isFunction,Z=_.isNil,x=D("packages/core/src/internal/warn.js").warnOnce,U=D("packages/core/src/model/rowkey.js").compositeKey,j=", ",k="";function b(u,d,s,g){if(u===null||typeof u!="object")return{id:u,label:u==null?"":String(u)};const i=u[d],n=u[s],f={id:i,label:n==null?String(i??""):String(n)};u.disabled&&(f.disabled=!0),u.variant&&(f.variant=u.variant),u.icon&&(f.icon=u.icon);const p=g?u[g]:u.group;return p!==void 0&&(f.group=p),f}function a(u,d,s=0,g=[],i=[]){for(const n of u||[]){const f=n&&typeof n=="object"?n[d]:null;if(i.push({raw:n,depth:s,path:g}),Array.isArray(f)&&f.length){const p=String(n&&typeof n=="object"?n.label??n.name??n.id??"":n);a(f,d,s+1,[...g,p],i)}}return i}function h(u){return!!u&&typeof u=="object"&&!Array.isArray(u)&&L(u.router&&u.router.subscribe)}class r{#e;#t;#n;#r;#s=[];#i=new Map;#o=new Map;#l=0;#a="idle";#c=null;#u;#d=null;#f=new Map;constructor(d,s={}){this.#e=d||{},this.#t=s.colId||"?",this.#n=s.locale,this.#r=s.onChange||null,this.#u=P(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.#s}setLocale(d){this.#n=d,this.#u=P(d)}#h(d){const s=this.#e,g=s.valueKey||"id",i=s.labelKey||"label",n=s.childrenKey||"children";this.#s=a(d,n).map(f=>{const p=b(f.raw,g,i,s.groupKey);return f.depth&&(p.depth=f.depth,p.path=f.path),p}),this.#i=new Map,this.#o=new Map,this.#s.forEach((f,p)=>{this.#i.set(f.id,f),this.#o.set(f.id,p)}),this.#a="ready",this.#l+=1}load(){if(this.#c)return this.#c;const d=this.#e.options;if(Array.isArray(d)||d===void 0)return this.#c=Promise.resolve(this.#s),this.#c;if(h(d))return this.#c=this.#p(d),this.#c;if(!L(d))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 s;try{s=d()}catch(g){return this.#a="error",x(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,g),this.#c=Promise.resolve([]),this.#c}return!s||!L(s.then)?(this.#h(s),this.#c=Promise.resolve(this.#s),this.#r&&this.#r(this),this.#c):(this.#c=s.then(g=>(this.#h(g),this.#r&&this.#r(this),this.#s),g=>(this.#a="error",x(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,g),[])),this.#c)}refresh(){return this.#c=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#s)):this.load()}#p(d){if(this.#d)return Promise.resolve(this.#s);const s=this.#e,g=s.valueKey||"id",i=s.labelKey||"label",n=s.groupKey,f=L(d.map)?d.map:null,p=y=>b(f?f(y):y,g,i,n).id,l=y=>this.#m(y,f,g,i,n);return d.router.subscribe(d.predicate,l,{rowKey:p}),this.#d=()=>{L(d.router.detach)&&d.router.detach(l)},this.#a="ready",Promise.resolve(this.#s)}#m(d,s,g,i,n){const f=d&&d.add||[],p=d&&d.update||[],l=d&&d.remove||[];if(!(!f.length&&!p.length&&!l.length)){for(const y of f)this.#g(y,s,g,i,n);for(const y of p)this.#g(y,s,g,i,n);for(const y of l){if(!this.#f.has(y))continue;const c=this.#f.get(y);this.#f.delete(y),this.#i.delete(c);const m=this.#s.findIndex(w=>w.id===c);m>=0&&this.#s.splice(m,1)}this.#o=new Map(this.#s.map((y,c)=>[y.id,c])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(d,s,g,i,n){const f=b(s?s(d):d,g,i,n);this.#f.set(U([f.id]),f.id);const p=this.#s.findIndex(l=>l.id===f.id);p>=0?this.#s[p]=f:this.#s.push(f),this.#i.set(f.id,f)}destroy(){this.#d&&(this.#d(),this.#d=null)}search(d,s){const g=this.#e;if(!L(g.search)){const f=String(d||"").toLowerCase();return Promise.resolve(f===""?this.#s:this.#s.filter(p=>p.label.toLowerCase().includes(f)))}const i=g.valueKey||"id",n=g.labelKey||"label";return Promise.resolve(g.search(d,s)).then(f=>(f||[]).map(p=>b(p,i,n,g.groupKey)))}option(d){return this.#i.get(d)}has(d){return this.#i.has(d)}label(d){if(Z(d)||d==="")return"";const s=this.#i.get(d);if(s)return s.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||x(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(d)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const g=this.#e.unknownLabel;return L(g)?String(g(d)??""):typeof g=="string"?g:String(d)}text(d){if(this.multiple){const s=t(d);return s.length===0?"":s.map(g=>this.label(g)).join(this.separator)}return this.label(d)}dictionary(){return this.#s.map(d=>d.id)}sorted(){const d=this.sortBy;if(d==="optionOrder"||d==="count")return this.#s.slice();if(d==="value")return this.#s.slice().sort((g,i)=>Y(g.id,i.id));const s=this.#u;return this.#s.slice().sort((g,i)=>s.compare(g.label,i.label))}comparator(){const d=this.sortBy,s=this.multiple,g=this.#u,i=this.#o;if(s&&d==="count")return(f,p)=>t(f).length-t(p).length;const n=s?f=>t(f)[0]:f=>f;return d==="value"?(f,p)=>Y(n(f),n(p)):d==="optionOrder"?(f,p)=>{const l=i.has(n(f))?i.get(n(f)):Number.MAX_SAFE_INTEGER,y=i.has(n(p))?i.get(n(p)):Number.MAX_SAFE_INTEGER;return l-y}:(f,p)=>{const l=n(f),y=n(p);return Z(l)?Z(y)?0:1:Z(y)?-1:g.compare(this.label(l),this.label(y))}}groupKey(d){return this.multiple?t(d).map(g=>String(g)).sort().join(k):Z(d)?"":String(d)}countValues(d){return this.multiple?t(d).length:Z(d)?0:1}contains(d,s,g){const i=this.multiple?t(d):Z(d)?[]:[d],n=Array.isArray(s)?s:[s];switch(g){case"containsAll":return n.every(f=>i.includes(f));case"containsNone":return!n.some(f=>i.includes(f));default:return n.some(f=>i.includes(f))}}exportText(d,s="label"){return s==="value"?this.multiple?t(d).join(this.separator):Z(d)?"":String(d):this.text(d)}exportColumns(){const d=this.multiple;return this.#s.map(s=>({id:s.id,label:s.label,has:g=>d?t(g).includes(s.id):g===s.id}))}}function t(u){return Array.isArray(u)?u:Z(u)||u===""?[]:[u]}function o(u,d={}){const s=u.lookup;if(!s)return null;const g=new r(s,{colId:u.id,locale:d.locale,onChange:d.onChange});return!Array.isArray(s.options)&&s.options!==void 0&&g.load(),g}}),We("packages/core/src/columns/value.js",function(e,D){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return u}});const P=D("packages/core/src/internal/paths.js").getPath,Y=D("packages/core/src/internal/predicates.js"),_=Y.isFunction,L=Y.isNil,Z=Y.isObject,x=D("packages/core/src/internal/lru.js").Lru,U=D("packages/core/src/internal/warn.js").warnOnce,k=D("packages/core/src/format/number.js").compileNumber,a=D("packages/core/src/columns/graph.js").depsProxy,h="\0";function r(i,n={}){const f=n.locale,p=n.grid??null,l=n.context,y=i.value&&i.value.format,c=i.formatter||null,m=i.dataType&&i.dataType.format,w=i.lookup||null,v=(E,V,G)=>({value:E,data:G,row:V,column:i,colId:i.id,grid:p,context:l,locale:f});if(_(y))return(E,V,G)=>{const q=y(v(E,V,G));return q==null?"":String(q)};if(c){if(w){const E=c.kind==="text";return(V,G,q)=>c(E?w.text(V):V,v(V,G,q))}return(E,V,G)=>c(E,v(E,V,G))}if(_(m))return(E,V,G)=>{const q=m(v(E,V,G));return q==null?"":String(q)};if(i.dataType&&i.dataType.base==="number"&&Z(i.typeOptions)&&typeof i.typeOptions.decimals=="number"){const E=k({decimals:i.typeOptions.decimals},f);return V=>E(V)}return w?E=>w.text(E):E=>L(E)?"":typeof E=="string"?E:String(E)}function t(i,n){!i||!i.value||i.value.pure!==!1||U(`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 o{#e;#t;#n;#r;#s;#i;#o=new x(4096);constructor(n){this.#e=n.columns instanceof Map?n.columns:new Map((n.columns||[]).map(f=>[f.id,f])),this.#t=n.graph,this.#n=n.grid??null,this.#r=n.context,this.#i=n.stored||null,this.#s=n.rowKey||u}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 f=n&&n.rows?new Set([...n.rows].map(String)):null,p=n&&n.columns?[...n.columns]:null;if(!f&&!p){this.#o.clear();return}const l=p?this.#l(p):null;for(const y of[...this.#o.keys()]){const c=String(y).split(h);c.length===3&&(f&&!f.has(c[0])||l&&!l.has(c[2])||this.#o.delete(y))}}#l(n){const f=new Set,p=this.#t,l=[...n];for(;l.length;){const y=l.pop();if(!f.has(y)){f.add(y);for(const c of p?p.dependents.get(y)||[]:[])l.push(c)}}return f}value(n,f,p){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return;if(!l.computed)return this.#c(l,f,p);if(l.value.pure!==!1&&this.#i&&p&&p.physical!=null&&this.#i.has(l.id))return this.#i.get(l.id,p.physical);if(l.volatile)return this.compute(l,f,p);if(l.value.pure===!1)return this.compute(l,f,p);const y=`${this.#a(f,p)}${h}${l.id}`;if(this.#o.has(y))return this.#o.get(y);const c=this.compute(l,f,p);return this.#o.set(y,c),c}#a(n,f){return`${this.#s(n,f)}${h}${d(n)}`}#c(n,f,p){if(this.#i&&p&&p.physical!=null&&this.#i.has(n.id))return this.#i.get(n.id,p.physical);if(n.field)return n.read?n.read(f):P(f,n.field)}compute(n,f,p){const l=this.#t,y=l&&l.wholeRow.has(n.id);let c;if(y)c=f??{};else{c={};const w=l&&l.deps.get(n.id)||[];for(const E of w)c[E]=this.value(E,f,p);const v=l&&l.external.get(n.id)||[];for(const E of v)c[E]=P(f,E);c=a(c,[...w,...v],n.id)}const m={data:f,row:p,column:n,grid:this.#n,context:this.#r};return n.value.compute(c,m)}values(n,f){const p={},l=this.#t?this.#t.order:[...this.#e.keys()];for(const y of l)p[y]=this.value(y,n,f);return p}text(n,f,p){const l=typeof n=="string"?this.#e.get(n):n;return l?l.formatValue(this.value(l,f,p),p,f):""}key(n,f,p){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return"";const y=this.value(l,f,p);return _(l.value.key)?String(l.value.key(this.#u(l,y,f,p))):l.lookup?l.lookup.groupKey(y):L(y)?"":String(y)}quickFilterText(n,f,p){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return"";if(_(l.value.quickFilterText)){const y=this.value(l,f,p);return String(l.value.quickFilterText(this.#u(l,y,f,p))??"")}return this.text(l,f,p)}#u(n,f,p,l){return{value:f,data:p,row:l,column:n,colId:n.id,grid:this.#n,context:this.#r}}parse(n,f,p,l){const y=typeof n=="string"?this.#e.get(n):n;if(!y)return f;const c={text:f,value:this.value(y,p,l),data:p,row:l,column:y,grid:this.#n,context:this.#r,locale:this.#n&&_(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&_(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return _(y.value.parse)?y.value.parse(c):y.dataType&&_(y.dataType.parse)?y.dataType.parse(c):f}validate(n,f,p,l,y){const c=typeof n=="string"?this.#e.get(n):n;if(!c||!_(c.edit.validate))return!0;const m=c.edit.validate({value:f,oldValue:p,data:l,row:y,column:c,grid:this.#n,context:this.#r});return m===!0||m===void 0?!0:String(m)}apply(n,f,p,l){const y=typeof n=="string"?this.#e.get(n):n;if(!y)return!1;const c=this.value(y,p,l);if(_(y.value.apply)){const m=y.value.apply({value:f,oldValue:c,data:p,row:l,column:y,grid:this.#n,context:this.#r});return this.#d(y,p,l),m!==!1}return y.field?c===f?!1:(y.write(p,f),this.#d(y,p,l),!0):(U(`apply:${y.id}`,`column "${y.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(n,f,p,l){const y=typeof n=="string"?this.#e.get(n):n;if(!y)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const c=this.value(y,p,l),m=this.parse(y,f,p,l),w=this.validate(y,m,c,p,l);if(w!==!0)return{ok:!1,value:m,oldValue:c,changed:!1,error:w};const v=this.apply(y,m,p,l);return{ok:!0,value:m,oldValue:c,changed:v}}#d(n,f,p){if(this.#o.size===0)return;const l=this.#a(f,p);this.#o.delete(`${l}${h}${n.id}`);for(const y of this.#t?this.#t.dependents.get(n.id)||[]:[])this.#o.delete(`${l}${h}${y}`)}}function u(i,n){return n&&n.key!=null?String(n.key):d(i)}function d(i){if(i&&typeof i=="object"){let n=s.get(i);return n===void 0&&(n=`#${g++}`,s.set(i,n)),n}return String(i)}const s=new WeakMap;let g=0}),We("packages/core/src/model/shadow.js",function(e,D){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"CLUSTER_SHADOW_KINDS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return n}});const P=D("packages/core/src/internal/warn.js").warnOnce,Y=2e5,_=20,L=1e3,Z=50;function H(f){return Math.min(L,Math.max(Z,Math.floor(f)))}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","cluster","clusterDistance"]),X=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),U=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),j=Object.freeze(["cluster","clusterDistance"]),k=.6745,b=3.5,a=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),h=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),r=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",cluster:"Cluster",clusterDistance:"Cluster distance"});function t(f,p){if(!p)return null;const l=Number.isFinite(Number(p.lower))?Number(p.lower):null,y=Number.isFinite(Number(p.upper))?Number(p.upper):null;if(l===null&&y===null||!Number.isFinite(f))return null;if(l!==null&&f<l||y!==null&&f>y)return a.FAIL;const c=Number.isFinite(Number(p.warnLower))?Number(p.warnLower):null,m=Number.isFinite(Number(p.warnUpper))?Number(p.warnUpper):null;return c!==null&&f<c||m!==null&&f>m?a.WARN:a.PASS}function o(f,p,l){if(!p||typeof p!="object")return null;if(p.kind!=="time")return p.kind!==void 0&&P(`shadow.history.window.kind:${f}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${p.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 y=p.minutes!=null?Number(p.minutes)*6e4:Number(p.span);if(!(y>0))return P(`shadow.history.window.span:${f}`,"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 c=Math.max(2,Math.floor(l)||_);return{span:y,bucketMs:Math.max(1,Math.floor(y/c))}}class u{#e;#t=new Map;#n=new Map;#r=new Map;#s=new Map;#i=new Map;#o=new Map;#l=0;#a;#c;#u;#d;#f=new Map;#h=null;#p=null;#m=null;constructor(p){this.#e=p.colId,this.#a=Math.max(2,p.depth||_),this.#c=Math.max(1,p.max||Y),this.#u=p.now||(()=>Date.now()),this.#d=o(this.#e,p.historyWindow,this.#a),this.#d&&(this.#h=Math.floor(this.#u()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(p,l){const y=i(l);if(y===null)return;if(!this.#n.has(p)){this.#p=null,this.#m=null,this.#g(),this.#t.set(p,y),this.#n.set(p,y),this.#r.set(p,0),this.#s.set(p,this.#u()),this.#i.set(p,[y]),this.#d&&this.#f.set(p,[y]),this.#o.set(p,0);return}const c=this.#n.get(p);if(c===y)return;this.#p=null,this.#m=null,this.#n.set(p,y),this.#r.set(p,(this.#r.get(p)||0)+1),this.#s.set(p,this.#u());const m=this.#i.get(p)||[];m.push(y),m.length>this.#a&&m.splice(0,m.length-this.#a),this.#i.set(p,m);const w=Math.sign(y-c),v=this.#o.get(p)||0;this.#o.set(p,Math.sign(v)===w?v+w:w)}#g(){if(this.#n.size<this.#c)return;const p=this.#n.keys().next().value;p!==void 0&&(this.#t.delete(p),this.#n.delete(p),this.#r.delete(p),this.#s.delete(p),this.#i.delete(p),this.#f.delete(p),this.#o.delete(p),this.#l++)}rebase(){for(const[p,l]of this.#n)this.#t.set(p,l);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#s.clear(),this.#i.clear(),this.#f.clear(),this.#o.clear(),this.#l=0,this.#p=null,this.#m=null,this.#d&&(this.#h=Math.floor(this.#u()/this.#d.bucketMs))}retain(p){const l=p instanceof Set?p:new Set(p);let y=0;for(const c of[...this.#n.keys()])l.has(c)||(this.#t.delete(c),this.#n.delete(c),this.#r.delete(c),this.#s.delete(c),this.#i.delete(c),this.#f.delete(c),this.#o.delete(c),y++);return y&&(this.#p=null,this.#m=null),y}advanceHistoryWindow(p=this.#u()){const l=this.#d;if(!l)return 0;const y=Math.floor(p/l.bucketMs),c=y-this.#h;if(!(c>0))return 0;const m=Math.min(c,this.#a);for(const[w,v]of this.#f){const E=this.#n.get(w);for(let V=0;V<m;V++)v.push(E);v.length>this.#a&&v.splice(0,v.length-this.#a)}return this.#h=y,c}read(p,l,y,c){switch(p){case"updates":return this.#r.has(l)?this.#r.get(l):0;case"updatedAt":{const m=this.#s.get(l);return m===void 0?null:new Date(m)}case"sinceUpdate":{const m=this.#s.get(l);return m===void 0?null:this.#u()-m}case"firstValue":return this.#t.has(l)?this.#t.get(l):null;case"delta":return this.#n.has(l)?this.#n.get(l)-this.#t.get(l):null;case"deltaPercent":{if(!this.#n.has(l))return null;const m=this.#t.get(l);return m?(this.#n.get(l)-m)/Math.abs(m)*100:null}case"rate":{const m=this.#i.get(l),w=this.#s.get(l);if(!m||m.length<2||w===void 0)return null;const v=this.#u()-w,E=m[m.length-1]-m[m.length-2];return v>0?E/v*1e3:E}case"history":return this.#d?this.#f.has(l)?[...this.#f.get(l)]:null:this.#i.has(l)?[...this.#i.get(l)]:null;case"streak":return this.#o.has(l)?this.#o.get(l):0;case"specStatus":return this.#n.has(l)?t(this.#n.get(l),c):null;default:return h.includes(p)?this.#O(p,l,y,c):null}}#b(p){if(p){if(this.#m&&this.#m.only===p)return this.#m.view;const l=this.#y(p);return this.#m={only:p,view:l},l}return this.#p?this.#p:(this.#p=this.#y(null),this.#p)}#y(p){const l=[];for(const[M,O]of this.#n)p&&!p.has(M)||l.push(O);const y=l.sort((M,O)=>M-O);let c=0,m=0,w=0,v=0;for(const M of y){v+=M,c++;const O=M-m;m+=O/c,w+=O*(M-m)}const E=[];for(const[M,O]of this.#t)p&&!p.has(M)||E.push(O);const V=c?d(y):0,G=y.map(M=>Math.abs(M-V)).sort((M,O)=>M-O),q=c?d(G):0;return{sorted:y,baseline:E.sort((M,O)=>M-O),sum:v,mean:c?m:0,sd:c>1?Math.sqrt(w/(c-1)):0,median:V,mad:q}}#O(p,l,y,c){if(!this.#n.has(l)||y&&!y.has(l))return null;const m=this.#n.get(l),w=this.#b(y),v=w.sorted.length;if(!v)return null;switch(p){case"rank":return v-g(w.sorted,m)+1;case"rankAsc":return s(w.sorted,m)+1;case"rankChange":{if(!this.#t.has(l)||!w.baseline.length)return null;const E=w.baseline.length-g(w.baseline,this.#t.get(l))+1,V=v-g(w.sorted,m)+1;return E-V}case"percentile":return g(w.sorted,m)/v*100;case"quartile":{const E=g(w.sorted,m)/v;return Math.min(4,Math.max(1,Math.ceil(E*4)))}case"zScore":return w.sd?(m-w.mean)/w.sd:null;case"anomalyScore":return w.mad?k*(m-w.median)/w.mad:null;case"anomalyFlag":{if(!w.mad)return null;const E=c&&Number.isFinite(Number(c.threshold))?Number(c.threshold):b;return Math.abs(k*(m-w.median)/w.mad)>E}case"shareOfTotal":return w.sum?m/w.sum*100:null;default:return null}}}function d(f){const p=f.length;if(!p)return 0;const l=(p-1)*.5,y=Math.floor(l),c=Math.ceil(l);return y===c?f[y]:f[y]+(l-y)*(f[c]-f[y])}function s(f,p){let l=0,y=f.length;for(;l<y;){const c=l+y>>1;f[c]<p?l=c+1:y=c}return l}function g(f,p){let l=0,y=f.length;for(;l<y;){const c=l+y>>1;f[c]<=p?l=c+1:y=c}return l}function i(f){if(f==null||f==="")return null;if(f instanceof Date){const l=f.getTime();return Number.isFinite(l)?l:null}const p=typeof f=="number"?f:Number(f);return Number.isFinite(p)?p:null}function n(f){const p=[];for(const l of f||[]){const y=l.shadow;if(!y)continue;const c=typeof y=="string"?{kind:y}:y,m=c.kind;x.includes(m)&&(X.includes(m)||U.includes(m)||j.includes(m)||p.push({colId:l.id||l.field,of:c.of||l.field||l.id,kind:m,depth:c.depth,historyWindow:m==="history"?c.window:void 0}))}return p}}),We("packages/core/src/columns/model.js",function(e,D){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return ve}});const ne=D("packages/core/src/internal/merge.js"),P=ne.expand,Y=ne.merge,_=ne.toArray,L=D("packages/core/src/internal/warn.js"),Z=L.fail,H=L.warnOnce,x=D("packages/core/src/internal/paths.js"),X=x.getPath,U=x.pathGetter,j=x.pathSetter,b=D("packages/core/src/internal/text.js").humanise,a=D("packages/core/src/internal/predicates.js"),h=a.isFunction,r=a.isObject,o=D("packages/core/src/internal/uid.js").uid,d=D("packages/core/src/format/index.js").compileFormat,s=D("packages/core/src/columns/datatypes.js"),g=s.comparatorFor,i=s.createTypeRegistry,n=s.storageKind,f=D("packages/core/src/columns/infer.js"),p=f.inferColumnType,l=f.DEFAULT_SAMPLE,y=D("packages/core/src/columns/graph.js"),c=y.buildGraph,m=y.affectedBy,v=D("packages/core/src/columns/lookup.js").createLookup,E=D("packages/core/src/columns/value.js"),V=E.compileDisplay,G=E.ValuePipeline,q=E.warnImpureUse,M=D("packages/core/src/model/shadow.js"),O=M.FIT_SHADOW_KINDS,T=M.CLUSTER_SHADOW_KINDS,A=Object.freeze({geometry:"geometry",list:"list"}),N={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},C={centre:"center"},S=new Set(["start","center","end","left","right"]);function F(pe){if(typeof pe!="string")return;const oe=pe.toLowerCase();return C[oe]?C[oe]:S.has(oe)?oe:void 0}function $(pe){if(typeof pe!="string")return;const oe=pe.toLowerCase();return oe==="center"||oe==="centre"?"middle":oe==="top"||oe==="middle"||oe==="bottom"?oe:void 0}const W=["cell","layout","header"];function K(pe){if(!r(pe))return{};const oe={...pe},be=(fe,le)=>{if(pe[fe]===void 0)return;const ye=P(pe[fe],le);ye&&W.includes(fe)&&!r(pe[fe])&&delete ye.enabled,oe[fe]=ye};return be("sort","direction"),be("filter","type"),be("cell","render"),be("edit","editor"),be("layout","width"),be("group","index"),be("pivot","index"),be("header","render"),be("facet","strategy"),oe}function I(pe,oe){const be={...pe||{}},fe=r(oe)&&r(oe.layout)&&oe.layout.width!==void 0;return be.fit==="content"&&!fe&&delete be.width,be}const B=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"]),J=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function te(pe,oe,be,fe){const le=be==="columnGroup"?"column group":"column";for(const ye of Object.keys(pe))if(!oe.has(ye)){if(ye==="timeZone"&&be==="column"){H("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${fe}". 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}H(`${be}.unknown:${ye}`,`'${ye}' is not a configuration key this grid recognises, so it had no effect on ${le} "${fe}". Check the spelling against the reference.`)}}function Q(pe){r(pe.cell)&&pe.cell.autoHeight!==void 0&&H("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${pe.id||pe.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function re(pe,oe){const be=oe&&h(pe.defaultsFor)?pe.defaultsFor(oe):null,fe={...pe.defaults||{},...r(be)?be:{}},le={};return fe.align&&(le.align=fe.align,le.cell={align:fe.align},le.header={align:fe.align}),fe.filter&&(le.filter=fe.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:fe.filter}),fe.editor&&(le.edit=fe.editor==="none"?{editor:null}:{editor:fe.editor}),fe.total&&(le.total=fe.total),fe.render&&(le.cell={...le.cell||{},render:fe.render}),pe.export&&(le.export={...pe.export}),le}function ie(pe){if(typeof pe=="string")return pe.trim()?[pe.trim()]:[];if(!Array.isArray(pe))return[];const oe=[];for(const be of pe){if(typeof be!="string")continue;const fe=be.trim();fe&&!oe.includes(fe)&&oe.push(fe)}return oe}class ue{#e=new Map;#t=[];#n=[];#r=new WeakMap;#s;#i;#o;#l;#a;#c;#u(oe,be,fe){if(oe&&typeof oe=="object"&&!h(oe)){const je=oe;return(typeof je.fn!="string"||!je.fn)&&Z(`column "${fe}": a total given as an object needs a \`fn\` name, such as { fn: 'percentile', p: 0.9 }.`),je.fn==="percentile"&&!(typeof je.p=="number"&&je.p>=0&&je.p<=1)&&Z(`column "${fe}": { fn: 'percentile' } needs \`p\`, a number from 0 to 1 (0.9 for the 90th percentile).`),this.#d(je.fn,be,fe),Object.freeze({...je})}const le=this.#d(oe,be,fe);if(typeof le!="string"||!this.#f)return le??null;const ye=be&&be.totals&&be.totals.implement;if(ye&&h(ye[le])){const je=ye[le];return je.totalName=le,je}const Ne=this.#f.totalFn?.(le);return h(Ne)?Ne:le}#d(oe,be,fe){if(typeof oe!="string")return oe;const le=be&&be.totals&&be.totals.supported;if(!Array.isArray(le)||le.includes(oe))return oe;const ye=le.length?le.join(", "):"none";return Z(`column "${fe}" is typed ${be.name||"a type"}, for which the total "${oe}" is not meaningful. Supported: ${ye}. Aggregating it anyway would produce a confident wrong number.`),oe}#f;#h;#p;#m;#g;#b;#y=!1;#O;#w;constructor(oe={}){this.#i=K(oe.columnDefaults||{}),this.#o=oe.columnPresets||{},this.#a=oe.locale,this.#l=oe.timeZone,this.#c=$(oe.verticalAlign),this.#f=oe.registry||null,this.#h=oe.grid||null,this.#p=oe.context,this.#O=oe.sampleSize??l,this.#w=oe.onChange||null,this.#b=h(oe.rowKey)?oe.rowKey:void 0,this.#s=i(oe.dataTypes,this.#f);const{leaves:be,groups:fe}=ve(oe.columns||[]);this.#n=fe;for(const le of be){le.facet!==void 0&&this.#r.set(le.def,le.facet);const ye=this.#A(le.def,null);if(ye.groupPath=le.path,this.#e.has(ye.id)){H(`columns.duplicate:${ye.id}`,`two columns resolve to the id '${ye.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}le.column=ye,this.#e.set(ye.id,ye),this.#t.push(ye.id)}this.#C(oe.stored||null)}#A(oe,be){te(oe,B,"column",oe.id||oe.field||"(unnamed)"),Q(oe);const fe=K(oe),le=_(oe.preset),ye=le.map(Be=>{const Ke=this.#o[Be];return Ke?K(Ke):(H(`preset:${Be}`,`unknown column preset "${Be}"; ignoring`),{})}),Ne=this.#S(fe,ye,be),je=this.#s.get(Ne)||this.#s.get("text");if(!this.#s.has(Ne)&&oe.type){const Be=A[Ne];H(`type:${Ne}`,`unknown data type "${Ne}"; falling back to "text"`+(Be?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Be}'.`:""))}const $e=h(je.items)?this.#P(fe,ye,oe.id||oe.field||"(unnamed)"):null;let Re=N;Re=Y(Re,this.#i),oe.type!==!1&&(Re=Y(Re,re(je,$e)));for(const Be of ye)Re=Y(Re,Be);this.#r.has(oe)&&(Re=Y(Re,K({facet:this.#r.get(oe)}))),Re=Y(Re,fe);const Se=Re.edit;Se&&Se.editor&&Se.enabled!==!0&&!h(Se.enabled)&&(oe.edit||{}).editor&&H(`column.editor-not-enabled:${oe.id||oe.field}`,`column '${oe.id||oe.field}' names the editor '${Se.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Ve=oe.id||oe.field||o("col");if(oe.shadow&&!h(Re.value&&Re.value.compute)){const Be=typeof oe.shadow=="string"?{kind:oe.shadow}:oe.shadow,Ke=Be.of||oe.field||Ve,qe=O.includes(Be.kind),rt=T.includes(Be.kind),nt=qe?Be.model||Be:null,dt=qe&&nt?[...Array.isArray(nt.predictors)?nt.predictors:[],nt.response].filter(Boolean):null,Pt=rt?(Array.isArray(Be.columns)?Be.columns:[]).filter(Boolean):null;Re.value={...Re.value||{},deps:Pt&&Pt.length?Pt:dt&&dt.length?dt:Be.orderBy&&Be.orderBy!==Ke?[Ke,Be.orderBy]:[Ke],pure:!1,compute:(Nt,it)=>{const ct=it.grid&&it.grid.statistics;if(!ct)return null;const ft=it.row&&it.row.key||ct.keyOf(it.data);if(!ft)return null;if(qe){if(!h(ct.fitShadow))return null;const Tt=Be.model?{...Be.model,threshold:Be.threshold}:Be;return ct.fitShadow(Be.kind,ft,Tt)}return rt?h(ct.clusterShadow)?ct.clusterShadow(Be.kind,ft,Be):null:ct.shadow(Ke,Be.kind,ft,Be.scope,Be)}}}if(oe.running&&!h(Re.value&&Re.value.compute)){const Be=typeof oe.running=="string"?{kind:oe.running}:oe.running,Ke=Be.of||oe.field||Ve;Re.value={...Re.value||{},deps:[Ke],pure:!1,compute:(qe,rt)=>{const nt=rt.grid&&rt.grid.statistics;if(!nt||!h(nt.running))return null;const dt=rt.row&&rt.row.key||nt.keyOf(rt.data);return dt?nt.running(Ke,Be.kind||"total",dt):null}},oe.sort===void 0&&(Re.sort={...Re.sort||{},enabled:!1})}const Fe=oe.field??(h(Re.value&&Re.value.compute)?null:oe.id??null),Ce=h(Re.value&&Re.value.compute),Ee={id:Ve,field:Fe,shadow:oe.shadow||null,running:oe.running||null,spec:oe.spec||null,validation:oe.validation||null,volatile:!!(oe.shadow||oe.running),title:Re.title??b(Fe||Ve),type:je.name,dataType:je,itemType:$e,nullable:Re.nullable!==!1,align:F(fe.cell&&fe.cell.align||fe.align||Re.cell&&Re.cell.align||Re.align||je.defaults&&je.defaults.align)||"start",verticalAlign:$(fe.cell&&fe.cell.verticalAlign||fe.verticalAlign||Re.cell&&Re.cell.verticalAlign||Re.verticalAlign)||this.#c,rowSpan:h(Re.rowSpan)?Re.rowSpan:null,colSpan:h(Re.colSpan)?Re.colSpan:null,value:{pure:!0,...Re.value||{}},cell:{...Re.cell||{}},edit:{...Re.edit||{}},sort:{...Re.sort||{}},filter:{...Re.filter||{}},group:{enabled:!1,index:-1,explode:!1,...Re.group||{}},pivot:{enabled:!1,index:-1,...Re.pivot||{}},total:this.#u(Re.total,je,oe.id||oe.field||"(unnamed)"),groupTotal:Re.groupTotal===void 0?null:this.#u(Re.groupTotal,je,oe.id||oe.field||"(unnamed)"),grandTotal:Re.grandTotal===void 0?null:this.#u(Re.grandTotal,je,oe.id||oe.field||"(unnamed)"),tags:ie(Re.tags),typeOptions:Re.typeOptions??null,...r(Re[Ne])?{[Ne]:Re[Ne]}:{},layout:I(Re.layout,fe),header:{...Re.header||{}},contextMenu:Re.contextMenu===void 0?null:Re.contextMenu,facet:{...Re.facet||{}},export:{...Re.export||{}},allowGroup:Re.allowGroup!==!1,allowPivot:Re.allowPivot!==!1,allowTotal:Re.allowTotal!==!1,quickFilter:Re.quickFilter!==!1,def:oe,format:Re.format,presets:le,inferred:be!=null&&!oe.type,computed:Ce,diff:oe.diff===void 0?void 0:!!oe.diff,read:Fe?U(Fe):null,write:Fe?j(Fe):null};Ee.cell.align=F(fe.cell&&fe.cell.align)||Ee.align,Ee.header.align=F(fe.header&&fe.header.align)||Ee.align;const Ie=Re.lookup||null;return Ee.lookup=Ie?v({id:Ve,lookup:Ie},{locale:this.#a,onChange:()=>{this.#w&&this.#w("lookup",{colId:Ve})}}):null,Ee.group.explode&&Ee.lookup&&Ee.lookup.multiple&&H(`explode:${Ve}`,`column "${Ve}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#v(Ee),Ee}#v(oe){oe.formatter=d(oe.format,oe.dataType,this.#a,this.#l,oe.id),oe.formatValue=V(oe,{locale:this.#a,grid:this.#h,context:this.#p}),oe.itemCompare=oe.itemType?g(oe.itemType,this.#a):null,oe.compare=h(oe.value.compare)?oe.value.compare:oe.lookup?oe.lookup.comparator():h(oe.dataType.compareFor)?oe.dataType.compareFor(oe):g(oe.dataType,this.#a),oe.excel=oe.formatter&&oe.formatter.ooxml||oe.dataType&&oe.dataType.excel||"General",oe.storeKind=n(oe.dataType,!!(oe.lookup&&oe.lookup.multiple))}#P(oe,be,fe){let le=r(oe.typeOptions)?oe.typeOptions:null;for(let $e=be.length-1;!le&&$e>=0;$e--)r(be[$e].typeOptions)&&(le=be[$e].typeOptions);!le&&r(this.#i.typeOptions)&&(le=this.#i.typeOptions);const ye=le&&le.of!==void 0?le.of:"text",Ne=typeof ye=="string"?this.#s.get(ye):void 0;return Ne&&!h(Ne.items)&&Ne.storage!=="object"?Ne:(H(`type:of:${String(ye)}`,`column "${fe}" names "${String(ye)}" as its item type (typeOptions.of), which is not ${Ne?"a scalar data type":"a known data type"}; its items are read as text.`),this.#s.get("text"))}#S(oe,be,fe){if(oe.type===!1)return"text";if(oe.type)return oe.type;for(let le=be.length-1;le>=0;le--)if(be[le].type)return be[le].type;if(this.#i.type)return this.#i.type;if(oe.shadow){const le=typeof oe.shadow=="string"?oe.shadow:oe.shadow.kind;if(le==="fitInfluence")return"boolean";if(le==="fitPredicted"||le==="fitResidual"||le==="fitStdResidual"||le==="fitLeverage"||le==="fitCooksD"||le==="tsTrend"||le==="tsSeasonal"||le==="tsResidual"||le==="tsCoverage"||le==="tsSmoothed"||le==="tsSmoothingAlpha"||le==="tsSmoothingBeta"||le==="cluster"||le==="clusterDistance")return"number"}return fe||(oe.lookup?"lookup":"text")}#C(oe){const be=this.all();this.#m=c(be),this.#g?this.#g.setGraph(this.#m):this.#g=new G({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:oe||null,rowKey:this.#b});const fe=this.#g;for(const le of be)le.getValue=(ye,Ne)=>fe.value(le,ye,Ne)}all(){return this.#t.map(oe=>this.#e.get(oe))}visible(){return this.all().filter(oe=>!oe.layout.hidden)}get(oe){return this.#e.get(oe)}groups(){const oe=be=>{const fe=[];for(const le of be)Array.isArray(le.columns)?fe.push({...le,columns:oe(le.columns)}):le.column&&fe.push(le.column);return fe};return oe(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#s}affectedBy(oe){return m(this.#m,oe)}value(oe,be,fe){return this.#g.value(oe,be,fe)}text(oe,be,fe){return this.#g.text(oe,be,fe)}checkImpure(oe,be){q(this.#e.get(oe),be)}setLocale(oe){this.#a=oe;for(const be of this.all())be.lookup&&be.lookup.setLocale(oe),this.#v(be);this.#w&&this.#w("locale",{locale:oe})}infer(oe){const be={};if(this.#y||!Array.isArray(oe)||oe.length===0)return be;this.#y=!0;let fe=!1;for(const le of this.all()){const ye=le.def;if(ye.type!==void 0||!le.field||le.computed||le.lookup||this.#E(le))continue;const Ne=le.read||(Re=>X(Re,le.field)),je=p(le.id,oe,Ne,this.#s,{sampleSize:this.#O});if(je===le.type)continue;be[le.id]=je;const $e=this.#A(ye,je);$e.groupPath=le.groupPath,$e.layout={...$e.layout,...ke(le.layout)},this.#e.set(le.id,$e),De(this.#n,le.id,$e),fe=!0}return fe&&this.#C(null),be}redecorate(oe,be,fe={}){const le=this.#e.get(oe);if(!le){H(`redecorate:${oe}`,`columns.decorate('${oe}', …): no column with id '${oe}'.`);return}const ye=le.def||{},Ne={...r(ye.cell)?ye.cell:{}};Ne.decoration=be??void 0,fe&&"variant"in fe&&(Ne.variant=fe.variant);const je={...ye,cell:Ne};this.#r.has(ye)&&this.#r.set(je,this.#r.get(ye));const $e=this.#A(je,le.type);return $e.groupPath=le.groupPath,$e.layout={...$e.layout,...ke(le.layout)},le.lookup&&le.lookup!==$e.lookup&&h(le.lookup.destroy)&&le.lookup.destroy(),this.#e.set(oe,$e),De(this.#n,oe,$e),this.#C(null),this.#w&&this.#w("decorate",{colId:oe}),$e}destroy(){for(const oe of this.#e.values())oe.lookup&&h(oe.lookup.destroy)&&oe.lookup.destroy()}#E(oe){for(const be of oe.presets){const fe=this.#o[be];if(fe&&fe.type)return!0}return!!this.#i.type}#T(oe){return!oe.computed&&h(oe.dataType&&oe.dataType.toStorage)}storeReader(oe){if(oe.computed)return be=>this.#g.value(oe,be,null);if(this.#T(oe)){const be=oe.dataType.toStorage,fe={timeZone:this.#l,colId:oe.id,itemType:oe.itemType||null};return le=>be(oe.read(le),fe)}return oe.read}storeValue(oe,be){if(!(!oe||oe.computed)&&h(oe.read))return this.storeReader(oe)(be)}storeSchema(){const oe=[];for(const be of this.all()){if(be.computed&&be.value.pure===!1||!be.computed&&!be.field)continue;const fe=this.storeReader(be);let le=null;!be.computed&&!this.#T(be)&&typeof be.field=="string"&&!be.lookup&&(le=be.field);const ye={id:be.id,kind:be.storeKind,nullable:be.nullable,read:fe};le!==null&&(ye.field=le),be.lookup&&(ye.dictionary=be.lookup.dictionary()),oe.push(ye)}return oe}state(){return this.all().map(oe=>({id:oe.id,width:oe.layout.width,flex:oe.layout.flex||void 0,hidden:!!oe.layout.hidden,headerWrap:oe.header?.wrap===!0?!0:void 0,headerOrientation:oe.header?.orientation==="vertical"?"vertical":void 0,pin:oe.layout.pin??null,sort:oe.sort.direction??null,sortIndex:oe.sort.direction?oe.sort.order??0:null,groupIndex:oe.group.enabled?oe.group.index??0:null,pivotIndex:oe.pivot.enabled?oe.pivot.index??0:null,total:typeof oe.total=="string"?oe.total:null,groupTotal:typeof oe.groupTotal=="string"?oe.groupTotal:void 0,grandTotal:typeof oe.grandTotal=="string"?oe.grandTotal:void 0,decoration:oe.cell&&oe.cell.decoration!=null?de(oe.cell.decoration):void 0,variant:oe.cell&&oe.cell.variant!=null?de(oe.cell.variant):void 0}))}applyState(oe,be={}){const fe={applied:[],skipped:[]},le=Array.isArray(oe)?oe:oe&&oe.columns||[],ye=!Array.isArray(oe)&&oe&&oe.columnOrder||null;for(const je of le){if(!je||!je.id){fe.skipped.push({key:"?",reason:"no id"});continue}let $e=this.#e.get(je.id);if(!$e){fe.skipped.push({key:je.id,reason:"unknown column"});continue}if(Object.hasOwn(je,"decoration")||Object.hasOwn(je,"variant")){const Re=$e.cell?$e.cell.decoration:void 0,Se=je.decoration??null,Ve=Object.hasOwn(je,"variant"),Fe=Ve&&!we($e.cell?$e.cell.variant:void 0,je.variant);(!we(Re,Se)||Fe)&&(this.redecorate(je.id,Se,Ve?{variant:je.variant??void 0}:{}),$e=this.#e.get(je.id)||$e)}je.width!=null&&($e.layout.width=je.width),je.flex!=null&&($e.layout.flex=je.flex),je.hidden!=null&&($e.layout.hidden=!!je.hidden),je.headerWrap!==void 0&&($e.header.wrap=!!je.headerWrap),je.headerOrientation!==void 0&&($e.header.orientation=je.headerOrientation==="vertical"?"vertical":"horizontal"),je.pin!==void 0&&($e.layout.pin=je.pin),je.sort!==void 0&&($e.sort.direction=je.sort),je.sortIndex!=null&&($e.sort.order=je.sortIndex),je.groupIndex!=null&&($e.group.enabled=!0,$e.group.index=je.groupIndex),je.pivotIndex!=null&&($e.pivot.enabled=!0,$e.pivot.index=je.pivotIndex),je.total!==void 0&&($e.total=je.total),je.groupTotal!==void 0&&($e.groupTotal=je.groupTotal),je.grandTotal!==void 0&&($e.grandTotal=je.grandTotal),fe.applied.push(je.id)}const Ne=ye||(be&&be.keepOrder?[]:le.map(je=>je&&je.id).filter(Boolean));if(Ne.length){const je=Ne.filter(Re=>this.#e.has(Re)),$e=this.#t.filter(Re=>!je.includes(Re));this.#t=[...je,...$e]}return this.#w&&this.#w("state",fe),fe}move(oe,be){this.#M(oe,be)&&(this.#R(),this.#w&&this.#w("move",{id:oe,to:be}))}reorder(oe){const be={applied:[],skipped:[]},fe=[];let le=0;for(const ye of Array.isArray(oe)?oe:[]){const Ne=le++;this.#M(ye,Ne)&&(be.applied.push(ye),fe.push({id:ye,to:Ne}))}if(!fe.length)return be;if(this.#R(),this.#w)for(const ye of fe)this.#w("move",ye);return be}#M(oe,be){const fe=this.#t.indexOf(oe);if(fe===-1||Math.max(0,Math.min(Number(be)||0,this.#t.length-1))===fe)return!1;const ye=this.#e.get(oe);if(ye.layout.movable===!1||ye.layout.lockPosition)return H(`move:${oe}`,`column "${oe}" is not movable; the move was ignored`),!1;const Ne=this.#N(oe,be);return Ne?(H(`move.married:${Ne}`,`band "${Ne}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(fe,1),this.#t.splice(Math.max(0,Math.min(be,this.#t.length)),0,oe),!0)}#N(oe,be){if(!this.#n||!this.#n.length)return null;const fe=this.#t.filter(je=>je!==oe),le=Math.max(0,Math.min(be,fe.length)),ye=(je,$e)=>{if(Array.isArray(je.columns)){for(const Se of je.columns)ye(Se,$e);return $e}const Re=je.column?je.column.id:je.id;return Re&&$e.push(Re),$e},Ne=je=>{for(const $e of je){if(!Array.isArray($e.columns))continue;if($e.marryChildren===!0){const Se=ye($e,[]),Ve=Se.includes(oe),Fe=Se.map(Ce=>fe.indexOf(Ce)).filter(Ce=>Ce>=0);if(Fe.length){const Ce=Math.min(...Fe),Ee=Math.max(...Fe);if(Ve?le<Ce||le>Ee+1:le>Ce&&le<=Ee)return $e.id}}const Re=Ne($e.columns);if(Re)return Re}return null};return Ne(this.#n)}#R(){const oe=new Map(this.#t.map((le,ye)=>[le,ye])),be=le=>{if(!Array.isArray(le.columns)){const Ne=le.column?le.column.id:le.id;return oe.has(Ne)?oe.get(Ne):1/0}let ye=1/0;for(const Ne of le.columns)ye=Math.min(ye,be(Ne));return ye},fe=le=>{le.sort((ye,Ne)=>be(ye)-be(Ne));for(const ye of le)Array.isArray(ye.columns)&&fe(ye.columns)};fe(this.#n)}#D(oe){const be=fe=>{for(let le=0;le<fe.length;le++){const ye=fe[le];if(Array.isArray(ye.columns)){const Ne=be(ye.columns);if(Ne)return Ne}else if(ye.column&&ye.column.id===oe)return fe.splice(le,1)[0]}return null};return be(this.#n)}#W(oe){const be=[];for(let fe=oe.length-1;fe>=0;fe--){const le=oe[fe];Array.isArray(le.columns)&&(be.push(...this.#W(le.columns)),le.columns.length===0&&(be.push(le.id),oe.splice(fe,1)))}return be}#V(){const oe=(be,fe,le)=>{for(const ye of be)Array.isArray(ye.columns)?oe(ye.columns,[...fe,ye.id]):ye.column&&(ye.column.groupPath=fe)};oe(this.#n,[])}#x(oe){const be=new Set(oe),fe=this.#t.filter(je=>be.has(je));if(!fe.length)return;const le=Math.min(...fe.map(je=>this.#t.indexOf(je))),ye=this.#t.slice(0,le).filter(je=>!be.has(je)),Ne=this.#t.slice(le).filter(je=>!be.has(je));this.#t=[...ye,...fe,...Ne]}#q(oe){const be=[],fe=le=>{if(Array.isArray(le.columns))for(const ye of le.columns)fe(ye);else le.column&&be.push(le.column.id)};return fe(oe),be}#B(oe){const be=fe=>{for(const le of fe){if(!Array.isArray(le.columns))continue;if(le.id===oe)return{node:le,parent:fe};const ye=be(le.columns);if(ye)return ye}return null};return be(this.#n)}groupColumns(oe,be={}){const fe=_(oe).filter($e=>this.#e.has($e));if(!fe.length)return H("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const $e of fe)if(this.#e.get($e).layout.lockPosition)return H(`columns.group.locked:${$e}`,`column "${$e}" is position-locked and cannot be grouped.`),null;const le=be.groupId?this.#B(be.groupId):null;if(be.groupId&&!le)return H(`columns.group.unknown:${be.groupId}`,`no band "${be.groupId}" to add to; nothing was grouped.`),null;let ye=null;if(!le&&be.id!=null&&(ye=String(be.id),this.#B(ye)||this.#e.has(ye)))return H(`columns.group.idtaken:${ye}`,`band id "${ye}" is already in use; nothing was grouped.`),null;const Ne=fe.map($e=>this.#D($e)).filter(Boolean);if(!Ne.length)return null;let je;if(le)le.node.columns.push(...Ne),je=le.node.id;else{const $e={id:ye||o("grp"),title:be.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Ne},Re=Number.isInteger(be.at)?Math.max(0,Math.min(be.at,this.#n.length)):this.#n.length;this.#n.splice(Re,0,$e),je=$e.id}return this.#W(this.#n),this.#x(fe),this.#V(),this.#R(),this.#w&&this.#w("columngroup",{action:"formed",groupId:je,ids:fe}),je}ungroupColumn(oe){const be=this.#e.get(oe);if(!be){H(`columns.ungroup.unknown:${oe}`,`no column "${oe}" to ungroup.`);return}const fe=be.groupPath||[];if(!fe.length)return;const le=fe[fe.length-1],ye=this.#B(le);if(!ye)return;const Ne=this.#D(oe);if(!Ne)return;const je=ye.parent.indexOf(ye.node);ye.parent.splice(je+1,0,Ne);const $e=this.#W(this.#n),Re=this.#q(ye.node);if(Re.length){this.#x(Re);const Se=Math.max(...Re.map(Fe=>this.#t.indexOf(Fe))),Ve=this.#t.filter(Fe=>Fe!==oe);Ve.splice(Se+1,0,oe),this.#t=Ve}this.#V(),this.#R(),this.#w&&this.#w("columngroup",{action:"removed",id:oe,dissolved:$e})}renameGroup(oe,be){const fe=this.#B(oe);if(!fe){H(`columns.group.rename:${oe}`,`no band "${oe}" to rename.`);return}fe.node.title=String(be??""),this.#w&&this.#w("columngroup",{action:"renamed",groupId:oe,title:fe.node.title})}dissolveGroup(oe){const be=this.#B(oe);if(!be){H(`columns.group.dissolve:${oe}`,`no band "${oe}" to dissolve.`);return}const fe=be.parent.indexOf(be.node);be.parent.splice(fe,1,...be.node.columns),this.#V(),this.#R(),this.#w&&this.#w("columngroup",{action:"dissolved",groupId:oe})}moveGroup(oe,be){const fe=this.#B(oe);if(!fe){H(`columns.group.move:${oe}`,`no band "${oe}" to move.`);return}const le=fe.parent,ye=le.indexOf(fe.node);ye!==-1&&(le.splice(ye,1),le.splice(Math.max(0,Math.min(be,le.length)),0,fe.node),this.#Y(),this.#V(),this.#w&&this.#w("columngroup",{action:"moved",groupId:oe,to:be}))}#Y(){const oe=[],be=le=>{for(const ye of le)Array.isArray(ye.columns)?be(ye.columns):ye.column&&oe.push(ye.column.id)};be(this.#n);const fe=new Set(oe);this.#t=[...oe,...this.#t.filter(le=>!fe.has(le))]}groupTree(){const oe=fe=>fe.map(le=>Array.isArray(le.columns)?{id:le.id,title:le.title||"",collapsible:!!le.collapsible,openByDefault:le.openByDefault!==!1,columns:oe(le.columns)}:le.column?le.column.id:null).filter(le=>le!==null),be=oe(this.#n);return be.some(fe=>fe&&typeof fe=="object")?be:[]}applyGroupTree(oe){if(!Array.isArray(oe))return;const be=new Set,fe=ye=>{const Ne=[];for(const je of ye)if(je&&typeof je=="object"&&Array.isArray(je.columns)){const $e=fe(je.columns);if(!$e.length)continue;Ne.push({id:je.id||o("grp"),title:je.title||"",collapsible:je.collapsible===!0,openByDefault:je.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:$e})}else if(typeof je=="string"){const $e=this.#e.get(je);$e&&!be.has(je)&&(be.add(je),Ne.push({column:$e,path:[]}))}return Ne},le=fe(oe);for(const ye of this.#t){if(be.has(ye))continue;const Ne=this.#e.get(ye);Ne&&le.push({column:Ne,path:[]})}this.#n=le,this.#V(),this.#R(),this.#w&&this.#w("columngroup",{action:"applied"})}show(oe){this.#G(oe,!1)}hide(oe){this.#G(oe,!0)}#G(oe,be){const fe=[];for(const le of _(oe)){const ye=this.#e.get(le);if(ye){if(be&&ye.layout.lockVisible){H(`lockVisible:${le}`,`column "${le}" is \`layout.lockVisible\` and cannot be hidden`);continue}ye.layout.hidden!==be&&(ye.layout.hidden=be,fe.push(le))}}fe.length&&this.#w&&this.#w("visible",{ids:fe,hidden:be})}pin(oe,be){const fe=this.#e.get(oe);fe&&(fe.layout.pin=be??null,this.#w&&this.#w("pin",{id:oe,side:fe.layout.pin}))}pinMany(oe){const be={};for(const[le,ye]of oe){const Ne=this.#e.get(le);Ne&&(Ne.layout.pin=ye??null,be[le]=Ne.layout.pin)}const fe=Object.keys(be);fe.length&&this.#w&&this.#w("pin",{ids:fe,pins:be})}#I(oe,be){const fe=oe.layout.min??0,le=oe.layout.max;let ye=Math.max(fe,be);return le!=null&&(ye=Math.min(le,ye)),oe.layout.width=ye,oe.layout.flex=0,ye}resize(oe,be){const fe=this.#e.get(oe);if(!fe)return;if(fe.layout.resizable===!1){H(`resize:${oe}`,`column "${oe}" is not resizable; the resize was ignored`);return}const le=this.#I(fe,be);this.#w&&this.#w("resize",{id:oe,width:le})}resizeMany(oe){const be={};for(const[le,ye]of oe){const Ne=this.#e.get(le);if(Ne){if(Ne.layout.resizable===!1){H(`resize:${le}`,`column "${le}" is not resizable; the resize was ignored`);continue}be[le]=this.#I(Ne,ye)}}const fe=Object.keys(be);fe.length&&this.#w&&this.#w("resize",{ids:fe,widths:be})}}function ke(pe){const oe={};return pe.width!=null&&(oe.width=pe.width),pe.hidden!=null&&(oe.hidden=pe.hidden),pe.pin!==void 0&&(oe.pin=pe.pin),oe}function de(pe){if(pe===null||typeof pe!="object")return pe;try{return structuredClone(pe)}catch{}try{return JSON.parse(JSON.stringify(pe))}catch{return pe}}function we(pe,oe){const be=pe??null,fe=oe??null;if(be===fe)return!0;if(be===null||fe===null)return!1;if(typeof be!="object"||typeof fe!="object")return be===fe;try{return JSON.stringify(be)===JSON.stringify(fe)}catch{return!1}}function ve(pe){const oe=[],be=(le,ye,Ne)=>{const je=[];for(const $e of le){if(!r($e)){Z("a column definition must be an object");continue}if(Array.isArray($e.columns)){te($e,J,"columnGroup",$e.title||$e.id||"(unnamed)");const Re={id:$e.id||o("grp"),title:$e.title||"",collapsible:$e.collapsible===!0,openByDefault:$e.openByDefault!==!1,showWhen:$e.showWhen||"always",marryChildren:$e.marryChildren===!0,header:$e.header||{},def:$e,columns:[]};Re.columns=be($e.columns,[...ye,Re.id],$e.facet!==void 0?$e.facet:Ne),je.push(Re)}else{const Re={def:$e,path:ye,facet:Ne};oe.push(Re),je.push(Re)}}return je},fe=be(pe,[],void 0);return{leaves:oe,groups:fe}}function De(pe,oe,be){for(const fe of pe){if(fe.columns){if(De(fe.columns,oe,be))return!0;continue}if(fe.column&&fe.column.id===oe)return fe.column=be,!0}return!1}}),We("packages/core/src/columns/autogroup.js",function(e,D){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return X}});const P=D("packages/core/src/internal/warn.js").warnOnce,Y="__lattice_group",_=240,L=.5;function Z(U){const j=U.def&&U.def.layout;return(typeof j=="number"||j&&j.width!=null||U.def&&U.def.width!=null)&&Number.isFinite(U.layout.width)?U.layout.width:null}function H(U){const j=U.def&&U.def.layout;return!!(j&&j.min!=null)||U.def&&U.def.minWidth!=null}function x(U){const{columns:j,groupBy:k}=U,b=k.map(u=>j.get(u)).filter(Boolean),a=b.length?b.map(u=>u.title||u.id).join(" > "):"Group",h=b.find(u=>Z(u)!=null),r=U.config&&U.config.autoGroupColumnWidth||(h?Z(h):_);let t=h&&H(h)?h.layout.min:120;h&&!H(h)&&(t=Math.min(t,r));const o=h&&h.layout.max!=null?h.layout.max:null;return{id:Y,field:null,title:a,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:k.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:r,min:t,max:o,pin:U.config&&U.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,d){return d&&d.group?d.groupValue:null},formatValue(u,d){if(!d||!d.group)return"";if(d.grandTotal)return U.config&&U.config.grandTotalLabel||"Total";const s=b[Math.min(d.level||0,b.length-1)];return s&&typeof s.formatValue=="function"?s.formatValue(u,d):u==null?"":String(u)}}}function X(U,j,k){!U.length||k<100||j<k*L||P(`grouping.cardinality:${U.join(",")}`,`grouping by ${U.join(", ")} produced ${j} groups for ${k} 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.`)}}),We("packages/core/src/columns/selectcolumn.js",function(e,D){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const ne="__lattice_select",P=44;function Y(L){const Z=L.selection||{},H=L.config&&L.config.selectionColumnWidth||P;return{id:ne,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:H,min:H,max:H,pin:L.config&&L.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:Z.headerCheckbox===!0,def:{},getValue(x,X){return X?X.selected:!1},formatValue(){return""}}}const _=Y}),We("packages/core/src/columns/rownumbercolumn.js",function(e,D){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const P=D("packages/core/src/internal/predicates.js").isFunction,Y="__lattice_rownumber",_=40,L=9,Z=22;function H(U){const j=String(Math.max(1,Math.trunc(Math.abs(U))||1)).length;return Math.max(_,j*L+Z)}function x(U){const j=U.rowNumbers,k=j&&typeof j=="object"?j:{},b=Number.isFinite(k.start)?k.start:1,a=Number.isFinite(k.width)?k.width:H((U.maxNumber||0)+b),h=P(U.rank)?U.rank:()=>null;return{id:Y,field:null,title:typeof k.title=="string"?k.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:a,min:a,max:a,pin:"start",hidden:!1,resizable:k.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(r,t){const o=h(t);return o==null?null:o-1+b},formatValue(r){return r==null?"":String(r)}}}const X=x}),We("packages/core/src/model/detail.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const P=D("packages/core/src/internal/predicates.js").isFunction,_=D("packages/core/src/internal/warn.js").warnOnce,L=240,Z=10;function H(U){if(!U)return null;const j=U===!0?{}:U;return j.enabled===!1?null:!P(j.rows)&&!j.render?(_("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:P(j.rows)?j.rows:null,height:j.height??L,maxHeight:j.maxHeight??null,cacheLimit:Number.isFinite(j.cacheLimit)?Math.max(0,j.cacheLimit):Z,isMaster:P(j.isMaster)?j.isMaster:null,target:j.target||null,onCreate:P(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=P(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 k=this.#e.isMaster;return k?!!k(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 k=this.#e.height;return P(k)?Number(k(j))||L:k==="auto"?L:Number(k)||L}open(j){return this.#t.has(j)?!1:(this.inline||this.#t.clear(),this.#t.add(j),this.#s(),!0)}close(j){return this.#t.delete(j)?(this.#s(),!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.#s())}prune(j){if(!this.#t.size||!P(j))return;let k=!1;for(const b of[...this.#t])j(b)||(this.#t.delete(b),k=!0);k&&this.#s()}signature(){return`${this.#r}`}set(j){this.#t.clear();const k=Array.isArray(j)?j:[];for(const b of this.inline?k:k.slice(0,1))this.#t.add(b);this.#s()}#s(){this.#r++,this.#n()}}const X=x}),We("packages/core/src/compute/special.js",function(e,D){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return r}});const ne=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),P=3e-12,Y=1e-300;function _(t){if(t<.5)return Math.log(Math.PI/Math.sin(Math.PI*t))-_(1-t);const o=t-1;let u=.9999999999998099;const d=o+7.5;for(let s=0;s<ne.length;s++)u+=ne[s]/(o+s+1);return .5*Math.log(2*Math.PI)+(o+.5)*Math.log(d)-d+Math.log(u)}function L(t,o,u){const d=t+o,s=t+1,g=t-1;let i=1,n=1-d*u/s;Math.abs(n)<Y&&(n=Y),n=1/n;let f=n;for(let p=1;p<=300;p++){const l=2*p;let y=p*(o-p)*u/((g+l)*(t+l));n=1+y*n,Math.abs(n)<Y&&(n=Y),i=1+y/i,Math.abs(i)<Y&&(i=Y),n=1/n,f*=n*i,y=-(t+p)*(d+p)*u/((t+l)*(s+l)),n=1+y*n,Math.abs(n)<Y&&(n=Y),i=1+y/i,Math.abs(i)<Y&&(i=Y),n=1/n;const c=n*i;if(f*=c,Math.abs(c-1)<P)break}return f}function Z(t,o,u){if(!(t>0)||!(o>0)||!Number.isFinite(u))return Number.NaN;if(u<=0)return 0;if(u>=1)return 1;const d=Math.exp(_(t+o)-_(t)-_(o)+t*Math.log(u)+o*Math.log(1-u));return u<(t+1)/(t+o+2)?d*L(t,o,u)/t:1-d*L(o,t,1-u)/o}function H(t){if(!(t>0)||!(t<1))return t===0?-1/0:t===1?1/0:Number.NaN;const o=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],u=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],d=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],s=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],g=.02425;let i,n,f;t<g?(i=Math.sqrt(-2*Math.log(t)),f=(((((d[0]*i+d[1])*i+d[2])*i+d[3])*i+d[4])*i+d[5])/((((s[0]*i+s[1])*i+s[2])*i+s[3])*i+1)):t<=1-g?(i=t-.5,n=i*i,f=(((((o[0]*n+o[1])*n+o[2])*n+o[3])*n+o[4])*n+o[5])*i/(((((u[0]*n+u[1])*n+u[2])*n+u[3])*n+u[4])*n+1)):(i=Math.sqrt(-2*Math.log(1-t)),f=-(((((d[0]*i+d[1])*i+d[2])*i+d[3])*i+d[4])*i+d[5])/((((s[0]*i+s[1])*i+s[2])*i+s[3])*i+1));const l=(.5*x(-f/Math.SQRT2)-t)*Math.sqrt(2*Math.PI)*Math.exp(f*f/2);return f-l/(1+f*l/2)}function x(t){const o=Math.abs(t),u=2/(2+o),d=4*u-2,s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let g=0,i=0,n;for(let p=s.length-1;p>0;p--)n=i,i=d*i-g+s[p],g=n;const f=u*Math.exp(-o*o+.5*(s[0]+d*i)-g);return t>=0?f:2-f}function X(t){return .5*x(-t/Math.SQRT2)}function U(t,o){if(!(o>0)||!Number.isFinite(t))return Number.NaN;const u=.5*Z(o/2,.5,o/(o+t*t));return t>0?1-u:u}function j(t,o){if(!(t>0)||!(t<1)||!(o>0))return Number.NaN;if(o>1e7)return H(t);let u=-1e4,d=1e4,s=H(t);const g=_(o/2)+_(.5)-_((o+1)/2);for(let i=0;i<60;i++){const n=U(s,o);n<t?u=s:d=s;const f=Math.exp(-((o+1)/2)*Math.log(1+s*s/o)-g)/Math.sqrt(o),p=f>0?(n-t)/f:0;if(Math.abs(p)<1e-12)break;const l=s-p;if(s=l>u&&l<d&&Number.isFinite(l)?l:(u+d)/2,d-u<1e-12)break}return s}function k(t,o){let u=t,d=1/t,s=d;for(let g=0;g<300&&(u+=1,s*=o/u,d+=s,!(Math.abs(s)<Math.abs(d)*P));g++);return d*Math.exp(-o+t*Math.log(o)-_(t))}function b(t,o){let u=o+1-t,d=1/Y,s=1/u,g=s;for(let i=1;i<=300;i++){const n=-i*(i-t);u+=2,s=n*s+u,Math.abs(s)<Y&&(s=Y),d=u+n/d,Math.abs(d)<Y&&(d=Y),s=1/s;const f=s*d;if(g*=f,Math.abs(f-1)<P)break}return Math.exp(-o+t*Math.log(o)-_(t))*g}function a(t,o){return!(t>0)||!(o>=0)||!Number.isFinite(o)?Number.NaN:o===0?0:o<t+1?k(t,o):1-b(t,o)}function h(t,o){return o>0?a(o/2,t/2):Number.NaN}function r(t,o){const u=h(t,o);return Number.isNaN(u)?Number.NaN:Math.min(1,Math.max(0,1-u))}}),We("packages/core/src/compute/linalg.js",function(e,D){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return Z}});function ne(H){const x=H.length,X=Array.from({length:x},()=>new Array(x).fill(0));for(let U=0;U<x;U++)for(let j=0;j<=U;j++){let k=H[U][j];for(let b=0;b<j;b++)k-=X[U][b]*X[j][b];if(U===j){if(!(k>0))return null;X[U][j]=Math.sqrt(k)}else X[U][j]=k/X[j][j]}return X}function P(H,x){const X=H.length,U=new Array(X).fill(0);for(let k=0;k<X;k++){let b=x[k];for(let a=0;a<k;a++)b-=H[k][a]*U[a];U[k]=b/H[k][k]}const j=new Array(X).fill(0);for(let k=X-1;k>=0;k--){let b=U[k];for(let a=k+1;a<X;a++)b-=H[a][k]*j[a];j[k]=b/H[k][k]}return j}function Y(H){const x=H.length,X=Array.from({length:x},()=>new Array(x).fill(0));for(let U=0;U<x;U++){const j=new Array(x).fill(0);j[U]=1;const k=P(H,j);for(let b=0;b<x;b++)X[b][U]=k[b]}return X}function _(H,x,X){const U=H.length,j=U?H[0].length:0,k=Array.from({length:j},()=>new Array(j).fill(0)),b=new Array(j).fill(0);for(let a=0;a<U;a++){const h=X?X[a]:1,r=H[a];for(let t=0;t<j;t++){const o=h*r[t];b[t]+=o*x[a];for(let u=t;u<j;u++)k[t][u]+=o*r[u]}}for(let a=0;a<j;a++)for(let h=0;h<a;h++)k[a][h]=k[h][a];return{xtwx:k,xtwy:b}}function L(H,x){return H.map(X=>X.reduce((U,j,k)=>U+j*x[k],0))}function Z(H,x){let X=0;for(let U=0;U<H.length;U++){let j=0;for(let k=0;k<H.length;k++)j+=x[U][k]*H[k];X+=H[U]*j}return X}}),We("packages/core/src/compute/sketch.js",function(e,D){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});class ne{#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(a){if(!Number.isFinite(a))return;this.#e++;const h=a-this.#t;this.#t+=h/this.#e,this.#n+=h*(a-this.#t)}merge(a){if(a.#e===0)return;if(this.#e===0){this.#e=a.#e,this.#t=a.#t,this.#n=a.#n;return}const h=this.#e+a.#e,r=a.#t-this.#t;this.#t+=r*(a.#e/h),this.#n+=a.#n+r*r*(this.#e*a.#e/h),this.#e=h}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 a=this.variance();return a===null?null:Math.sqrt(a)}stddevP(){const a=this.varianceP();return a===null?null:Math.sqrt(a)}}class P{#e=[];#t=0;#n;#r;constructor(a,h=Math.random){if(!(a>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(a),this.#r=h}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(a){if(!Number.isFinite(a))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(a);return}const h=Math.floor(this.#r()*this.#t);h<this.#n&&(this.#e[h]=a)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let a=0;for(const h of this.#e)a+=h;return a/this.#e.length}quantile(a){const h=this.#e.length;if(!h)return null;const r=this.#e.slice().sort((d,s)=>d-s);if(h===1)return r[0];const t=(h-1)*Math.min(1,Math.max(0,a)),o=Math.floor(t),u=Math.ceil(t);return o===u?r[o]:r[o]+(t-o)*(r[u]-r[o])}}function Y(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){if(typeof b=="number"){const r=new DataView(new ArrayBuffer(8));return r.setFloat64(0,b===0?0:b),Y(r.getUint32(0)^r.getUint32(4))}const a=typeof b=="string"?b:String(b);let h=2166136261;for(let r=0;r<a.length;r++)h^=a.charCodeAt(r),h=Math.imul(h,16777619);return Y(h)}class L{#e;#t;#n;constructor(a=14){const h=Math.floor(a);if(h<4||h>16)throw new RangeError("HLL precision must be 4..16");this.#e=h,this.#t=1<<h,this.#n=new Uint8Array(this.#t)}static errorBoundFor(a=14){const h=1<<Math.floor(a),r=1.04/Math.sqrt(h);return Object.freeze({kind:"probabilistic",metric:"relative",value:r,statement:`distinct count within ~${(r*100).toFixed(2)}% relative standard error (m=${h} buckets)`})}errorBound(){return L.errorBoundFor(this.#e)}add(a){const h=_(a),r=h&this.#t-1,t=h>>>this.#e|1<<32-this.#e;let o=1,u=t;for(;(u&1)===0;)o++,u>>>=1;o>this.#n[r]&&(this.#n[r]=o)}count(){const a=this.#t,h=32-this.#e,r=new Float64Array(h+2);for(let u=0;u<a;u++)r[this.#n[u]]++;let t=a*x(1-r[h+1]/a);for(let u=h;u>=1;u--)t=.5*(t+r[u]);t+=a*H(r[0]/a);const o=Z*a*a/t;return Math.round(o)}}const Z=.5/Math.log(2);function H(b){if(b===1)return 1/0;let a=1,h=b,r;do b*=b,r=h,h+=b*a,a+=a;while(h!==r);return h}function x(b){if(b===0||b===1)return 0;let a=1,h=1-b,r;do b=Math.sqrt(b),r=h,a*=.5,h-=(1-b)**2*a;while(h!==r);return h/3}class X{#e=new Map;#t;#n=0;constructor(a){if(!(a>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(a)}errorBoundFor(a){const h=a/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:h,statement:`each count overestimates the truth by at most N/m = ${h.toFixed(2)} (N=${a}, m=${this.#t})`})}get seen(){return this.#n}add(a){this.#n++;const h=this.#e.get(a);if(h){h.count++;return}if(this.#e.size<this.#t){this.#e.set(a,{count:1,error:0});return}let r,t=1/0;for(const[o,u]of this.#e)u.count<t&&(t=u.count,r=o);this.#e.delete(r),this.#e.set(a,{count:t+1,error:t})}top(a=this.#t){return[...this.#e.entries()].map(([r,t])=>({item:r,count:t.count,error:t.error})).sort((r,t)=>t.count-r.count).slice(0,Math.max(0,Math.floor(a)))}}class U{#e;#t=[[]];#n=0;#r;#s;constructor(a=200,h=Math.random){this.#e=Math.max(8,Math.floor(a)),this.#r=h,this.#s=2/3}static errorBoundFor(a=200){const h=1/Math.max(8,Math.floor(a));return Object.freeze({kind:"probabilistic",metric:"rank",value:h,statement:`queried quantile's true rank within ~${(h*100).toFixed(2)}% of N of the requested rank (k=${a})`})}errorBound(){return U.errorBoundFor(this.#e)}get count(){return this.#n}#i(a){const r=this.#t.length-1-a,t=Math.ceil(this.#e*this.#s**r);return Math.max(2,t)}add(a){Number.isFinite(a)&&(this.#n++,this.#t[0].push(a),this.#t[0].length>=this.#i(0)&&this.#o(0))}#o(a){const h=this.#t[a];h.sort((o,u)=>o-u),a+1>=this.#t.length&&this.#t.push([]);const r=this.#t[a+1],t=this.#r()<.5?0:1;for(let o=t;o<h.length;o+=2)r.push(h[o]);this.#t[a]=[];for(let o=0;o<this.#t.length;o++)if(this.#t[o].length>=this.#i(o)){this.#o(o);return}}#l(){const a=[];for(let h=0;h<this.#t.length;h++){const r=1<<h;for(const t of this.#t[h])a.push({v:t,w:r})}return a}quantile(a){const h=this.#l();if(!h.length)return null;h.sort((u,d)=>u.v-d.v);let r=0;for(const u of h)r+=u.w;const t=Math.min(1,Math.max(0,a))*r;let o=0;for(const u of h)if(o+=u.w,o>=t)return u.v;return h[h.length-1].v}rank(a){let h=0;for(let r=0;r<this.#t.length;r++){const t=1<<r;for(const o of this.#t[r])o<=a&&(h+=t)}return h}}const j=Object.freeze({distinct:L.errorBoundFor(14),median:U.errorBoundFor(200),p25:U.errorBoundFor(200),p75:U.errorBoundFor(200),p90:U.errorBoundFor(200),p95:U.errorBoundFor(200),p99:U.errorBoundFor(200),iqr:U.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),k={Welford:ne,Reservoir:P,HyperLogLog:L,SpaceSaving:X,KLL:U,hash32:_,SKETCH_BOUNDS:j}}),We("packages/core/src/compute/statistics.js",function(e,D){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return it}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return Ae}});const ne=D("packages/core/src/compute/handle.js"),P=ne.presenceReader,Y=ne.valueReader,_=D("packages/core/src/compute/special.js"),L=_.studentTQuantile,Z=_.studentT,H=_.normalQuantile,x=_.normalCdf,X=_.chiSquareUpperTail,U=D("packages/core/src/compute/linalg.js"),j=U.cholesky,k=U.choleskySolve,b=U.choleskyInverse,a=U.normalEquations,h=U.quadForm,t=D("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,o=5e3,u=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",percentile:"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"}),d=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:t.distinct}),median:Object.freeze({sketch:"KLL",bound:t.median}),p25:Object.freeze({sketch:"KLL",bound:t.p25}),p75:Object.freeze({sketch:"KLL",bound:t.p75}),p90:Object.freeze({sketch:"KLL",bound:t.p90}),p95:Object.freeze({sketch:"KLL",bound:t.p95}),p99:Object.freeze({sketch:"KLL",bound:t.p99}),iqr:Object.freeze({sketch:"KLL",bound:t.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK})});function s(ge){const Le=ge==="sum"||ge==="avg"||ge==="countValues"||ge==="min"||ge==="max"?"maintained":Object.prototype.hasOwnProperty.call(u,ge)?u[ge]:null,Me=Object.prototype.hasOwnProperty.call(d,ge)?d[ge]:null;return{stat:ge,exact:Le,approximate:Me}}function g(ge,Le){const Me=Le.length,He=new Float64Array(Me);let ce=0;if(ge&&(ge.kind==="float64"||ge.kind==="int32")){const Te=ge.values,xe=P(ge);for(let _e=0;_e<Me;_e++){const Ye=Le[_e];if(xe&&xe(Ye)!==1)continue;const Qe=Te[Ye];Number.isNaN(Qe)||(He[ce++]=Qe)}return He.subarray(0,ce)}const Pe=Y(ge);for(let Te=0;Te<Me;Te++){const xe=Pe(Le[Te]);if(xe==null||xe==="")continue;const _e=typeof xe=="number"?xe:Number(xe);Number.isFinite(_e)&&(He[ce++]=_e)}return He.subarray(0,ce)}function i(ge,Le){const Me=new Map,He=Y(ge);let ce=0;for(let Pe=0;Pe<Le.length;Pe++){const Te=He(Le[Pe]);if(Te==null||Te===""||typeof Te=="number"&&Number.isNaN(Te))continue;const xe=typeof Te=="object"?String(Te):Te;Me.set(xe,(Me.get(xe)||0)+1),ce++}const ae=[...Me.values()].sort((Pe,Te)=>Te-Pe);return{counts:ae,total:ce,distinct:ae.length}}function n(ge){return ge.total>0?ge.counts.map(Le=>Le/ge.total):[]}function f(ge,Le){const Me=i(ge,Le);if(!Me.total)return null;let He=0;for(const ce of n(Me))He+=ce*ce;return He}function p(ge,Le){const Me=i(ge,Le);if(!Me.total)return null;let He=0;for(const ce of n(Me))ce>0&&(He-=ce*Math.log2(ce));return He}function l(ge,Le){const Me=i(ge,Le);if(!Me.total||Me.distinct<2)return Me.total?1:null;let He=0;for(const ce of n(Me))ce>0&&(He-=ce*Math.log2(ce));return He/Math.log2(Me.distinct)}function y(ge,Le,Me=3){const He=i(ge,Le);if(!He.total)return null;const ce=Math.max(1,Math.floor(Me));let ae=0;for(let Pe=0;Pe<Math.min(ce,He.counts.length);Pe++)ae+=He.counts[Pe];return ae/He.total}function c(ge,Le){const Me=g(ge,Le),He=Me.length;if(!He)return null;const ce=Me.slice().sort();if(ce[0]<0)return null;let ae=0,Pe=0;for(let Te=0;Te<He;Te++)ae+=ce[Te],Pe+=(Te+1)*ce[Te];return ae===0?0:2*Pe/(He*ae)-(He+1)/He}function m(ge){let Le=0,Me=0,He=0;for(let ce=0;ce<ge.length;ce++){const ae=ge[ce];Le++;const Pe=ae-Me;Me+=Pe/Le,He+=Pe*(ae-Me)}return{n:Le,mean:Me,m2:He}}function w(ge,Le){const Me=ge.length;if(!Me)return NaN;if(Me===1)return ge[0];const He=(Me-1)*Math.min(1,Math.max(0,Le)),ce=Math.floor(He),ae=Math.ceil(He);return ce===ae?ge[ce]:ge[ce]+(He-ce)*(ge[ae]-ge[ce])}function v(ge,Le){if(!ge.length)return NaN;const Me=ge.slice().sort();return w(Me,Le)}function E(ge,Le){const Me=Y(ge);let He=0,ce=0,ae=0;for(let Pe=0;Pe<Le.length;Pe++){const Te=Me(Le[Pe]);if(Te==null||Te==="")continue;const xe=String(Te).toUpperCase();xe==="PASS"?He++:xe==="FAIL"?ce++:xe==="WARN"&&ae++}return{pass:He+ae,fail:ce,warn:ae,judged:He+ae+ce}}const V=Object.freeze({hhi:(ge,Le)=>f(ge,Le),entropy:(ge,Le)=>p(ge,Le),evenness:(ge,Le)=>l(ge,Le),top3Share:(ge,Le)=>y(ge,Le,3),top10Share:(ge,Le)=>y(ge,Le,10),gini:(ge,Le)=>c(ge,Le),trimmedMean:(ge,Le)=>T(g(ge,Le),.1),winsorizedMean:(ge,Le)=>A(g(ge,Le),.1),robustOutliers:(ge,Le)=>N(g(ge,Le),3.5),jarqueBera:(ge,Le)=>C(g(ge,Le)),variance:(ge,Le)=>{const{n:Me,m2:He}=m(g(ge,Le));return Me>1?He/(Me-1):null},varianceP:(ge,Le)=>{const{n:Me,m2:He}=m(g(ge,Le));return Me>0?He/Me:null},stddev:(ge,Le)=>{const{n:Me,m2:He}=m(g(ge,Le));return Me>1?Math.sqrt(He/(Me-1)):null},stddevP:(ge,Le)=>{const{n:Me,m2:He}=m(g(ge,Le));return Me>0?Math.sqrt(He/Me):null},median:(ge,Le)=>{const Me=g(ge,Le);return Me.length?v(Me,.5):null},percentile:(ge,Le,Me)=>{const He=Me?Me.p:void 0;if(typeof He!="number"||!(He>=0&&He<=1))return null;const ce=g(ge,Le);return ce.length?v(ce,He):null},p25:(ge,Le)=>{const Me=g(ge,Le);return Me.length?v(Me,.25):null},p75:(ge,Le)=>{const Me=g(ge,Le);return Me.length?v(Me,.75):null},p90:(ge,Le)=>{const Me=g(ge,Le);return Me.length?v(Me,.9):null},p95:(ge,Le)=>{const Me=g(ge,Le);return Me.length?v(Me,.95):null},p99:(ge,Le)=>{const Me=g(ge,Le);return Me.length?v(Me,.99):null},iqr:(ge,Le)=>{const Me=g(ge,Le);if(!Me.length)return null;const He=Me.slice().sort();return w(He,.75)-w(He,.25)},mad:(ge,Le)=>{const Me=g(ge,Le);if(!Me.length)return null;const He=v(Me,.5),ce=new Float64Array(Me.length);for(let ae=0;ae<Me.length;ae++)ce[ae]=Math.abs(Me[ae]-He);return v(ce,.5)},range:(ge,Le)=>{const Me=g(ge,Le);if(!Me.length)return null;let He=1/0,ce=-1/0;for(let ae=0;ae<Me.length;ae++)Me[ae]<He&&(He=Me[ae]),Me[ae]>ce&&(ce=Me[ae]);return ce-He},distinct:(ge,Le)=>{const Me=Y(ge),He=new Set;for(let ce=0;ce<Le.length;ce++){const ae=Me(Le[ce]);ae==null||ae===""||He.add(ae instanceof Date?ae.getTime():ae)}return He.size},mode:(ge,Le)=>{const Me=Y(ge),He=new Map;for(let Pe=0;Pe<Le.length;Pe++){const Te=Me(Le[Pe]);if(Te==null||Te==="")continue;const xe=Te instanceof Date?Te.getTime():Te;He.set(xe,(He.get(xe)||0)+1)}let ce=null,ae=1;for(const[Pe,Te]of He)Te>ae&&(ae=Te,ce=Pe);return ce},skewness:(ge,Le)=>{const Me=g(ge,Le),{n:He,mean:ce,m2:ae}=m(Me);if(He<3||ae<=0)return null;const Pe=Math.sqrt(ae/(He-1));let Te=0;for(let xe=0;xe<Me.length;xe++)Te+=((Me[xe]-ce)/Pe)**3;return He/((He-1)*(He-2))*Te},kurtosis:(ge,Le)=>{const Me=g(ge,Le),{n:He,mean:ce,m2:ae}=m(Me);if(He<4||ae<=0)return null;const Pe=Math.sqrt(ae/(He-1));let Te=0;for(let Ye=0;Ye<Me.length;Ye++)Te+=((Me[Ye]-ce)/Pe)**4;const xe=He*(He+1)/((He-1)*(He-2)*(He-3)),_e=3*(He-1)**2/((He-2)*(He-3));return xe*Te-_e},geomean:(ge,Le)=>{const Me=g(ge,Le);if(!Me.length)return null;let He=0;for(let ce=0;ce<Me.length;ce++){if(Me[ce]<=0)return null;He+=Math.log(Me[ce])}return Math.exp(He/Me.length)},harmean:(ge,Le)=>{const Me=g(ge,Le);if(!Me.length)return null;let He=0;for(let ce=0;ce<Me.length;ce++){if(Me[ce]===0)return null;He+=1/Me[ce]}return Me.length/He},sumSquares:(ge,Le)=>{const Me=g(ge,Le);let He=0;for(let ce=0;ce<Me.length;ce++)He+=Me[ce]*Me[ce];return He},passRate:(ge,Le)=>{const{pass:Me,judged:He}=E(ge,Le);return He?Me/He:null},failureCount:(ge,Le)=>E(ge,Le).fail}),G=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",percentile:"Percentile",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function q(ge,Le,Me){const He=Y(ge),ce=Y(Le);let ae=0,Pe=0;for(let Te=0;Te<Me.length;Te++){const xe=Me[Te],_e=Number(He(xe)),Ye=Number(ce(xe));!Number.isFinite(_e)||!Number.isFinite(Ye)||(ae+=_e*Ye,Pe+=Ye)}return Pe===0?null:ae/Pe}function M(ge,Le,Me){const He=Y(ge);let ce=null,ae=Me?-1/0:1/0;for(let Pe=0;Pe<Le.length;Pe++){const Te=Le[Pe],xe=Number(He(Te));Number.isFinite(xe)&&(Me?xe>ae:xe<ae)&&(ae=xe,ce=Te)}return ce}function O(ge,Le,Me){const He=Y(ge),ce=Y(Le);let ae=0,Pe=0,Te=0,xe=0,_e=0,Ye=0;for(let bt=0;bt<Me.length;bt++){const Rt=Me[bt],Dt=Number(He(Rt)),Ct=Number(ce(Rt));!Number.isFinite(Dt)||!Number.isFinite(Ct)||(ae++,Pe+=Dt,Te+=Ct,xe+=Dt*Dt,_e+=Ct*Ct,Ye+=Dt*Ct)}if(ae<2)return null;const Qe=ae*Ye-Pe*Te,ut=Math.sqrt((ae*xe-Pe*Pe)*(ae*_e-Te*Te));if(ut===0)return null;const mt=Qe/ut;return Math.max(-1,Math.min(1,mt))}function T(ge,Le=.1){const Me=ge.length;if(!Me)return null;const He=Array.from(ge).sort((Te,xe)=>Te-xe),ce=Math.floor(Me*Math.min(.49,Math.max(0,Le))),ae=He.slice(ce,Me-ce);if(!ae.length)return w(He,.5);let Pe=0;for(const Te of ae)Pe+=Te;return Pe/ae.length}function A(ge,Le=.1){const Me=ge.length;if(!Me)return null;const He=Array.from(ge).sort((xe,_e)=>xe-_e),ce=Math.floor(Me*Math.min(.49,Math.max(0,Le))),ae=He[ce],Pe=He[Me-1-ce];let Te=0;for(const xe of He)Te+=Math.min(Pe,Math.max(ae,xe));return Te/Me}function N(ge,Le=3.5){if(!ge.length)return null;const He=Array.from(ge).sort((xe,_e)=>xe-_e),ce=w(He,.5),ae=He.map(xe=>Math.abs(xe-ce)).sort((xe,_e)=>xe-_e),Pe=w(ae,.5);if(Pe===0)return null;let Te=0;for(const xe of He)Math.abs(.6745*(xe-ce)/Pe)>Le&&Te++;return Te}function C(ge){const Le=ge.length;if(Le<8)return null;let Me=0;for(const xe of ge)Me+=xe;Me/=Le;let He=0,ce=0,ae=0;for(const xe of ge){const _e=xe-Me;He+=_e*_e,ce+=_e*_e*_e,ae+=_e*_e*_e*_e}if(He/=Le,ce/=Le,ae/=Le,He===0)return null;const Pe=ce/He**1.5,Te=ae/(He*He)-3;return Le/6*(Pe*Pe+Te*Te/4)}function S(ge,Le,Me){const He=[];let ce=0;for(let xe=0;xe<ge.length;xe++){const _e=Number(ge[xe]),Ye=Number(Le[xe]);!Number.isFinite(_e)||!Number.isFinite(Ye)||Ye<=0||(He.push([_e,Ye]),ce+=Ye)}if(!He.length||ce<=0)return null;if(He.sort((xe,_e)=>xe[0]-_e[0]),He.length===1)return He[0][0];const ae=[];let Pe=0;for(const[,xe]of He)ae.push((Pe+xe/2)/ce),Pe+=xe;const Te=Math.max(0,Math.min(1,Me));if(Te<=ae[0])return He[0][0];if(Te>=ae[ae.length-1])return He[He.length-1][0];for(let xe=1;xe<ae.length;xe++){if(Te>ae[xe])continue;const _e=ae[xe]-ae[xe-1],Ye=_e>0?(Te-ae[xe-1])/_e:0;return He[xe-1][0]+(He[xe][0]-He[xe-1][0])*Ye}return He[He.length-1][0]}function F(ge,Le,Me){const He=Y(ge),ce=Y(Le),ae=new Float64Array(Me.length),Pe=new Float64Array(Me.length);let Te=0;for(let xe=0;xe<Me.length;xe++){const _e=Me[xe],Ye=Number(He(_e)),Qe=Number(ce(_e));!Number.isFinite(Ye)||!Number.isFinite(Qe)||(ae[Te]=Ye,Pe[Te]=Qe,Te++)}return{xs:ae.subarray(0,Te),ys:Pe.subarray(0,Te),n:Te}}function $(ge,Le,Me,He=!1){const{xs:ce,ys:ae,n:Pe}=F(ge,Le,Me);if(Pe<2)return null;let Te=0,xe=0;for(let Ye=0;Ye<Pe;Ye++)Te+=ce[Ye],xe+=ae[Ye];Te/=Pe,xe/=Pe;let _e=0;for(let Ye=0;Ye<Pe;Ye++)_e+=(ce[Ye]-Te)*(ae[Ye]-xe);return _e/(He?Pe:Pe-1)}function W(ge,Le,Me){const{xs:He,ys:ce,n:ae}=F(ge,Le,Me);if(ae<2)return null;let Pe=0,Te=0;for(let Dt=0;Dt<ae;Dt++)Pe+=He[Dt],Te+=ce[Dt];Pe/=ae,Te/=ae;let xe=0,_e=0,Ye=0;for(let Dt=0;Dt<ae;Dt++){const Ct=He[Dt]-Pe,_t=ce[Dt]-Te;xe+=Ct*Ct,_e+=Ct*_t,Ye+=_t*_t}if(xe===0)return null;const Qe=_e/xe,ut=Te-Qe*Pe,mt=Ye===0?1:Math.max(0,Math.min(1,_e*_e/(xe*Ye))),bt=Math.max(0,Ye-Qe*_e),Rt=ae>2?Math.sqrt(bt/(ae-2)/xe):0;return{slope:Qe,intercept:ut,r2:mt,stdError:Rt,n:ae}}const K=new Set(["ols","wls","robust"]),I=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),J=1.345;function te(ge,Le,Me){const{xtwx:He,xtwy:ce}=a(ge,Le,Me),ae=j(He);if(!ae)return null;const Pe=k(ae,ce),Te=b(ae),xe=Q(ge,Pe),_e=Le.map((Ye,Qe)=>Ye-xe[Qe]);return{beta:Pe,cov:Te,fitted:xe,residuals:_e}}function Q(ge,Le){return ge.map(Me=>Me.reduce((He,ce,ae)=>He+ce*Le[ae],0))}function re(ge,Le){const Me=ge.length,He=ge.map(_e=>_e[Le]),ce=ge.map(_e=>[1,..._e.filter((Ye,Qe)=>Qe!==Le)]),ae=te(ce,He,null);if(!ae)return 1;const Pe=He.reduce((_e,Ye)=>_e+Ye,0)/Me;let Te=0,xe=0;for(let _e=0;_e<Me;_e++)Te+=ae.residuals[_e]**2,xe+=(He[_e]-Pe)**2;return xe===0?1:Math.max(0,Math.min(1,1-Te/xe))}function ie(ge){const Le=[...ge].sort((ce,ae)=>ce-ae),Me=ue(Le),He=ge.map(ce=>Math.abs(ce-Me)).sort((ce,ae)=>ce-ae);return ue(He)/.6745}function ue(ge){const Le=ge.length;if(!Le)return 0;const Me=Math.floor(Le/2);return Le%2?ge[Me]:(ge[Me-1]+ge[Me])/2}function ke(ge,Le,Me={}){const He=Me.method||"ols";if(B.has(He))throw new Error(`[lattice] regression method "${He}" is out of scope; use ols, wls or robust.`);if(I.has(He))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!K.has(He))throw new Error(`[lattice] unknown regression method "${He}"; use ols, wls or robust.`);const ce=Array.isArray(Le)?Le.length:0,ae=ce&&Array.isArray(ge[0])?ge[0].length:0,Pe=ae+1;if(!(ce>Pe))return null;for(let jt=0;jt<ce;jt++){if(!Number.isFinite(Le[jt])||!Array.isArray(ge[jt])||ge[jt].length!==ae)return null;for(let $t=0;$t<ae;$t++)if(!Number.isFinite(ge[jt][$t]))return null}let Te=null;if(He==="wls"){if(Te=Me.weights,!Array.isArray(Te)||Te.length!==ce)return null;for(let jt=0;jt<ce;jt++)if(!(Te[jt]>0)||!Number.isFinite(Te[jt]))return null}const xe=ge.map(jt=>[1,...jt]);let _e,Ye=null;if(He==="robust"){if(_e=te(xe,Le,null),!_e)return null;for(let jt=0;jt<50;jt++){const $t=ie(_e.residuals);if(!($t>0))break;const Vt=_e.residuals.map(Ut=>{const Gt=Math.abs(Ut/$t);return Gt<=J?1:J/Gt}),zt=te(xe,Le,Vt);if(!zt)return null;const Wt=zt.beta.reduce((Ut,Gt,It)=>Math.max(Ut,Math.abs(Gt-_e.beta[It])),0);if(_e=zt,Ye=Vt,Wt<1e-10)break}}else if(_e=te(xe,Le,Te),!_e)return null;const Qe=He==="robust"?Ye:Te,{beta:ut,cov:mt,fitted:bt,residuals:Rt}=_e;let Dt=0,Ct=0,_t=0;for(let jt=0;jt<ce;jt++){const $t=Qe?Qe[jt]:1;Dt+=$t*Rt[jt]**2,Ct+=$t,_t+=$t*Le[jt]}const tn=_t/Ct;let Ht=0;for(let jt=0;jt<ce;jt++){const $t=Qe?Qe[jt]:1;Ht+=$t*(Le[jt]-tn)**2}const Xt=ce-Pe,Je=Dt/Xt,at=Ht===0?1:Math.max(0,Math.min(1,1-Dt/Ht)),St=1-(1-at)*(ce-1)/Xt,wt=Array.isArray(Me.names)&&Me.names.length===ae?Me.names:ge[0].map((jt,$t)=>`x${$t+1}`),vt=qe(Me.confidence),Xe=Xt>0?L(1-(1-vt)/2,Xt):1/0,ht=ut.map((jt,$t)=>{const Vt=Math.sqrt(Math.max(0,Je*mt[$t][$t])),zt=Vt>0?jt/Vt:jt===0?0:1/0,Wt=Number.isFinite(zt)?2*(1-Z(Math.abs(zt),Xt)):0,Ut=Number.isFinite(Xe)?Xe*Vt:null;return{name:$t===0?"(intercept)":wt[$t-1],estimate:jt,stdError:Vt,t:zt,p:Math.max(0,Math.min(1,Wt)),lower:Ut===null?null:jt-Ut,upper:Ut===null?null:jt+Ut}}),ot=new Array(ce),gt=new Array(ce);for(let jt=0;jt<ce;jt++){const $t=Qe?Qe[jt]:1,Vt=Math.max(0,Math.min(1,$t*h(xe[jt],mt)));ot[jt]=Vt;const zt=(1-Vt)**2;gt[jt]=zt>0&&Je>0?Rt[jt]**2/(Pe*Je)*(Vt/zt):null}const xt=ge[0].map((jt,$t)=>{if(ae<2)return 1;const Vt=re(ge,$t);return Vt>=1?1/0:1/(1-Vt)});let Lt=null;{const jt=Rt.map(Vt=>Vt*Vt),$t=te(xe,jt,null);if($t){const Vt=jt.reduce((Jt,ln)=>Jt+ln,0)/ce;let zt=0,Wt=0;for(let Jt=0;Jt<ce;Jt++)zt+=$t.residuals[Jt]**2,Wt+=(jt[Jt]-Vt)**2;const Ut=Wt===0?0:Math.max(0,Math.min(1,1-zt/Wt)),Gt=ce*Ut,It=X(Gt,ae);Lt={statistic:Gt,df:ae,p:It,heteroscedastic:It<.05}}}let kt=null;if(ae===1){const jt=ge.map(($t,Vt)=>Vt).sort(($t,Vt)=>ge[$t][0]-ge[Vt][0]);kt={confidence:vt,points:jt.map($t=>{const Vt=xe[$t],zt=Math.sqrt(Math.max(0,Je*h(Vt,mt)));return{x:ge[$t][0],yhat:bt[$t],lower:bt[$t]-Xe*zt,upper:bt[$t]+Xe*zt}})}}return{method:He,coefficients:ht,r2:at,adjR2:St,n:ce,df:Xt,sigma2:Je,fitted:bt,residuals:Rt,leverage:ot,cooksD:gt,vif:xt,heteroscedasticity:Lt,band:kt,weights:Qe?[...Qe]:null}}function de(ge){const Le=ge.length,Me=Array.from({length:Le},(ae,Pe)=>Pe).sort((ae,Pe)=>ge[ae]-ge[Pe]),He=new Float64Array(Le);let ce=0;for(;ce<Le;){let ae=ce;for(;ae+1<Le&&ge[Me[ae+1]]===ge[Me[ce]];)ae++;const Pe=(ce+ae)/2+1;for(let Te=ce;Te<=ae;Te++)He[Me[Te]]=Pe;ce=ae+1}return He}const we=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function ve(ge){const Le=[.01,.05,.1],Me=[we["1%"],we["5%"],we["10%"]];if(ge<=Me[0]){const ae=(Math.log(Le[1])-Math.log(Le[0]))/(Me[1]-Me[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(Le[0])+ae*(ge-Me[0]))))}if(ge>=Me[2]){const ae=(Math.log(Le[2])-Math.log(Le[1]))/(Me[2]-Me[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(Le[2])+ae*(ge-Me[2]))))}const He=ge<Me[1]?0:1,ce=(ge-Me[He])/(Me[He+1]-Me[He]);return Math.exp(Math.log(Le[He])+ce*(Math.log(Le[He+1])-Math.log(Le[He])))}function De(ge,Le,Me,He){const ce=Me-He,ae=He+3,Pe=new Array(ce),Te=new Array(ce);let xe=!0,_e=He;for(let bt=0;bt<ce;bt++){const Rt=He+bt,Dt=new Float64Array(ae);Dt[0]=1,Dt[1]=bt+1,Dt[2]=ge[Rt];for(let Ct=1;Ct<=He;Ct++)Dt[2+Ct]=Le[Rt-Ct];for(let Ct=1;Ct<ae;Ct++)Number.isFinite(Dt[Ct])||(_e=Math.min(_e,Ct-3));Pe[bt]=Dt,Te[bt]=Le[Rt],Number.isFinite(Te[bt])||(xe=!1)}if(!xe)return 0;const{xtwx:Ye,xtwy:Qe}=a(Pe,Te,null);let ut=0,mt=1/0;for(let bt=0;bt<=_e;bt++){const Rt=bt+3;if(!(ce>Rt))continue;const Dt=new Array(Rt);for(let at=0;at<Rt;at++)Dt[at]=Ye[at].slice(0,Rt);const Ct=j(Dt);if(!Ct)continue;const _t=k(Ct,Qe.slice(0,Rt));let tn=0;for(let at=0;at<ce;at++){const St=Pe[at];let wt=0;for(let vt=0;vt<Rt;vt++)wt+=St[vt]*_t[vt];tn+=(Te[at]-wt)**2}const Xt=tn/(ce-Rt)*(ce-Rt);if(!(Xt>0))continue;const Je=ce*Math.log(Xt/ce)+2*Rt;Je<mt&&(mt=Je,ut=bt)}return ut}function pe(ge,Le={}){const Me=[];for(let mt=0;mt<ge.length;mt++){const bt=Number(ge[mt]);Number.isFinite(bt)&&Me.push(bt)}const He=Me.length,ce=He-1;if(He<8||ce<6)return null;const ae=new Array(ce);for(let mt=0;mt<ce;mt++)ae[mt]=Me[mt+1]-Me[mt];let Pe=Number.isFinite(Le.maxlag)?Math.floor(Le.maxlag):Math.ceil(12*(He/100)**.25);Pe=Math.max(0,Math.min(Pe,Math.floor((ce-5)/2)));const Te=(mt,bt)=>{const Rt=[],Dt=[];for(let Ct=bt;Ct<ce;Ct++){const _t=[Ct-bt+1,Me[Ct]];for(let tn=1;tn<=mt;tn++)_t.push(ae[Ct-tn]);Rt.push(_t),Dt.push(ae[Ct])}return ke(Rt,Dt,{method:"ols"})},xe=De(Me,ae,ce,Pe),_e=Te(xe,xe);if(!_e||!_e.coefficients[2])return null;const Ye=_e.coefficients[2].t,Qe=ve(Ye),ut=Ye<we["5%"];return{statistic:Ye,usedLag:xe,nobs:ce-xe,criticalValues:{...we},pValue:Qe,pApproximate:!0,stationary:ut,verdict:ut?"stationary":"non-stationary",regression:"ct"}}function oe(ge,Le={}){const Me=[];for(let ut=0;ut<ge.length;ut++){const mt=Number(ge[ut]);Number.isFinite(mt)&&Me.push(mt)}const He=Me.length;if(He<3)return null;let ce=Number.isFinite(Le.maxlag)?Math.floor(Le.maxlag):Math.min(10,He-1);ce=Math.max(1,Math.min(ce,He-1));let ae=0;for(const ut of Me)ae+=ut;ae/=He;const Pe=Me.map(ut=>ut-ae);let Te=0;for(const ut of Pe)Te+=ut*ut;Te/=He;const xe=new Array(ce+1).fill(0);xe[0]=1;for(let ut=1;ut<=ce;ut++){let mt=0;for(let bt=ut;bt<He;bt++)mt+=Pe[bt]*Pe[bt-ut];xe[ut]=Te>0?mt/He/Te:0}const _e=new Array(ce+1).fill(0);_e[0]=1;let Ye=[];for(let ut=1;ut<=ce;ut++){let mt=xe[ut];for(let Ct=1;Ct<ut;Ct++)mt-=Ye[Ct-1]*xe[ut-Ct];let bt=1;for(let Ct=1;Ct<ut;Ct++)bt-=Ye[Ct-1]*xe[Ct];const Rt=bt!==0?mt/bt:0,Dt=new Array(ut);for(let Ct=1;Ct<ut;Ct++)Dt[Ct-1]=Ye[Ct-1]-Rt*Ye[ut-1-Ct];Dt[ut-1]=Rt,_e[ut]=Rt,Ye=Dt}const Qe=1.96/Math.sqrt(He);return{acf:xe,pacf:_e,bounds:{upper:Qe,lower:-Qe},n:He,nlags:ce,approximate:!0}}function be(ge,Le,Me){const{xs:He,ys:ce,n:ae}=F(ge,Le,Me);if(ae<2)return null;const Pe=de(He),Te=de(ce);let xe=0,_e=0;for(let mt=0;mt<ae;mt++)xe+=Pe[mt],_e+=Te[mt];xe/=ae,_e/=ae;let Ye=0,Qe=0,ut=0;for(let mt=0;mt<ae;mt++){const bt=Pe[mt]-xe,Rt=Te[mt]-_e;Ye+=bt*Rt,Qe+=bt*bt,ut+=Rt*Rt}return Qe===0||ut===0?null:Math.max(-1,Math.min(1,Ye/Math.sqrt(Qe*ut)))}function fe(ge,Le,Me){const{xs:He,ys:ce,n:ae}=F(ge,Le,Me);if(ae<2||ae>o)return null;let Pe=0,Te=0,xe=0,_e=0;for(let ut=0;ut<ae;ut++)for(let mt=ut+1;mt<ae;mt++){const bt=Math.sign(He[ut]-He[mt]),Rt=Math.sign(ce[ut]-ce[mt]),Dt=bt*Rt;Dt>0?Pe++:Dt<0?Te++:bt===0&&Rt===0||(bt===0?xe++:_e++)}const Ye=Pe+Te+_e,Qe=Pe+Te+xe;return Ye===0||Qe===0?null:(Pe-Te)/Math.sqrt(Ye*Qe)}function le(ge,Le={}){const Me=ge.length;if(Me<2)return null;const He=ge[0],ce=ge[Me-1],ae=[];for(let Ct=1;Ct<Me;Ct++){const _t=ge[Ct-1];_t!==0&&ae.push((ge[Ct]-_t)/Math.abs(_t))}let Pe=null;if(ae.length>1){let Ct=0;for(const tn of ae)Ct+=tn;Ct/=ae.length;let _t=0;for(const tn of ae)_t+=(tn-Ct)**2;Pe=Math.sqrt(_t/(ae.length-1))}const Te=Number(Le.periodsPerYear)>0?Number(Le.periodsPerYear):null;let xe=ge[0],_e=0,Ye=0,Qe=0,ut=0;for(let Ct=1;Ct<Me;Ct++){if(ge[Ct]>xe){xe=ge[Ct],_e=Ct;continue}if(xe<=0)continue;const _t=(xe-ge[Ct])/xe;_t>Ye&&(Ye=_t,Qe=_e,ut=Ct)}let mt=null;if(Me>2){let Ct=0;for(let Ht=0;Ht<Me;Ht++)Ct+=ge[Ht];Ct/=Me;let _t=0,tn=0;for(let Ht=0;Ht<Me;Ht++){const Xt=ge[Ht]-Ct;tn+=Xt*Xt,Ht>0&&(_t+=Xt*(ge[Ht-1]-Ct))}mt=tn>0?_t/tn:null}let bt=0,Rt=0;for(const Ct of ae)Ct>0?bt++:Ct<0&&Rt++;let Dt=null;if(He>0&&ce>0){const Ct=(ce/He)**(1/(Me-1))-1;Dt=Te?(1+Ct)**Te-1:Ct}return{n:Me,first:He,last:ce,change:ce-He,changePercent:He===0?null:(ce-He)/Math.abs(He)*100,volatility:Pe,annualisedVolatility:Pe!==null&&Te?Pe*Math.sqrt(Te):null,growth:Dt,maxDrawdown:Ye,maxDrawdownFrom:Qe,maxDrawdownTo:ut,autocorrelation:mt,upDays:bt,downDays:Rt}}const ye=1.128,Ne=3.267;function je(ge){const Le=ge.length;if(Le<2)return null;const Me=[];for(let ce=1;ce<Le;ce++)Me.push(Math.abs(ge[ce]-ge[ce-1]));const He=Me.reduce((ce,ae)=>ce+ae,0)/Me.length;return{ranges:Me,centre:He,upper:Ne*He,lower:0}}function $e(ge){const Le=ge.length;if(Le<2)return null;let Me=0;for(let ce=1;ce<Le;ce++)Me+=Math.abs(ge[ce]-ge[ce-1]);const He=Me/(Le-1);return{sigma:He/ye,meanRange:He}}function Re(ge,Le){const Me=ge.length;if(Me<2||!Le)return null;const He=Number.isFinite(Number(Le.lower))?Number(Le.lower):null,ce=Number.isFinite(Number(Le.upper))?Number(Le.upper):null;if(He===null&&ce===null)return null;let ae=0;for(let bt=0;bt<Me;bt++)ae+=ge[bt];ae/=Me;let Pe=0;for(let bt=0;bt<Me;bt++)Pe+=(ge[bt]-ae)**2;const Te=Math.sqrt(Pe/(Me-1)),xe=$e(ge),_e=xe?xe.sigma:null,Ye=bt=>{if(!bt||bt<=0)return{index:null,k:null};const Dt=He!==null&&ce!==null?(ce-He)/(6*bt):null,Ct=ce!==null?(ce-ae)/(3*bt):1/0,_t=He!==null?(ae-He)/(3*bt):1/0;return{index:Dt,k:Math.min(Ct,_t)}},Qe=Ye(_e),ut=Ye(Te);let mt=0;for(let bt=0;bt<Me;bt++){if(He!==null&&ge[bt]<He){mt++;continue}ce!==null&&ge[bt]>ce&&mt++}return{n:Me,mean:ae,lower:He,upper:ce,target:Number.isFinite(Number(Le.target))?Number(Le.target):null,sigmaWithin:_e,sigmaOverall:Te,cp:Qe.index,cpk:Qe.k,pp:ut.index,ppk:ut.k,outOfSpec:mt,defectRate:Me?mt/Me:null}}function Se(ge){const Le=ge.length;if(Le<2)return null;const Me=$e(ge);if(!Me||!(Me.sigma>0))return null;let He=0;for(let ce=0;ce<Le;ce++)He+=ge[ce];return He/=Le,{centre:He,sigma:Me.sigma,upper:He+3*Me.sigma,lower:He-3*Me.sigma}}function Ve(ge,Le){if(!Le||!(Le.sigma>0))return[];const Me=ge.length,{centre:He,sigma:ce}=Le,ae=Te=>(ge[Te]-He)/ce,Pe=[];for(let Te=0;Te<Me;Te++){if(Math.abs(ae(Te))>3&&Pe.push({index:Te,rule:1,description:"beyond three sigma"}),Te>=2)for(const xe of[1,-1]){let _e=0;for(let Ye=Te-2;Ye<=Te;Ye++)ae(Ye)*xe>2&&_e++;if(_e>=2){Pe.push({index:Te,rule:2,description:"two of three past two sigma"});break}}if(Te>=4)for(const xe of[1,-1]){let _e=0;for(let Ye=Te-4;Ye<=Te;Ye++)ae(Ye)*xe>1&&_e++;if(_e>=4){Pe.push({index:Te,rule:3,description:"four of five past one sigma"});break}}if(Te>=7)for(const xe of[1,-1]){let _e=!0;for(let Ye=Te-7;Ye<=Te;Ye++)if(ae(Ye)*xe<=0){_e=!1;break}if(_e){Pe.push({index:Te,rule:4,description:"eight in a row on one side"});break}}}return Pe}function Fe(ge,Le){if(!Le||!(Le.sigma>0))return[];const Me=ge.length,{centre:He,sigma:ce}=Le,ae=xe=>(ge[xe]-He)/ce,Pe=(xe,_e,Ye,Qe)=>{for(const ut of[1,-1]){let mt=0;for(let bt=xe;bt<=_e;bt++)ae(bt)*ut>Ye&&mt++;if(mt>=Qe)return!0}return!1},Te=[];for(let xe=0;xe<Me;xe++){if(Math.abs(ae(xe))>3&&Te.push({index:xe,rule:1,description:"beyond three sigma"}),xe>=8)for(const _e of[1,-1]){let Ye=!0;for(let Qe=xe-8;Qe<=xe;Qe++)if(ae(Qe)*_e<=0){Ye=!1;break}if(Ye){Te.push({index:xe,rule:2,description:"nine in a row on one side"});break}}if(xe>=5)for(const _e of[1,-1]){let Ye=!0;for(let Qe=xe-4;Qe<=xe;Qe++)if((ge[Qe]-ge[Qe-1])*_e<=0){Ye=!1;break}if(Ye){Te.push({index:xe,rule:3,description:_e>0?"six rising":"six falling"});break}}if(xe>=13){let _e=!0;for(let Ye=xe-12;Ye<=xe;Ye++){const Qe=ge[Ye]-ge[Ye-1],ut=ge[Ye+1<=xe?Ye+1:Ye]-ge[Ye];if(Ye+1>xe)break;if(Qe===0||ut===0||Qe>0==ut>0){_e=!1;break}}_e&&Te.push({index:xe,rule:4,description:"fourteen alternating"})}if(xe>=2&&Pe(xe-2,xe,2,2)&&Te.push({index:xe,rule:5,description:"two of three past two sigma"}),xe>=4&&Pe(xe-4,xe,1,4)&&Te.push({index:xe,rule:6,description:"four of five past one sigma"}),xe>=14){let _e=!0;for(let Ye=xe-14;Ye<=xe;Ye++)if(Math.abs(ae(Ye))>=1){_e=!1;break}_e&&Te.push({index:xe,rule:7,description:"fifteen within one sigma"})}if(xe>=7){let _e=!0;for(let Ye=xe-7;Ye<=xe;Ye++)if(Math.abs(ae(Ye))<=1){_e=!1;break}_e&&Te.push({index:xe,rule:8,description:"eight beyond one sigma"})}}return Te}const Ce=Object.freeze(["westernElectric","nelson"]);function Ee(ge,Le,Me="westernElectric"){return String(Me)==="nelson"?Fe(ge,Le):Ve(ge,Le)}function Ie(ge,Le,Me){let He=0;for(let ce=0;ce<ge.length;ce++)(ge[ce]<Le||ge[ce]>Me)&&He++;return He}function Be(ge,Le,Me,He=20){const ce=ge.length;if(!ce)return[];const ae=ge[0],Pe=ge[ce-1];if(Pe===ae)return[{from:ae,to:Pe,count:ce}];const Te=Me-Le,xe=1.5*Te;let _e=Te>0?Math.max(ae,Le-xe):ae,Ye=Te>0?Math.min(Pe,Me+xe):Pe;Ye>_e||(_e=ae,Ye=Pe);const Qe=Te>0?2*Te/Math.cbrt(ce):(Ye-_e)/(Math.ceil(Math.log2(ce))+1),ut=Qe>0?Math.min(He,Math.max(1,Math.ceil((Ye-_e)/Qe))):1,mt=(Ye-_e)/ut,bt=[];for(let Rt=0;Rt<ut;Rt++)bt.push({from:_e+Rt*mt,to:_e+(Rt+1)*mt,count:0});for(let Rt=0;Rt<ce;Rt++){const Dt=Math.min(ut-1,Math.max(0,Math.floor((ge[Rt]-_e)/mt)));bt[Dt].count++}return bt[0].from=ae,bt[ut-1].to=Pe,bt}const Ke=.95;function qe(ge){const Le=Number(ge);return Number.isFinite(Le)&&Le>0&&Le<1?Le:Ke}function rt(ge,Le=Ke){const Me=ge.length;if(Me<2)return null;let He=0;for(let Ye=0;Ye<Me;Ye++)He+=ge[Ye];const ce=He/Me;let ae=0;for(let Ye=0;Ye<Me;Ye++){const Qe=ge[Ye]-ce;ae+=Qe*Qe}const Pe=Math.sqrt(ae/(Me-1)),Te=qe(Le),_e=L(1-(1-Te)/2,Me-1)*Pe/Math.sqrt(Me);return{mean:ce,lower:ce-_e,upper:ce+_e,margin:_e,n:Me,confidence:Te}}function nt(ge,Le,Me=Ke){const He=Number(ge),ce=Number(Le);if(!(ce>0)||!(He>=0)||He>ce)return null;const ae=qe(Me),Pe=H(1-(1-ae)/2),Te=He/ce,xe=Pe*Pe,_e=1+xe/ce,Ye=(Te+xe/(2*ce))/_e,Qe=Pe/_e*Math.sqrt(Te*(1-Te)/ce+xe/(4*ce*ce));return{proportion:Te,lower:Math.max(0,Ye-Qe),upper:Math.min(1,Ye+Qe),n:ce,confidence:ae}}function dt(ge,Le=Ke){if(!ge||!(ge.n>2)||!Number.isFinite(ge.stdError))return null;const Me=qe(Le),ce=L(1-(1-Me)/2,ge.n-2)*ge.stdError;return{slope:ge.slope,lower:ge.slope-ce,upper:ge.slope+ce,margin:ce,confidence:Me}}function Pt(ge,Le,Me=Ke){const He=Number(ge),ce=Number(Le);if(!Number.isFinite(He)||!(ce>1))return null;const ae=qe(Me),Te=H(1-(1-ae)/2)*Math.sqrt(1/(9*ce)+He*He/(2*(ce-1)));return{index:He,lower:He-Te,upper:He+Te,margin:Te,n:ce,confidence:ae}}function Nt(ge,Le){return!ge||!(ge.sd>0)||!Number.isFinite(Le)||!Number.isFinite(ge.mean)?null:(Le-ge.mean)/ge.sd}function it(ge){return Number.isFinite(ge)?Math.min(1,Math.max(0,2*x(Math.abs(ge)/2)-1)):0}function ct(ge,Le){const Me=new Map,He=Y(ge);let ce=0;for(let ae=0;ae<Le.length;ae++){const Pe=He(Le[ae]);if(Pe==null||Pe===""||typeof Pe=="number"&&Number.isNaN(Pe))continue;const Te=Pe instanceof Date?Pe.getTime():typeof Pe=="object"?String(Pe):Pe;Me.set(Te,(Me.get(Te)||0)+1),ce++}return{map:Me,total:ce}}function ft(ge,Le,Me,He){if(!(Le>0)||!(He>0))return null;let ce=0;const ae=new Set(ge.keys());for(const Pe of Me.keys())ae.add(Pe);for(const Pe of ae){const Te=(ge.get(Pe)||0)/Le,xe=(Me.get(Pe)||0)/He;ce+=Math.abs(Te-xe)}return ce/2}const Tt=10;function pt(ge,Le,Me){if(Me&&Me.numeric){const Te=g(ge,Le),{n:xe,mean:_e}=m(Te),Ye=xe>0?Nt({mean:Me.mean,sd:Me.sd},_e):null;return{measure:"standardizedMeanDifference",magnitude:Ye,distance:Ye===null?0:it(Ye),direction:Ye===null?0:Math.sign(Ye),subsetN:xe,populationN:Me.n||0,reliable:xe>=Tt}}const{map:ce,total:ae}=ct(ge,Le),Pe=ft(ce,ae,Me.map,Me.total);return{measure:"categoricalTotalVariation",magnitude:Pe,distance:Pe===null?0:Pe,direction:0,subsetN:ae,populationN:Me.total||0,reliable:ae>=Tt}}function Oe(ge,Le){if(ge&&(ge.kind==="float64"||ge.kind==="int32"))return!0;const Me=Y(ge);let He=0,ce=0;for(let ae=0;ae<Le.length&&He<200;ae++){const Pe=Me(Le[ae]);if(Pe==null||Pe==="")continue;if(Pe instanceof Date)return!1;He++;const Te=typeof Pe=="number"?Pe:Number(Pe);Number.isFinite(Te)&&ce++}return He===0?!1:ce/He>=.9}function Ae(ge,Le){if(Oe(ge,Le)){const ce=g(ge,Le),{n:ae,mean:Pe,m2:Te}=m(ce);return{numeric:!0,mean:Pe,sd:ae>0?Math.sqrt(Te/ae):0,n:ae}}const{map:Me,total:He}=ct(ge,Le);return{numeric:!1,map:Me,total:He}}}),We("packages/core/src/compute/total.js",function(e,D){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return m}});const P=D("packages/core/src/internal/predicates.js").isFunction,_=D("packages/core/src/internal/warn.js").warnOnce,L=D("packages/core/src/compute/handle.js"),Z=L.presenceReader,H=L.valueComparator,x=L.valueReader,X=D("packages/core/src/compute/statistics.js"),U=X.STAT_FNS,j=X.STAT_LABELS;function k(w){return!!w&&(w.kind==="float64"||w.kind==="int32")}function b(w,v){const E=v.length;let V=0;if(k(w)){const q=w.values,M=Z(w);if(!M){for(let O=0;O<E;O++){const T=q[v[O]];Number.isNaN(T)||(V+=T)}return V}for(let O=0;O<E;O++){const T=v[O];if(M(T)===1){const A=q[T];Number.isNaN(A)||(V+=A)}}return V}const G=x(w);for(let q=0;q<E;q++){const M=g(G(v[q]));M!==null&&(V+=M)}return V}b.kernel=!0;function a(w,v){const E=v.length;let V=0;if(k(w)){const q=w.values,M=Z(w);if(!M){for(let O=0;O<E;O++)Number.isNaN(q[v[O]])||V++;return V}for(let O=0;O<E;O++){const T=v[O];M(T)===1&&!Number.isNaN(q[T])&&V++}return V}const G=x(w);for(let q=0;q<E;q++){const M=G(v[q]);M!=null&&!(typeof M=="number"&&Number.isNaN(M))&&V++}return V}a.kernel=!0;function h(w,v){return v.length}h.kernel=!0;function r(w,v){const E=a(w,v);return E===0?null:b(w,v)/E}r.kernel=!0;function t(w,v,E,V){const G=v.length;if(k(w)){const T=w.values,A=Z(w);let N=null;if(!A){for(let C=0;C<G;C++){const S=T[v[C]];Number.isNaN(S)||(N===null||(E<0?S<N:S>N))&&(N=S)}return N}for(let C=0;C<G;C++){const S=v[C];if(A(S)===0)continue;const F=T[S];Number.isNaN(F)||(N===null||(E<0?F<N:F>N))&&(N=F)}return N}const q=x(w),M=H(V);let O=null;for(let T=0;T<G;T++){const A=q(v[T]);A==null||typeof A=="number"&&Number.isNaN(A)||(O===null||(E<0?M(A,O)<0:M(A,O)>0))&&(O=A)}return O}function o(w,v,E){return t(w,v,-1,E&&E.locale)}o.kernel=!0;function u(w,v,E){return t(w,v,1,E&&E.locale)}u.kernel=!0;function d(w,v){return v.length===0?null:x(w)(v[0])}d.kernel=!0;function s(w,v){return v.length===0?null:x(w)(v[v.length-1])}s.kernel=!0;function g(w){if(typeof w=="number")return Number.isNaN(w)?null:w;if(w==null||w===""||typeof w=="boolean")return null;if(w instanceof Date)return w.getTime();const v=Number(w);return Number.isNaN(v)?null:v}const i={sum:b,min:o,max:u,avg:r,count:h,first:d,last:s,countValues:a,...U},n=Object.freeze({...j,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function f(w){return w?typeof w=="string"?n[w]||w:"Total":""}const p=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function l(w){const v=w&&w.dataType&&w.dataType.totals&&w.dataType.totals.supported;if(Array.isArray(v))return v.slice();const E=p.filter(V=>V in i);for(const V of Object.keys(i))E.includes(V)||E.push(V);return E}function y(w,v){return typeof v!="string"?!0:l(w).includes(v)}function c(w,v){const E=x(w),V=[];for(let G=0;G<v.length;G++){const q=E(v[G]);q!=null&&V.push(q)}return V}function m(w,v,E,V){const G=v||[];if(E&&typeof E=="object"&&typeof E.fn=="string"){const{fn:q,...M}=E,O=i[q];return O?O(w,G,{...V,...M}):(_(`total:${q}`,`unknown total function "${q}"; register it in config.totalFns`),null)}if(typeof E=="string"){const q=i[E];return q?q(w,G,V):(_(`total:${E}`,`unknown total function "${E}"; register it in config.totalFns`),null)}return P(E)?E.kernel===!0?E(w,G,V):E(c(w,G),V||{}):null}}),We("packages/core/src/compute/windowed.js",function(e,D){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const P=D("packages/core/src/compute/sketch.js").Welford;class Y{#e;#t;#n=[];#r;#s;constructor(x,X=0,U=Date.now){if(x!=="count"&&x!=="time"&&x!=="session")throw new RangeError(`unknown window kind: ${x}`);if((x==="count"||x==="time")&&!(X>0))throw new RangeError(`a ${x} window needs a positive span`);this.#e=x,this.#t=Math.floor(X),this.#r=U,this.#s=U()}get size(){return this.#n.length}push(x,X=this.#r()){Number.isFinite(x)&&(this.#n.push({t:X,v:x}),this.#i(X))}#i(x){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const X=x-this.#t;for(;this.#n.length&&this.#n[0].t<X;)this.#n.shift()}}spec(){const x=this.#e==="session"?this.#r()-this.#s: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 X=new P;let U=0,j=1/0,k=-1/0;for(const{v:b}of this.#n)U+=b,b<j&&(j=b),b>k&&(k=b),X.add(b);return{over:x,count:this.#n.length,sum:U,mean:X.mean(),min:j,max:k,variance:X.variance(),stddev:X.stddev()}}reduce(x){const X=this.aggregate(),U={sum:X.sum,avg:X.mean,mean:X.mean,min:X.min,max:X.max,count:X.count,variance:X.variance,stddev:X.stddev};if(!(x in U))throw new RangeError(`unknown windowed aggregate: ${x}`);return{value:U[x],over:X.over}}}const _=Object.freeze(["count","time","session"]);function L(H,x=Date.now){const X=H.kind==="time"&&H.minutes!=null?H.minutes*6e4:H.span??0;return new Y(H.kind,X,x)}const Z={Window:Y,WINDOW_KINDS:_,openWindow:L}}),We("packages/core/src/compute/rolling.js",function(e,D){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const P=D("packages/core/src/compute/windowed.js").openWindow,_=D("packages/core/src/compute/sketch.js").KLL,L=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function Z(i,n,f,p){if(i.kind==="count"){const l=Math.max(1,Math.floor(i.span||0));return{coverage:Math.min(1,n/l),partial:n<l}}if(i.kind==="time"){const l=i.minutes!=null?i.minutes*6e4:i.span||0;if(!(l>0))return{coverage:1,partial:!1};const y=f-p;return{coverage:Math.min(1,y/l),partial:y<l}}return{coverage:null,partial:!1}}function H(i,n){const f=P(n),p=new Map,l=i.length?i[0].at:0;for(let y=0;y<i.length;y++){const{key:c,at:m,value:w}=i[y];Number.isFinite(w)&&f.push(w,m);const v=f.aggregate(),E=Z(n,v.count,m,l);c!=null&&p.set(String(c),{sum:v.sum,avg:v.mean,min:v.min,max:v.max,count:v.count,coverage:E.coverage,partial:E.partial})}return p}function x(i){const n=new Map;let f=0;for(const{key:p,value:l}of i)Number.isFinite(l)&&(f+=l),p!=null&&n.set(String(p),f);return n}function X(i,n=1){const f=new Map,p=Math.max(1,Math.floor(n));for(let l=0;l<i.length;l++){const{key:y,value:c}=i[l];if(y==null)continue;const m=l>=p?i[l-p].value:null,w=Number.isFinite(c)?c:null,v=Number.isFinite(m)?m:null;f.set(String(y),w!==null&&v!==null?w-v:null)}return f}const U=4096;function j(i){let n=i>>>0;return()=>{n+=1831565813;let f=n;return f=Math.imul(f^f>>>15,f|1),f^=f+Math.imul(f^f>>>7,f|61),((f^f>>>14)>>>0)/4294967296}}function k(i,n){const f=i.length;if(f===1)return i[0];const p=(f-1)*n,l=Math.floor(p),y=Math.ceil(p);return l===y?i[l]:i[l]+(p-l)*(i[y]-i[l])}function b(i,n,f={}){const p=Math.min(1,Math.max(0,f.q==null?.5:f.q)),l=Math.max(1,Math.floor(f.cap==null?U:f.cap)),y=j(f.seed==null?2654435769:f.seed),c=new Map,m=i.length?i[0].at:0;if(n.kind==="session"){const v=new _(200,y);let E=0;for(const{key:V,value:G}of i)Number.isFinite(G)&&(v.add(G),E++),V!=null&&c.set(String(V),{value:E?v.quantile(p):null,approx:E>0,count:E,coverage:null,partial:!1});return c}const w=P(n);for(const{key:v,at:E,value:V}of i){Number.isFinite(V)&&w.push(V,E);const G=w.values(),q=G.length;let M=null,O=!1;if(q)if(q<=l)M=k([...G].sort((A,N)=>A-N),p);else{const A=new _(200,y);for(const N of G)A.add(N);M=A.quantile(p),O=!0}const T=Z(n,q,E,m);v!=null&&c.set(String(v),{value:M,approx:O,count:q,coverage:T.coverage,partial:T.partial})}return c}function a(i,n){const f=i.length,p=new Array(f).fill(null),l=Math.floor(n/2),y=n%2===0;for(let c=0;c<f;c++){if(c-l<0||c+l>=f)continue;let m=0,w=!0;if(y)for(let v=-l;v<=l;v++){const E=i[c+v];if(!Number.isFinite(E)){w=!1;break}m+=v===-l||v===l?E*.5:E}else for(let v=-l;v<=l;v++){const E=i[c+v];if(!Number.isFinite(E)){w=!1;break}m+=E}w&&(p[c]=m/n)}return p}function h(i,n){const f=new Map,p=Math.floor(Number(n&&n.period));if(!(p>=2))return f;const l=n&&n.model==="multiplicative",y=i.length,c=i.map(O=>Number.isFinite(O.value)?O.value:null),m=a(c,p),w=new Array(y).fill(null);for(let O=0;O<y;O++){const T=m[O],A=c[O];T===null||A===null||(l?T!==0&&(w[O]=A/T):w[O]=A-T)}const v=new Array(p).fill(0),E=new Array(p).fill(0);for(let O=0;O<y;O++){if(w[O]===null)continue;const T=O%p;v[T]+=w[O],E[T]+=1}const V=l?1:0,G=v.map((O,T)=>E[T]?O/E[T]:V),q=G.reduce((O,T)=>O+T,0)/p,M=l?G.map(O=>q!==0?O/q:1):G.map(O=>O-q);for(let O=0;O<y;O++){const{key:T}=i[O];if(T==null)continue;const A=m[O],N=M[O%p],C=c[O];let S=null;A!==null&&C!==null&&(S=l?A*N!==0?C/(A*N):null:C-A-N),f.set(String(T),{trend:A,seasonal:C===null?null:N,residual:S,coverage:A===null?0:1,partial:A===null})}return f}function r(i,n,f,p=80){const l=(Math.sqrt(5)-1)/2;let y=n,c=f,m=c-l*(c-y),w=y+l*(c-y),v=i(m),E=i(w);for(let V=0;V<p;V++)v<E?(c=w,w=m,E=v,m=c-l*(c-y),v=i(m)):(y=m,m=w,v=E,w=y+l*(c-y),E=i(w));return(y+c)/2}const t=1e-4,o=1-1e-4;function u(i,n){const f=i.length,p=new Array(f).fill(null),l=new Array(f).fill(null);let y=null,c=0;for(let m=0;m<f;m++){const w=i[m];if(!Number.isFinite(w)){y!==null&&(l[m]=y,p[m]=y);continue}if(y===null){y=w,l[m]=w,p[m]=w;continue}l[m]=y,c+=(w-y)**2,y=n*w+(1-n)*y,p[m]=y}return{smoothed:p,fitted:l,sse:c}}function d(i,n,f){const p=i.length,l=new Array(p).fill(null),y=new Array(p).fill(null);let c=null,m=null,w=0;for(let v=0;v<p;v++){const E=i[v];if(!Number.isFinite(E)){c!==null&&(c+=m,l[v]=c);continue}if(c===null){c=E,l[v]=E;continue}if(m===null){m=E-c;const q=c+m;y[v]=q,w+=(E-q)**2;const M=c;c=n*E+(1-n)*(M+m),m=f*(c-M)+(1-f)*m,l[v]=c;continue}const V=c+m;y[v]=V,w+=(E-V)**2;const G=c;c=n*E+(1-n)*(G+m),m=f*(c-G)+(1-f)*m,l[v]=c}return{smoothed:l,fitted:y,sse:w}}function s(i,n={}){const f=new Map,p=n.method==="holt",l=i.map(V=>Number.isFinite(V.value)?V.value:null),y=l.filter(V=>V!==null).length,c=V=>Math.min(o,Math.max(t,V)),m=()=>{for(const{key:V}of i)V!=null&&f.set(String(V),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return f};if(y<(p?2:1))return m();let w=Number.isFinite(n.alpha)?c(n.alpha):null,v=p&&Number.isFinite(n.beta)?c(n.beta):null;if(p){if(w===null||v===null){let V=w===null?.5:w,G=v===null?.5:v;for(let q=0;q<6;q++)w===null&&(V=r(M=>d(l,M,G).sse,t,o)),v===null&&(G=r(M=>d(l,V,M).sse,t,o));w=w===null?V:w,v=v===null?G:v}}else w===null&&(w=r(V=>u(l,V).sse,t,o));const E=p?d(l,w,v):u(l,w);for(let V=0;V<i.length;V++){const{key:G}=i[V];G!=null&&f.set(String(G),{smoothed:E.smoothed[V],fitted:E.fitted[V],alpha:w,beta:p?v:null,sse:E.sse})}return f}const g={ROLLING_WINDOW_FIELDS:L,QUANTILE_SPAN_CAP:U,rollingWindow:H,rollingQuantile:b,cumulativeToDate:x,periodOverPeriod:X,seasonalDecompose:h,exponentialSmoothing:s}}),We("packages/core/src/compute/cluster.js",function(e,D){"use strict";Object.defineProperty(e,"CLUSTER_ROW_CAP",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"DBSCAN_ROW_CAP",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"DEFAULT_K",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DEFAULT_MIN_POINTS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"orderByCentre",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"kmeans",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"dbscan",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"autoK",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"standardise",{enumerable:!0,get:function(){return t}});const ne=1e5,P=2e4,Y=3,_=5,L=100;function Z(o){let u=o>>>0;return function(){u=u+1831565813|0;let s=Math.imul(u^u>>>15,1|u);return s=s+Math.imul(s^s>>>7,61|s)^s,((s^s>>>14)>>>0)/4294967296}}function H(o,u){let d=0;for(let s=0;s<o.length;s++){const g=o[s]-u[s];d+=g*g}return d}function x(o,u){return Math.sqrt(H(o,u))}function X(o,u){let d=-1,s=1/0;for(let g=0;g<u.length;g++){const i=H(o,u[g]);i<s&&(s=i,d=g)}return d}function U(o,u,d){const s=Z(d),g=o.length,i=[Array.from(o[Math.floor(s()*g)])],n=new Float64Array(g).fill(1/0);for(let f=1;f<u;f++){let p=0;for(let m=0;m<g;m++){const w=H(o[m],i[i.length-1]);w<n[m]&&(n[m]=w),p+=n[m]}const l=s()*(p||g);let y=0,c=g-1;for(let m=0;m<g;m++)if(y+=p?n[m]:1,y>=l){c=m;break}i.push(Array.from(o[c]))}return i}function j(o,u){for(let d=0;d<o.length;d++){const s=o[d]-u[d];if(s!==0)return s}return 0}function k(o,u,d,s){const g=u.map((n,f)=>({centre:n,i:f})).sort((n,f)=>j(n.centre,f.centre)),i=new Int32Array(u.length);for(let n=0;n<g.length;n++)i[g[n].i]=n;for(let n=0;n<o.length;n++)o[n]>=0&&(o[n]=i[o[n]]);return{assignments:o,centres:g.map(n=>n.centre),sizes:g.map(n=>d[n.i]),distances:s}}function b(o,u={}){const d=o.length,s=d?o[0].length:0,g=Math.floor(u.k||Y);if(!(d>=g)||g<1||s<1)return null;let i=U(o,g,u.seed===void 0?1:u.seed);const n=new Int32Array(d);let f=!0;for(let c=0;c<L&&f;c++){f=!1;for(let v=0;v<d;v++){const E=X(o[v],i);n[v]!==E&&(n[v]=E,f=!0)}const m=i.map(()=>new Float64Array(s)),w=new Array(g).fill(0);for(let v=0;v<d;v++){const E=n[v];for(let V=0;V<s;V++)m[E][V]+=o[v][V];w[E]++}for(let v=0;v<g;v++)if(w[v])for(let E=0;E<s;E++)i[v][E]=m[v][E]/w[v];else{let E=0,V=-1/0;for(let G=0;G<d;G++){const q=H(o[G],i[v]);q>V&&(V=q,E=G)}i[v]=Array.from(o[E]),f=!0}}const p=new Array(g).fill(0),l=new Float64Array(d);let y=0;for(let c=0;c<d;c++){const m=n[c];p[m]++;const w=H(o[c],i[m]);l[c]=Math.sqrt(w),y+=w}return{assignments:n,centres:i,sizes:p,inertia:y,distances:l}}function a(o,u={}){const d=o.length,s=d?o[0].length:0,g=Number(u.eps),i=Math.max(1,Math.floor(u.minPoints||_));if(!(g>0)||d===0||s<1)return null;const n=new Array(d);for(let w=0;w<d;w++){const v=[];for(let E=0;E<d;E++)w!==E&&x(o[w],o[E])<=g&&v.push(E);n[w]=v}const f=new Int32Array(d).fill(-1);let p=0;for(let w=0;w<d;w++){if(f[w]!==-1||n[w].length<i)continue;f[w]=p;const v=[...n[w]];for(let E=0;E<v.length;E++){const V=v[E];f[V]===-1&&(f[V]=p,n[V].length>=i&&v.push(...n[V]))}p++}if(!p)return{assignments:f,centres:[],sizes:[],distances:new Float64Array(d).fill(NaN)};const l=[],y=new Array(p).fill(0),c=Array.from({length:p},()=>new Float64Array(s));for(let w=0;w<d;w++){const v=f[w];if(!(v<0)){y[v]++;for(let E=0;E<s;E++)c[v][E]+=o[w][E]}}for(let w=0;w<p;w++){const v=new Array(s);for(let E=0;E<s;E++)v[E]=c[w][E]/y[w];l.push(v)}const m=new Float64Array(d).fill(NaN);for(let w=0;w<d;w++){const v=f[w];v>=0&&(m[w]=x(o[w],l[v]))}return{assignments:f,centres:l,sizes:y,distances:m}}function h(o,u,d){const s=o.length;if(s===0)return 0;const g=new Int32Array(d);for(let n=0;n<s;n++)g[u[n]]++;let i=0;for(let n=0;n<s;n++){const f=u[n],p=new Float64Array(d);for(let c=0;c<s;c++)n!==c&&(p[u[c]]+=x(o[n],o[c]));const l=g[f]>1?p[f]/(g[f]-1):0;let y=1/0;for(let c=0;c<d;c++){if(c===f||g[c]===0)continue;const m=p[c]/g[c];m<y&&(y=m)}y!==1/0&&(i+=(y-l)/Math.max(l,y))}return i/s}function r(o,u={}){const d=o.length;if(!d)return null;const s=u.criterion==="silhouette"?"silhouette":"elbow",g=Math.max(2,Math.floor(u.maxK||8)),i=u.seed===void 0?1:u.seed;if(s==="silhouette"){const w=[],v=[];for(let V=2;V<=Math.min(g,d);V++){const G=b(o,{k:V,seed:i});G&&(w.push(V),v.push(h(o,G.assignments,V)))}if(!w.length)return null;let E=0;for(let V=1;V<v.length;V++)v[V]>v[E]&&(E=V);return{k:w[E],criterion:s,scores:v,ks:w}}const n=[],f=[];for(let w=1;w<=Math.min(g,d);w++){const v=b(o,{k:w,seed:i});v&&(n.push(w),f.push(v.inertia))}if(f.length<2)return null;const p={k:n[0],y:f[0]},l={k:n[n.length-1],y:f[f.length-1]},y=Math.hypot(l.k-p.k,l.y-p.y)||1;let c=0,m=-1/0;for(let w=0;w<f.length;w++){const v=Math.abs((l.k-p.k)*(p.y-f[w])-(p.k-n[w])*(l.y-p.y))/y;v>m&&(m=v,c=w)}return{k:n[c],criterion:s,scores:f,ks:n}}function t(o){const u=o.length,d=u?o[0].length:0;if(!u||!d)return null;const s=new Array(d).fill(0);for(let i=0;i<u;i++)for(let n=0;n<d;n++)s[n]+=o[i][n];for(let i=0;i<d;i++)s[i]/=u;const g=new Array(d).fill(0);for(let i=0;i<u;i++)for(let n=0;n<d;n++){const f=o[i][n]-s[n];g[n]+=f*f}for(let i=0;i<d;i++)g[i]=u>1?Math.sqrt(g[i]/(u-1)):0;for(let i=0;i<u;i++)for(let n=0;n<d;n++)g[n]>0?o[i][n]=(o[i][n]-s[n])/g[n]:o[i][n]=o[i][n]-s[n];return{mean:s,sd:g}}}),We("packages/core/src/compute/compare.js",function(e,D){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return a}});const ne=D("packages/core/src/compute/statistics.js"),P=ne.numbers,Y=ne.moments,_=ne.frequencyMap,L=ne.categoricalDistance,Z=ne.normalTotalVariation,H=ne.isNumericColumn,x=ne.SUBSET_RELIABILITY_FLOOR,X=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function U(h,r){if(!h||!r||!(h.n>0)||!(r.n>0)||!Number.isFinite(h.mean)||!Number.isFinite(r.mean))return null;const t=(h.n*h.sd*h.sd+r.n*r.sd*r.sd)/(h.n+r.n);return t>0?(h.mean-r.mean)/Math.sqrt(t):null}function j(h,r){const t=P(h,r),{n:o,mean:u,m2:d}=Y(t),s=o>0?Math.sqrt(d/o):0;return{mean:u,sd:s,n:o}}function k(h,r,t,o){return H(h,r)&&H(t,o)}function b(h,r,t,o){if(k(h,r,t,o)){const g=j(h,r),i=j(t,o),n=U(g,i);return{measure:X.numeric,magnitude:n,distance:n===null?0:Z(n),direction:n===null?0:Math.sign(n),nA:g.n,nB:i.n,meanA:g.mean,meanB:i.mean,reliable:g.n>=x&&i.n>=x}}const u=_(h,r),d=_(t,o),s=L(u.map,u.total,d.map,d.total);return{measure:X.categorical,magnitude:s,distance:s===null?0:s,direction:0,nA:u.total,nB:d.total,meanA:null,meanB:null,reliable:u.total>=x&&d.total>=x}}function a(h,r,t={}){const o=new Set(h.columns),u=new Set(r.columns),d=h.columns.filter(f=>u.has(f)),s=Array.isArray(t.columns)&&t.columns.length?d.filter(f=>t.columns.includes(f)):d,g=h.indices(),i=r.indices(),n=[];for(const f of s){const p=h.handle(f),l=r.handle(f);if(!p||!l)continue;const y=b(p,g,l,i);n.push({column:f,name:h.name&&h.name(f)||r.name&&r.name(f)||f,measure:y.measure,magnitude:y.magnitude,distance:y.distance,direction:y.direction,nA:y.nA,nB:y.nB,meanA:y.meanA,meanB:y.meanB,reliable:y.reliable})}return n.sort((f,p)=>p.distance-f.distance||Math.abs(p.magnitude||0)-Math.abs(f.magnitude||0)),{ranked:n,nA:g.length,nB:i.length,unmatched:{onlyA:h.columns.filter(f=>!u.has(f)),onlyB:r.columns.filter(f=>!o.has(f))},measures:X}}}),We("packages/core/src/compute/anomaly.js",function(e,D){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return g}});const P=D("packages/core/src/compute/statistics.js").quantileSorted,_=D("packages/core/src/compute/special.js").logGamma,L=.6745,Z=3.5,H=1.5,x=.975,X=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function U(i){if(!i.length)return null;const f=Array.from(i,Number).sort((c,m)=>c-m),p=P(f,.5),l=f.map(c=>Math.abs(c-p)).sort((c,m)=>c-m),y=P(l,.5);return{median:p,mad:y}}function j(i,n={}){const f=Number.isFinite(n.threshold)?n.threshold:Z,p=i.length,l=new Array(p).fill(null),y=new Array(p).fill(!1),c=[];for(let v=0;v<p;v++){const E=Number(i[v]);Number.isFinite(E)&&c.push(E)}if(!c.length)return{median:null,mad:null,threshold:f,scores:l,flags:y,flagged:0};const m=U(c);if(m.mad===0)return{median:m.median,mad:0,threshold:f,scores:l,flags:y,flagged:0};let w=0;for(let v=0;v<p;v++){const E=Number(i[v]);if(!Number.isFinite(E))continue;const V=L*(E-m.median)/m.mad;l[v]=V,Math.abs(V)>f&&(y[v]=!0,w++)}return{median:m.median,mad:m.mad,threshold:f,scores:l,flags:y,flagged:w}}function k(i,n={}){const f=Number.isFinite(n.k)?n.k:H,p=[];for(let w=0;w<i.length;w++){const v=Number(i[w]);Number.isFinite(v)&&p.push(v)}if(!p.length)return null;const l=p.sort((w,v)=>w-v),y=P(l,.25),c=P(l,.75),m=c-y;return{q1:y,q3:c,iqr:m,lower:y-f*m,upper:c+f*m,k:f}}function b(i,n){if(n<=0)return 0;const f=_(i);if(n<i+1){let v=i,E=1/i,V=E;for(let G=0;G<1e3&&(v+=1,V*=n/v,E+=V,!(Math.abs(V)<Math.abs(E)*1e-15));G++);return E*Math.exp(-n+i*Math.log(n)-f)}const p=1e-300;let l=n+1-i,y=1/p,c=1/l,m=c;for(let v=1;v<1e3;v++){const E=-v*(v-i);l+=2,c=E*c+l,Math.abs(c)<p&&(c=p),y=l+E/y,Math.abs(y)<p&&(y=p),c=1/c;const V=c*y;if(m*=V,Math.abs(V-1)<1e-15)break}return 1-Math.exp(-n+i*Math.log(n)-f)*m}function a(i,n){return i<=0?0:b(n/2,i/2)}function h(i,n=x){if(!(n>0)||!(n<1))return NaN;let f=0,p=Math.max(1,i);for(;a(p,i)<n;)p*=2;for(let l=0;l<200;l++){const y=(f+p)/2;if(a(y,i)<n?f=y:p=y,p-f<1e-10)break}return(f+p)/2}function r(i){const n=i.length,f=i.map((p,l)=>{const y=p.slice();for(let c=0;c<n;c++)y.push(l===c?1:0);return y});for(let p=0;p<n;p++){let l=p;for(let c=p+1;c<n;c++)Math.abs(f[c][p])>Math.abs(f[l][p])&&(l=c);if(Math.abs(f[l][p])<1e-12)return null;if(l!==p){const c=f[l];f[l]=f[p],f[p]=c}const y=f[p][p];for(let c=0;c<2*n;c++)f[p][c]/=y;for(let c=0;c<n;c++){if(c===p)continue;const m=f[c][p];if(m!==0)for(let w=0;w<2*n;w++)f[c][w]-=m*f[p][w]}}return f.map(p=>p.slice(n))}function t(i,n){const f=i.length,p=new Array(n).fill(0);for(const c of i)for(let m=0;m<n;m++)p[m]+=c[m];for(let c=0;c<n;c++)p[c]/=f;const l=Array.from({length:n},()=>new Array(n).fill(0));for(const c of i)for(let m=0;m<n;m++){const w=c[m]-p[m];for(let v=m;v<n;v++)l[m][v]+=w*(c[v]-p[v])}const y=f>1?f-1:1;for(let c=0;c<n;c++)for(let m=c;m<n;m++)l[c][m]/=y,l[m][c]=l[c][m];return{mean:p,cov:l}}function o(i,n={}){const f=Number.isFinite(n.p)?n.p:x,p=Number.isFinite(n.ridge)?n.ridge:1e-6,l=i.length;if(!l)return null;const y=i[0].length;if(!y)return null;const c=new Array(l).fill(null),m=new Array(l).fill(null),w=new Array(l).fill(!1),v=[],E=[];for(let N=0;N<l;N++){const C=i[N];let S=C.length===y;const F=new Array(y);for(let $=0;S&&$<y;$++){const W=Number(C[$]);Number.isFinite(W)?F[$]=W:S=!1}S&&(v.push(N),E.push(F))}const V=y,G=h(V,f);if(E.length<=y)return{center:[],df:V,cutoff:G,singular:!0,used:E.length,distances:c,squared:m,flags:w,flagged:0};const{mean:q,cov:M}=t(E,y);let O=r(M),T=!1;if(!O){T=!0;let N=0;for(let F=0;F<y;F++)N+=M[F][F];const C=N/y*p||p,S=M.map((F,$)=>F.map((W,K)=>$===K?W+C:W));if(O=r(S),!O)return{center:q,df:V,cutoff:G,singular:!0,used:E.length,distances:c,squared:m,flags:w,flagged:0}}let A=0;for(let N=0;N<E.length;N++){const C=E[N],S=new Array(y);for(let W=0;W<y;W++)S[W]=C[W]-q[W];let F=0;for(let W=0;W<y;W++){let K=0;for(let I=0;I<y;I++)K+=O[W][I]*S[I];F+=S[W]*K}F<0&&(F=0);const $=v[N];m[$]=F,c[$]=Math.sqrt(F),F>G&&(w[$]=!0,A++)}return{center:q,df:V,cutoff:G,singular:T,used:E.length,distances:c,squared:m,flags:w,flagged:A}}const u=20,d=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function s(i,n={}){const f=n.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",p=Number.isFinite(n.windowLen)&&n.windowLen>=1?Math.floor(n.windowLen):u,l=Number.isFinite(n.threshold)?n.threshold:Z,y=Number.isFinite(n.k)?n.k:H,c=Number.isFinite(n.minPeriods)&&n.minPeriods>=1?Math.floor(n.minPeriods):p,m=i.length,w=new Array(m).fill(null),v=new Array(m).fill(!1);let E=0;for(let V=0;V<m;V++){const G=Number(i[V]);if(!Number.isFinite(G))continue;const q=Math.max(0,V-p+1),M=[];for(let O=q;O<=V;O++){const T=Number(i[O]);Number.isFinite(T)&&M.push(T)}if(!(M.length<c))if(f==="rollingIqr"){const O=k(M,{k:y});if(!O)continue;(G<O.lower||G>O.upper)&&(v[V]=!0,E++)}else{const O=U(M);if(!O||O.mad===0)continue;const T=L*(G-O.median)/O.mad;w[V]=T,Math.abs(T)>l&&(v[V]=!0,E++)}}return{method:f,windowLen:p,minPeriods:c,threshold:l,k:y,scores:w,flags:v,flagged:E}}function g(i={}){const n=i||{},f=n.field;if(typeof f!="string"||!f)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const p=n.method||"modifiedZScore";if(!(X.includes(p)||d.includes(p))||p==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${p}'`);const y=typeof n.orderBy=="string"?n.orderBy:null,c=n.latest===!0,m=d.includes(p),w=v=>Number(v==null?NaN:v[f]);return v=>{const E=Array.isArray(v)?v.slice():[...v];y&&E.sort((O,T)=>{const A=O?.[y],N=T?.[y];return A===N?0:A==null?-1:N==null?1:A<N?-1:1});const V=E.map(w);let G,q;if(m)({flags:G,scores:q}=s(V,{method:p,windowLen:n.windowLen,threshold:n.threshold,k:n.k,minPeriods:n.minPeriods}));else if(p==="iqr"){const O=k(V,{k:n.k});G=V.map(T=>O?Number.isFinite(T)&&(T<O.lower||T>O.upper):!1),q=V.map(()=>null)}else({flags:G,scores:q}=j(V,{threshold:n.threshold}));if(c){const O=G.length-1;return O<0||!G[O]?!1:{method:p,field:f,flagged:[{row:E[O],score:q[O]}]}}const M=[];for(let O=0;O<G.length;O++)G[O]&&M.push({row:E[O],score:q[O]});return M.length?{method:p,field:f,flagged:M}:!1}}}),We("packages/core/src/compute/forecast.js",function(e,D){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const ne=D("packages/core/src/compute/special.js"),P=ne.normalQuantile,Y=ne.studentTQuantile,L=D("packages/core/src/internal/warn.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),H=1e-4,x=1-1e-4;function X(n){const f=[];for(let p=0;p<n.length;p++){const l=n[p];if(l!==null&&typeof l=="object"){const y=Number.isFinite(l.at)?l.at:p,c=Number.isFinite(l.value)?l.value:null;f.push({at:y,value:c})}else f.push({at:p,value:Number.isFinite(l)?Number(l):null})}return f}function U(n){const f=n.filter(m=>m.value!==null),p=f[0],l=f[f.length-1],y=l.at-p.at,c=f.length>1&&y>0?y/(f.length-1):1;return{lastAt:l.at,step:c}}function j(n){return Math.min(x,Math.max(H,n))}function k(n,f=H,p=x,l=80){const y=(Math.sqrt(5)-1)/2;let c=f,m=p,w=m-y*(m-c),v=c+y*(m-c),E=n(w),V=n(v);for(let G=0;G<l;G++)E<V?(m=v,v=w,V=E,w=m-y*(m-c),E=n(w)):(c=w,w=v,E=V,v=c+y*(m-c),V=n(v));return(c+m)/2}function b(n,f){let p=null,l=0,y=0;for(let c=0;c<n.length;c++){const m=n[c];if(m!==null){if(p===null){p=m;continue}l+=(m-p)**2,y+=1,p=f*m+(1-f)*p}}return{level:p,sse:l,m:y}}function a(n,f,p){let l=null,y=null,c=0,m=0;for(let w=0;w<n.length;w++){const v=n[w];if(v===null){l!==null&&y!==null&&(l+=y);continue}if(l===null){l=v;continue}y===null&&(y=v-l);const E=l+y;c+=(v-E)**2,m+=1;const V=l;l=f*v+(1-f)*(V+y),y=p*(l-V)+(1-p)*y}return{level:l,trend:y,sse:c,m}}function h(n,f,p,l,y){const c=n.length;if(c<2*f)return null;const m=T=>{let A=0,N=0;for(let C=T;C<T+f&&C<c;C++)n[C]!==null&&(A+=n[C],N+=1);return N?A/N:null},w=m(0),v=m(f);if(w===null||v===null)return null;let E=w,V=(v-w)/f;const G=new Array(f).fill(0);for(let T=0;T<f;T++)G[T]=n[T]===null?0:n[T]-E;const q=G.reduce((T,A)=>T+A,0)/f;for(let T=0;T<f;T++)G[T]-=q;let M=0,O=0;for(let T=f;T<c;T++){const A=T%f,N=G[A],C=n[T];if(C===null){E+=V;continue}const S=E+V+N;M+=(C-S)**2,O+=1;const F=E;E=p*(C-N)+(1-p)*(E+V),V=l*(E-F)+(1-l)*V,G[A]=y*(C-E)+(1-y)*N}return{level:E,trend:V,season:G,phase:(c-1)%f,sse:M,count:O}}function r(n,f,p){let l=1;for(const c of f)l+=c*c;const y=Math.sqrt(n*l);return{se:y,margin:p*y}}function t(n,f={}){if(!n||typeof n.length!="number"||n.length===0)return null;const p=Z.includes(f.method)?f.method:"linear",l=Math.max(1,Math.floor(Number(f.horizon)||1)),y=Number.isFinite(f.confidence)&&f.confidence>0&&f.confidence<1?f.confidence:.95,c=1-(1-y)/2,m=X(n),w=m.map(M=>M.value),v=w.filter(M=>M!==null),E=v.length,{lastAt:V,step:G}=E?U(m):{lastAt:0,step:1},q=M=>V+M*G;return p==="linear"?o(m,E,l,y,c,q):p==="movingAverage"?u(v,E,l,y,c,f,q):p==="ses"?d(w,E,l,y,c,f,q):p==="holt"?s(w,E,l,y,c,f,q):g(w,E,l,y,c,f,q)}function o(n,f,p,l,y,c){if(f<2)return null;let m=0,w=0;for(const C of n)C.value!==null&&(m+=C.at,w+=C.value);m/=f,w/=f;let v=0,E=0,V=0;for(const C of n){if(C.value===null)continue;const S=C.at-m,F=C.value-w;v+=S*S,E+=S*F,V+=F*F}if(v===0)return null;const G=E/v,q=w-G*m,M=V===0?1:Math.max(0,Math.min(1,E*E/(v*V))),O=Math.max(0,V-G*E),T=f>2?Math.sqrt(O/(f-2)):null,A=f>2?Y(y,f-2):null,N=[];for(let C=1;C<=p;C++){const S=c(C),F=q+G*S;let $=null,W=null,K=null,I=null,B=null;if(T!==null){const J=1/f+(S-m)**2/v,te=T*Math.sqrt(1+J),Q=T*Math.sqrt(J);B=te,$=F-A*te,W=F+A*te,K=F-A*Q,I=F+A*Q}N.push({step:C,at:S,mean:F,lower:$,upper:W,lowerMean:K,upperMean:I,se:B})}return{method:"linear",horizon:p,confidence:l,n:f,sigma:T,r2:M,params:{slope:G,intercept:q},points:N}}function u(n,f,p,l,y,c,m){if(f<1)return null;const w=Math.max(1,Math.min(f,Math.floor(Number(c.windowLen)||f))),v=n.slice(f-w);let E=0;for(const T of v)E+=T;const V=E/w;let G=null,q=null;if(w>1){let T=0;for(const N of v)T+=(N-V)**2;G=Math.sqrt(T/(w-1))*Math.sqrt(1+1/w),q=Y(y,w-1)}const M=G===null?null:q*G,O=[];for(let T=1;T<=p;T++)O.push({step:T,at:m(T),mean:V,lower:M===null?null:V-M,upper:M===null?null:V+M,se:G});return{method:"movingAverage",horizon:p,confidence:l,n:f,sigma:G===null?null:G,params:{windowLen:w},points:O}}function d(n,f,p,l,y,c,m){if(f<1)return null;let w=Number.isFinite(c.alpha)?j(c.alpha):null;w===null&&(w=k(q=>b(n,q).sse));const v=b(n,w),E=P(y),V=v.m>0?v.sse/v.m:null,G=[];for(let q=1;q<=p;q++){const M=v.level;let O=null,T=null,A=null;if(V!==null){const N=[];for(let S=1;S<q;S++)N.push(w);const C=r(V,N,E);A=C.se,O=M-C.margin,T=M+C.margin}G.push({step:q,at:m(q),mean:M,lower:O,upper:T,se:A})}return{method:"ses",horizon:p,confidence:l,n:f,sigma:V===null?null:Math.sqrt(V),params:{alpha:w},points:G}}function s(n,f,p,l,y,c,m){if(f<2)return null;let w=Number.isFinite(c.alpha)?j(c.alpha):null,v=Number.isFinite(c.beta)?j(c.beta):null;if(w===null||v===null){let O=w===null?.5:w,T=v===null?.5:v;for(let A=0;A<6;A++)w===null&&(O=k(N=>a(n,N,T).sse)),v===null&&(T=k(N=>a(n,O,N).sse));w=w===null?O:w,v=v===null?T:v}const E=a(n,w,v),V=P(y),G=E.m>0?E.sse/E.m:null,q=w*v,M=[];for(let O=1;O<=p;O++){const T=E.level+O*E.trend;let A=null,N=null,C=null;if(G!==null){const S=[];for(let $=1;$<O;$++)S.push(w+$*q);const F=r(G,S,V);C=F.se,A=T-F.margin,N=T+F.margin}M.push({step:O,at:m(O),mean:T,lower:A,upper:N,se:C})}return{method:"holt",horizon:p,confidence:l,n:f,sigma:G===null?null:Math.sqrt(G),params:{alpha:w,beta:v},points:M}}function g(n,f,p,l,y,c,m){const w=Math.floor(Number(c.period));if(!(w>=2))return L("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(f<2*w)return null;let v=Number.isFinite(c.alpha)?j(c.alpha):null,E=Number.isFinite(c.beta)?j(c.beta):null,V=Number.isFinite(c.gamma)?j(c.gamma):null;const G=(C,S,F)=>{const $=h(n,w,C,S,F);return $?$.sse:1/0};if(v===null||E===null||V===null){let C=v===null?.5:v,S=E===null?.5:E,F=V===null?.5:V;for(let $=0;$<8;$++)v===null&&(C=k(W=>G(W,S,F))),E===null&&(S=k(W=>G(C,W,F))),V===null&&(F=k(W=>G(C,S,W)));v=v===null?C:v,E=E===null?S:E,V=V===null?F:V}const q=h(n,w,v,E,V);if(!q)return null;const M=P(y),O=q.count>0?q.sse/q.count:null,T=v*E,A=V*(1-v),N=[];for(let C=1;C<=p;C++){const S=q.season[(q.phase+C)%w],F=q.level+C*q.trend+S;let $=null,W=null,K=null;if(O!==null){const I=[];for(let J=1;J<C;J++)I.push(v+J*T+(J%w===0?A:0));const B=r(O,I,M);K=B.se,$=F-B.margin,W=F+B.margin}N.push({step:C,at:m(C),mean:F,lower:$,upper:W,se:K})}return{method:"holtWinters",horizon:p,confidence:l,n:f,sigma:O===null?null:Math.sqrt(O),params:{alpha:v,beta:E,gamma:V,period:w},points:N}}const i={FORECAST_METHODS:Z,forecast:t}}),We("packages/core/src/compute/hypothesis.js",function(e,D){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return M}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/compute/handle.js").valueReader,L=D("packages/core/src/compute/statistics.js"),Z=L.numbers,H=L.moments,x=L.frequencyMap,X=L.categoricalDistance,U=L.isNumericColumn,j=L.jarqueBera,k=L.proportionInterval,b=L.SUBSET_RELIABILITY_FLOOR,h=D("packages/core/src/compute/compare.js").pooledStandardMeanDifference,r=D("packages/core/src/compute/special.js"),t=r.studentT,o=r.studentTQuantile,u=r.normalCdf,d=r.normalQuantile,s=r.chiSquareUpperTail,g=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),i=.05,n=2e6;function f(O){const T=Number(O);return Number.isFinite(T)&&T>0&&T<1?T:.95}function p(O){const{n:T,mean:A,m2:N}=H(O);return{mean:A,sd:T>0?Math.sqrt(N/T):0,n:T}}function l(O,T){const A=O.length;if(A<2)return 0;let N=0;for(let C=0;C<A;C++){const S=O[C]-T;N+=S*S}return N/(A-1)}function y(O,T){return{name:"pooledStandardMeanDifference",value:h(p(O),p(T))}}function c(O,T,A){const N=O.length,C=T.length;if(N<2||C<2)return null;const S=f(A),{mean:F}=H(O),{mean:$}=H(T),W=l(O,F),K=l(T,$),I=W/N+K/C;if(!(I>0))return null;const B=Math.sqrt(I),J=(F-$)/B,te=W/N*(W/N)/(N-1),Q=K/C*(K/C)/(C-1),re=I*I/(te+Q),ie=Math.min(1,Math.max(0,2*(1-t(Math.abs(J),re)))),ue=F-$,ke=o(1-(1-S)/2,re)*B;return{test:g.WELCH,statistic:J,statisticName:"t",df:re,pValue:ie,interval:{estimate:ue,lower:ue-ke,upper:ue+ke,confidence:S,method:"welch-t (difference of means)"},effectSize:y(O,T),nA:N,nB:C,reliable:N>=b&&C>=b,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function m(O){const T=O.length;if(T===0)return Number.NaN;const A=T>>1;return T%2?O[A]:(O[A-1]+O[A])/2}function w(O,T,A){const N=O.length,C=T.length,S=N*C;if(S===0||S>n)return null;const F=new Float64Array(S);let $=0;for(let te=0;te<N;te++)for(let Q=0;Q<C;Q++)F[$++]=O[te]-T[Q];F.sort();const W=m(F),K=Math.sqrt(N*C*(N+C+1)/12),I=d(1-(1-A)/2);let B=Math.round(S/2-I*K);B>=0||(B=0);const J=Math.floor((S-1)/2);return B>J&&(B=J),{estimate:W,lower:F[B],upper:F[S-1-B],confidence:A,method:"hodges-lehmann (normal approximation)"}}function v(O,T,A){const N=O.length,C=T.length;if(N<1||C<1)return null;const S=f(A),F=N+C,$=new Array(F);for(let ie=0;ie<N;ie++)$[ie]={v:O[ie],g:0};for(let ie=0;ie<C;ie++)$[N+ie]={v:T[ie],g:1};$.sort((ie,ue)=>ie.v-ue.v);let W=0,K=0,I=0;for(;I<F;){let ie=I;for(;ie<F&&$[ie].v===$[I].v;)ie++;const ue=ie-I,ke=(I+1+ie)/2;for(let de=I;de<ie;de++)$[de].g===0&&(W+=ke);K+=ue*ue*ue-ue,I=ie}const B=W-N*(N+1)/2,J=N*C/2,te=N*C/12*(F+1-K/(F*(F-1)));let Q=1;if(te>0){const ie=Math.max(0,Math.abs(B-J)-.5);Q=Math.min(1,2*u(-ie/Math.sqrt(te)))}const re=w(O,T,S);return{test:g.MANN_WHITNEY,statistic:B,statisticName:"U",df:null,pValue:Q,interval:re,effectSize:y(O,T),nA:N,nB:C,reliable:N>=b&&C>=b,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function E(O,T,A,N,C){const S=k(O,T,C),F=k(A,N,C);if(!S||!F)return null;const $=S.proportion-F.proportion,W=$-Math.sqrt((S.proportion-S.lower)**2+(F.upper-F.proportion)**2),K=$+Math.sqrt((S.upper-S.proportion)**2+(F.proportion-F.lower)**2);return{lower:W,upper:K}}function V(O,T,A,N,C,S={}){if(!(T>0)||!(N>0))return null;const F=new Set([...O.keys(),...A.keys()]),$=F.size;if($<2)return null;const W=T+N;let K=0;for(const Q of F){const re=O.get(Q)||0,ie=A.get(Q)||0,ue=re+ie,ke=T*ue/W,de=N*ue/W;ke>0&&(K+=(re-ke)*(re-ke)/ke),de>0&&(K+=(ie-de)*(ie-de)/de)}const I=$-1,B=s(K,I);let J=null;S.category!==void 0&&F.has(S.category)?J=S.category:$===2&&([J]=[...F]);let te=null;if(J!==null){const Q=E(O.get(J)||0,T,A.get(J)||0,N,f(C));Q&&(te={estimate:(O.get(J)||0)/T-(A.get(J)||0)/N,lower:Q.lower,upper:Q.upper,confidence:f(C),method:"newcombe (difference in this category's share)",category:J})}return{test:g.CHI_SQUARE,statistic:K,statisticName:"chiSquare",df:I,pValue:B,interval:te,effectSize:{name:"categoricalTotalVariation",value:X(O,T,A,N)},nA:T,nB:N,reliable:T>=b&&N>=b,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function G(O){return O==null||O===""||typeof O=="number"&&Number.isNaN(O)?null:O instanceof Date?O.getTime():typeof O=="object"?String(O):O}function q(O,T,A){if(A===g.WELCH||A===g.MANN_WHITNEY)return{test:A,chosenBy:"override",reason:`caller override: ${A}`};const N=j(O),C=j(T),S=N===null?null:Math.exp(-N/2),F=C===null?null:Math.exp(-C/2);return S!==null&&S<i||F!==null&&F<i?{test:g.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${i})`}:{test:g.WELCH,chosenBy:"auto",reason:S!==null||F!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function M(O,T,A,N={}){if(!O||!T)return null;const C=f(N.confidence),S=_(T);let F;if(Array.isArray(N.groups)&&N.groups.length===2)F=[G(N.groups[0]),G(N.groups[1])];else{const{map:ie}=x(T,A),ue=[...ie.entries()].sort((ke,de)=>de[1]-ke[1]).slice(0,2).map(ke=>ke[0]);if(ue.length<2)return P("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;F=ue}const[$,W]=F;if($===null||W===null||$===W)return P("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const K=[],I=[];for(let ie=0;ie<A.length;ie++){const ue=G(S(A[ie]));ue===$?K.push(A[ie]):ue===W&&I.push(A[ie])}if(K.length===0||I.length===0)return P("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const B=N.test&&N.test!=="auto"?String(N.test):null,J=U(O,K.concat(I));let te,Q,re;if(B===g.CHI_SQUARE||!B&&!J){Q=B?"override":"auto",re=B?"caller override: chiSquare":"column family: categorical";const ie=x(O,K),ue=x(O,I);te=V(ie.map,ie.total,ue.map,ue.total,C,{category:N.category})}else{if((B===g.WELCH||B===g.MANN_WHITNEY)&&!J)return P("compareGroups:numeric-override",`[lattice] compareGroups: ${B} needs a numeric column, but the column is not numeric.`),null;const ie=Z(O,K),ue=Z(O,I),ke=q(ie,ue,B);Q=ke.chosenBy,re=ke.reason,te=ke.test===g.MANN_WHITNEY?v(ie,ue,C):c(ie,ue,C)}return te?{...te,chosenBy:Q,reason:re,groups:[$,W]}:(P("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),We("packages/core/src/compute/significance.js",function(e,D){"use strict";Object.defineProperty(e,"COMPARE_TESTS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compare",{enumerable:!0,get:function(){return we}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/compute/handle.js").valueReader,L=D("packages/core/src/compute/statistics.js"),Z=L.numbers,H=L.moments,x=L.frequencyMap,X=L.isNumericColumn,U=L.jarqueBera,j=L.proportionInterval,k=D("packages/core/src/compute/special.js"),b=k.studentT,a=k.studentTQuantile,h=k.normalCdf,r=k.normalQuantile,t=k.chiSquareUpperTail,o=k.incompleteBeta,u=Object.freeze({T:"t",WELCH:"welch",MANN_WHITNEY:"mannWhitney",ANOVA:"anova",KRUSKAL:"kruskal",CHI_SQUARE:"chiSquare",PROPORTIONS:"proportions"}),d=new Set([u.T,u.WELCH,u.MANN_WHITNEY]),s=new Set([u.ANOVA,u.KRUSKAL]),g=new Set([u.CHI_SQUARE,u.PROPORTIONS]),i=.05,n=[.2,.5,.8],f=[.147,.33,.474],p=[.01,.06,.14],l=[[.1,.3,.5],[.07,.21,.35],[.06,.17,.29],[.05,.15,.25]];function y(pe){const oe=Number(pe);return Number.isFinite(oe)&&oe>0&&oe<1?oe:.05}function c(pe){return pe==null||pe===""||typeof pe=="number"&&Number.isNaN(pe)?null:pe instanceof Date?pe.getTime():typeof pe=="object"?String(pe):pe}function m(pe,oe){const be=_(pe),fe=[],le=new Map;for(let ye=0;ye<oe.length;ye++){const Ne=c(be(oe[ye]));if(Ne===null)continue;let je=le.get(Ne);je||(je={value:Ne,rows:[]},le.set(Ne,je),fe.push(je)),je.rows.push(oe[ye])}return fe}function w(pe){const{n:oe,mean:be,m2:fe}=H(pe),le=oe>1?fe/(oe-1):0;return{n:oe,mean:be,sd:Math.sqrt(le),variance:le}}function v(pe,oe,be){if(!(oe>0)||!(be>0)||!(pe>=0)||!Number.isFinite(pe))return Number.NaN;if(pe===0)return 1;const fe=oe*pe/(oe*pe+be);return 1-o(oe/2,be/2,fe)}function E(pe,oe){const be=Math.abs(pe);return Number.isFinite(be)?be>=oe[2]?"large":be>=oe[1]?"medium":be>=oe[0]?"small":"negligible":"negligible"}function V(pe,oe,be){if(pe==="cohensD")return E(oe,n);if(pe==="cliffsDelta")return E(oe,f);if(pe==="etaSquared")return E(oe,p);const fe=Math.max(1,Math.min(l.length,Math.floor(be||1)));return E(oe,l[fe-1])}function G(pe,oe){if(!(pe.n>1)||!(oe.n>1))return null;const be=((pe.n-1)*pe.variance+(oe.n-1)*oe.variance)/(pe.n+oe.n-2);return be>0?(pe.mean-oe.mean)/Math.sqrt(be):null}function q(pe,oe){const be=pe.length,fe=oe.length;if(!be||!fe)return null;const le=Array.from(oe).sort((je,$e)=>je-$e);let ye=0,Ne=0;for(let je=0;je<be;je++){const $e=pe[je];let Re=0,Se=fe;for(;Re<Se;){const Ee=Re+Se>>1;le[Ee]<$e?Re=Ee+1:Se=Ee}const Ve=Re;let Fe=Re;for(;Fe<fe&&le[Fe]===$e;)Fe++;const Ce=Fe-Re;ye+=Ve,Ne+=fe-Fe}return(ye-Ne)/(be*fe)}function M(pe,oe,be,fe){const le=Math.min(be-1,fe-1);return!(oe>0)||!(le>0)?null:Math.sqrt(pe/(oe*le))}function O(pe){return Number.isFinite(pe)?pe<.001?"p < 0.001":pe>=.995?"p > 0.995":`p = ${pe.toFixed(3)}`:"p = —"}function T(pe){if(!Number.isFinite(pe))return"0";const oe=Math.abs(pe);return oe===0?"0":oe>=1e3?String(Math.round(pe)):oe>=100?String(Number(pe.toFixed(0))):oe>=10?String(Number(pe.toFixed(1))):oe>=1?String(Number(pe.toFixed(2))):String(Number(pe.toPrecision(2)))}const A=new Set(["cohensD","cliffsDelta"]);function N(pe){if(pe.difference!=null&&Math.abs(pe.difference)>=1e-12)return Math.sign(pe.difference);const oe=pe.effectSize;if(oe&&A.has(oe.name)&&Number.isFinite(oe.value)&&Math.abs(oe.value)>=1e-12)return Math.sign(oe.value);const[be,fe]=pe.groups;return Number.isFinite(be.mean)&&Number.isFinite(fe.mean)&&be.mean!==fe.mean?Math.sign(be.mean-fe.mean):0}function C(pe){const oe=pe.measureName||"values";return{subject:oe.charAt(0).toUpperCase()+oe.slice(1),be:oe==="values"?"are":"is",name:oe}}function S(pe,oe){const be=oe.unit?` ${oe.unit}`:"",{subject:fe,be:le}=C(oe),ye=pe.groups[0].label,Ne=pe.groups[1].label,je=pe.effectSize?pe.effectSize.label:"negligible",$e=pe.pValue<pe.alpha,Re=$e?"unlikely to be chance":"consistent with chance";if(!$e&&je==="negligible")return`${fe} ${le} essentially the same for ${ye} and ${Ne} (${O(pe.pValue)}); the effect is ${je}.`;const Se=N(pe),Ve=`the difference is ${Re} (${O(pe.pValue)}) and the effect is ${je}.`;if(Se===0)return`${fe} ${le} different between ${ye} and ${Ne}; ${Ve}`;const Fe=Se>0?ye:Ne,Ce=Se>0?Ne:ye,Ie=pe.difference!=null&&Math.abs(pe.difference)>=1e-12?` by about ${T(Math.abs(pe.difference))}${be}`:"";return`${fe} ${le} higher for ${Fe} than for ${Ce}${Ie}; ${Ve}`}function F(pe,oe){const{name:be}=C(oe),fe=pe.effectSize?pe.effectSize.label:"negligible",le=O(pe.pValue);return pe.pValue<pe.alpha?`The groups differ in ${be}; the difference is unlikely to be chance (${le}) and the effect is ${fe}.`:fe==="negligible"?`The groups are essentially the same in ${be} (${le}); the effect is ${fe}.`:`The groups show a ${fe} effect in ${be}, but the difference is consistent with chance (${le}).`}function $(pe,oe){const be=pe.length;if(be<2)return null;const{mean:fe,m2:le}=H(pe),ye=le/(be-1);if(!(ye>0))return null;const Ne=Math.sqrt(ye),je=Ne/Math.sqrt(be),$e=fe/je,Re=be-1,Se=Math.min(1,Math.max(0,2*(1-b(Math.abs($e),Re)))),Ve=a(1-oe/2,Re)*je,Fe=fe/Ne;return{test:u.T,statistic:$e,statisticName:"t",df:Re,pValue:Se,difference:fe,interval:{estimate:fe,lower:fe-Ve,upper:fe+Ve,confidence:1-oe,method:"paired-t (mean of the pair differences)"},effectSize:{name:"cohensD",label:E(Fe,n),value:Fe}}}function W(pe,oe){const be=Array.from(pe).filter(Ie=>Ie!==0),fe=be.length;if(!fe)return null;const le=Array.from({length:fe},(Ie,Be)=>Be).sort((Ie,Be)=>Math.abs(be[Ie])-Math.abs(be[Be])),ye=new Array(fe);let Ne=0;for(;Ne<fe;){let Ie=Ne;for(;Ie+1<fe&&Math.abs(be[le[Ie+1]])===Math.abs(be[le[Ne]]);)Ie++;const Be=(Ne+Ie)/2+1;for(let Ke=Ne;Ke<=Ie;Ke++)ye[le[Ke]]=Be;Ne=Ie+1}let je=0,$e=0;for(let Ie=0;Ie<fe;Ie++)$e+=ye[Ie],be[Ie]>0&&(je+=ye[Ie]);const Re=$e-je,Se=fe*(fe+1)/4,Ve=Math.sqrt(fe*(fe+1)*(2*fe+1)/24),Fe=Ve>0?(Math.abs(je-Se)-.5)/Ve:0,Ce=Math.min(1,Math.max(0,2*h(-Math.max(0,Fe)))),Ee=$e>0?(je-Re)/$e:0;return{test:u.MANN_WHITNEY,statistic:je,statisticName:"W",df:null,pValue:Ce,difference:null,interval:null,effectSize:{name:"cliffsDelta",label:E(Ee,f),value:Ee}}}function K(pe,oe,be){const fe=w(pe),le=w(oe);if(fe.n<2||le.n<2)return null;const ye=((fe.n-1)*fe.variance+(le.n-1)*le.variance)/(fe.n+le.n-2);if(!(ye>0))return null;const Ne=Math.sqrt(ye*(1/fe.n+1/le.n)),je=(fe.mean-le.mean)/Ne,$e=fe.n+le.n-2,Re=Math.min(1,Math.max(0,2*(1-b(Math.abs(je),$e)))),Se=fe.mean-le.mean,Ve=a(1-be/2,$e)*Ne,Fe=G(fe,le);return{test:u.T,statistic:je,statisticName:"t",df:$e,pValue:Re,difference:Se,interval:{estimate:Se,lower:Se-Ve,upper:Se+Ve,confidence:1-be,method:"student-t (pooled variance, difference of means)"},effectSize:{name:"cohensD",label:E(Fe,n),value:Fe},summaries:[fe,le]}}function I(pe,oe,be){const fe=w(pe),le=w(oe);if(fe.n<2||le.n<2)return null;const ye=fe.variance/fe.n+le.variance/le.n;if(!(ye>0))return null;const Ne=Math.sqrt(ye),je=(fe.mean-le.mean)/Ne,$e=fe.variance/fe.n*(fe.variance/fe.n)/(fe.n-1),Re=le.variance/le.n*(le.variance/le.n)/(le.n-1),Se=ye*ye/($e+Re),Ve=Math.min(1,Math.max(0,2*(1-b(Math.abs(je),Se)))),Fe=fe.mean-le.mean,Ce=a(1-be/2,Se)*Ne,Ee=G(fe,le);return{test:u.WELCH,statistic:je,statisticName:"t",df:Se,pValue:Ve,difference:Fe,interval:{estimate:Fe,lower:Fe-Ce,upper:Fe+Ce,confidence:1-be,method:"welch-t (unequal variances, difference of means)"},effectSize:{name:"cohensD",label:E(Ee,n),value:Ee},summaries:[fe,le]}}function B(pe,oe,be){const fe=pe.length,le=oe.length;if(fe<1||le<1)return null;const ye=w(pe),Ne=w(oe),je=fe+le,$e=new Array(je);for(let Ke=0;Ke<fe;Ke++)$e[Ke]={v:pe[Ke],g:0};for(let Ke=0;Ke<le;Ke++)$e[fe+Ke]={v:oe[Ke],g:1};$e.sort((Ke,qe)=>Ke.v-qe.v);let Re=0,Se=0,Ve=0;for(;Ve<je;){let Ke=Ve;for(;Ke<je&&$e[Ke].v===$e[Ve].v;)Ke++;const qe=(Ve+1+Ke)/2;for(let nt=Ve;nt<Ke;nt++)$e[nt].g===0&&(Re+=qe);const rt=Ke-Ve;Se+=rt*rt*rt-rt,Ve=Ke}const Fe=Re-fe*(fe+1)/2,Ce=fe*le/2,Ee=fe*le/12*(je+1-Se/(je*(je-1)));let Ie=1;if(Ee>0){const Ke=Math.max(0,Math.abs(Fe-Ce)-.5);Ie=Math.min(1,2*h(-Ke/Math.sqrt(Ee)))}const Be=q(pe,oe);return{test:u.MANN_WHITNEY,statistic:Fe,statisticName:"U",df:null,pValue:Ie,difference:null,interval:J(pe,oe,1-be),effectSize:{name:"cliffsDelta",label:E(Be,f),value:Be},summaries:[ye,Ne]}}function J(pe,oe,be){const fe=pe.length,le=oe.length,ye=fe*le;if(ye===0||ye>2e6)return null;const Ne=new Float64Array(ye);let je=0;for(let Ee=0;Ee<fe;Ee++)for(let Ie=0;Ie<le;Ie++)Ne[je++]=pe[Ee]-oe[Ie];Ne.sort();const $e=ye>>1,Re=ye%2?Ne[$e]:(Ne[$e-1]+Ne[$e])/2,Se=Math.sqrt(fe*le*(fe+le+1)/12),Ve=r(1-(1-be)/2);let Fe=Math.round(ye/2-Ve*Se);Fe>=0||(Fe=0);const Ce=Math.floor((ye-1)/2);return Fe>Ce&&(Fe=Ce),{estimate:Re,lower:Ne[Fe],upper:Ne[ye-1-Fe],confidence:be,method:"hodges-lehmann (location shift)"}}function te(pe,oe){const be=pe.length,fe=pe.map(w);if(fe.some(Ie=>Ie.n<2))return null;const le=fe.reduce((Ie,Be)=>Ie+Be.n,0),ye=fe.reduce((Ie,Be)=>Ie+Be.mean*Be.n,0)/le;let Ne=0,je=0;for(let Ie=0;Ie<be;Ie++)Ne+=fe[Ie].n*(fe[Ie].mean-ye)**2,je+=(fe[Ie].n-1)*fe[Ie].variance;const $e=be-1,Re=le-be;if(!(je>0)||Re<1)return null;const Se=Ne/$e,Ve=je/Re,Fe=Se/Ve,Ce=Math.min(1,Math.max(0,v(Fe,$e,Re))),Ee=Ne/(Ne+je);return{test:u.ANOVA,statistic:Fe,statisticName:"F",df:{between:$e,within:Re},pValue:Ce,difference:null,interval:null,effectSize:{name:"etaSquared",label:E(Ee,p),value:Ee},summaries:fe}}function Q(pe,oe){const be=pe.length,fe=pe.map(w);if(be<2)return null;const le=fe.reduce((Be,Ke)=>Be+Ke.n,0),ye=[];for(let Be=0;Be<be;Be++)for(let Ke=0;Ke<pe[Be].length;Ke++)ye.push({v:pe[Be][Ke],g:Be});ye.sort((Be,Ke)=>Be.v-Ke.v);const Ne=new Array(ye.length);let je=0,$e=0;for(;$e<ye.length;){let Be=$e;for(;Be<ye.length&&ye[Be].v===ye[$e].v;)Be++;const Ke=($e+1+Be)/2;for(let rt=$e;rt<Be;rt++)Ne[rt]=Ke;const qe=Be-$e;je+=qe*qe*qe-qe,$e=Be}const Re=new Array(be).fill(0);for(let Be=0;Be<ye.length;Be++)Re[ye[Be].g]+=Ne[Be];let Se=0;for(let Be=0;Be<be;Be++)Se+=Re[Be]*Re[Be]/fe[Be].n;Se=12/(le*(le+1))*Se-3*(le+1);const Ve=1-je/(le*le*le-le),Fe=Ve>0?Se/Ve:Se,Ce=be-1,Ee=Math.min(1,Math.max(0,t(Fe,Ce))),Ie=(Fe-be+1)/(le-be);return{test:u.KRUSKAL,statistic:Fe,statisticName:"H",df:Ce,pValue:Ee,difference:null,interval:null,effectSize:{name:"etaSquared",label:E(Ie,p),value:Math.max(0,Ie)},summaries:fe}}function re(pe,oe,be,fe,le){const ye=j(pe,oe,le),Ne=j(be,fe,le);if(!ye||!Ne)return null;const je=ye.proportion-Ne.proportion,$e=je-Math.sqrt((ye.proportion-ye.lower)**2+(Ne.upper-Ne.proportion)**2),Re=je+Math.sqrt((ye.upper-ye.proportion)**2+(Ne.proportion-Ne.lower)**2);return{estimate:je,lower:$e,upper:Re}}function ie(pe,oe,be,fe){const le=_(oe),ye=new Set,Ne=[];for(const Ke of pe){const qe=new Map;let rt=0;for(const nt of Ke.rows){const dt=c(le(nt));dt!==null&&(qe.set(dt,(qe.get(dt)||0)+1),rt++,ye.add(dt))}Ne.push(qe),Ke.total=rt}const je=[...ye];if(je.length<2)return null;const $e=pe.reduce((Ke,qe)=>Ke+qe.total,0);if(!($e>0))return null;let Re=0;for(const Ke of pe)for(const qe of je){const rt=Ne[pe.indexOf(Ke)].get(qe)||0,nt=pe.reduce((Pt,Nt)=>Pt+(Ne[pe.indexOf(Nt)].get(qe)||0),0),dt=Ke.total*nt/$e;dt>0&&(Re+=(rt-dt)*(rt-dt)/dt)}const Se=pe.length,Ve=je.length,Fe=(Se-1)*(Ve-1),Ce=Math.min(1,Math.max(0,t(Re,Fe))),Ee=M(Re,$e,Se,Ve);let Ie=null;if(Se===2&&Ve===2){const[Ke]=je,qe=Ne[0].get(Ke)||0,rt=Ne[1].get(Ke)||0,nt=re(qe,pe[0].total,rt,pe[1].total,fe);nt&&(Ie={...nt,confidence:fe,method:"newcombe (difference in this category's share)",category:Ke})}const Be=pe.map((Ke,qe)=>{const rt={};for(const nt of je)rt[String(nt)]=(Ne[qe].get(nt)||0)/Ke.total;return rt});return{test:u.CHI_SQUARE,statistic:Re,statisticName:"chiSquare",df:Fe,pValue:Ce,difference:null,interval:Ie,effectSize:{name:"cramersV",label:V("cramersV",Ee,Math.min(Se-1,Ve-1)),value:Ee},proportions:Be}}function ue(pe,oe,be,fe){const le=_(oe),ye=new Set;for(const nt of pe)for(const dt of nt.rows){const Pt=c(le(dt));Pt!==null&&ye.add(Pt)}if(ye.size!==2)return null;const[Ne]=[...ye],je=pe[0].rows.reduce((nt,dt)=>nt+(c(le(dt))===Ne?1:0),0),$e=pe[1].rows.reduce((nt,dt)=>nt+(c(le(dt))===Ne?1:0),0),Re=pe[0].rows.length,Se=pe[1].rows.length;if(!(Re>0)||!(Se>0))return null;const Ve=je/Re,Fe=$e/Se,Ce=(je+$e)/(Re+Se);if(!(Ce>0)||!(Ce<1))return null;const Ee=Math.sqrt(Ce*(1-Ce)*(1/Re+1/Se)),Ie=(Ve-Fe)/Ee,Be=Math.min(1,Math.max(0,2*h(-Math.abs(Ie)))),Ke=Ve-Fe,qe=re(je,Re,$e,Se,fe),rt=M(Ie*Ie,Re+Se,2,2);return{test:u.PROPORTIONS,statistic:Ie,statisticName:"z",df:null,pValue:Be,difference:Ke,interval:qe?{...qe,confidence:fe,method:"newcombe (difference in proportions)",category:Ne}:null,effectSize:{name:"cramersV",label:V("cramersV",rt,1),value:rt},proportions:[{[String(Ne)]:Ve},{[String(Ne)]:Fe}],focalCategory:Ne}}function ke(pe,oe,be,fe){if(be&&d.has(be))return{test:be,reason:`caller override: ${be}`};const le=U(pe),ye=U(oe),Ne=le===null?null:Math.exp(-le/2),je=ye===null?null:Math.exp(-ye/2);if(Ne!==null&&Ne<i||je!==null&&je<i)return{test:u.MANN_WHITNEY,reason:"two numeric groups, non-normal by Jarque-Bera"};const $e=w(pe),Re=w(oe);if($e.n>=3&&Re.n>=3&&$e.variance>0&&Re.variance>0){const Se=Math.max($e.variance,Re.variance)/Math.min($e.variance,Re.variance),Ve=$e.variance>=Re.variance?$e.n-1:Re.n-1,Fe=$e.variance>=Re.variance?Re.n-1:$e.n-1;if(2*Math.min(v(Se,Ve,Fe),1-v(Se,Ve,Fe))<fe)return{test:u.WELCH,reason:"two numeric groups, unequal variances (F-test)"}}return{test:u.T,reason:Ne!==null||je!==null?"two numeric groups, equal variances and no departure from normality":"two numeric groups (too few rows to screen normality)"}}function de(pe,oe){if(oe&&s.has(oe))return{test:oe,reason:`caller override: ${oe}`};for(const be of pe){const fe=U(be),le=fe===null?null:Math.exp(-fe/2);if(le!==null&&le<i)return{test:u.KRUSKAL,reason:"three or more numeric groups, non-normal by Jarque-Bera"}}return{test:u.ANOVA,reason:"three or more numeric groups, no departure from normality detected"}}function we(pe,oe,be,fe={},le=null){if(!pe||!oe)return null;const ye=y(fe.alpha),Ne=1-ye,je=fe.test&&fe.test!=="auto"?String(fe.test):null,$e=m(oe,be);if($e.length<2)return P("compare:groups",'[lattice] statistics.compare: the "by" column has fewer than two distinct values to group by.'),null;let Re;if(Array.isArray(fe.groups)&&fe.groups.length===2){const qe=[c(fe.groups[0]),c(fe.groups[1])];if(qe[0]===null||qe[1]===null||qe[0]===qe[1])return P("compare:distinct","[lattice] statistics.compare: the two groups must be two distinct, present values."),null;if(Re=$e.filter(rt=>rt.value===qe[0]||rt.value===qe[1]),Re.length!==2)return P("compare:empty","[lattice] statistics.compare: one of the two groups has no rows in the current set."),null;Re.sort((rt,nt)=>rt.value===qe[0]?-1:1)}else $e.length===2||je&&d.has(je)||je&&g.has(je)?Re=$e.slice(0,2):(je&&s.has(je),Re=$e);const Ve=X(pe,be),Fe=!!fe.paired&&le&&Re.length===2&&Ve;let Ce,Ee,Ie;if(Ve)if(Re.length===2&&!(je&&s.has(je))){const qe=Z(pe,Re[0].rows),rt=Z(pe,Re[1].rows);if(qe.length<3||rt.length<3)return P("compare:small","[lattice] statistics.compare: each group needs at least three readings to compare."),null;if(w(qe).variance===0||w(rt).variance===0)return P("compare:zero-variance","[lattice] statistics.compare: a group has zero variance, so the difference has no scale to test."),null;if(Fe){const dt=De(pe,le,Re[0].rows,Re[1].rows);return dt?(Ee=je?"override":"auto",Ie=je?`caller override: ${je} (paired)`:"two numeric groups, paired",Ce=je===u.MANN_WHITNEY?W(dt.diffs,ye):$(dt.diffs,ye),Ce?(Ce.paired=!0,Ce.chosenBy=Ee,Ce.reason=Ie,Ce.groups=[{value:Re[0].value,label:String(Re[0].value),n:dt.n},{value:Re[1].value,label:String(Re[1].value),n:dt.n}],Ce.alpha=ye,Ce.method=Ce.test===u.MANN_WHITNEY?"Wilcoxon signed-rank test (paired)":"Student's paired t-test (difference of pairs)",Ce.verdict=S(Ce,fe),Ce.categorical=!1,Ce):(P("compare:degenerate","[lattice] statistics.compare: the paired test had too little to work with."),null)):(P("compare:paired","[lattice] statistics.compare: not enough matched pairs to run a paired test."),null)}const nt=ke(qe,rt,je,ye);Ee=je?"override":"auto",Ie=nt.reason,nt.test===u.MANN_WHITNEY?Ce=B(qe,rt,ye):nt.test===u.WELCH?Ce=I(qe,rt,ye):Ce=K(qe,rt,ye),Ce&&Ce.interval&&Ce.difference===null&&(Ce.difference=Ce.interval.estimate)}else{const qe=Re.map(nt=>Z(pe,nt.rows));if(qe.some(nt=>nt.length<3))return P("compare:small","[lattice] statistics.compare: each group needs at least three readings to compare."),null;const rt=de(qe,je);Ee=je?"override":"auto",Ie=rt.reason,Ce=rt.test===u.KRUSKAL?Q(qe,ye):te(qe,ye)}else if(Re.length===2){const qe=ve(pe,Re).size===2;if(je===u.PROPORTIONS||qe&&!je)Ee=je?"override":"auto",Ie=je?"caller override: proportions":"categorical measure with two categories (binary)",Ce=ue(Re,pe,ye,Ne);else if(je===u.CHI_SQUARE||!qe&&!je)Ee=je?"override":"auto",Ie=je?"caller override: chiSquare":`categorical measure with ${ve(pe,Re).size} categories`,Ce=ie(Re,pe,ye,Ne);else return P("compare:numeric-needed",`[lattice] statistics.compare: ${je} needs a numeric measure, but the column is categorical.`),null}else Ee=je?"override":"auto",Ie=je?`caller override: ${je}`:`categorical measure with ${ve(pe,Re).size} categories`,Ce=ie(Re,pe,ye,Ne);if(!Ce)return P("compare:degenerate","[lattice] statistics.compare: the chosen test had too little to work with (too few values, or no variation)."),null;const Be=Ce.summaries,Ke=Ce.proportions;return{test:Ce.test,chosenBy:Ee,reason:Ie,statistic:Ce.statistic,statisticName:Ce.statisticName,df:Ce.df===void 0?null:Ce.df,pValue:Ce.pValue,alpha:ye,paired:!1,interval:Ce.interval||null,effectSize:Ce.effectSize,groups:Re.map((qe,rt)=>({value:qe.value,label:String(qe.value),n:Be?Be[rt].n:qe.total,...Be?{mean:Be[rt].mean,sd:Be[rt].sd}:{},...Ke?{proportions:Ke[rt]}:{}})),difference:Ce.difference===void 0?null:Ce.difference,method:Ce.test,categorical:!Ve,verdict:Re.length===2?S({...Ce,alpha:ye,groups:[{value:Re[0].value,label:String(Re[0].value),mean:Be?Be[0].mean:void 0},{value:Re[1].value,label:String(Re[1].value),mean:Be?Be[1].mean:void 0}],categorical:!Ve,difference:Ce.difference===void 0?null:Ce.difference},fe):F({...Ce,alpha:ye},fe)}}function ve(pe,oe){const be=_(pe),fe=new Set;for(const le of oe)for(const ye of le.rows){const Ne=c(be(ye));Ne!==null&&fe.add(Ne)}return fe}function De(pe,oe,be,fe){const le=_(oe),ye=_(pe),Ne=new Map;for(const $e of fe){const Re=c(le($e));Re!==null&&Ne.set(Re,ye($e))}const je=[];for(const $e of be){const Re=c(le($e));if(Re===null||!Ne.has(Re))continue;const Se=Number(ye($e)),Ve=Number(Ne.get(Re));!Number.isFinite(Se)||!Number.isFinite(Ve)||je.push(Se-Ve)}return je.length<2?null:{diffs:Float64Array.from(je),n:je.length}}}),We("packages/core/src/columns/detailcolumn.js",function(e,D){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const ne="__lattice_detail",P=36;function Y(L){const Z=L.config&&L.config.detailColumnWidth||P;return{id:ne,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:Z,min:Z,max:Z,pin:L.config&&L.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(H,x){return!!(x&&x.expanded)},formatValue(){return""}}}const _=Y}),We("packages/core/src/columns/treecolumn.js",function(e,D){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const P=D("packages/core/src/internal/predicates.js").isFunction,Y="__lattice_tree",_=260;function L(H){const x=H.tree||{},X=H.config&&H.config.treeColumnWidth||_,U=!!(H.config&&H.config.treeColumnFlex),j=()=>(H.columns&&P(H.columns.visible)?H.columns.visible():[]).find(h=>!h.generated)||null,k=(a,h)=>{if(h&&h.group)return h.groupValue;if(P(x.label))return x.label(a,h);if(typeof x.label=="string")return a==null?null:a[x.label];const r=j();return r&&P(r.getValue)?r.getValue(a,h):null},b=()=>{if(x.title)return x.title;const a=typeof x.label=="string"?H.columns&&P(H.columns.get)?H.columns.get(x.label):null:j();return a&&(a.title||a.id)||"Hierarchy"};return{id:Y,get title(){return b()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group",props:{icon:x.icon,iconClass:x.iconClass,content:x.content,checkbox:x.checkbox,onCheck:x.onCheck}},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:U?{flex:1,min:0,pin:H.config&&H.config.treeColumnPin||null,hidden:!1,resizable:!1,movable:!1,lockPosition:!0}:{width:X,min:140,pin:H.config&&H.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(a,h){return k(a,h)},formatValue(a,h){if(h&&h.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";if(a==null)return"";if(!x.label){const r=j();if(r&&P(r.formatValue))return r.formatValue(a,h)}return String(a)}}}const Z=L}),We("packages/core/src/columns/pivotcolumns.js",function(e,D){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return L}});const P=D("packages/core/src/internal/warn.js").warnOnce,Y="__lattice_pivot",_=500;function L(X){const{pivot:U,valueColumns:j,config:k}=X,b=U&&U.paths||[],a=X.separator||k&&k.pivot&&k.pivot.separator||" | ",h=k&&k.pivot&&k.pivot.maxColumns||_;if(!b.length||!j.length)return{tree:[],leaves:[],error:null};const r=Z(k),t=b.length*j.length+(r?j.length:0);if(t>h){const d=`pivot would generate ${t} columns, above the limit of ${h}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return P(`pivot.maxColumns:${t}`,d),{tree:[],leaves:[],error:d}}const o=[],u=[];for(const d of b){const s=[];for(const g of j){const i=x(d,g,a);s.push(i),u.push(i)}s.length===1?(s[0].title=String(d),o.push(s[0])):o.push({id:`${Y}:group:${d}`,title:String(d),columns:s,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(r){const d=j.map(g=>H(g,k));u.push(...d);const s=k&&k.pivot&&k.pivot.totalsLabel||"Total";if(d.length===1)d[0].title=s,r==="before"?o.unshift(d[0]):o.push(d[0]);else{const g={id:`${Y}:group:__totals`,title:s,columns:d,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};r==="before"?o.unshift(g):o.push(g)}}return{tree:o,leaves:u,error:null}}function Z(X){const U=X&&X.pivot&&X.pivot.groupTotals;return U==="before"||U==="after"?U:null}function H(X,U){return{id:`${Y}:__total${U&&U.pivot&&U.pivot.separator||" | "}${X.id}`,field:null,title:X.title||X.id,type:X.type,dataType:X.dataType,nullable:!0,align:X.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:X.id,total:!0},value:{pure:!0},cell:{align:X.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:X.total,lookup:null,layout:{width:X.layout&&X.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,k){const b=k&&k.totals;return b&&Object.hasOwn(b,X.id)?b[X.id]:null},formatValue(j,k){return j==null?"":X.formatValue?X.formatValue(j,k):String(j)}}}function x(X,U,j){return{id:`${Y}:${X}${j}${U.id}`,field:null,title:U.title||U.id,type:U.type,dataType:U.dataType,nullable:!0,align:U.align,generated:!0,pivot:{enabled:!1,index:0,path:X,sourceId:U.id},value:{pure:!0},cell:{align:U.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:U.total,lookup:null,layout:{width:U.layout&&U.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(){return null},formatValue(k,b){return k==null?"":U.formatValue?U.formatValue(k,b):String(k)}}}}),We("packages/core/src/compute/group.js",function(e,D){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return k}});const ne=D("packages/core/src/compute/handle.js"),P=ne.dictSize,Y=ne.identity,_=ne.presenceReader,L=ne.rowCount,Z=ne.valueReader,H="",x="\0",X=1<<20;function U(b,a,h,r){const t=b.length,o=b.map(n=>Z(n)),u=Array.isArray(r)&&r.some(Boolean),d=u?o.map((n,f)=>r[f]?p=>r[f](n(p)):n):o;if(!u&&t>0&&b.every(n=>n&&n.kind==="dictionary"&&n.dict)){const n=b.map(p=>P(p.dict)+1);let f=1;for(let p=0;p<t;p++)f*=n[p];if(f<=Number.MAX_SAFE_INTEGER){const p=b.map(m=>m.values),l=b.map(m=>_(m)),y=m=>{let w=0;for(let v=0;v<t;v++){const E=l[v],V=E&&E(m)===0?n[v]-1:p[v][m];w=w*n[v]+V}return w},c=new Float64Array(h);for(let m=0;m<h;m++)c[m]=y(a[m]);return{packed:c,strings:null,product:f,readers:d,keyOf:y}}}const g=n=>{let f="";for(let p=0;p<t;p++){const l=d[p](n);f+=(p===0?"":H)+(l==null?x:String(l))}return f},i=new Array(h);for(let n=0;n<h;n++)i[n]=g(a[n]);return{packed:null,strings:i,product:1/0,readers:d,keyOf:g}}function j(b,a,h,r){const t=new Uint32Array(r+1);for(let s=0;s<h;s++)t[a[s]+1]++;for(let s=0;s<r;s++)t[s+1]+=t[s];const o=new Uint32Array(h),u=t.slice(0,r);for(let s=0;s<h;s++)o[u[a[s]]++]=b[s];const d=new Array(r);for(let s=0;s<r;s++)d[s]=o.subarray(t[s],t[s+1]);return d}function k(b,a,h={}){const r=b||[],t=a||Y(L(r[0],h)),o=t.length;if(r.length===0||o===0)return{keys:[],buckets:[]};const{packed:u,strings:d,product:s,readers:g}=U(r,t,o,h.project),i=new Uint32Array(o);let n=0,f=null;if(u&&s<=Math.max(1024,Math.min(X,o*4))){const c=s,m=new Int32Array(c).fill(-1);for(let w=0;w<o;w++)m[u[w]]=0;for(let w=0;w<c;w++)m[w]===0&&(m[w]=n++);for(let w=0;w<o;w++)i[w]=m[u[w]];f=new Float64Array(n);for(let w=0;w<c;w++)m[w]>=0&&(f[m[w]]=w)}else if(u){const c=new Map;for(let m=0;m<o;m++){const w=u[m];let v=c.get(w);v===void 0&&(v=n++,c.set(w,v)),i[m]=v}f=new Float64Array(n);for(const[m,w]of c)f[w]=m}else{const c=new Map;for(let m=0;m<o;m++){const w=d[m];let v=c.get(w);v===void 0&&(v=n++,c.set(w,v)),i[m]=v}}const p=j(t,i,o,n),l=new Array(n);for(let c=0;c<n;c++){const m=p[c][0],w=new Array(g.length);for(let v=0;v<g.length;v++)w[v]=g[v](m);l[c]=w}const y={keys:l,buckets:p};return f&&(y.packed=f),y}}),We("packages/core/src/compute/pivot.js",function(e,D){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return o}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/compute/handle.js").valueComparator,Z=D("packages/core/src/compute/group.js").packKeys,x=D("packages/core/src/compute/total.js").total,X="|",U="/",j=2e3;function k(s,g,i){return`${s}${X}${g}${X}${i}`}function b(s,g){let i="";for(let n=0;n<s.length;n++){const f=s[n];i+=(n===0?"":g)+(f==null?"":String(f))}return i}function a(s,g,i={}){const n=i.separator||U,f=g.length,{keyOf:p,readers:l}=Z(s,g,0),y=new Map,c=[],m=[];for(let M=0;M<f;M++){const O=g[M],T=p(O);if(y.has(T))continue;y.set(T,c.length),m.push(T);const A=new Array(l.length);for(let N=0;N<l.length;N++)A[N]=l[N](O);c.push(A)}const w=_(i.locale),v=c.map((M,O)=>O);v.sort((M,O)=>{const T=c[M],A=c[O];for(let N=0;N<T.length;N++){const C=h(T[N],A[N],w);if(C!==0)return C}return M-O});const E=new Array(v.length),V=new Array(v.length),G=new Map;for(let M=0;M<v.length;M++){const O=v[M];E[M]=c[O],V[M]=b(c[O],n),G.set(m[O],M)}return{keys:E,paths:V,idOf:M=>{const O=G.get(p(M));return O===void 0?-1:O}}}function h(s,g,i){const n=s==null,f=g==null;return n||f?n&&f?0:n?1:-1:i(s,g)}function r(s){const g=s.values||s.totals||[];if(g.length&&typeof g[0]=="object"&&g[0]!==null)return g.filter(p=>p&&p.handle);const i=typeof s.handle=="function"?s.handle:null;if(!i)return g.length&&P("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 n=typeof s.totalOf=="function"?s.totalOf:null,f=[];for(const p of g){const l=i(p);l&&f.push({colId:p,handle:l,fn:n?n(p):"sum"})}return f}function t(s,g,i){if(Array.isArray(s)){const n=i||{};return{...n,pivotHandles:s,order:g||null,groups:n.groups||null}}return s||{}}function o(s,g,i){const n=t(s,g,i),f=n.separator||U,p=r(n),l=n.maxColumns===void 0?j:n.maxColumns,y=n.groups&&n.groups.buckets?n.groups:null,c=y?y.buckets:[n.order||new Uint32Array(0)],m=n.groupPaths||(y?y.keys.map(T=>b(T,f)):[""]),w=d(c),{keys:v,paths:E,idOf:V}=a(n.pivotHandles||[],w,n),G=E.length*Math.max(1,p.length),q=u(E,p,f);if(l&&G>l){const T=new Map;return{keys:v,paths:E,fields:q,groupPaths:m,columns:G,values:T,cells:T,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${G} columns, above pivot.maxColumns of ${l}. Narrow the pivot columns or raise the limit.`,columns:G,maxColumns:l}}}const M=new Map,O=E.length;for(let T=0;T<c.length;T++){const A=c[T],N=m[T]===void 0?"":m[T],C=A.length;if(C===0)continue;const S=new Int32Array(C),F=new Uint32Array(O+1);for(let K=0;K<C;K++){const I=V(A[K]);S[K]=I,I>=0&&F[I+1]++}for(let K=0;K<O;K++)F[K+1]+=F[K];const $=new Uint32Array(C),W=F.slice(0,O);for(let K=0;K<C;K++){const I=S[K];I>=0&&($[W[I]++]=A[K])}for(let K=0;K<O;K++){const I=F[K],B=F[K+1];if(B===I)continue;const J=$.subarray(I,B);for(let te=0;te<p.length;te++){const Q=p[te],re=x(Q.handle,J,Q.fn,n.totalContext||{locale:n.locale});M.set(k(N,E[K],Q.colId),re)}}}return{keys:v,paths:E,fields:q,groupPaths:m,columns:G,values:M,cells:M,error:null}}function u(s,g,i){if(g.length===0)return s.slice();const n=[];for(const f of s)for(const p of g)n.push(`${f}${i}${p.colId}`);return n}function d(s){if(s.length===1)return s[0]||new Uint32Array(0);let g=0;for(const f of s)g+=f?f.length:0;const i=new Uint32Array(g);let n=0;for(const f of s)!f||f.length===0||(i.set(f,n),n+=f.length);return i}}),We("packages/core/src/compute/explain.js",function(e,D){"use strict";Object.defineProperty(e,"explainContributors",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"explainChange",{enumerable:!0,get:function(){return k}});const P=D("packages/core/src/compute/total.js").total,_=D("packages/core/src/compute/group.js").groupByColumns,L=new Set(["sum","count","countValues"]),Z=new Set(["min","max"]),H=new Set(["avg"]);function x(b){return typeof b=="string"?b:typeof b=="function"&&b.totalName?b.totalName:null}function X(b,a,h,r){return P(b,a,h,r||{})}function U(b,a){if(a)try{return a(b)}catch{}return b==null?"":String(b)}function j(b){const{handle:a,fn:h,leaves:r,by:t,labelOf:o,rowLabel:u}=b,d={locale:b.locale},s=r&&r.length?r:[],g=x(h),i=X(a,s,h,d),n=Z.has(g);let f;if(n){let y=-1;for(let c=0;c<s.length;c++){const m=X(a,[s[c]],h,d);if(Object.is(m,i)){y=s[c];break}}f=y<0?[]:[{key:y,indices:[y],label:u?u(y):String(y)}]}else if(t){const y=_([t],s);f=y.keys.map((c,m)=>({key:c[0],indices:y.buckets[m],label:U(c[0],o)}))}else f=Array.from({length:s.length},(y,c)=>{const m=s[c];return{key:m,indices:[m],label:u?u(m):String(m)}});const p=s.length,l=[];for(const y of f){const c=X(a,y.indices,h,d),m=y.indices.length;let w,v;if(g==="avg")w=((typeof c=="number"?c:0)-(typeof i=="number"?i:0))*m,v=p?m/p:0;else if(n)w=typeof c=="number"?c:0,v=1;else{w=typeof c=="number"?c:0;const E=typeof i=="number"?i:0;v=E?w/E:0}l.push({key:y.key,label:y.label,count:m,value:c,contribution:w,share:v})}return l.sort((y,c)=>Math.abs(c.contribution)-Math.abs(y.contribution)||(y.label<c.label?-1:y.label>c.label?1:0)),{total:i,fn:g,weighted:H.has(g),single:n,contributors:l}}function k(b){const a=j({...b,leaves:b.after}),h=j({...b,leaves:b.before}),r=typeof a.total=="number"?a.total:0,t=typeof h.total=="number"?h.total:0,o=new Map;for(const s of a.contributors)o.set(s.key,s);const u=[],d=new Set;for(const s of h.contributors){d.add(s.key);const g=o.get(s.key);if(g===void 0)u.push({key:s.key,label:s.label,before:s.value,after:null,effect:-s.contribution,kind:"dropped",count:s.count});else{const i=g.contribution-s.contribution;i!==0&&u.push({key:s.key,label:s.label,before:s.value,after:g.value,effect:i,kind:"changed",count:g.count})}}for(const s of a.contributors)d.has(s.key)||u.push({key:s.key,label:s.label,before:null,after:s.value,effect:s.contribution,kind:"new",count:s.count});return u.sort((s,g)=>Math.abs(g.effect)-Math.abs(s.effect)||(s.label<g.label?-1:s.label>g.label?1:0)),{before:h.total,after:a.total,delta:r-t,weighted:a.weighted||h.weighted,single:a.single||h.single,drivers:u}}}),We("packages/core/src/store/bitset.js",function(e,D){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return P}});const ne=8;class P{static#e=new Uint8Array(256);static{for(let _=1;_<256;_++)P.#e[_]=P.#e[_>>1]+(_&1)}#t;#n;constructor(_=0){const L=Math.max(0,_|0);this.#n=L,this.#t=new Uint8Array(Math.ceil(L/ne))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(_){return _<0||_>=this.#n?0:this.#t[_>>3]>>(_&7)&1}set(_){return _>=0&&_<this.#n&&(this.#t[_>>3]|=1<<(_&7)),this}clear(_){return _>=0&&_<this.#n&&(this.#t[_>>3]&=~(1<<(_&7))),this}assign(_,L){return L?this.set(_):this.clear(_)}fill(_=!1){return this.#t.fill(_?255:0),_&&this.#r(),this}grow(_){const L=Math.max(0,_|0);if(L<=this.#n)return this;const Z=Math.ceil(L/ne);if(Z>this.#t.length){const H=new Uint8Array(Z);H.set(this.#t),this.#t=H}return this.#n=L,this}count(){const _=this.#t,L=P.#e;let Z=0;for(let H=0;H<_.length;H++)Z+=L[_[H]];return Z}and(_){const L=_ instanceof P?_.words:_,Z=this.#t,H=Math.min(Z.length,L.length);for(let x=0;x<H;x++)Z[x]&=L[x];for(let x=H;x<Z.length;x++)Z[x]=0;return this}or(_){const L=_ instanceof P?_.words:_,Z=this.#t,H=Math.min(Z.length,L.length);for(let x=0;x<H;x++)Z[x]|=L[x];return this}not(){const _=this.#t;for(let L=0;L<_.length;L++)_[L]=~_[L]&255;return this.#r(),this}clone(){const _=new P(this.#n);return _.words.set(this.#t.subarray(0,_.words.length)),_}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const _=this.#n&7;if(_===0)return;const L=this.#n>>3;L<this.#t.length&&(this.#t[L]&=(1<<_)-1)}static from(_){const L=Array.isArray(_)?_:Array.from(_),Z=new P(L.length);for(let H=0;H<L.length;H++)L[H]&&Z.set(H);return Z}}}),We("packages/core/src/store/dictionary.js",function(e,D){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return _}});const ne=D("packages/core/src/internal/compare.js"),P=ne.collator,Y=ne.defaultCompare;class _{#e;#t=new Map;#n=0;#r=null;#s=-1;#i="\0";constructor(Z=[]){this.#e=[];for(let H=0;H<Z.length;H++){const x=Z[H];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 Z=this.#e.length*8;for(let H=0;H<this.#e.length;H++){const x=this.#e[H];typeof x=="string"&&(Z+=x.length*2),Z+=16}return Z}codeOf(Z){const H=this.#t.get(Z);if(H!==void 0)return H;const x=this.#e.length;return this.#e.push(Z),this.#t.set(Z,x),this.#n++,x}lookup(Z){const H=this.#t.get(Z);return H===void 0?-1:H}has(Z){return this.#t.has(Z)}valueOf(Z){return this.#e[Z]}values(){return this.#e}ranks(Z){const H=Z||"";if(this.#r&&this.#s===this.#n&&this.#i===H)return this.#r;const x=this.#e.length,X=new Array(x);for(let b=0;b<x;b++)X[b]=b;const U=P(Z).compare,j=this.#e;X.sort((b,a)=>this.#o(j[b],j[a],U));const k=new Uint32Array(x);for(let b=0;b<x;b++)k[X[b]]=b;return this.#r=k,this.#s=this.#n,this.#i=H,k}#o(Z,H,x){return typeof Z=="string"&&typeof H=="string"?x(Z,H):Y(Z,H)}}}),We("packages/core/src/store/multivalue.js",function(e,D){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return ne}});class ne{#e;#t;#n=0;#r=0;constructor(Y={}){const _=Math.max(1,Y.rows??16),L=Math.max(1,Y.values??_);this.#e=new Int32Array(L),this.#t=new Uint32Array(_+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(Y){return Y<0||Y>=this.#n?0:this.#t[Y+1]-this.#t[Y]}at(Y){return Y<0||Y>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[Y],this.#t[Y+1])}has(Y,_){if(Y<0||Y>=this.#n)return!1;const L=this.#e,Z=this.#t[Y+1];for(let H=this.#t[Y];H<Z;H++)if(L[H]===_)return!0;return!1}hasAny(Y,_){for(let L=0;L<_.length;L++)if(this.has(Y,_[L]))return!0;return!1}hasAll(Y,_){for(let L=0;L<_.length;L++)if(!this.has(Y,_[L]))return!1;return!0}hasNone(Y,_){return!this.hasAny(Y,_)}push(Y){const _=this.#n,L=Y.length;this.#s(_+1),this.#i(this.#r+L);const Z=this.#r;for(let H=0;H<L;H++)this.#e[Z+H]=Y[H]|0;return this.#r+=L,this.#n=_+1,this.#t[_]=Z,this.#t[_+1]=this.#r,_}write(Y,_){if(Y===this.#n){this.push(_);return}if(Y<0||Y>this.#n)return;const L=this.#t[Y],Z=this.#t[Y+1],H=_.length;if(Z-L===H){for(let x=0;x<H;x++)this.#e[L+x]=_[x]|0;return}this.#o(Y,_)}compact(Y,_,L){const Z=this.#e,H=this.#t,x=this.#n,X=new Int32Array(Math.max(1,this.#r)),U=new Uint32Array(_+1);let j=0;for(let k=0;k<x;k++){if(Y[k]===L)continue;const b=H[k],a=H[k+1];U[Y[k]]=j;for(let h=b;h<a;h++)X[j++]=Z[h];U[Y[k]+1]=j}this.#e=X,this.#t=U,this.#n=_,this.#r=j}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#s(Y){if(Y+1<=this.#t.length)return;let _=this.#t.length-1;for(;_<Y;)_=_*2||16;const L=new Uint32Array(_+1);L.set(this.#t),this.#t=L}#i(Y){if(Y<=this.#e.length)return;let _=this.#e.length;for(;_<Y;)_=_*2||16;const L=new Int32Array(_);L.set(this.#e),this.#e=L}#o(Y,_){const L=this.#e,Z=this.#t,H=this.#n,x=_.length-(Z[Y+1]-Z[Y]),X=new Int32Array(Math.max(1,this.#r+x)),U=new Uint32Array(Z.length);let j=0;for(let k=0;k<H;k++){if(U[k]=j,k===Y)for(let b=0;b<_.length;b++)X[j++]=_[b]|0;else for(let b=Z[k];b<Z[k+1];b++)X[j++]=L[b];U[k+1]=j}this.#e=X,this.#t=U,this.#r=j}}}),We("packages/core/src/compute/sort.js",function(e,D){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return O}});const ne=D("packages/core/src/compute/handle.js"),P=ne.bitReader,Y=ne.dictRanks,_=ne.dictSize,L=ne.identity,Z=ne.isMissing,H=ne.presenceReader,x=ne.rowCount,X=ne.valueComparator,U=ne.valueReader,j=new Uint32Array(0),k=new ArrayBuffer(8),b=new Float64Array(k),a=new Uint32Array(k),h=(b[0]=-1,(a[1]&2147483648)!==0?1:0),r=h===1?0:1;function t(A,N){b[0]=A;let C=a[h],S=a[r];(C&2147483648)!==0?(C=~C>>>0,S=~S>>>0):C=(C^2147483648)>>>0,N[0]=S,N[1]=C}function o(A,N,C,S){if(S<2)return A;const F=new Uint32Array(256*8);for(let Q=0;Q<S;Q++){const re=N[Q],ie=C[Q];F[re&255]++,F[256+(re>>>8&255)]++,F[512+(re>>>16&255)]++,F[768+(re>>>24&255)]++,F[1024+(ie&255)]++,F[1280+(ie>>>8&255)]++,F[1536+(ie>>>16&255)]++,F[1792+(ie>>>24&255)]++}let $=A,W=N,K=C,I=new Uint32Array(S),B=new Uint32Array(S),J=new Uint32Array(S);const te=new Uint32Array(256);for(let Q=0;Q<8;Q++){const re=Q<<8,ie=(Q&3)<<3,ue=Q>=4;let ke=!1;for(let ve=0;ve<256;ve++)if(F[re+ve]===S){ke=!0;break}if(ke)continue;let de=0;for(let ve=0;ve<256;ve++)te[ve]=de,de+=F[re+ve];for(let ve=0;ve<S;ve++){const De=W[ve],pe=K[ve],oe=(ue?pe:De)>>>ie&255,be=te[oe]++;I[be]=$[ve],B[be]=De,J[be]=pe}let we=$;$=I,I=we,we=W,W=B,B=we,we=K,K=J,J=we}return $}function u(A,N,C){if(C<2)return A;const S=new Uint32Array(256*4);for(let B=0;B<C;B++){const J=N[B];S[J&255]++,S[256+(J>>>8&255)]++,S[512+(J>>>16&255)]++,S[768+(J>>>24&255)]++}let F=A,$=N,W=new Uint32Array(C),K=new Uint32Array(C);const I=new Uint32Array(256);for(let B=0;B<4;B++){const J=B<<8,te=B<<3;let Q=!1;for(let ue=0;ue<256;ue++)if(S[J+ue]===C){Q=!0;break}if(Q)continue;let re=0;for(let ue=0;ue<256;ue++)I[ue]=re,re+=S[J+ue];for(let ue=0;ue<C;ue++){const ke=$[ue],de=I[ke>>>te&255]++;W[de]=F[ue],K[de]=ke}let ie=F;F=W,W=ie,ie=$,$=K,K=ie}return F}function d(A,N,C,S){const F=new Uint32Array(S+1);for(let K=0;K<C;K++)F[N[K]]++;let $=0;for(let K=0;K<=S;K++){const I=F[K];F[K]=$,$+=I}const W=new Uint32Array(C);for(let K=0;K<C;K++)W[F[N[K]]++]=A[K];return W}function s(A,N,C,S){return C<2?A:S<=65536||S<=C*2?d(A,N,C,S):u(A,N,C)}function g(A,N){return A.length===N&&A.byteOffset===0?A:Uint32Array.prototype.slice.call(A,0,N)}function i(A,N,C=!1){const S=N||L(A.length),F=S.length;if(F<2)return Uint32Array.from(S);const $=new Uint32Array(F),W=new Uint32Array(F),K=new Uint32Array(F),I=new Uint32Array(F),B=new Uint32Array(2);let J=0,te=0;for(let ie=0;ie<F;ie++){const ue=S[ie],ke=A[ue];if(Number.isNaN(ke)){I[te++]=ue;continue}t(ke,B),C?(W[J]=~B[0]>>>0,K[J]=~B[1]>>>0):(W[J]=B[0],K[J]=B[1]),$[J++]=ue}const Q=o($.subarray(0,J),W.subarray(0,J),K.subarray(0,J),J);if(te===0)return g(Q,J);const re=new Uint32Array(F);return re.set(Q.subarray(0,J),0),re.set(I.subarray(0,te),J),re}function n(A,N,C=!1){const S=N||L(A.length),F=S.length;if(F<2)return Uint32Array.from(S);const $=Uint32Array.from(S),W=new Uint32Array(F);for(let K=0;K<F;K++){const I=(A[$[K]]^2147483648)>>>0;W[K]=C?~I>>>0:I}return g(u($,W,F),F)}function f(A,N,C={}){const S=N||L(x(A,C)),F=S.length;if(F<2)return Uint32Array.from(S);const $=Y(A.dict,C.locale),W=A.values,K=H(A),I=Math.max(_(A.dict),$.length),B=I,J=Uint32Array.from(S),te=new Uint32Array(F),Q=!!C.descending;for(let re=0;re<F;re++){const ie=J[re];let ue=K&&K(ie)===0?B:$[W[ie]];ue===void 0&&(ue=B),te[re]=Q?B-ue:ue}return g(s(J,te,F,I+1),F)}function p(A,N,C){const S=N.length;let F=Uint32Array.from(N);if(S<2)return F;let $=new Uint32Array(S);for(let W=1;W<S;W<<=1){for(let I=0;I<S;I+=W<<1){const B=Math.min(I+W,S),J=Math.min(I+(W<<1),S);let te=I,Q=B,re=I;for(;te<B&&Q<J;)$[re++]=C(A[F[te]],A[F[Q]])<=0?F[te++]:F[Q++];for(;te<B;)$[re++]=F[te++];for(;Q<J;)$[re++]=F[Q++]}const K=F;F=$,$=K}return F}function l(A,N,C){const S=P(A.values),F=N.length,$=new Uint32Array(F),W=C?1:0;let K=0;for(let I=0;I<F;I++)S(N[I])===W&&($[K++]=N[I]);for(let I=0;I<F;I++)S(N[I])!==W&&($[K++]=N[I]);return $}function y(A,N){const C=A.values,S=A.kind;if((S==="object"||S===void 0)&&(Array.isArray(C)||ArrayBuffer.isView(C))&&!A.presence)return C;const $=U(A),W=new Array(x(A)||0);for(let K=0;K<N.length;K++){const I=N[K];W[I]=$(I)}return W}function c(A,N){for(let C=0;C<N.length;C++)if(typeof A[N[C]]!="string")return!1;return!0}function m(A,N,C,S,F){const $=A.length,W=Uint32Array.from(A);if($<2||S<1)return W;const K=new Uint32Array($),I=S-1;for(let B=0;B<$;B++){const J=C[N[B]];K[B]=F?I-J:J}return g(s(W,K,$,S),$)}function w(A,N,C){const S=X(C),F=new Array(N);for(let W=0;W<N;W++)F[W]=W;F.sort((W,K)=>S(A[W],A[K])||W-K);const $=new Uint32Array(N);for(let W=0;W<N;W++)$[F[W]]=W;return $}function v(A,N,C){const S=N.length,F=new Map,$=[],W=new Uint32Array(S);for(let B=0;B<S;B++){const J=A[N[B]];let te=F.get(J);te===void 0&&(te=$.length,F.set(J,te),$.push(J)),W[B]=te}const K=$.length,I=w($,K,C.locale);return m(N,W,I,K,!!C.descending)}function E(A,N,C){const S=y(A,N);if(N.length>=2&&c(S,N)){const W=A.stringRank;return W&&W.version===A.version&&W.usable(N,S,C.locale)?W.sort(N,C):v(S,N,C)}const F=X(C.locale),$=C.descending?(W,K)=>F(K,W):F;return p(S,N,$)}function V(A,N,C){const S=y(A,N),F=C.compare,W=!!C.descending?(K,I)=>-F(K,I,void 0,void 0,!0):(K,I)=>F(K,I,void 0,void 0,!1);return p(S,N,W)}function G(A,N){const C=N.length,S=H(A),F=A.values,$=A.kind==="float64"&&!!F,W=A.kind==="object"||A.kind==="multi"||A.kind===void 0;if(!S&&!$&&!W)return{present:N,absent:j};const K=new Uint32Array(C),I=new Uint32Array(C);let B=0,J=0;if(S&&$)for(let te=0;te<C;te++){const Q=N[te];S(Q)===1&&!Number.isNaN(F[Q])?K[B++]=Q:I[J++]=Q}else if($&&!S)for(let te=0;te<C;te++){const Q=N[te];Number.isNaN(F[Q])?I[J++]=Q:K[B++]=Q}else if(S&&!W)for(let te=0;te<C;te++){const Q=N[te];S(Q)===1?K[B++]=Q:I[J++]=Q}else{const te=U(A);for(let Q=0;Q<C;Q++){const re=N[Q];Z(te(re))?I[J++]=re:K[B++]=re}}return J===0?{present:N,absent:j}:{present:K.subarray(0,B),absent:I.subarray(0,J)}}function q(A,N,C){if(N.length===0)return A;const S=new Uint32Array(A.length+N.length);return C?(S.set(N,0),S.set(A,N.length)):(S.set(A,0),S.set(N,A.length)),S}function M(A,N,C={}){const S=N||L(x(A,C));if(!A||S.length<2)return Uint32Array.from(S);const{present:F,absent:$}=G(A,S);if(F.length===0)return Uint32Array.from(S);const W=!!C.descending;let K;if(typeof C.compare=="function")K=V(A,F,C);else switch(A.kind){case"float64":K=i(A.values,F,W);break;case"int32":K=n(A.values,F,W);break;case"dictionary":K=f(A,F,C);break;case"bitset":K=l(A,F,W);break;default:K=E(A,F,C);break}return q(K,$,!!C.nullsFirst)}function O(A,N,C,S={}){const F=N||[],$=F.length&&(F[0].handle||T(A,F[0].col))||A&&A[0];let W=C||L(x($,S));for(let K=F.length-1;K>=0;K--){const I=F[K],B=I.handle||T(A,I.col)||A&&A[K];B&&(W=M(B,W,{descending:I.descending!==void 0?!!I.descending:I.dir==="desc",nullsFirst:!!I.nullsFirst,locale:I.locale!==void 0?I.locale:S.locale,compare:I.compare}))}return W instanceof Uint32Array?W:Uint32Array.from(W)}function T(A,N){if(!(!A||N===void 0)){for(let C=0;C<A.length;C++)if(A[C]&&A[C].id===N)return A[C]}}}),We("packages/core/src/store/stringrank.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return L}});const ne=D("packages/core/src/compute/sort.js"),P=ne.collateStringRanks,Y=ne.rankSortStrings,_=1e5;class L{#e=[];#t=new Map;#n;#r=0;#s=0;#i=-1;#o;#l=!1;#a=null;#c=-1;#u="\0";constructor(H=_){this.#o=H>0?H:_,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(H){this.#i=H}get generation(){return this.#s}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let H=this.#n.byteLength;const x=this.#e;for(let X=0;X<x.length;X++)H+=x[X].length*2+24;return H}#d(H,x){const X=this.#t.get(H);if(X!==void 0)return X;if(this.#l)return-1;if(x&&this.#e.length>=this.#o)return this.#l=!0,-1;const U=this.#e.length;return this.#e.push(H),this.#t.set(H,U),this.#s++,U}build(H,x){const X=x|0;this.#e=[],this.#t=new Map,this.#s=0,this.#l=!1,this.#a=null,this.#c=-1,this.#n=new Uint32Array(X);for(let U=0;U<X;U++){const j=H[U],k=typeof j=="string"?this.#d(j,!1):-1;this.#n[U]=k<0?0:k}this.#r=X}append(H,x,X){const U=(x|0)+(X|0);if(U>this.#n.length){const j=new Uint32Array(U);j.set(this.#n.subarray(0,this.#r)),this.#n=j}for(let j=x|0;j<U;j++){const k=H[j],b=typeof k=="string"?this.#d(k,!0):-1;this.#n[j]=b<0?0:b}this.#r=Math.max(this.#r,U)}ranks(H){const x=H||"";if(this.#a&&this.#c===this.#s&&this.#u===x)return this.#a;const X=P(this.#e,this.#e.length,H);return this.#a=X,this.#c=this.#s,this.#u=x,X}usable(H,x,X){if(this.#l||this.#e.length===0)return!1;const U=this.#n,j=this.#e,k=this.#r;for(let b=0;b<H.length;b++){const a=H[b];if(a>=k||j[U[a]]!==x[a])return!1}return!0}sort(H,x){const X=this.ranks(x.locale),U=this.#e.length,j=H.length,k=new Uint32Array(j),b=this.#n;for(let a=0;a<j;a++)k[a]=b[H[a]];return Y(H,k,X,U,!!x.descending)}}}),We("packages/core/src/store/columnstore.js",function(e,D){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return l}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/internal/predicates.js").isFunction,Z=D("packages/core/src/internal/paths.js").pathGetter,x=D("packages/core/src/store/bitset.js").Bitset,U=D("packages/core/src/store/dictionary.js").Dictionary,k=D("packages/core/src/store/multivalue.js").MultiValue,a=D("packages/core/src/store/stringrank.js").StringRankIndex,h=4294967295,r=1024,t=5e3,o=.2,u=new Set(["float64","int32","bitset","dictionary","object","multi"]);function d(y){return y==null}function s(y){if(typeof y=="number")return y;if(y instanceof Date)return y.getTime();if(typeof y=="boolean")return y?1:0;const c=Number(y);return Number.isNaN(c)&&typeof y=="string"?Date.parse(y):c}function g(y){const c=s(y);return Number.isFinite(c)?c|0:0}function i(y){return d(y)?[]:Array.isArray(y)?y:[y]}function n(y,c){switch(y.kind){case"float64":case"int32":return y.buf[c];case"bitset":return y.bits.get(c)===1;case"dictionary":return y.dict.valueOf(y.buf[c]);case"multi":{const m=y.mv.at(c),w=new Array(m.length);for(let v=0;v<m.length;v++)w[v]=y.dict.valueOf(m[v]);return w}default:return y.buf[c]}}function f(y,c){switch(y.kind){case"float64":case"int32":return y.values[c];case"bitset":return(y.values[c>>3]&1<<(c&7))!==0;case"dictionary":return(y.table||[])[y.values[c]];case"multi":{const m=y.offsets[c],w=y.offsets[c+1],v=y.table||[],E=new Array(w-m);for(let V=m;V<w;V++)E[V-m]=v[y.values[V]];return E}default:return y.values[c]}}class p{#e;#t;#n;#r;#s;#i;#o;#l=!1;#a=null;#c=null;#u=null;#d=null;#f=null;#h;#p;#m=-1;#g=null;#b=0;#y=0;#O=null;#w=null;#A=!1;constructor(c,m){this.#e=c.id;const w=u.has(c.kind)?c.kind:"object";c.kind&&!u.has(c.kind)&&P(`store.kind.${c.id}`,`column "${c.id}" declares unknown storage kind "${c.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=c.nullable!==!1,this.#o=c.dictionary??null,this.#i=m,this.#s=_(c.read)?c.read:Z(c.field||c.id),this.#h=c.stringRankIndex!=="off",this.#p=typeof c.stringRankMaxDistinct=="number"?c.stringRankMaxDistinct:0,this.#O=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.#A?null:this.#l?this.#t==="bitset"?this.#c.words:this.#t==="multi"?this.#u.values:this.#a:this.#T().values}get presence(){return this.#A||!this.#r?null:this.#l?this.#g:this.#T().presence}get dict(){return this.#A||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#A||!this.#h||this.kind!=="object")return null;const c=this.values,m=this.#i.physical();if(!c||m===0)return null;if(this.#f===null){if(typeof c[0]!="string")return null;const w=new a(this.#v());return w.build(c,m),w.version=this.#y,this.#f=w,this.#m=this.#y,w.capped?null:w}return this.#f.length<m&&this.#f.append(c,this.#f.length,m-this.#f.length),this.#f.version=this.#y,this.#m=this.#y,this.#f.capped?null:this.#f}#v(){return this.#p}#P(){this.#f=null,this.#m=-1}get offsets(){return this.#A||!this.#l||this.#t!=="multi"?null:this.#u.offsets}get version(){return this.#y}get bytes(){let c=0;return this.#a&&(c+=this.#a.byteLength??this.#a.length*8),this.#c&&(c+=this.#c.bytes),this.#u&&(c+=this.#u.bytes),this.#g&&(c+=this.#g.bytes),this.#d&&(c+=this.#d.bytes),this.#O&&(c+=this.#O.size*24),c}get(c){if(!this.#A&&!(c<0||c>=this.#i.physical())){if(!this.#l)return this.#E(c);if(this.#r&&this.#g.get(c)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[c];case"bitset":return this.#c.get(c)===1;case"dictionary":return this.#d.valueOf(this.#a[c]);case"multi":{const m=this.#u.at(c),w=new Array(m.length);for(let v=0;v<m.length;v++)w[v]=this.#d.valueOf(m[v]);return w}default:return this.#a[c]}}}set(c,m){this.#A||(this.#l?this.#C(c,m):this.#O.set(c,m===void 0?null:m),this.#f&&this.#P(),this.#y++)}read(c){return this.#s(c)}appendColumn(c,m,w){if(this.#A||w<=0)return;if(!this.#l){this.#y++;return}const v=this.#s,E=this.#r,V=this.#g;let G=!1;switch(this.#t){case"float64":{const q=this.#a;for(let M=0;M<w;M++){const O=v(c[M]);if(typeof O=="number"){E&&V.set(m+M),q[m+M]=O;continue}const T=O==null;E?V.assign(m+M,!T):T&&(G=!0),q[m+M]=T?NaN:s(O)}break}case"int32":{const q=this.#a;for(let M=0;M<w;M++){const O=v(c[M]),T=O==null;E?V.assign(m+M,!T):T&&(G=!0),q[m+M]=T?0:g(O)}break}case"bitset":{const q=this.#c;for(let M=0;M<w;M++){const O=v(c[M]),T=O==null;E?V.assign(m+M,!T):T&&(G=!0),q.assign(m+M,!T&&!!O)}break}case"dictionary":{const q=this.#a,M=this.#d;for(let O=0;O<w;O++){const T=v(c[O]),A=T==null;E?V.assign(m+O,!A):A&&(G=!0),q[m+O]=A?0:M.codeOf(T)}break}case"multi":{const q=this.#u,M=this.#d;for(let O=0;O<w;O++){const T=v(c[O]),A=T==null;E?V.assign(m+O,!A):A&&(G=!0);const N=i(T),C=new Array(N.length);for(let S=0;S<N.length;S++)C[S]=M.codeOf(N[S]);q.write(m+O,C)}break}default:{const q=this.#a;for(let M=0;M<w;M++){const O=v(c[M]),T=O==null;E?V.assign(m+M,!T):T&&(G=!0),q[m+M]=T?null:O}break}}G&&P(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#f&&this.#t==="object"&&(this.#f.append(this.#a,m,w),this.#f.version=this.#y+1,this.#m=this.#y+1),this.#y++}appendPacked(c,m,w){if(this.#A||w<=0||!c)return;if(!this.#l){this.#y++;return}const v=this.#g,E=c.presence;if(v)if(E)for(let G=0;G<w;G++)v.assign(m+G,(E[G>>3]&1<<(G&7))!==0);else for(let G=0;G<w;G++)v.set(m+G);const V=c.kind===this.#t;if(V&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(c.values,m),this.#y++;return}if(V&&this.#t==="bitset"){const G=c.values;for(let q=0;q<w;q++)this.#c.assign(m+q,(G[q>>3]&1<<(q&7))!==0);this.#y++;return}if(V&&this.#t==="dictionary"){const G=c.table||[],q=new Uint32Array(G.length);for(let A=0;A<G.length;A++)q[A]=this.#d.codeOf(G[A]);const M=c.values,O=this.#a,T=v;for(let A=0;A<w;A++){if(T&&(E&&(E[A>>3]&1<<(A&7))===0)){O[m+A]=0;continue}O[m+A]=q[M[A]]??0}this.#y++;return}if(V&&this.#t==="multi"){const G=c.table||[],q=new Uint32Array(G.length);for(let T=0;T<G.length;T++)q[T]=this.#d.codeOf(G[T]);const M=c.values,O=c.offsets;for(let T=0;T<w;T++){const A=O[T],N=O[T+1],C=new Array(N-A);for(let S=A;S<N;S++)C[S-A]=q[M[S]]??0;this.#u.write(m+T,C)}this.#y++;return}for(let G=0;G<w;G++){const q=E?(E[G>>3]&1<<(G&7))===0:c.kind==="object"?c.values[G]===null:!1;this.#C(m+G,q?null:f(c,G))}this.#y++}touch(){this.#y++}columnarise(c,m){if(this.#l||this.#A)return;const w=new Array(m);for(let v=0;v<m;v++)w[v]=this.#E(v);this.#t=this.#n,this.#l=!0,this.#S(c);for(let v=0;v<m;v++)this.#C(v,w[v]);this.#O.clear(),this.#w=null,this.#P(),this.#y++}grow(c){if(!(!this.#l||this.#A||c<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const m=new this.#a.constructor(c);m.set(this.#a),this.#a=m;break}case"bitset":this.#c.grow(c);break;case"multi":break;default:this.#a.length=c;break}this.#g&&this.#g.grow(c),this.#b=c,this.#y++}}convert(c){if(this.#A||!u.has(c)||(this.#n=c,!this.#l||c===this.#t))return!1;const m={kind:this.#t,buf:this.#a,bits:this.#c,mv:this.#u,dict:this.#d},w=this.#i.physical(),v=this.#g;this.#t=c,this.#S(this.#b);for(let E=0;E<w;E++){const V=v!==null&&v.get(E)===0;V&&c!=="multi"||this.#C(E,V?null:n(m,E))}return this.#P(),this.#y++,!0}compact(c,m,w){if(!this.#A){if(this.#P(),!this.#l){const v=this.#O;if(v.size){const E=new Map;for(const[V,G]of v)c[V]!==h&&E.set(c[V],G);this.#O=E}this.#w=null,this.#y++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const v=this.#a;for(let E=0;E<m;E++)c[E]!==h&&(v[c[E]]=v[E]);if(this.#t==="object")for(let E=w;E<m;E++)v[E]=void 0;break}case"bitset":{const v=this.#c;for(let E=0;E<m;E++)c[E]!==h&&v.assign(c[E],v.get(E)===1);for(let E=w;E<m;E++)v.clear(E);break}case"multi":this.#u.compact(c,w,h);break;default:break}if(this.#g){const v=this.#g;for(let E=0;E<m;E++)c[E]!==h&&v.assign(c[E],v.get(E)===1);for(let E=w;E<m;E++)v.clear(E)}this.#y++}}release(){this.#A||(this.#A=!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.#d=null,this.#f=null,this.#O=new Map,this.#w=null,this.#b=0,this.#y++)}#S(c){const m=Math.max(1,c);switch(this.#a=null,this.#c=null,this.#u=null,this.#t){case"float64":this.#a=new Float64Array(m);break;case"int32":this.#a=new Int32Array(m);break;case"bitset":this.#c=new x(m);break;case"dictionary":this.#a=new Uint32Array(m),this.#d=this.#d??new U(this.#o??[]);break;case"multi":this.#u=new k({rows:m,values:m}),this.#d=this.#d??new U(this.#o??[]);break;default:this.#a=new Array(m);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(m):this.#g=new x(m)),this.#b=m}#C(c,m){const w=d(m);switch(this.#r?this.#g.assign(c,!w):w&&P(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[c]=w?NaN:s(m);break;case"int32":this.#a[c]=w?0:g(m);break;case"bitset":this.#c.assign(c,!w&&!!m);break;case"dictionary":this.#a[c]=w?0:this.#d.codeOf(m);break;case"multi":{const v=i(m),E=new Array(v.length);for(let V=0;V<v.length;V++)E[V]=this.#d.codeOf(v[V]);this.#u.write(c,E);break}default:this.#a[c]=w?null:m;break}}#E(c){if(this.#O.has(c))return this.#O.get(c);const m=this.#s(this.#i.rowAt(c));return m===void 0?null:m}#T(){if(this.#w&&this.#w.version===this.#y)return this.#w;const c=this.#i.physical(),m=new Array(c),w=this.#r?new x(c):null;for(let v=0;v<c;v++){const E=this.#E(v);m[v]=E,w&&!d(E)&&w.set(v)}return this.#w={version:this.#y,values:m,presence:w},this.#w}}class l{#e;#t=new Map;#n=[];#r=[];#s=0;#i=0;#o=0;#l=0;#a=new x(0);#c=!1;#u=!0;#d;#f;#h;#p=!1;constructor(c,m={}){this.#e=Array.isArray(c)?c:[],this.#f=Math.max(1,m.initialCapacity??r),this.#u=m.retainSource!==!1,this.#d=this.#u?m.columnarBelow??t:0,this.#h=m.compactRatio??o;const w={rowAt:v=>this.#r[v],physical:()=>this.#s};for(const v of this.#e){if(!v||!v.id)continue;if(this.#t.has(v.id)){P(`store.dup.${v.id}`,`duplicate column id "${v.id}" in the store schema; ignoring the second`);continue}const E=new p(v,w);this.#t.set(v.id,E),this.#n.push(E)}this.#d<=0&&this.#b()}get count(){return this.#o}get physical(){return this.#s}get capacity(){return this.#c?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#c}get destroyed(){return this.#p}get bytes(){let c=this.#a.bytes+this.#r.length*8;for(const m of this.#n)c+=m.bytes;return c}append(c){const m=this.#s;if(this.#p||!c)return{from:m,to:m};const w=c.length|0;if(w===0)return{from:m,to:m};if(this.#u)for(let E=0;E<w;E++)this.#r[m+E]=c[E];if(this.#s=m+w,this.#o+=w,this.#a.grow(this.#s),!this.#c){if(this.#s>=this.#d)this.#b();else for(const E of this.#n)E.touch();return{from:m,to:this.#s}}this.#m(this.#s);const v=this.#n;for(let E=0;E<v.length;E++)v[E].appendColumn(c,m,w);return{from:m,to:this.#s}}appendPacked(c,m){const w=this.#s;if(this.#p||!c)return{from:w,to:w};const v=c.count|0;if(v===0)return{from:w,to:w};if(this.#u&&m)for(let V=0;V<v;V++)this.#r[w+V]=m[V];this.#s=w+v,this.#o+=v,this.#a.grow(this.#s),this.#c||this.#b(),this.#m(this.#s);const E=new Map;for(const V of c.columns)E.set(V.id,V);for(const V of this.#n){const G=E.get(V.id);G?V.appendPacked(G,w,v):V.grow(this.#i)}return{from:w,to:this.#s}}source(c){if(this.#u)return this.#r[c];if(!(c<0||c>=this.#s))return this.#g(c)}setSource(c,m){this.#p||c<0||c>=this.#s||this.#u&&(this.#r[c]=m)}get(c,m){const w=this.#t.get(c);return w?w.get(m):void 0}set(c,m,w){if(this.#p||m<0||m>=this.#s)return;const v=this.#t.get(c);if(!v){P(`store.set.${c}`,`set() on unknown column "${c}"`);return}v.set(m,w)}remove(c){return this.#p||c<0||c>=this.#s||this.#a.get(c)===1?!1:(this.#a.set(c),this.#l++,this.#o--,!0)}live(c){return c<0||c>=this.#s?!1:this.#a.get(c)===0}compact(c={}){if(this.#p||this.#l===0||!c.force&&this.#l/this.#s<this.#h)return null;const m=this.#s,w=new Uint32Array(m);let v=0;for(let E=0;E<m;E++)w[E]=this.#a.get(E)===1?h:v++;for(const E of this.#n)E.compact(w,m,v);if(this.#u){const E=this.#r;for(let V=0;V<m;V++)w[V]!==h&&(E[w[V]]=E[V]);E.length=v}return this.#s=v,this.#o=v,this.#l=0,this.#a=new x(Math.max(this.#i,v)),w}column(c){return this.#t.get(c)}columns(){return this.#n.slice()}liveIndices(){const c=new Uint32Array(this.#o);if(this.#l===0){for(let w=0;w<this.#s;w++)c[w]=w;return c}let m=0;for(let w=0;w<this.#s;w++)this.#a.get(w)===0&&(c[m++]=w);return c}convert(c,m){const w=this.#t.get(c);return w?w.convert(m):!1}destroy(){if(!this.#p){this.#p=!0;for(const c of this.#n)c.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#s=0,this.#o=0,this.#l=0,this.#i=0}}#m(c){if(c<=this.#i)return;let m=this.#i||this.#f;for(;m<c;)m*=2;for(const w of this.#n)w.grow(m);this.#a.grow(m),this.#i=m}#g(c){const m={};for(const w of this.#n)m[w.id]=w.get(c);return m}#b(){if(this.#c)return;let c=this.#f;for(;c<this.#s;)c*=2;this.#c=!0,this.#i=c,this.#a.grow(c);for(const m of this.#n)m.columnarise(c,this.#s)}}}),We("packages/core/src/store/pool.js",function(e,D){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return L}});const ne=64,P=8;function Y(H){let x=ne;for(;x<H;)x*=2;return x}class _{#e=new Map;#t=new WeakSet;#n;#r=0;#s={acquired:0,reused:0,released:0};constructor(x={}){this.#n=x.limit??P}get bytes(){return this.#r}mask(x){const X=new Uint8Array(this.#i(x),0,x);return X.fill(0),X}indices(x){return new Uint32Array(this.#i(x*4),0,x)}release(x){if(!x||!x.buffer)return!1;const X=x.buffer;if(!this.#t.has(X))return!1;this.#t.delete(X),this.#s.released++;const U=X.byteLength;let j=this.#e.get(U);return j||this.#e.set(U,j=[]),j.length>=this.#n||(j.push(X),this.#r+=U),!0}releaseAll(x){for(const X of x)this.release(X)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#s,retained:this.#r}}#i(x){const X=Y(x),U=this.#e.get(X);this.#s.acquired++;let j;return U&&U.length?(j=U.pop(),this.#r-=X,this.#s.reused++):j=new ArrayBuffer(X),this.#t.add(j),j}}function L(){return Z??=new _,Z}let Z=null}),We("packages/core/src/compute/sortspec.js",function(e,D){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return L}});function ne(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function P(Z){return!!Z&&typeof Z.compare!="function"}function Y(Z){if(!Z)return!0;for(let H=0;H<Z.length;H++)if(!P(Z[H]))return!1;return!0}function _(Z,H){const x=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,X=Z.locale!==void 0?Z.locale:H;return{col:x,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:ne(X)}}function L(Z,H){const x=Z||[],X=new Array(x.length);for(let U=0;U<x.length;U++)X[U]=_(x[U],H);return X}}),We("packages/core/src/compute/facet.js",function(e,D){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const ne=D("packages/core/src/compute/handle.js"),P=ne.presenceReader,Y=ne.valueReader,_=ne.dictSize,L=ne.dictValue,Z=Object.freeze(["equal","quantile","log"]),H=Object.freeze(["hour","day","week","month","quarter","year"]),x=20,X=50,U=1e4;function j(v,E){if(!v)return"none";const V=E;if(V&&(V.multi===!0||typeof V.items=="function"))return"category";const G=E&&E.base;if(G==="date"||G==="datetime"||G==="time"||G==="dateString")return"date";switch(v.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return G==="number"?"numeric":G==="boolean"?"boolean":G==="text"?"category":"none"}}function k(v){const E=v.values,V=v.kind;if((V==="float64"||V==="int32")&&E)return q=>E[q];const G=Y(v);return q=>b(G(q))}function b(v){if(typeof v=="number")return v;if(v instanceof Date)return v.getTime();if(v==null||v==="")return NaN;if(typeof v=="boolean")return v?1:0;if(typeof v=="string"){const E=Number(v);if(Number.isFinite(E))return E;const V=Date.parse(v);return Number.isFinite(V)?V:NaN}return NaN}function a(v,E,V,G=X){if(!v)return{cardinality:0,exact:!0};if(v.dict)return{cardinality:_(v.dict),exact:!0};if(v.kind==="bitset")return{cardinality:2,exact:!0};const q=Y(v),M=E?E.length:V,O=new Set;for(let T=0;T<M;T++){const A=q(E?E[T]:T);if(A!=null&&(O.add(A),O.size>G))return{cardinality:O.size,exact:!1}}return{cardinality:O.size,exact:!0}}const h=36e5,r=864e5;function t(v,E=x){const V=Number.isFinite(v)&&v>0?v:0,G=Math.max(1,E)*2;return V/h<=G?"hour":V/r<=G?"day":V/(7*r)<=G?"week":V/(30*r)<=G?"month":V/(91*r)<=G?"quarter":"year"}function o(v,E){if(!Number.isFinite(v))return NaN;const V=new Date(v);switch(E){case"hour":return V.setMinutes(0,0,0),V.getTime();case"day":return V.setHours(0,0,0,0),V.getTime();case"week":{V.setHours(0,0,0,0);const G=(V.getDay()+6)%7;return V.setDate(V.getDate()-G),V.getTime()}case"month":return V.setDate(1),V.setHours(0,0,0,0),V.getTime();case"quarter":return V.setMonth(Math.floor(V.getMonth()/3)*3,1),V.setHours(0,0,0,0),V.getTime();default:return V.setMonth(0,1),V.setHours(0,0,0,0),V.getTime()}}function u(v,E){const V=new Date(v);switch(E){case"hour":V.setHours(V.getHours()+1);break;case"day":V.setDate(V.getDate()+1);break;case"week":V.setDate(V.getDate()+7);break;case"month":V.setMonth(V.getMonth()+1);break;case"quarter":V.setMonth(V.getMonth()+3);break;default:V.setFullYear(V.getFullYear()+1);break}return V.getTime()}function d(v,E,V){const G=k(v),q=P(v),M=E?E.length:V;let O=1/0,T=-1/0,A=0,N=0;for(let C=0;C<M;C++){const S=E?E[C]:C;if(q&&!q(S)){A++;continue}const F=G(S);if(!Number.isFinite(F)){A++;continue}F<O&&(O=F),F>T&&(T=F),N++}return{min:O,max:T,nulls:A,finite:N}}function s(v,E,V,G){const q=k(v),M=P(v),O=E?E.length:V,T=O>G?O/G:1,A=[];for(let C=0;C<O;C+=T){const S=E?E[Math.floor(C)]:Math.floor(C);if(M&&!M(S))continue;const F=q(S);Number.isFinite(F)&&A.push(F)}const N=Float64Array.from(A);return N.sort(),N}function g(v,E,V,G={}){const q=G.kind||j(v,G.type);return q==="none"||!v?{kind:"none",buckets:[],suppressed:"type"}:q==="boolean"?i(v,E,V,G):q==="category"?n(v,E,V,G):p(v,E,V,q,G)}function i(v,E,V,G={}){const q=P(v);let M=0;if(q){const T=E?E.length:V;for(let A=0;A<T;A++)q(E?E[A]:A)||M++}const O=[{value:!1,label:"false"},{value:!0,label:"true"}];return M>0&&G.blanks!==!1&&O.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:O}}function n(v,E,V,G){const q=G.cardinalityLimit??X,{cardinality:M}=a(v,E,V,q);if(M>q&&(G.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:M};const O=Y(v),T=E?E.length:V,A=new Map;let N=0;for(let W=0;W<T;W++){const K=O(E?E[W]:W);if(K==null||K===""){N++;continue}if(Array.isArray(K)){if(!K.length){N++;continue}for(const I of K)A.set(I,(A.get(I)||0)+1);continue}A.set(K,(A.get(K)||0)+1)}let C=[...A.entries()];G.order==="alpha"?C.sort((W,K)=>String(W[0]).localeCompare(String(K[0]))):C.sort((W,K)=>K[1]-W[1]);let S=0,F=0;if(C.length>q){F=C.length-q;for(let W=q;W<C.length;W++)S+=C[W][1];C=C.slice(0,q)}const $=C.map(([W])=>({value:W,label:String(W)}));return S>0&&$.push({remainder:!0,label:`Other (${F} values)`}),N>0&&G.blanks!==!1&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:M}}function f(v,E,V,G,q){const M=s(v,E,V,U),O=M.length;if(O<100)return null;const T=M[Math.floor(.01*O)],A=M[Math.ceil(.99*O)-1];return!(A>T)||q-G<=2*(A-T)?null:{lo:T,hi:A}}function p(v,E,V,G,q){const{min:M,max:O,nulls:T,finite:A}=d(v,E,V);if(!A)return{kind:G,buckets:T&&q.blanks!==!1?[{null:!0,label:"Empty"}]:[],empty:!0};const N=Math.max(1,Math.floor(q.buckets||x));let C=[];if(G==="date"){const F=H.includes(q.granularity)?q.granularity:t(O-M,N);let $=o(M,F);for(;$<=O&&C.length<4096;){const W=u($,F);if(!(W>$))break;C.push({from:$,to:W}),$=W}return{kind:G,buckets:l(C,q.blanks===!1?0:T),granularity:F}}const S=Z.includes(q.strategy)?q.strategy:"equal";if(S==="quantile"){const F=s(v,E,V,U);if(F.length){const $=[F[0]];for(let W=1;W<N;W++){const K=F[Math.min(F.length-1,Math.floor(W/N*F.length))];K>$[$.length-1]&&$.push(K)}$.push(O);for(let W=0;W<$.length-1;W++)C.push({from:$[W],to:$[W+1]})}}else if(S==="log"&&M>0){const F=Math.log10(M),W=(Math.log10(O)-F)/N||1;for(let K=0;K<N;K++)C.push({from:10**(F+K*W),to:10**(F+(K+1)*W)})}if(!C.length&&S==="equal"){const F=f(v,E,V,M,O);if(F){const $=(F.hi-F.lo)/N;F.lo>M&&C.push({from:M,to:F.lo,overflow:"low"});for(let W=0;W<N;W++)C.push({from:F.lo+W*$,to:F.lo+(W+1)*$});C[C.length-1].to=F.hi,F.hi<O&&C.push({from:F.hi,to:O,overflow:"high"})}}if(!C.length){const F=(O-M)/N||1;for(let $=0;$<N;$++)C.push({from:M+$*F,to:M+($+1)*F})}return C[C.length-1].to=O,{kind:G,buckets:l(C,q.blanks===!1?0:T),strategy:S,min:M,max:O}}function l(v,E){return E>0?[...v,{null:!0,label:"Empty"}]:v}function y(v,E,V,G,q){const M=G&&G.buckets||[],O=q&&q.length>=M.length?q.subarray(0,M.length):new Uint32Array(M.length);if(O.fill(0),!v||!M.length)return O;const T=M.length-1,A=!!M[T]&&M[T].null===!0,N=E?E.length:V;if(G.kind==="boolean"){const W=Y(v);for(let K=0;K<N;K++){const I=W(E?E[K]:K);if(I==null){A&&O[T]++;continue}O[I?1:0]++}return O}if(G.kind==="category"){const W=new Map;for(let B=0;B<M.length;B++)!M[B].null&&!M[B].remainder&&W.set(M[B].value,B);const K=M.findIndex(B=>B.remainder),I=Y(v);for(let B=0;B<N;B++){const J=I(E?E[B]:B);if(J==null||J===""){A&&O[T]++;continue}if(Array.isArray(J)){if(!J.length){A&&O[T]++;continue}for(const Q of J){const re=W.get(Q);re!==void 0?O[re]++:K>=0&&O[K]++}continue}const te=W.get(J);te!==void 0?O[te]++:K>=0&&O[K]++}return O}const C=A?M.length-1:M.length,S=new Float64Array(C+1);for(let W=0;W<C;W++)S[W]=M[W].from;S[C]=C?M[C-1].to:0;const F=k(v),$=P(v);for(let W=0;W<N;W++){const K=E?E[W]:W;if($&&!$(K)){A&&O[T]++;continue}const I=F(K);if(!Number.isFinite(I)){A&&O[T]++;continue}const B=c(S,C,I);B>=0&&O[B]++}return O}function c(v,E,V){if(!E||V<v[0])return-1;if(V>=v[E])return V===v[E]?E-1:-1;let G=0,q=E-1;for(;G<q;){const M=G+q+1>>>1;V>=v[M]?G=M:q=M-1}return G}function m(v,E,V,G={}){const q=G.bounds||g(v,G.boundsIndices??E,V,G);return{bounds:q,counts:y(v,E,V,q)}}const w=m}),We("packages/core/src/compute/pivotmatrix.js",function(e,D){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return o}});const P=D("packages/core/src/compute/handle.js").valueComparator,_=D("packages/core/src/compute/total.js").total,Z=D("packages/core/src/compute/group.js").packKeys,H=D("packages/core/src/compute/pivot.js"),x=H.joinPath,X=H.DEFAULT_PATH_SEPARATOR,U=H.DEFAULT_MAX_COLUMNS,j="";function k(u,d,s={}){const g=s.separator||X,i=u||[],n=d instanceof Uint32Array?d:Uint32Array.from(d||[]),f=n.length;if(i.length===0)return{tuples:[[]],paths:[j],buckets:[n]};const{keyOf:p,readers:l}=Z(i,n,0),y=new Map,c=[],m=[],w=[];for(let M=0;M<f;M++){const O=n[M],T=p(O);let A=y.get(T);if(A===void 0){A=c.length,y.set(T,A),m.push(T);const N=new Array(l.length);for(let C=0;C<l.length;C++)N[C]=l[C](O);c.push(N),w.push([])}w[A].push(O)}const v=P(s.locale),E=c.map((M,O)=>O);E.sort((M,O)=>{const T=c[M],A=c[O];for(let N=0;N<T.length;N++){const C=b(T[N],A[N],v);if(C!==0)return C}return M-O});const V=new Array(E.length),G=new Array(E.length),q=new Array(E.length);for(let M=0;M<E.length;M++){const O=E[M];V[M]=c[O],G[M]=x(c[O],g),q[M]=Uint32Array.from(w[O])}return{tuples:V,paths:G,buckets:q}}function b(u,d,s){const g=u==null,i=d==null;return g||i?g&&i?0:g?1:-1:s(u,d)}function a(u,d,s){const g=[];for(let i=0;i<u.length;i++)s.has(u[i])&&g.push(u[i]);return Uint32Array.from(g)}function h(u,d,s,g){return{value:d.length?_(u,d,s,g):null,leaves:d,count:d.length}}function r(u){const d=u&&u.opts||{},s=d.separator||X,g=d.totalContext||{locale:d.locale},i=(u.measures||[]).filter(G=>G&&G.handle),n=u.leaves instanceof Uint32Array?u.leaves:Uint32Array.from(u.leaves||[]),f=k(u.rowHandles||[],n,{...d,separator:s}),p=k(u.columnHandles||[],n,{...d,separator:s}),l=d.maxColumns===void 0?U:d.maxColumns,y=p.paths.length*Math.max(1,i.length),c=new Map;if(l&&y>l)return{rowAxis:f,columnAxis:p,measures:i.map(G=>({colId:G.colId,fn:G.fn})),body:c,rowMargin:c,columnMargin:c,grand:c,columns:y,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${y} columns, above pivot.maxColumns of ${l}. Narrow the pivot columns or raise the limit.`,columns:y,maxColumns:l}};const m=new Map,w=new Map,v=new Map,E=new Map,V=p.buckets.map(G=>new Set(G));for(let G=0;G<p.paths.length;G++){const q=p.buckets[G],M=p.paths[G];for(const O of i)v.set(o(M,O.colId),h(O.handle,q,O.fn,g))}for(let G=0;G<f.paths.length;G++){const q=f.buckets[G],M=f.paths[G];for(const O of i)w.set(o(M,O.colId),h(O.handle,q,O.fn,g));for(let O=0;O<p.paths.length;O++){const T=a(q,p.buckets[O],V[O]);if(T.length===0)continue;const A=p.paths[O];for(const N of i)m.set(t(M,A,N.colId),h(N.handle,T,N.fn,g))}}for(const G of i)E.set(G.colId,h(G.handle,n,G.fn,g));return{rowAxis:f,columnAxis:p,measures:i.map(G=>({colId:G.colId,fn:G.fn})),body:m,rowMargin:w,columnMargin:v,grand:E,columns:y,error:null}}function t(u,d,s){return`${u}\0${d}\0${s}`}function o(u,d){return`${u}\0${d}`}}),We("packages/core/src/compute/reference.js",function(e,D){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return U}}),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 a}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return r}});const P=D("packages/core/src/internal/paths.js").getPath,Y=D("packages/core/src/compute/handle.js"),_=Y.isMissing,L=Y.valueComparator,H=D("packages/core/src/compute/filter.js").testValue,x="",X="\0";function U(u,d){const s=d.includes(".")?P(u,d):u?.[d];return s===void 0?null:s}function j(u,d,s={}){const g=d||[];let i=u.map((n,f)=>f);if(g.length===0)return i;for(let n=g.length-1;n>=0;n--)i=k(u,i,g[n],s);return i}function k(u,d,s,g){const i=s.locale!==void 0?s.locale:g.locale,n=L(i),f=s.descending!==void 0?!!s.descending:s.dir==="desc",p=[],l=[];for(const m of d){const w=U(u[m],s.col);_(w)?l.push(m):p.push(m)}const y=new Map;for(let m=0;m<p.length;m++)y.set(p[m],m);const c=(m,w)=>{const v=U(u[m],s.col),E=U(u[w],s.col);let V;return typeof s.compare=="function"?(V=s.compare(v,E,u[m],u[w],f),f&&(V=-V)):V=f?n(E,v):n(v,E),V!==0?V:y.get(m)-y.get(w)};return p.sort(c),s.nullsFirst?l.concat(p):p.concat(l)}function b(u,d,s={}){const g=[];for(let i=0;i<u.length;i++)a(u[i],d,s,i)&&g.push(i);return g}function a(u,d,s,g){if(!d)return!0;if(Array.isArray(d.conditions)){const i=d.conditions.filter(f=>f!=null);if(i.length===0)return!0;if(d.op==="or")return i.some(f=>a(u,f,s,g));const n=i.every(f=>a(u,f,s,g));return d.op==="not"?!n:n}return d.col===void 0&&typeof s.custom=="function"?!!s.custom(d,u,g):H(U(u,d.col),d,s.locale)}function h(u,d,s,g){const i=s||u.map((l,y)=>y),n=new Map,f=[],p=[];for(const l of i){const y=d.map((w,v)=>{const E=U(u[l],w);return g&&g[v]?g[v](E):E}),c=y.map(w=>w==null?X:String(w)).join(x);let m=n.get(c);m===void 0&&(m=f.length,n.set(c,m),f.push(y),p.push([])),p[m].push(l)}return{keys:f,buckets:p}}function r(u,d,s={}){const g=L(s.locale),i=u.filter(f=>!_(f)),n=i.map(t).filter(f=>f!==null);switch(d){case"count":return u.length;case"countValues":return i.length;case"sum":return n.reduce((f,p)=>f+p,0);case"avg":return i.length===0?null:n.reduce((f,p)=>f+p,0)/i.length;case"min":return i.length===0?null:i.reduce((f,p)=>g(p,f)<0?p:f);case"max":return i.length===0?null:i.reduce((f,p)=>g(p,f)>0?p:f);case"first":return u.length===0?null:o(u[0]);case"last":return u.length===0?null:o(u[u.length-1]);default:return null}}function t(u){if(typeof u=="number")return Number.isNaN(u)?null:u;if(u==null||u===""||typeof u=="boolean")return null;if(u instanceof Date)return u.getTime();const d=Number(u);return Number.isNaN(d)?null:d}function o(u){return u===void 0?null:u}}),We("packages/core/src/compute/index.js",function(e,D){"use strict";const ne=D("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return ne.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return ne.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return ne.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return ne.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return ne.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return ne.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return ne.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return ne.rankSortStrings}});const P=D("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return P.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return P.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return P.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return P.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return P.describeSort}});const Y=D("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return Y.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return Y.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return Y.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return Y.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return Y.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return Y.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return Y.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return Y.mentionsColumn}});const _=D("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return _.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return _.packKeys}});const L=D("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return L.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return L.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return L.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return L.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return L.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return L.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return L.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return L.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return L.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return L.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return L.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return L.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return L.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return L.QUANTILE_SAMPLE}});const Z=D("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const H=D("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return H.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return H.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return H.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return H.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return H.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return H.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return H.DEFAULT_MAX_COLUMNS}});const x=D("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 X=D("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return X.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return X.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return X.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return X.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return X.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return X.referenceValue}});const U=D("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return U.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return U.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return U.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return U.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return U.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return U.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return U.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return U.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return U.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return U.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return U.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return U.isMissing}});const j=D("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 k=D("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return k.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return k.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return k.openWindow}});const b=D("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 a=D("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return a.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return a.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return a.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return a.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return a.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return a.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return a.anomalyCondition}});const h=D("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return h.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return h.forecast}})}),We("packages/core/src/source/rows.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return h}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/internal/predicates.js").isFunction,L=32,Z="\0";function H(r){return new x(r)}class x{#e;#t;constructor(t){this.#e=_(t&&t.rowKey)?t.rowKey:null;const o=t&&t.config?t.config.rowHeight:void 0;this.#t=typeof o=="number"||_(o)?o:L}get keyed(){return this.#e!==null}keyOf(t,o){if(this.#e){const u=this.#e(t);if(u!=null)return String(u)}else P("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${o}`}heightOf(t){return _(this.#t)?Number(this.#t(t))||L:this.#t}leaf(t,o,u=0,d=null){const s={key:this.keyOf(t,o),data:t,level:u,parent:d,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:o};return s.height=this.heightOf(s),s}group(t){const o={key:a(t.keyPath||t.path),data:null,level:t.level,parent:t.parent||null,children:[],group:!0,expanded:t.expanded!==!1,leafCount:t.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:t.column,groupValue:t.value,groupPath:t.path,hasChildren:t.hasChildren!==!1};return t.totals&&(o.totals=t.totals),o.height=this.heightOf(o),o}footer(t){const o={key:`${t.key}${Z}footer`,data:null,level:t.level,parent:t,group:!0,footer:!0,expanded:!1,leafCount:t.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:t.groupColumn,groupValue:t.groupValue,groupPath:t.groupPath,hasChildren:!1,totals:t.totals};return o.height=this.heightOf(o),o}detail(t,o){return{key:`${t.key}${Z}detail`,data:t.data,level:t.level+1,parent:t,group:!1,detail:!0,expanded:!1,leafCount:0,height:o,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:t.key}}grandTotal(t,o){const u={key:`${Z}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:o,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:t};return u.height=this.heightOf(u),u}skeleton(t,o=0,u=!1){const d={key:`${Z}pending${Z}${t}`,data:null,level:o,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:t,selected:!1,physical:null,pending:!0};return u&&(d.loadError=!0),d.height=this.heightOf(d),d}}function X(r,t,o,u){return{key:`${Z}pinned${Z}${o}${Z}${t}`,data:r,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:u,index:null,selected:!1,physical:null,hasChildren:!1,pinned:o}}function U(r,t){return new Proxy([],{get(o,u,d){if(u==="length")return r();if(typeof u=="string"){const s=Number(u);if(Number.isInteger(s)&&s>=0)return t(s)}return Reflect.get(o,u,d)},has(o,u){if(typeof u=="string"){const d=Number(u);if(Number.isInteger(d)&&d>=0)return d<r()}return Reflect.has(o,u)}})}function j(r){return r==null?"":String(r)}const k="";function b(r){if(r==null)return k;const t=String(r);return t.startsWith(k)?k+t:t}function a(r){const t=r||[];let o="g";for(let u=0;u<t.length;u++)o+=Z+b(t[u]);return o}function h(r){const t=new Array(r.length),o=[];for(let u=0;u<r.length;u++)o.push(r[u]),t[u]=a(o);return t}}),We("packages/core/src/source/handles.js",function(e,D){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return Z}});const P=D("packages/core/src/internal/predicates.js").isFunction,_=D("packages/core/src/internal/warn.js").warnOnce;class L{#e;#t;#n;#r=new Map;#s=0;constructor(x,X,U){this.#e=x,this.#t=X,this.#n=P(U)?U:()=>!1}get store(){const x=this.#e.store;return x&&P(x.column)?x:null}invalidate(){this.#s++}handle(x){const X=this.store;if(X){const b=X.column(x);if(b)return b}const U=this.#r.get(x);if(U&&U.builtAt===this.#s)return U.handle;const j=this.#i(x);if(!j)return;if(X&&this.#n()){_(`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 k=this.#o(j);return this.#r.set(x,{handle:k,builtAt:this.#s}),k}#i(x){const X=this.#e.columns;return X&&P(X.get)?X.get(x):void 0}#o(x){const X=this.#t()||[],U=X.length,j=new Array(U),k=P(x.getValue)?a=>x.getValue(a):a=>a?.[x.field||x.id];for(let a=0;a<U;a++)j[a]=X[a]===void 0?void 0:k(X[a]);const b=this.#s;return{id:x.id,kind:"object",nullable:!1,values:j,presence:null,dict:null,offsets:null,get(a){return j[a]},version:b}}}function Z(H,x,X){return new L(H,x,X)}}),We("packages/core/src/compute/incremental.js",function(e,D){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const P=D("packages/core/src/store/columnstore.js").toFloat,Y=Object.freeze(["sum","avg","countValues","min","max"]),_=Object.freeze(["float64"]),L=1e15;function Z(U,j){return typeof U!="string"||!Y.includes(U)?!1:!!j&&_.includes(j.kind)}function H(U){if(U==null)return null;const j=P(U);return Number.isNaN(j)?null:j}class x{#e;#t=0;#n=0;#r=0;#s=1/0;#i=-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 k=0;k<j.length;k++){const b=H(j[k]);b!==null&&this.#c(b)}this.#o=!0}seedColumn(j,k,b){this.#a();for(let a=0;a<b.length;a++){const h=b[a];if(k&&k(h)===0)continue;const r=j[h];Number.isNaN(r)||this.#c(r)}this.#o=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#s=1/0,this.#i=-1/0,this.#l=!1}#c(j){if(!Number.isFinite(j)){this.#l=!0;return}const k=this.#t+j;this.#n+=Math.abs(this.#t)>=Math.abs(j)?this.#t-k+j:j-k+this.#t,this.#t=k,this.#r++,j<this.#s&&(this.#s=j),j>this.#i&&(this.#i=j)}#u(j){const k=this.#t-j;this.#n+=Math.abs(this.#t)>=Math.abs(j)?this.#t-k-j:-j-k+this.#t,this.#t=k,this.#r--}update(j,k){if(!this.#o)return!1;const b=H(j),a=H(k);return b===null&&a===null?!0:b!==null&&!Number.isFinite(b)||a!==null&&!Number.isFinite(a)?!1:this.#e==="min"||this.#e==="max"?b===null||a===null?!1:this.#e==="min"?a<this.#s?(this.#s=a,!0):b>this.#s:a>this.#i?(this.#i=a,!0):b<this.#i:Math.abs(this.#t)>L?!1:(b!==null&&this.#u(b),a!==null&&this.#c(a),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#s:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#o=!1}}const X=x}),We("packages/core/src/source/filterwire.js",function(e,D){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return v}});const P=D("packages/core/src/internal/warn.js").warnOnce,Y="source.remote.hostFilter",_="source.where.pageRelative";function L(G,q){!Array.isArray(G)||!G.length||P(_,`filters.where (${G.join(", ")}) runs over the rows the ${q} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function Z(G){const q=(G||{}).config;!q||!q.hostFilter||P(Y,"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 H="source.where.notApplied";function x(G,q){P(`${H}:${G}`,`filters.where("${G}") is registered but the ${q} 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 X="source.where.overThreshold";function U(G,q,M,O){!Array.isArray(G)||!G.length||P(`${X}:${q}`,`filters.where (${G.join(", ")}) is not applied to the ${q} pushdown source:`,M===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${M.toLocaleString()} rows, at or past the whereRowLimit of ${O.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 k(G){let q=j.get(G);return q||(q=new Intl.DateTimeFormat("en-US",{timeZone:G,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),j.set(G,q)),q}function b(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function a(G,q){const M=k(q).formatToParts(new Date(G)),O={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const T of M)T.type==="year"?O.y=+T.value:T.type==="month"?O.m=+T.value:T.type==="day"?O.d=+T.value:T.type==="hour"?O.h=+T.value%24:T.type==="minute"?O.mi=+T.value:T.type==="second"&&(O.s=+T.value);return O}function h(G,q){const M=a(G,q);return Date.UTC(M.y,M.m-1,M.d,M.h,M.mi,M.s)-Math.floor(G/1e3)*1e3}function r(G,q,M,O){const T=Date.UTC(G,q-1,M),A=T-h(T,O);return T-h(A,O)}function t(G,q,M){const O=new Date(Date.UTC(G.y,G.m-1,G.d+q));return r(O.getUTCFullYear(),O.getUTCMonth()+1,O.getUTCDate(),M)}const o=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function u(G,q){if(typeof G!="string")return null;const M=G.trim().toLowerCase().replace(/[\s_-]+/g,""),O=/^last(\d*|n)days?$/.exec(M);if(O){const T=O[1]==="n"?"":O[1],A=Number(T||q);return!Number.isFinite(A)||A<=0?null:{kind:"lastNDays",n:Math.floor(A)}}switch(M){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 d(G,q={}){const M=u(G,q.n);if(!M)return null;const O=q.tz||b(),T=q.now instanceof Date?q.now.getTime():typeof q.now=="number"?q.now:Date.now(),A=a(T,O),N=r(A.y,A.m,A.d,O),C=t(A,1,O);let S=N,F=C;switch(M.kind){case"today":break;case"yesterday":S=t(A,-1,O),F=N;break;case"lastNDays":F=q.includeToday?C:N,S=t(A,q.includeToday?-(M.n-1):-M.n,O);break;case"thisWeek":{const $=Number.isFinite(q.weekStartsOn)?Number(q.weekStartsOn):1,K=(new Date(Date.UTC(A.y,A.m-1,A.d)).getUTCDay()-$+7)%7;S=t(A,-K,O),F=t(A,-K+7,O);break}case"thisMonth":S=r(A.y,A.m,1,O),F=r(A.m===12?A.y+1:A.y,A.m===12?1:A.m+1,1,O);break;case"thisQuarter":case"quarterToDate":{const $=Math.floor((A.m-1)/3)*3+1;S=r(A.y,$,1,O),F=M.kind==="quarterToDate"?C:$===10?r(A.y+1,1,1,O):r(A.y,$+3,1,O);break}case"thisYear":case"yearToDate":S=r(A.y,1,1,O),F=M.kind==="yearToDate"?C:r(A.y+1,1,1,O);break;default:return null}return{from:new Date(S).toISOString(),to:new Date(F).toISOString(),bounds:"[)",tz:O,relative:M.kind==="lastNDays"?`last${M.n}Days`:M.kind,n:M.n}}function s(G){if(!G||typeof G!="object")return null;const q=G.value;if(q&&typeof q=="object"&&!Array.isArray(q)&&"relative"in q)return{token:String(q.relative),n:typeof q.n=="number"?q.n:void 0};if(G.op==="relative"&&typeof G.value=="string")return{token:G.value,n:void 0};const M=G.meta;return M&&typeof M.relative=="string"&&G.value===void 0?{token:M.relative,n:typeof M.n=="number"?M.n:void 0}:null}function g(){return`Known tokens: ${o.filter(q=>q!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function i(G){const q=s(G);return q?u(q.token,q.n)!==null:!1}function n(G,q={}){const M=s(G);if(!M)return G;const O=d(M.token,{...q,n:M.n});return O?{...G,type:G.type||"date",op:"between",value:[O.from,O.to],bounds:G.bounds||O.bounds,meta:{...G.meta||{},relative:O.relative,tz:O.tz}}:(P(`source.relative.${M.token}`,`unknown relative date token "${M.token}"; sending the condition unresolved.`,g()),G)}function f(G){return!!G&&typeof G=="object"&&Array.isArray(G.conditions)}function p(G,q){if(G){if(f(G)){for(const M of G.conditions)p(M,q);return}q(G)}}function l(G,q){if(!G)return null;if(!f(G))return q(G);const M=G;let O=!1;const T=[];for(const A of M.conditions){const N=l(A,q);N!==A&&(O=!0),N&&T.push(N)}return!O&&T.length===M.conditions.length?G:T.length?{...M,conditions:T}:null}function y(G){if(!G)return null;if(!f(G))return G;const q=G,M=[];for(const O of q.conditions){const T=y(O);T&&M.push(T)}return M.length?{op:q.op,conditions:M}:null}function c(G){const q=y(G);return q?f(q)&&q.op==="and"?q:{op:"and",conditions:[q]}:null}function m(G){const q=(G||[]).filter(Boolean);return q.length?{op:"and",conditions:q}:null}function w(G,q={}){const M=l(G,O=>n(O,q));return c(M)}function v(G){const q=E(G.filters??null);return JSON.stringify([q,G.sort??null,G.quick??"",G.groupBy??null,G.pivotBy??null,V(G.context)])}function E(G){if(!G)return null;if(f(G)){const O=G;return{op:O.op,conditions:O.conditions.map(E)}}const q=G,M=q.meta&&typeof q.meta.relative=="string"?q.meta.relative:s(q)?.token;return{col:q.col,op:q.op,bounds:q.bounds??null,caseSensitive:q.caseSensitive??!1,value:M?`rel:${M}`:q.value??null}}function V(G){if(G==null)return null;try{return JSON.parse(JSON.stringify(G))}catch{return P("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),We("packages/core/src/source/tree.js",function(e,D){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return a}});const P=D("packages/core/src/internal/predicates.js").isFunction,_=D("packages/core/src/internal/warn.js").warnOnce,L="",Z="\0tree:";function H(h,r){return{physical:h,key:r,level:0,children:[],value:void 0}}function x(h,r){const t=[],o=new Map;for(let u=0;u<h.length;u++){const d=h[u],s=r.pathOf(d),g=Array.isArray(s)?s.map(n=>String(n)):[];if(!g.length){const n=H(d,r.keyOf(d));t.push(n);continue}let i=null;for(let n=0;n<g.length;n++){const f=g.slice(0,n+1).join(L),p=n===g.length-1;let l=o.get(f);l&&p&&l.physical===-1&&(l.physical=d,l.key=r.keyOf(d)),l||(l=H(p?d:-1,p?r.keyOf(d):Z+f),l.level=n,l.value=g[n],o.set(f,l),i?i.children.push(l):t.push(l)),i=l}}return{roots:t,nodes:o}}function X(h,r){const t=new Map,o=[];for(let g=0;g<h.length;g++){const i=h[g],n=r.keyOf(i),f=H(i,n);t.set(n,f);const p=r.parentOf(i);p!=null&&p!==""&&o.push({node:f,parent:String(p)})}let u=null;const d=new Map;for(const{node:g,parent:i}of o){const n=t.get(i);if(n){d.set(g.key,n);continue}r.orphans&&r.orphans!=="root"&&(u||(u=H(-1,`${Z}orphans`),u.value=r.orphans),d.set(g.key,u))}const s=[];for(const g of t.values()){const i=d.get(g.key);i?i.children.push(g):s.push(g)}return u&&u.children.length&&s.push(u),{roots:U(s,t,r.orphans,u),nodes:t}}function U(h,r,t,o){const u=new Set,d=[...h];for(;d.length;){const f=d.pop();if(!u.has(f.key)){u.add(f.key);for(const p of f.children)d.push(p)}}const s=[];for(const f of r.values())u.has(f.key)||s.push(f);if(!s.length)return h;const g=!!t&&t!=="root";_("tree.cycle",`tree.parentKey produced ${s.length} row(s) inside a parent cycle; `+(g?`they are shown under "${t}".`:"they are shown at the root."));for(const f of s)f.children=f.children.filter(p=>u.has(p.key));if(!g)return[...h,...s];let i=o;const n=[...h];return i||(i=H(-1,`${Z}orphans`),i.value=t,n.push(i)),i.children.push(...s),n}function j(h){let r=0;const t=(o,u)=>{for(const d of o)d.level=u,u>r&&(r=u),d.children.length&&t(d.children,u+1)};return t(h,0),r}function k(h,r){if(!h||typeof h!="object")return null;const t=h.path,o=h.parentKey,u=P(h.hasChildren)?d=>!!h.hasChildren(r.dataAt(d)):null;if(P(t))return{mode:"path",pathOf:d=>t(r.dataAt(d)),keyOf:r.keyOf,declaresChildren:u};if(o!=null){const d=P(o)?o:s=>s?.[o];return{mode:"parentKey",parentOf:s=>d(r.dataAt(s)),keyOf:r.keyOf,orphans:h.orphans||"root",declaresChildren:u}}return _("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function b(h,r){const t=r.mode==="path"?x(h,r):X(h,r),o=j(t.roots);return{...t,depth:o}}function a(h,r){const t=new Map,o=u=>{for(let d=0;d<u.length;d++){const s=u[d];if(s.physical>=0){const g=r?r(s.physical):!1,i=g&&s.children.length===0;t.set(s.physical,{level:s.level,posinset:d+1,setsize:u.length,hasChildren:s.children.length>0||g,lazy:i})}s.children.length&&o(s.children)}};return o(h),t}}),We("packages/core/src/source/settle.js",function(e,D){"use strict";Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return P}});const ne=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function P(Y){const _=Y&&typeof Y=="object"?Y.reason:null;return typeof _=="string"&&ne.includes(_)}}),We("packages/core/src/source/memory.js",function(e,D){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return K}});const P=D("packages/core/src/internal/lru.js").Lru,Y=D("packages/core/src/internal/warn.js"),_=Y.warnOnce,L=Y.fail,H=D("packages/core/src/internal/predicates.js").isFunction,X=D("packages/core/src/internal/compare.js").defaultCompare,j=D("packages/core/src/internal/merge.js").mergeRow,k=D("packages/core/src/source/rows.js"),b=k.createRowFactory,a=k.groupKey,h=k.groupPathElement,r=k.groupPrefixKeys,t=k.lazyRowView,u=D("packages/core/src/source/handles.js").createHandleProvider,d=D("packages/core/src/compute/incremental.js"),s=d.RunningTotal,g=d.isIncremental,n=D("packages/core/src/compute/handle.js").presenceReader,f=D("packages/core/src/source/filterwire.js"),p=f.querySignature,l=f.mapConditions,y=f.resolveRelativeCondition,c=D("packages/core/src/source/tree.js"),m=c.buildTree,w=c.resolveTree,v=c.indexTree,E=D("packages/core/src/source/settle.js"),V=E.PIPELINE_SETTLE_REASONS,G=E.isPipelineSettle,q=Object.freeze(["filter","sort","group","total","pivot","flatten"]),M=Object.freeze([]);function O(I,B){if(!I)return null;const J=B==="grand"?I.grandTotal:I.groupTotal;return J??I.total}function T(I){return!!I&&!I.running}function A(I){if(I)return I.value&&H(I.value.compare)?I.value.compare:H(I.compare)?I.compare:void 0}function N(I){const B=I&&I.dataType;return!B||!H(B.items)?null:{items:B.items,type:I.itemType&&I.itemType.name||"text"}}function C(I){return!!I&&(typeof I=="object"||typeof I=="function")&&H(I.then)}const S=new Uint32Array(0),F=4096;function $(I,B){return new K(I,B)}function W(I,B){if(B==="regex")try{const J=new RegExp(I,"iu");return te=>J.test(te)}catch{return J=>J.includes(I)}if(B==="fuzzy"){const J=[...I].filter(te=>te!==" ");return J.length?te=>{let Q=0;for(let re=0;re<te.length&&Q<J.length;re++)te[re]===J[Q]&&Q++;return Q===J.length}:()=>!0}if(B==="words"){const J=I.split(/\s+/).filter(Boolean);return J.length?te=>J.every(Q=>te.includes(Q)):()=>!0}return J=>J.includes(I)}class K{mode="memory";#e;#t;#n;#r=!1;#s=null;#i;#o;#l=new Map;#a=!1;#c=0;#u=0;#d=new Map;#f=new Map;#h;#p=null;#m=K.#g();static#g(){return{slots:[],groupHeadings:M,unnumbered:M,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#b=new Map;#y=null;#O=new Map;#w=-1;#A=[];#v=new Map;#P=-1;#S=[];#C=null;#E=null;#T=null;#M=null;#N=null;#R=null;#D=null;#W=null;#V=Symbol("unset");#x=new Map;#q=null;get#B(){return this.#m.slots}set#B(B){this.#m.slots=B}get#Y(){return this.#m.inlineLeaves}set#Y(B){this.#m.inlineLeaves=B}get#G(){return this.#m.groupHeadings}set#G(B){this.#m.groupHeadings=B}get#I(){return this.#m.unnumbered}set#I(B){this.#m.unnumbered=B}get#H(){return this.#m.pivot}set#H(B){this.#m.pivot=B}constructor(B,J){this.#t=B||{mode:"memory"},this.#e=J||{};const te=this.#e.config||{};this.#n=this.#t.rows||te.rows||[],this.#i=b(this.#e),this.#o=u(this.#e,()=>this.#n,()=>this.#r),this.#h=new P(Number(te.rowCacheSize)||F);for(const Q of q)this.#l.set(Q,{key:null,result:null,id:0,computed:!1})}count(){this.#U();const B=this.#be();return B?B.length:this.#B.length}#be(){const B=Number(this.#K("pageSize",0))||0;if(B<=0)return null;const J=this.#B.length,te=Math.max(1,Math.ceil(J/B)),re=Math.min(Math.max(0,Number(this.#K("page",0))||0),te-1)*B;return{offset:re,length:Math.max(0,Math.min(B,J-re))}}pageInfo(){this.#U();const B=Number(this.#K("pageSize",0))||0,J=this.#B.length;if(B<=0)return{page:0,pageSize:0,total:J,pageCount:1};const te=Math.max(1,Math.ceil(J/B));return{page:Math.min(Math.max(0,Number(this.#K("page",0))||0),te-1),pageSize:B,total:J,pageCount:te}}totalCount(){return this.#Ke().length}matchCount(){return this.#U(),this.#m.matchCount}at(B){this.#U();const J=this.#be();if(J)return B<0||B>=J.length?void 0:this.#ft(J.offset+B,B);if(!(B<0||B>=this.#B.length))return this.#ft(B,B)}byKey(B){this.#U(),this.#p||this.#se();const J=this.#p.get(B);if(J!==void 0)return this.#le(J);for(let te=0;te<this.#B.length;te++){const Q=this.#B[te];if(typeof Q!="number"&&Q&&Q.key===B)return this.#ft(te)}}loaded(B){return B>=0&&B<this.count()}hint(B,J){}display(){return this.#U(),this.#q||(this.#q=this.#$e()),this.#q}invalidateQuickText(){this.#x.clear(),this.invalidate("filter")}invalidate(B){const J=q.indexOf(B);J<0&&L(`unknown pipeline stage "${B}"; expected one of ${q.join(", ")}`);for(let te=J;te<q.length;te++){const Q=this.#l.get(q[te]);Q.key=null,Q.computed=!1}this.#q=null}apply(B){const J=[],te={added:[],updated:[],removed:[],rejected:J};if(!B)return te;let Q=!1;const re=new Set;if(B.remove&&B.remove.length)for(const ie of B.remove){const ue=this.#_e(ie);if(ue===void 0){J.push({operation:"remove",id:this.#he(ie),reason:"unknown-id"});continue}te.removed.push(this.#i.keyOf(this.#r?this.#j(ue):this.#n[ue],ue)),this.#r||(this.#n[ue]=void 0),this.#h.delete(ue),this.#x.delete(ue),Q=!0}if(B.update&&B.update.length){const ie=this.#O.size||this.#kt()?this.#De():null,ue=this.#v.size?this.#et():null,ke=ue&&ue.length?this.#De():null;for(const de of B.update){const we=this.#_e(de);if(we===void 0){J.push({operation:"update",id:this.#Re(de),reason:"unknown-id"});continue}const ve=this.#r?this.#s&&this.#s.has(we)?this.#s.get(we):this.#j(we):this.#n[we],De=j(ve,de);for(const pe of this.#xe(ve,De))re.add(pe);if(this.#r||(this.#n[we]=De),ie&&this.#Qe(ie,we,ve,De),ke&&this.#wt(ue,ke,we,ve,De),this.#p){const pe=this.#i.keyOf(ve,we),oe=this.#i.keyOf(De,we);pe!==oe&&(this.#p.delete(pe),this.#p.set(oe,we))}this.#h.delete(we),this.#x.delete(we),te.updated.push(this.#le(we))}}if(B.add&&B.add.length&&this.#r){typeof B.at=="number"&&B.at<this.#dt()&&(this.#h.clear(),this.#x.clear()),this.#p=null;for(const ie of B.add){const ue=this.#Pe(this.#Re(ie));ue!==void 0&&te.added.push(this.#le(ue))}Q=!0}else if(B.add&&B.add.length){let ie=typeof B.at=="number"?B.at:this.#n.length;if(ie<this.#n.length){let de=0;for(let we=0;we<this.#n.length;we++)this.#n[we]!==void 0&&de++;if(de!==this.#n.length){let we=0;for(let ve=0;ve<this.#n.length;ve++)this.#n[ve]!==void 0&&(this.#n[we++]=this.#n[ve]);this.#n.length=we,this.#p=null,this.#h.clear(),this.#x.clear()}}const ue=this.#n.length;ie=Math.max(0,ie);let ke=B.add===this.#n?B.add.slice():B.add;if(this.#i.keyed){const de=[];for(const we of ke){const ve=this.#Re(we);if(this.#_e(ve)!==void 0){J.push({operation:"add",id:ve,reason:"duplicate-id"});continue}de.push(we)}de.length!==ke.length&&(ke=de)}if(!ke.length)return te;if(ie>=ue)for(let de=0;de<ke.length;de++)this.#n.push(ke[de]);else this.#n.splice(ie,0,...ke),this.#h.clear(),this.#x.clear();for(let de=0;de<ke.length;de++)te.added.push(this.#le(ie>=ue?ue+de:ie+de));Q=!0}return this.#c++,Q&&(this.#p=null,this.#rt()),this.#o.invalidate(),this.#q=null,Q||this.#z(re)?(this.#u++,this.invalidate("filter")):this.invalidate("total"),this.#gt("rows:changed",{companion:!0,added:te.added.length,updated:te.updated.length,removed:te.removed.length}),this.#s=null,te}groupHeadingsAt(B){this.#U();const J=this.#G;if(!J.length||!Number.isInteger(B)||B<0)return M;let te=0,Q=J.length-1,re=-1;for(;te<=Q;){const ue=te+Q>>1;J[ue].at<=B?(re=ue,te=ue+1):Q=ue-1}if(re<0)return M;const ie=[];for(let ue=J[re].row;ue;ue=ue.parent)ie.push(ue);return ie.reverse(),ie}unnumberedRowCount(B){this.#U();const J=this.#I;if(!J.length||!Number.isInteger(B)||B<0)return 0;let te=0,Q=J.length-1,re=-1;for(;te<=Q;){const ie=te+Q>>1;J[ie].at<=B?(re=ie,te=ie+1):Q=ie-1}return re+1}moveRow(B,J){if(this.#r)return _("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 te=this.#n;if(!Number.isInteger(B)||!Number.isInteger(J))return!1;let Q=0;for(let ue=0;ue<te.length;ue++)te[ue]!==void 0&&Q++;if(B<0||B>=Q)return!1;const re=Math.max(0,Math.min(Q-1,J));if(re===B)return!1;if(Q!==te.length){let ue=0;for(let ke=0;ke<te.length;ke++)te[ke]!==void 0&&(te[ue++]=te[ke]);te.length=ue}const[ie]=te.splice(B,1);return te.splice(re,0,ie),this.#c++,this.#u++,this.#p=null,this.#h.clear(),this.#x.clear(),this.#rt(),this.#o.invalidate(),this.#q=null,this.invalidate("filter"),this.#gt("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(B){this.#ce(),this.#c++,this.#u++,this.#p=null,this.#x.clear(),this.#h.clear(),this.#rt(),this.#o.invalidate(),this.invalidate("filter"),this.#gt("model:changed",{reason:"reload"})}destroy(){this.#ce(),this.#h.clear(),this.#x.clear(),this.#p=null,this.#B=[],this.#Y=null,this.#q=null,this.#rt();for(const B of q)this.#l.set(B,{key:null,result:null,id:0,computed:!1})}#ce(){for(const{controller:B}of this.#b.values())try{B.abort()}catch{}this.#b.clear()}setRows(B){this.#n=B||[],this.#r=!1,this.#c++,this.#u++,this.#p=null,this.#x.clear(),this.#h.clear(),this.#rt(),this.#o.invalidate(),this.invalidate("filter")}notePriorRows(B){this.#s=B||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 B=this.#e.store;if(!B||!H(B.source))return this.#n;const J=B.physical||0,te=new Array(J);for(let Q=0;Q<J;Q++)te[Q]=B.live&&!B.live(Q)?void 0:B.source(Q);return te}#de(){const B=this.#K("detail",null);return!B||!H(B.isOpen)||B.inline===!1?null:B}#Me(){const B=(this.#e.config||{}).tree;return this.#V!==B&&(this.#V=B,this.#W=w(B,{dataAt:J=>this.#j(J),keyOf:J=>this.#i.keyOf(this.#j(J),J)})),this.#W}#re(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#re())return null;this.#U();const B=this.#m.grand;return B?this.#i.grandTotal(B,this.#nt(this.#m.grandLeaves)):null}pivot(){return this.#U(),this.#H}pivotMatrix(){this.#U();const B=this.#m.groupLeaves,J=(this.#e.compute||{}).pivotMatrix;if(!H(J))return null;const te=this.#K("groupBy",[]),Q=this.#K("pivotBy",[]);if(!te.length&&!Q.length)return _("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 re=this.#De().map(ue=>({colId:ue.id,handle:this.#o.handle(ue.id),fn:O(ue,"group")})).filter(ue=>ue.handle&&ue.fn),ie=this.#e.config||{};return J({rowHandles:te.map(ue=>this.#o.handle(ue)).filter(Boolean),columnHandles:Q.map(ue=>this.#o.handle(ue)).filter(Boolean),measures:re,leaves:B||new Uint32Array(0),opts:{locale:ie.locale,separator:(ie.pivot||{}).separator,maxColumns:(ie.pivot||{}).maxColumns}})}keysForLeaves(B){const J=[];if(!B)return J;for(let te=0;te<B.length;te++){const Q=this.#le(B[te]);Q&&Q.key!=null&&J.push(String(Q.key))}return J}leavesOf(B){this.#U();const J=this.#l.get("group"),te=J&&J.result;if(!te||!te.nodes)return[];const Q=te.nodes.get(B);if(!Q)return[];const re=[],ie=ue=>{const ke=ue.row&&ue.row.children;if(ke&&ke.length){for(const de of ke){const we=te.nodes.get(de.key);we&&ie(we)}return}if(ue.leaves)for(let de=0;de<ue.leaves.length;de++)re.push(this.#le(ue.leaves[de]))};return ie(Q),re}#he(B){return typeof B=="string"?B:this.#Re(B)}#Re(B){try{return this.#i.keyOf(B,-1)}catch{return"(unkeyed)"}}#_e(B){if(typeof B=="string")return this.#Pe(B);if(this.#i.keyed){const te=this.#i.keyOf(B,-1),Q=this.#Pe(te);if(Q!==void 0)return Q}if(this.#r)return;const J=this.#n.indexOf(B);return J>=0?J:void 0}#Pe(B){return this.#p||this.#se(),this.#p.get(B)}#se(){this.#p=new Map;const B=this.#dt(),J=this.#e.store,te=J&&H(J.live)?Q=>J.live(Q):null;for(let Q=0;Q<B;Q++){if(te&&!te(Q))continue;const re=this.#j(Q);re!==void 0&&this.#p.set(this.#i.keyOf(re,Q),Q)}}#xe(B,J){const te=[];for(const Q of this.#Z())this.#He(Q)&&this.#oe(Q,B,J,new Set)&&te.push(Q);return te}#oe(B,J,te,Q){if(Q.has(B))return!1;Q.add(B);const re=this.#He(B);if(!re)return!1;const ie=re.value&&re.value.deps;return Array.isArray(ie)&&ie.length?ie.some(ue=>this.#oe(String(ue),J,te,Q)):H(re.getValue)?!Object.is(re.getValue(J),re.getValue(te)):!1}#Z(){const B=new Set;for(const te of this.#K("sort",[]))B.add(te.col);for(const te of this.#K("groupBy",[]))B.add(te);const J=te=>{if(te){if(Array.isArray(te.conditions)){te.conditions.forEach(J);return}te.col&&B.add(te.col)}};return J(this.#K("filters",null)),[...B]}#z(B){if(!B.size)return!1;if(this.#K("quick",""))return!0;for(const J of this.#Z())if(B.has(J))return!0;return!1}#U(){if(!this.#a){this.#a=!0;try{this.#J()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#J(){const B=this.#te("filter",()=>this.#fe(),()=>this.#je()),J=this.#Ee(B),te=this.#te("group",()=>this.#ae(),()=>this.#k(J)),Q=this.#te("total",()=>this.#F(),()=>this.#Ve(te));this.#te("pivot",()=>this.#we(),()=>this.#Ot(te)),this.#te("flatten",()=>this.#ie(),()=>this.#qe(te)),this.#Ae(te,Q)}#Ee(B){const J=this.#l.get("sort"),te=this.#$();if(J.computed&&J.key===te&&!this.#b.has("sort"))return J.result;const Q=this.#b.get("sort");return Q&&Q.key===te?J.result:J.result&&this.#ve(B)?(this.#ke(B,te),J.result):this.#te("sort",()=>te,()=>this.#Ue(B))}#ee(){if(this.#y===null){const B=this.#e.pipelineWorker,J=H(B)?B():null;this.#y=J||!1}return this.#y||null}#pe(){const B=this.#K("sort",[]);if(!Array.isArray(B)||!B.length)return null;const J=(this.#e.config||{}).locale,te=[],Q=[];for(const re of B){const ie=this.#He(re.col);if(ie&&ie.running)continue;if(ie&&ie.value&&H(ie.value.compare))return null;const ue=this.#o.handle(re.col);if(!ue)return null;te.push({col:re.col,descending:re.dir==="desc",nullsFirst:!!re.nullsFirst,locale:J}),Q.push(ue)}return te.length?{entries:te,handles:Q,locale:J}:null}#ve(B){if(this.#_())return!1;const J=this.#ee();if(!J)return!1;const te=Number(J.threshold);return Number.isFinite(te)&&B.length<te?!1:!!this.#pe()}#ke(B,J){const te=this.#ee(),Q=te&&this.#pe();if(!Q){this.#te("sort",()=>J,()=>this.#Ue(B));return}const re=new AbortController;this.#b.set("sort",{key:J,controller:re});const ie=Q.entries.length===1?te.sortColumn(Q.handles[0],B,{descending:Q.entries[0].descending,nullsFirst:Q.entries[0].nullsFirst,locale:Q.locale,signal:re.signal,key:"sort"}):te.sortMulti(Q.handles,Q.entries.map((ue,ke)=>({...ue,handle:Q.handles[ke]})),B,{signal:re.signal,key:"sort"});if(!C(ie)){this.#b.delete("sort"),this.#te("sort",()=>J,()=>ie);return}ie.then(ue=>this.#Te(J,ue),ue=>this.#ye("sort",J,ue))}#Te(B,J){const te=this.#b.get("sort");if(!(!te||te.key!==B)){if(this.#$()!==B){this.#b.delete("sort");return}this.#b.delete("sort"),this.#te("sort",()=>B,()=>J),this.#q=null,this.#U(),this.#gt("model:changed",{reason:V[0]})}}#ye(B,J,te){const Q=this.#b.get(B);if(!(!Q||Q.key!==J)&&(this.#b.delete(B),!(te&&te.name==="AbortError")&&B==="sort"&&this.#$()===J)){const re=this.#te("filter",()=>this.#fe(),()=>this.#je());this.#te("sort",()=>J,()=>this.#Ue(re)),this.#q=null,this.#U(),_("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",te),this.#gt("model:changed",{reason:V[1]})}}#Ae(B,J){const te=B&&B.leaves?B.leaves.length:this.#m.slots.length;this.#m.matchCount=te,this.#m.grand=J&&J.grand||null,this.#m.grandLeaves=B&&B.leaves?B.leaves.length:0,this.#m.groupLeaves=B&&B.leaves?B.leaves:null}#te(B,J,te){const Q=this.#l.get(B),re=J();return Q.computed&&Q.key===re||(Q.result=te(),Q.key=re,Q.computed=!0,Q.id++,B==="flatten"&&(this.#q=null)),Q.result}#me(B){return this.#l.get(B).id}#fe(){const B=(this.#e.config||{}).hostFilter,J=B&&H(B.active)&&B.active()?1:0,te=this.#K("where",null),Q=te?te.version:0,re=this.#Et("filter.sig",`${this.#pt()}`,()=>p({filters:this.#K("filters",null),quick:this.#K("quick",""),quickMode:this.#K("quickMode","contains")}));return`${this.#u}|${re}|${J}|${Q}`}#$(){const B=this.#_();return`${this.#me("filter")}|${JSON.stringify(this.#K("sort",[]))}`+(B?`|manual:${B.version}`:"")}#_(){const B=this.#K("rowOrder",null);return B&&Array.isArray(B.keys)?B:null}#ue(B,J){this.#p||this.#se();const te=this.#p,Q=this.#dt(),re=J.keys.length,ie=new Float64Array(Q);for(let ue=0;ue<Q;ue++)ie[ue]=re+ue;for(let ue=0;ue<re;ue++){const ke=te.get(J.keys[ue]);ke!==void 0&&(ie[ke]=ue)}return Uint32Array.from(B).sort((ue,ke)=>ie[ue]-ie[ke])}orderedKeys(){this.#p||this.#se();const B=this.#p,J=new Map;for(const[ue,ke]of B)J.set(ke,ue);const te=Uint32Array.from([...J.keys()]).sort(),Q=this.#_(),re=Q?this.#ue(te,Q):this.#Ue(te),ie=new Array(re.length);for(let ue=0;ue<re.length;ue++)ie[ue]=J.get(re[ue]);return ie}#ae(){const B=this.#K("pivotBy",[]).length>0?"p":"u";return`${this.#me("sort")}|${JSON.stringify(this.#K("groupBy",[]))}|${B}`}#F(){const B=this.#at()?"f":"a",J=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#me("group")}|${JSON.stringify(this.#K("totals",[]))}|${B}${J}|${this.#c}`}#we(){return`${this.#me("group")}|${JSON.stringify(this.#K("pivotBy",[]))}`}#ie(){const J=this.#We()||!this.#re()?this.#me("total"):"x",te=`${this.#pt()}`,Q=this.#Et("flatten.keys",te,()=>{const ie=this.#K("expanded",null);return ie?[...ie].sort().join(""):"*"}),re=this.#Et("flatten.detail",te,()=>{const ie=this.#K("detail",null);return ie&&H(ie.signature)?ie.signature():""});return`${J}|${this.#me("pivot")}|${Q}|${re}`}#We(){const B=this.#K("groupBy",[]);return Array.isArray(B)&&B.length>0}stageState(){const B=[];for(const[J,te]of this.#l){const Q=te.result;B.push({stage:J,materialised:!!te.computed,bytes:Q&&typeof Q.byteLength=="number"?Q.byteLength:null,rows:Q&&typeof Q.length=="number"?Q.length:null,rebuilds:te.id})}return B}facetIndices(B){return this.#je(B||null)}facetRows(B){const J=this.facetIndices(B),te=[];for(let Q=0;Q<J.length;Q++){const re=this.#le(J[Q]);re&&te.push(re)}return te}invalidateRows(){this.#h.clear(),this.#x.clear(),this.#q=null}invalidateHandles(){this.#o.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Ke()}filteredIndices(){const B=this.#l.get("filter");if(B&&B.computed&&B.key===this.#fe())return B.result||this.#Ke();this.#U();const J=this.#l.get("filter");return(J&&J.computed?J.result:null)||this.#Ke()}unfilteredRows(){const B=this.#Ke(),J=[];for(let te=0;te<B.length;te++){const Q=this.#le(B[te]);Q&&J.push(Q)}return J}#je(B=null){const J=this.#Ke(),te=this.#K("filters",null),Q=B?this.#Ye("pruneColumn")(te,B):te,re=this.#lt(Q),ie=String(this.#K("quick","")||"").trim().toLowerCase(),ue=ie?W(ie,String(this.#K("quickMode","contains")||"contains")):null,ke=(this.#e.config||{}).hostFilter,de=!!(ke&&H(ke.active)&&ke.active()),we=this.#K("where",null),ve=!!(we&&we.active);if(!re&&!ie&&!de&&!ve)return J;let De=null;re&&(De=this.#Ye("evaluateFilters")(re,{handle:fe=>this.#o.handle(fe),count:this.#dt(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:fe=>N(this.#He(fe))}));const pe=new Uint32Array(J.length);let oe=0;for(let be=0;be<J.length;be++){const fe=J[be];if(!(De&&!De[fe])&&!(ue&&!this.#Ce(fe,ue))){if(de||ve){const le=this.#le(fe);if(de&&!ke.passes(le)||ve&&!we.passes(le.data,le.key))continue}pe[oe++]=fe}}if(De){const be=(this.#e.compute||{}).releaseMask;H(be)&&be({pool:this.#e.pool},De)}return pe.subarray(0,oe)}handleFor(B){return this.#o.handle(B)}#Ue(B){const J=this.#_();if(J)return this.#ue(B,J);const te=this.#K("sort",[]).filter(ie=>{const ue=this.#He(ie.col);return!ue||!ue.running?!0:(_(`source.sort.running.${ie.col}`,`sort ignores "${ie.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!te.length)return B;const Q=(this.#e.config||{}).locale;if(te.length===1){const ie=te[0],ue=this.#o.handle(ie.col);if(!ue)return _(`source.sort.${ie.col}`,`sort ignores unknown column "${ie.col}".`),B;const ke=this.#He(ie.col);return this.#Ye("sortColumn")(ue,B,{descending:ie.dir==="desc",nullsFirst:ie.nullsFirst,locale:Q,compare:A(ke)})}const re=[];for(const ie of te){const ue=this.#o.handle(ie.col);if(!ue){_(`source.sort.${ie.col}`,`sort ignores unknown column "${ie.col}".`);continue}re.push({handle:ue,descending:ie.dir==="desc",nullsFirst:ie.nullsFirst,locale:Q,compare:A(this.#He(ie.col))})}return re.length?this.#Ye("sortMulti")(re.map(ie=>ie.handle),re,B):B}#k(B){const J=this.#K("groupBy",[]),te=this.#Me();if(te&&!J.length){const be=m(B,te);return this.#R=v(be.roots,te.declaresChildren),{roots:null,leaves:B,nodes:new Map,tree:be}}if(this.#R=null,te&&J.length&&_("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:B,nodes:new Map};const Q=(this.#e.config||{}).timeZone,re=[],ie=[];let ue=!1;for(const be of J){const fe=this.#o.handle(be);if(!fe){_(`source.group.${be}`,`grouping ignores unknown column "${be}".`);continue}re.push(fe);const le=this.#He(be),ye=le&&le.dataType;if(ye&&H(ye.groupProjector)){const Ne=le.typeOptions&&le.typeOptions.timeZone||Q||void 0,je=ye.groupProjector(le,Ne);ie.push(je||null),je&&(ue=!0)}else ie.push(null)}if(!re.length)return{roots:null,leaves:B,nodes:new Map};const{keys:ke,buckets:de}=this.#Ye("groupByColumns")(re,B,{locale:(this.#e.config||{}).locale,project:ue?ie:void 0}),we=this.#K("pivotBy",[]).length>0,ve=[],De=new Map;for(let be=0;be<de.length;be++){const fe=ke[be];let le=null;const ye=[];for(let Ne=0;Ne<fe.length;Ne++){ye.push(h(fe[Ne]));const je=a(ye),$e=Ne===fe.length-1;let Re=De.get(je);if(!Re){const Se=this.#i.group({path:[...ye],column:J[Ne],value:fe[Ne],level:Ne,parent:le,expanded:we&&$e?!1:this.#Je(je,{key:je,column:J[Ne],value:fe[Ne],level:Ne,path:[...ye]}),hasChildren:!(we&&$e)});Re={row:Se,leaves:null},De.set(je,Re),le?le.children.push(Se):ve.push(Se)}Re.row.leafCount+=de[be].length,Ne===fe.length-1&&(Re.leaves=de[be]),le=Re.row}}const pe=this.#K("sort",[])||[],oe=(be,fe)=>{if(!be||be.length<2){if(be)for(const je of be)oe(je.children,fe+1);return}const le=J[fe],ye=pe.find(je=>je.col===le),Ne=ye&&ye.dir==="desc"?-1:1;be.sort((je,$e)=>Ne*X(je.groupValue,$e.groupValue));for(const je of be)oe(je.children,fe+1)};return oe(ve,0),{roots:ve,leaves:B,nodes:De,keys:ke,buckets:de}}#Le(B,J){const te=new Map,Q=new Map,re=ie=>{const ue=ie.physical>=0?[ie.physical]:[];for(const ke of ie.children)ue.push(...re(ke));if(ie.children.length){const ke=this.#Ze(J,Uint32Array.from(ue),null);ie.physical>=0?te.set(ie.physical,ke):Q.set(ie.key,ke)}return ue};for(const ie of B.roots)re(ie);return{byPhysical:te,byKey:Q}}#Ve(B){const J=this.#De();if(!J.length)return this.#E=null,this.#T=null,{grand:null};const te={id:this.#me("group"),columns:J.map(pe=>pe.id).join("")},Q=this.#E&&this.#E.id===te.id&&this.#E.columns===te.columns,re=this.#kt()&&Q?this.#C:null,ie=re?J.filter(pe=>re.has(pe.id)):J,ue=Q?this.#T:null,ke=this.#at()?null:this.#vt(),de=this.#Oe(J),we=pe=>{const oe=B.nodes.get(pe.key);let be=oe&&oe.leaves?oe.leaves:null;if(pe.children&&pe.children.length){const ye=pe.children.map(we);let Ne=0;for(const Re of ye)Ne+=Re.length;const je=new Uint32Array(Ne);let $e=0;for(const Re of ye)je.set(Re,$e),$e+=Re.length;be=je}be=be||new Uint32Array(0);const fe=ke?ke.get(pe.key)||S:be,le=this.#Ct(pe,re?ie:J,fe,de);return pe.totals=re?{...pe.totals,...le}:le,be};if(B.roots&&ie.length)for(const pe of B.roots)we(pe);if(this.#D=B.tree?this.#Le(B.tree,J):null,this.#E=te,this.#C=this.#kt()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#A.length=0,this.#T=null,{grand:null};const De=ke?this.#ne():B.leaves;return this.#T=this.#Xe(J,De,re,ue),{grand:this.#T}}#Xe(B,J,te,Q){const re={},ie=this.#me("group");ie!==this.#w&&(this.#Pt(),this.#w=ie);const ue=this.#A;this.#A=[];for(const ke of B){if(!T(ke))continue;const de=this.#o.handle(ke.id);if(!de)continue;const we=O(ke,"grand");if(!g(we,de)){if(te&&!te.has(ke.id)&&Q&&ke.id in Q){re[ke.id]=Q[ke.id];continue}re[ke.id]=this.#Ze([ke],J,null,"grand")[ke.id];continue}let ve=this.#O.get(ke.id);if((!ve||ve.fn!==we)&&(ve=new s(we),this.#O.set(ke.id,ve)),ve.valid){let De=!0;for(const pe of ue)if(pe.colId===ke.id&&!ve.update(pe.before,pe.after)){De=!1;break}if(De){re[ke.id]=ve.value();continue}ve.invalidate()}ve.seedColumn(de.values,n(de),J),re[ke.id]=ve.valid?ve.value():this.#Ze([ke],J,null,"grand")[ke.id]}return re}#Oe(B){const J=this.#me("group");J!==this.#P&&(this.#v.clear(),this.#P=J);const te=new Map;for(const re of B){if(!T(re))continue;const ie=this.#o.handle(re.id),ue=O(re,"group");g(ue,ie)&&te.set(re.id,{fn:ue})}if(!te.size)return this.#S.length=0,te;const Q=this.#S;this.#S=[];for(const re of Q){const{beforeKeys:ie,afterKeys:ue,colDeltas:ke}=re,de=ie.length?new Set(ie):null,we=ue.length?new Set(ue):null;for(const{colId:ve,before:De,after:pe}of ke)if(te.has(ve)){for(const oe of ie)we&&we.has(oe)||this.#Se(oe,ve,De,null);for(const oe of ue)de&&de.has(oe)||this.#Se(oe,ve,null,pe);for(const oe of ie)we&&!we.has(oe)||this.#Se(oe,ve,De,pe)}}return te}#Se(B,J,te,Q){const re=this.#v.get(B),ie=re&&re.get(J);!ie||!ie.valid||ie.update(te,Q)||ie.invalidate()}#Ct(B,J,te,Q){if(!Q||!Q.size)return this.#Ze(J,te,B);const re={};let ie=null,ue=this.#v.get(B.key);for(const ke of J){const de=Q.get(ke.id);if(!de){(ie||(ie=[])).push(ke);continue}const we=this.#o.handle(ke.id);if(!we)continue;ue||(ue=new Map,this.#v.set(B.key,ue));let ve=ue.get(ke.id);if((!ve||ve.fn!==de.fn)&&(ve=new s(de.fn),ue.set(ke.id,ve)),ve.valid||ve.seedColumn(we.values,n(we),te),ve.valid){re[ke.id]=ve.value();continue}(ie||(ie=[])).push(ke)}return ie&&Object.assign(re,this.#Ze(ie,te,B)),re}#Qe(B,J,te,Q){const re=!this.#at()||this.#Ge(J);for(const ie of B){const ue=ie.getValue;if(!H(ue))continue;const ke=ue(te),de=ue(Q);Object.is(ke,de)||(this.#C&&this.#C.add(ie.id),re&&this.#O.has(ie.id)&&this.#A.push({colId:ie.id,before:ke,after:de}))}}#et(){const B=this.#K("groupBy",[]),J=[];for(const te of B){const Q=this.#He(te);Q&&J.push(Q)}return J}#tt(B,J){const te=new Array(B.length);for(let Q=0;Q<B.length;Q++){const re=B[Q].getValue;te[Q]=h(H(re)?re(J):void 0)}return te}#wt(B,J,te,Q,re){if(this.#at()&&!this.#Ge(te))return;const ie=r(this.#tt(B,Q)),ue=r(this.#tt(B,re)),ke=ie.length!==ue.length||ie.some((we,ve)=>we!==ue[ve]),de=[];for(const we of J){const ve=we.getValue;if(!H(ve))continue;const De=ve(Q),pe=ve(re);!ke&&Object.is(De,pe)||de.push({colId:we.id,before:De,after:pe})}!de.length&&!ke||this.#S.push({beforeKeys:ie,afterKeys:ue,colDeltas:de})}#Ge(B){const J=this.#l.get("filter"),te=J&&J.computed?J.result:null;if(!te)return!0;let Q=0,re=te.length-1;for(;Q<=re;){const ie=Q+re>>1,ue=te[ie];if(ue===B)return!0;ue<B?Q=ie+1:re=ie-1}return!1}#at(){return(this.#e.config||{}).totalFilteredOnly!==!1}#nt(B){return this.#at()?B:this.#ne().length}#ne(){return(!this.#M||this.#M.version!==this.#u)&&(this.#M={version:this.#u,indices:this.#Ke()}),this.#M.indices}#vt(){const B=this.#K("groupBy",[]),J=`${this.#u}|${JSON.stringify(B)}`;if(this.#N&&this.#N.key===J)return this.#N.map;const te=new Map,Q=[];for(const re of B){const ie=this.#o.handle(re);ie&&Q.push(ie)}if(Q.length){const re=this.#ne(),{keys:ie,buckets:ue}=this.#Ye("groupByColumns")(Q,re,{locale:(this.#e.config||{}).locale}),ke=new Map;for(let de=0;de<ue.length;de++){const we=ie[de],ve=[];for(let De=0;De<we.length;De++){ve.push(h(we[De]));const pe=a(ve);let oe=ke.get(pe);oe||(oe=[],ke.set(pe,oe));for(let be=0;be<ue[de].length;be++)oe.push(ue[de][be])}}for(const[de,we]of ke)te.set(de,Uint32Array.from(we))}return this.#N={key:J,map:te},te}#kt(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#rt(){this.#Pt(),this.#st(),this.#C=null,this.#E=null,this.#T=null}#Pt(){this.#O.clear(),this.#A.length=0,this.#w=-1}#st(){this.#v.clear(),this.#S.length=0,this.#P=-1}#Ot(B){const J=this.#K("pivotBy",[]);if(!J.length)return this.#H=null,null;const te=(this.#e.compute||{}).pivot;if(!H(te))return _("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#H=null,null;const Q=J.map(ie=>this.#o.handle(ie)).filter(Boolean),re=this.#De();return this.#H=te(Q,B.leaves,{groups:B.keys&&B.buckets?{keys:B.keys,buckets:B.buckets}:null,totals:re.map(ie=>ie.id),handle:ie=>this.#o.handle(ie),totalOf:ie=>O(re.find(ue=>ue.id===ie),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#H}#qe(B){const J=this.#l.get("total").result,te=!!(this.#e.config||{}).groupFooter,Q=this.#de();if(B.tree)return this.#Fe(B,J,Q);if(!B.roots&&!Q){if(J&&J.grand&&!this.#re()){const we=this.#i.grandTotal(J.grand,this.#nt(B.leaves.length));if(this.#Y===B.leaves&&Array.isArray(this.#B))this.#B[this.#B.length-1]=we;else{const ve=Array.from(B.leaves);ve.push(we),this.#B=ve,this.#Y=B.leaves}this.#I=[{at:this.#B.length-1}]}else this.#Y=null,this.#B=B.leaves,this.#I=M;return this.#G=M,this.#B}const re=[],ie=[],ue=[],ke=we=>{if(re.push(we),!Q)return;const ve=this.#le(we);!ve||!Q.isOpen(ve.key)||(ve.master=!0,ve.expanded=!0,ue.push({at:re.length}),re.push(this.#i.detail(ve,Q.heightOf(ve))))};if(!B.roots){for(let we=0;we<B.leaves.length;we++)ke(B.leaves[we]);return J&&J.grand&&!this.#re()&&(ue.push({at:re.length}),re.push(this.#i.grandTotal(J.grand,this.#nt(B.leaves.length)))),this.#Y=null,this.#G=M,this.#I=ue.length?ue:M,this.#B=re,re}const de=(we,ve,De)=>{if(we.expanded=we.hasChildren===!1?!1:this.#Je(we.key,{key:we.key,column:we.groupColumn,value:we.groupValue,level:we.level,path:we.groupPath}),we.posinset=ve+1,we.setsize=De,ie.push({at:re.length,row:we}),ue.push({at:re.length}),re.push(we),!!we.expanded){if(we.children&&we.children.length)for(let pe=0;pe<we.children.length;pe++)de(we.children[pe],pe,we.children.length);else{const pe=B.nodes.get(we.key),oe=pe&&pe.leaves?pe.leaves:null;if(oe)for(let be=0;be<oe.length;be++)ke(oe[be])}te&&we.totals&&(ue.push({at:re.length}),re.push(this.#i.footer(we)))}};for(let we=0;we<B.roots.length;we++)de(B.roots[we],we,B.roots.length);return J&&J.grand&&!this.#re()&&(ue.push({at:re.length}),re.push(this.#i.grandTotal(J.grand,this.#nt(B.leaves.length)))),this.#G=ie,this.#I=ue,this.#B=re,re}#Ke(){const B=this.#e.store;if(B&&H(B.liveIndices))return B.liveIndices();const J=new Uint32Array(this.#n.length);let te=0;for(let Q=0;Q<this.#n.length;Q++)this.#n[Q]!==void 0&&(J[te++]=Q);return J.subarray(0,te)}#dt(){const B=this.#e.store;return B&&typeof B.physical=="number"?B.physical:this.#n.length}#j(B){const J=this.#e.store;return J&&H(J.source)?J.source(B):this.#n[B]}#ft(B,J=B){const te=this.#B[B];if(typeof te!="number")return te.index=J,te;const Q=this.#le(te);return Q.index=J,Q}#le(B){let J=this.#h.get(B);J||(J=this.#i.leaf(this.#j(B),B),this.#h.set(B,J));const te=this.#R?this.#R.get(B):null;if(te){J.level=te.level,J.posinset=te.posinset,J.setsize=te.setsize,J.hasChildren=te.hasChildren,J.expanded=te.hasChildren&&!te.lazy&&this.#Je(J.key);const Q=this.#D?this.#D.byPhysical.get(B):void 0;Q?J.totals=Q: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}#Fe(B,J,te){const Q=[],re=[],ie=ke=>{if(ke.leafCount!==void 0)return ke.leafCount;let de=ke.physical>=0?1:0;for(const we of ke.children)de+=ie(we);return ke.leafCount=de,de},ue=ke=>{const de=this.#Je(ke.key);if(ke.physical>=0){if(Q.push(ke.physical),te&&te.isOpen(this.#le(ke.physical).key)){const we=this.#le(ke.physical);re.push({at:Q.length}),Q.push(this.#i.detail(we,te.heightOf(we)))}}else Q.push(this.#i.group({path:[ke.key],column:null,value:ke.value,level:ke.level,parent:null,expanded:de,hasChildren:ke.children.length>0,leafCount:ie(ke),totals:this.#D?this.#D.byKey.get(ke.key):void 0}));if(de)for(const we of ke.children)ue(we)};for(const ke of B.tree.roots)ue(ke);return J&&J.grand&&!this.#re()&&(re.push({at:Q.length}),Q.push(this.#i.grandTotal(J.grand,this.#nt(B.leaves.length)))),this.#Y=null,this.#G=M,this.#I=re.length?re:M,this.#B=Q,Q}#$e(){return t(()=>this.count(),B=>this.at(B))}#Ce(B,J){let te=this.#x.get(B);if(te===void 0){const Q=this.#j(B),re=this.#mt(),ie=[],ue=this.#e.columnHidden;for(const ke of re){if(ke.quickFilter===!1||H(ue)&&ue(ke.id))continue;const de=ke.value&&H(ke.value.quickFilterText)?ke.value.quickFilterText({value:void 0,data:Q,row:null,column:ke,colId:ke.id,grid:null,context:this.#K("context",null)}):null,we=de??(H(ke.formatValue)?ke.formatValue(H(ke.getValue)?ke.getValue(Q):void 0):"");we!=null&&we!==""&&ie.push(String(we))}te=ie.join(" ").toLowerCase(),this.#x.set(B,te)}return J(te)}#De(){const B=this.#K("totals",[]),J=B&&B.length?new Set(B):null;return this.#mt().filter(te=>J?J.has(te.id):!!(te.total||te.groupTotal||te.grandTotal))}#Ze(B,J,te,Q="group"){const re={},ie=(this.#e.compute||{}).total;for(const ue of B){if(!T(ue))continue;const ke=this.#o.handle(ue.id);if(!ke)continue;const de=O(ue,Q);if(de)if(H(de)){const we=new Array(J.length);for(let ve=0;ve<J.length;ve++)we[ve]=ke.get(J[ve]);re[ue.id]=de(we,{row:te,column:ue,grid:this.#e.grid||null,context:this.#K("context",null),valueAt:(ve,De)=>{const pe=this.#o.handle(ve);return pe&&De>=0&&De<J.length?pe.get(J[De]):null}})}else H(ie)&&(re[ue.id]=ie(ke,J,de))}return re}#lt(B){if(!B)return B;const J=this.#e.config||{},te={tz:J.timeZone,weekStartsOn:J.weekStartsOn};return l(B,Q=>{const re=y(Q,te),ie=this.#He(re&&re.col),ue=ie&&ie.type==="datetime";if(re&&re.type)return re.type==="datetime"&&!re.timeZone&&ie?{...re,timeZone:J.timeZone||void 0}:re;if(ue)return{...re,type:"datetime",timeZone:J.timeZone||void 0};const ke=ie&&(ie.dataType?.base||ie.type);return ke?{...re,type:ke}:re})}#Je(B,J){const te=this.#K("expanded",null);return te?H(te.has)?te.has(B,J):Array.prototype.includes.call(te,B):!0}#K(B,J){if(B==="context"||!H(this.#e.stateVersion))return this.#ht(B,J);const te=this.#ct(B),Q=this.#d.get(B);if(Q&&Q.version===te)return Q.value;const re=this.#ht(B,J);return this.#d.set(B,{version:te,value:re}),re}#ht(B,J){const te=this.#e.state;if(te&&H(te[B])){const Q=te[B]();return Q??J}return J}#pt(){const B=this.#e.stateVersion;return H(B)?B():0}#Rt(){const B=this.#e.columnsVersion,J=this.#e.permissionsVersion;return`${H(B)?B():0}|${H(J)?J():0}`}#ct(B){return B==="totals"?this.#Rt():`${this.#pt()}`}#Et(B,J,te){if(!H(this.#e.stateVersion))return te();const Q=this.#f.get(B);if(Q&&Q.version===J)return Q.key;const re=te();return this.#f.set(B,{version:J,key:re}),re}#Ye(B){const J=(this.#e.compute||{})[B];return H(J)||L(`ctx.compute.${B} is required by the memory source pipeline`),J}#mt(){const B=this.#e.columns;return B&&H(B.all)?B.all():[]}#He(B){const J=this.#e.columns;return J&&H(J.get)?J.get(B):void 0}#gt(B,J){const te=this.#e.emit;H(te)&&te(B,J)}}}),We("packages/core/src/source/abort.js",function(e,D){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return L}});class ne extends Error{constructor(H,x="superseded"){super(`[lattice] request ${H?`"${H}" `:""}${x}`),this.name="SupersededError",this.superseded=!0,this.key=H}}class P{#e;constructor(H,x,X,U){this.#e=H,this.key=x,this.controller=X,this.signal=X.signal,this.seq=U}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(H){this.signal.aborted||this.controller.abort(new ne(this.key,H)),this.#e.settle(this)}}class Y{#e=new Map;#t=0;begin(H="",x="superseded"){const X=this.#e.get(H);X&&!X.signal.aborted&&X.controller.abort(new ne(H,x));const U=new P(this,H,new AbortController,++this.#t);return this.#e.set(H,U),U}tokenFor(H){return this.#e.get(H)}pending(H=""){const x=this.#e.get(H);return!!x&&!x.signal.aborted}get size(){return this.#e.size}settle(H){this.#e.get(H.key)===H&&this.#e.delete(H.key)}abort(H="",x="superseded"){const X=this.#e.get(H);X&&X.abort(x)}abortAll(H="superseded"){for(const x of[...this.#e.values()])x.abort(H);this.#e.clear()}}function _(){return new Y}function L(Z){if(!Z||typeof Z!="object")return!1;const H=Z;return H.superseded===!0||H.name==="AbortError"||H.name==="SupersededError"}}),We("packages/core/src/source/blockcache.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return _}});const ne=100,P=32;class Y{constructor(Z){this.id=Z,this.rows=null,this.state="pending",this.token=null,this.error=null}}class _{#e=new Map;#t;#n;#r=0;#s=-1;constructor(Z={}){this.#t=Math.max(1,Math.floor(Number(Z.pageSize)||ne)),this.#n=Math.max(1,Math.floor(Number(Z.maxCachedPages)||P))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(Z){return Math.floor(Z/this.#t)}rangeOf(Z){return{start:Z*this.#t,end:(Z+1)*this.#t}}has(Z){return this.#e.has(Z)}pending(Z){const H=this.#e.get(Z);return!!H&&H.state==="pending"}loaded(Z){const H=this.#e.get(Z);return!!H&&H.state==="loaded"}begin(Z,H){let x=this.#e.get(Z);return x||(x=new Y(Z)),x.state="pending",x.token=H,x.error=null,this.#i(Z,x),x}fill(Z,H){const x=this.#e.get(Z)||new Y(Z);x.rows=H,x.state="loaded",x.token=null,this.#i(Z,x)}failed(Z,H){const x=this.#e.get(Z)||new Y(Z);x.state="error",x.error=H,x.token=null,this.#i(Z,x)}delete(Z){return this.#e.delete(Z)}rowAt(Z){const H=this.blockOf(Z),x=this.#e.get(H);if(!(!x||x.state!=="loaded"||!x.rows))return this.#i(H,x),x.rows[Z-H*this.#t]}rowLoaded(Z){const H=this.blockOf(Z),x=this.#e.get(H);return!!x&&x.state==="loaded"&&!!x.rows&&Z-H*this.#t<x.rows.length}erroredAt(Z){const H=this.#e.get(this.blockOf(Z));return!!H&&H.state==="error"}loadedExtent(){let Z=0;for(const H of this.#e.values()){if(H.state!=="loaded"||!H.rows)continue;const x=H.id*this.#t+H.rows.length;x>Z&&(Z=x)}return Z}fillOf(Z){const H=this.#e.get(Z);return H&&H.state==="loaded"&&H.rows?H.rows.length:null}protect(Z,H){this.#r=this.blockOf(Math.max(0,Z)),this.#s=this.blockOf(Math.max(0,H))}evict(){const Z=[];if(this.#e.size<=this.#n)return Z;for(const[H,x]of this.#e){if(this.#e.size-Z.length<=this.#n)break;H>=this.#r&&H<=this.#s||x.state!=="pending"&&Z.push(H)}for(const H of Z)this.#e.delete(H);return Z}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(Z,H){this.#e.delete(Z),this.#e.set(Z,H)}}}),We("packages/core/src/source/pagewindow.js",function(e,D){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return ne}});function ne(P,Y,_,L){const Z=Math.floor(Number(P)||0);if(Z<=0)return null;const H=Math.max(0,Math.floor(Number(Y)||0)),x=Math.max(0,Math.floor(Number(_)||0));if(L){const X=Math.max(1,Math.ceil(x/Z)),U=Math.min(H,X-1),j=U*Z;return{page:U,pageSize:Z,offset:j,length:Math.max(0,Math.min(Z,x-j)),pageCount:X,total:x}}return{page:H,pageSize:Z,offset:H*Z,length:Z,pageCount:Math.max(H+2,Math.ceil(x/Z)),total:null}}}),We("packages/core/src/source/paged.js",function(e,D){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return p}});const P=D("packages/core/src/internal/lru.js").Lru,_=D("packages/core/src/internal/predicates.js").isFunction,Z=D("packages/core/src/internal/warn.js").warnOnce,x=D("packages/core/src/internal/schedule.js").settleDebounce,X=D("packages/core/src/source/abort.js"),U=X.createAbortScope,j=X.isAbortError,k=D("packages/core/src/source/blockcache.js"),b=k.BlockCache,a=k.DEFAULT_PAGE_SIZE,h=k.DEFAULT_MAX_CACHED_PAGES,t=D("packages/core/src/source/rows.js").createRowFactory,o=D("packages/core/src/source/filterwire.js"),u=o.wireFilters,d=o.querySignature,s=o.warnHostFilterNotApplied,i=D("packages/core/src/source/pagewindow.js").pageWindow,n=120;function f(l,y){return new p(l,y)}class p{mode="paged";#e;#t;#n;#r=U();#s;#i;#o=new Map;#l=null;#a=null;#c=!1;#u=0;#d="";#f={start:0,end:0};#h;#p=!1;#m=0;#g="";constructor(y,c){this.#e=y||{mode:"paged"},this.#t=c||{},this.#n=new b({pageSize:this.#e.pageSize||a,maxCachedPages:this.#e.maxCachedPages||h}),this.#s=t(this.#t),this.#i=new P(this.#n.pageSize*4),this.#h=x((m,w)=>this.#w(m,w),n),this.#d=this.#C(),_(this.#e.fetch)||Z("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),s(this.#t)}count(){const y=this.#y();return y?y.length:this.#b()}#b(){if(this.#P(),this.#l!==null)return this.#l;const y=Math.max(this.#u,this.#n.loadedExtent());return this.#c?y:y+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const y=this.#y();if(!y){const c=this.#b();return{page:0,pageSize:0,total:this.exact()?c:null,pageCount:1,counting:!1}}return{page:y.page,pageSize:y.pageSize,total:y.total,pageCount:y.pageCount,counting:y.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const y=this.#b(),c=i(this.#T("pageSize",0),this.#T("page",0),y,this.exact());if(!c)return this.#g="",null;const m=`${this.#m}:${c.offset}:${c.length}`;if(m!==this.#g&&!this.#p&&(this.#g=m,c.length>0)){const w=c.offset+c.length-1;this.#f={start:c.offset,end:w},this.#w(c.offset,w)}return c}at(y){const c=this.#y();if(c){if(y<0||y>=c.length)return;const m=this.#O(c.offset+y);return m&&(m.index=y),m}return this.#O(y)}#O(y){if(y<0||y>=this.#b())return;const c=this.#i.get(y);if(c&&(c.data!==null||!this.#n.rowLoaded(y)))return c;const m=this.#n.rowAt(y);if(m===void 0){const v=this.#s.skeleton(y,0,this.#n.erroredAt(y));return this.#i.set(y,v),v}const w=this.#s.leaf(m,y);return w.index=y,this.#i.set(y,w),this.#o.set(w.key,y),w}byKey(y){const c=this.#o.get(y);return c===void 0?void 0:this.#O(c)}loaded(y){const c=this.#y();return c?y>=0&&y<c.length&&this.#n.rowLoaded(c.offset+y):this.#n.rowLoaded(y)}loadedCount(){this.#P();let y=0;for(const c of this.#n.ids()){if(!this.#n.loaded(c))continue;const m=this.#n.fillOf(c);typeof m=="number"&&(y+=m)}return y}residentRows(){this.#P();const y=this.#y(),c=y?y.offset:0,m=y?y.offset+y.length:1/0,w=[],v=this.#n.ids().sort((E,V)=>E-V);for(const E of v){if(!this.#n.loaded(E))continue;const{start:V}=this.#n.rangeOf(E),G=this.#n.fillOf(E)||0;for(let q=V;q<V+G;q++){if(q<c||q>=m)continue;const M=this.#i.peek(q);if(M&&M.data!==null&&M.data!==void 0){w.push(M);continue}const O=this.#n.rowAt(q);if(O===void 0)continue;const T=this.#s.leaf(O,q);T.index=q,this.#i.set(q,T),this.#o.set(T.key,q),w.push(T)}}return w}hint(y,c){if(this.#p)return;const m=this.#P();let w=Math.max(0,Math.floor(y)),v=Math.max(w,Math.floor(c));const E=this.#y();if(E){if(E.length===0)return;w=E.offset,v=E.offset+E.length-1}this.#f={start:w,end:v},this.#n.protect(w,v);for(const V of this.#n.evict())this.#v(V);this.#h(w,v),m&&this.#h.flush()}#w(y,c){if(this.#p)return;this.#n.protect(y,c);const m=this.#n.blockOf(y),w=this.#n.blockOf(c);for(let v=m;v<=w&&!(this.#l!==null&&v*this.#n.pageSize>=this.#l);v++)this.#n.has(v)||this.#A(v)}apply(y){const c={added:[],updated:[],removed:[]};if(!y)return c;if(y.update)for(const m of y.update){const w=this.#s.keyOf(m,-1),v=this.#o.get(w);if(v===void 0)continue;const E=this.#s.leaf(m,v);E.index=v,this.#i.set(v,E),c.updated.push(E)}return(y.add&&y.add.length||y.remove&&y.remove.length)&&this.reload(),c}reload(y){this.#S("reload"),this.#h.cancel(),this.hint(this.#f.start,this.#f.end)}destroy(){this.#p=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#o.clear()}exact(){return this.#l!==null||this.#c}pending(){return this.#r.size}async#A(y){if(!_(this.#e.fetch))return;const c=this.#r.begin(`block:${y}`);this.#n.begin(y,c);const{start:m,end:w}=this.#n.rangeOf(y),v=this.#d;try{const E=await this.#e.fetch({range:{start:m,end:w},sort:this.#T("sort",[]),filters:u(this.#T("filters",null),this.#E()),quick:this.#T("quick","")||void 0,context:this.#T("context",null),signal:c.signal});if(!c.current||v!==this.#d||this.#p)return;c.settle();const V=E&&E.rows||[];this.#n.fill(y,V);for(let q=0;q<V.length;q++)this.#i.delete(m+q);const G=E&&typeof E.total=="number"?E.total:E&&typeof E.count=="number"?E.count:null;G!==null?(this.#l=G,this.#c=!0):V.length<this.#n.pageSize?(this.#c=!0,this.#l=m+V.length):this.#u=Math.max(this.#u,m+V.length),this.#M("model:changed",{reason:"page",block:y,from:m,to:m+V.length}),this.#M("rows:changed",{companion:!0,reason:"page",block:y,from:m,to:m+V.length}),this.#l!==null&&this.#l!==this.#a&&(this.#a=this.#l,this.#M("source:total",{total:this.#l,groupPath:[]}))}catch(E){if(c.settle(),j(E))return;this.#n.failed(y,E);for(let V=m;V<w;V++)this.#i.delete(V);this.#M("model:changed",{reason:"page-error",block:y,range:{start:m,end:w}}),this.#M("source:error",{error:E,block:y,range:{start:m,end:w}})}}#v(y){const{start:c,end:m}=this.#n.rangeOf(y);for(let w=c;w<m;w++){const v=this.#i.peek(w);v&&this.#o.delete(v.key),this.#i.delete(w)}}#P(){const y=this.#C();return y===this.#d?!1:(this.#d=y,this.#S("query"),!0)}#S(y){this.#r.abortAll(y),this.#n.clear(),this.#i.clear(),this.#o.clear(),this.#l=null,this.#a=null,this.#c=!1,this.#u=0,this.#m++,this.#M("model:changed",{reason:y})}#C(){return d({filters:this.#T("filters",null),sort:this.#T("sort",[]),quick:this.#T("quick",""),context:this.#T("context",null)})}#E(){const y=this.#t.config||{};return{tz:y.timeZone,weekStartsOn:y.weekStartsOn}}#T(y,c){const m=this.#t.state;if(m&&_(m[y])){const w=m[y]();return w??c}return c}#M(y,c){const m=this.#t.emit;_(m)&&m(y,c)}}}),We("packages/core/src/source/aggregates.js",function(e,D){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"aggregateP",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return U}});const ne=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)"},percentile:{pushable:!0,class:"identical",sql:"quantile_cont(%c, %p)",parametric:!0},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 P(){const j=new Set;for(const[k,b]of Object.entries(ne))b.pushable&&j.add(k);return j}function Y(j,k,b,a="?"){let h=j.split("%c").join(k);return b!==void 0&&(h=h.split("%w").join(b)),h.split("%p").join(a)}function _(j){const k=j&&(j.p!==void 0?j.p:j.params&&j.params.p);return typeof k=="number"&&k>=0&&k<=1?k:void 0}function L(j){const k=j||{},b=k.default==="engine"||k.default==="engine-if-identical"?k.default:"client",a={};if(k.overrides&&typeof k.overrides=="object")for(const[h,r]of Object.entries(k.overrides))(r==="engine"||r==="client")&&(a[h]=r);return{default:b,overrides:a}}function Z(j,k){const b=ne[j];if(!b||!b.pushable)return"client";const a=k.overrides[j];return a==="engine"||a==="client"?a:k.default==="client"?"client":k.default==="engine-if-identical"?b.class==="identical"?"engine":"client":"engine"}function H(j,k){const b=L(k),a=[],h=[];for(const r of j||[]){const t=ne[r.fn],o=Z(r.fn,b),u={id:r.id,col:r.col,fn:r.fn,class:t?t.class:"fallback"};if(r.weight!==void 0&&(u.weight=r.weight),r.params!==void 0&&(u.params=r.params),t&&t.parametric){const d=_(r);d!==void 0&&(u.p=d)}if(o==="engine"&&t&&t.parametric&&u.p===void 0){h.push({...u,reason:`"${r.fn}" needs \`p\`, a number from 0 to 1`});continue}o==="engine"?a.push(u):(u.reason=t&&!t.pushable?t.note||"the engine cannot express this stat":"client by config",h.push(u))}return{engine:a,client:h,config:b}}const x=/^[A-Za-z_][A-Za-z0-9_$]*$/;function X(j,k=[]){return(j||[]).every(a=>{if(typeof a=="string")return x.test(a);if(!a||typeof a!="object")return!1;const h=a;return Array.isArray(k)&&k.includes(h.bucket)&&typeof h.col=="string"&&x.test(h.col)&&typeof h.size=="number"&&Number.isFinite(h.size)&&h.size>0})}function U(){return Object.entries(ne).map(([j,k])=>({stat:j,class:k.class,sql:k.sql?Y(k.sql,"col",k.twoColumn?"weight":void 0):"",note:k.note||(k.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),We("packages/core/src/source/pushdown.js",function(e,D){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return te}});const P=D("packages/core/src/internal/compare.js").defaultCompare,_=D("packages/core/src/internal/predicates.js").isFunction,Z=D("packages/core/src/internal/merge.js").toArray,x=D("packages/core/src/internal/warn.js").warnOnce,X=D("packages/core/src/source/filterwire.js"),U=X.isGroup,j=X.warnWherePageRelative,k=X.warnWhereOverThreshold,b=X.wireFilters,a=D("packages/core/src/source/aggregates.js"),h=a.resolveAggregatePlan,r=a.groupKeysPushable,t=a.STAT_PUSHDOWN,o=a.aggregateP,u=a.fillAggregateSql,s=D("packages/core/src/source/abort.js").SupersededError,g=1e3;function i(Q){const re=Q&&Q.signal;if(!re||!re.aborted)return;const ie=re.reason;throw ie instanceof Error?ie:new s("","superseded before it was sent")}const n=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function f(Q){if(!Q||typeof Q!="object")return!1;const re=Q.returning==="row"||Q.returning==="key"?Q.returning:"none";return{append:Q.append===!0,update:Q.update===!0,delete:Q.delete===!0,returning:re}}function p(Q,re){if(!Q||typeof re!="string")return;if(!re.includes("."))return Q[re];let ie=Q;for(const ue of re.split(".")){if(ie===null||typeof ie!="object")return;ie=ie[ue]}return ie}function l(Q){if(Q===!0)return!0;if(!Q||typeof Q!="object")return!1;const re=Q;return re.enabled===!1?!1:re.enabled===!0||_(re.commit)}function y(Q){const re={...n,...Q||{}};return re.operators=new Set(re.operators||[]),re.mutate=f(re.mutate),re}function c(Q,re){return!Q||!Q.op||!re.operators.size?!1:re.operators.has(Q.op)}function m(Q,re){if(!Q)return{pushed:null,residual:null};if(!re.filter)return{pushed:null,residual:Q};if(re.filter==="term"){if(U(Q)){const de=Q.conditions||[];if(String(Q.op)!=="and")return{pushed:null,residual:Q};const we=de.findIndex(De=>!U(De)&&c(De,re));if(we<0)return{pushed:null,residual:Q};const ve=de.filter((De,pe)=>pe!==we);return{pushed:de[we],residual:ve.length?{op:"and",conditions:ve}:null}}return c(Q,re)?{pushed:Q,residual:null}:{pushed:null,residual:Q}}if(!U(Q))return c(Q,re)?{pushed:Q,residual:null}:{pushed:null,residual:Q};if(String(Q.op)!=="and")return(Q.conditions||[]).every(we=>U(we)?m(we,re).residual===null:c(we,re))?{pushed:Q,residual:null}:{pushed:null,residual:Q};const ie=[],ue=[];for(const de of Q.conditions||[]){if(U(de)){if(re.filter==="flat"){ue.push(de);continue}const we=m(de,re);we.pushed&&ie.push(we.pushed),we.residual&&ue.push(we.residual);continue}(c(de,re)?ie:ue).push(de)}const ke=de=>de.length===0?null:de.length===1?de[0]:{op:"and",conditions:de};return{pushed:ke(ie),residual:ke(ue)}}const w="__lattice_leaves";function v(Q){return Q.aggregates?Q.aggregates instanceof Set?Q.aggregates:new Set(Z(Q.aggregates)):new Set}function E(Q){const re=v(Q);return re.size?re.has("count")?Q.filter!=="tree"||!Q.operators||!Q.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(Q,re,ie,ue,ke,de,we){const ve=Array.isArray(Q.groupBy)?Q.groupBy:[],De=Array.isArray(Q.groupPath)?Q.groupPath:[],pe=Array.isArray(Q.groupValues)?Q.groupValues:null;if(!re.group){const oe=E(re);if(oe)return oe}return r(ve)?ie.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":ue?ke?de&&!de.conditioned?"a host `where` predicate can only run in the browser, over rows the engine grouped":we?"fullDataset holds the whole matching set, so the grid groups it itself":!pe||pe.length!==De.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const G="pushdown:pivot-unsupported",q="pushdown:group-unsupported",M=Symbol("lattice.remote.ungroupedLevel");function O(Q,re,ie,ue,ke,de){const we=Array.isArray(Q.pivotBy)?Q.pivotBy:[],ve=Array.isArray(Q.groupBy)?Q.groupBy:[],De=Array.isArray(Q.groupPath)?Q.groupPath:[],pe=Array.isArray(Q.groupValues)?Q.groupValues:null;return re.pivot?r(we)?ve.length&&!r(ve)?"a grouping key is not a plain column the engine can name in a GROUP BY":ie.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":ue?ke?de&&!de.conditioned?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!pe||pe.length!==De.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function T(Q,re,ie=!1){const ue=m(Q.filters||null,re),ke=[];ue.residual&&ke.push("filter");const de=Q.sort||[],we=de.length===0||re.sort==="multi"&&de.length>=1||re.sort==="single"&&de.length===1;!we&&de.length&&ke.push("sort");const ve=Q.quick?String(Q.quick):"",De=!ve||!!re.quick;De||ke.push("quick");const pe=Q.where&&Q.where.active?Q.where:null;pe&&ke.push("where");const oe={filters:ue.residual,sort:we?null:de,quick:De?"":ve,where:pe},be=!!ie,fe=Array.isArray(Q.groupBy)&&Q.groupBy.length>0,le=fe?V(Q,re,ue,we,De,pe,be):"",ye=Q.pivotMode!==!1&&Array.isArray(Q.pivotBy)&&Q.pivotBy.length>0,Ne=ye?O(Q,re,ue,we,De,pe):"",je=ye&&Ne==="";ye&&!je&&ke.push("pivot");const $e=ye?je&&fe:fe&&le==="";fe&&!ye&&!$e&&ke.push("group");const Re=($e||je)&&Array.isArray(Q.groupValues)?Q.groupValues.length:0;pe&&pe.conditioned&&($e||je)&&(oe.where=null,ke.splice(ke.indexOf("where"),1));const Se=$e||ye?!1:be||!!(oe.filters||oe.sort||oe.quick||oe.where)||!re.range;return{pushed:{...Q,filters:ue.pushed,sort:we?de:[],quick:De?ve:"",range:Se?null:Q.range},residual:oe,needsAll:Se,unpushed:ke,full:be,grouped:$e,groupLevel:Re,groupReason:ye?"":le,pivoted:je,pivotReason:Ne}}function A(Q){const re=Array.isArray(Q.totals)?Q.totals:[],ie=Q.totalFns&&typeof Q.totalFns=="object"?Q.totalFns:{},ue=[],ke=[];for(const de of re){const we=String(de),ve=ie[we],De=typeof ve=="string"?ve:ve&&typeof ve.fn=="string"?ve.fn:null,pe=ve&&typeof ve=="object"?o(ve):void 0,oe=De?t[De]:null;oe&&oe.parametric&&pe===void 0?ke.push({id:we,fn:De,class:oe.class,reason:`"${De}" needs \`p\`, a number from 0 to 1`}):De?!oe||!oe.pushable||!oe.sql?ke.push({id:we,fn:De,class:oe?oe.class:"fallback",reason:oe&&oe.note?oe.note:`the pushdown map cannot express "${De}"`}):oe.twoColumn?ke.push({id:we,fn:De,class:oe.class,reason:`"${De}" reduces two columns, and a grouped request carries no weight column`}):ue.push({id:we,col:we,fn:De,class:oe.class,...pe!==void 0?{p:pe}:{}}):ke.push({id:we,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:ue,client:ke}}function N(Q){return{...Q,engine:Q.engine.map(re=>{const ie=t[re.fn];if(!ie||!ie.sql)return re;const ue=ke=>`"${ke}"`;return{...re,sql:u(ie.sql,ue(re.col),re.weight!==void 0?ue(re.weight):void 0)}})}}const C=Object.freeze({items:Q=>Q==null?[]:Array.isArray(Q)?Q:[Q]});function S(Q,re,ie){if(!re)return Q;let ue=Q;if(re.filters&&_(ie.evaluateFilters)){const ke=ue,de={count:ue.length,handle:De=>({id:De,get:pe=>p(ke[pe],De)}),itemwise:De=>ke.some(pe=>Array.isArray(p(pe,De)))?C:null},we=ie.evaluateFilters(re.filters,de),ve=[];for(let De=0;De<ue.length;De++)we[De]&&ve.push(ue[De]);ue=ve}if(re.where&&re.where.active&&(re.whole||j(re.where.names,"pushdown"),ue=ue.filter(ke=>re.where.passes(ke))),re.quick){const ke=re.quick.toLowerCase();ue=ue.filter(de=>{if(!de||typeof de!="object")return!1;for(const we of Object.values(de))if(we!=null&&String(we).toLowerCase().includes(ke))return!0;return!1})}if(re.sort&&re.sort.length&&_(ie.sortMulti)){const ke=[...new Set(re.sort.map(De=>De.col))],de=ue,we=ke.map(De=>({id:De,get:pe=>p(de[pe],De)})),ve=ie.sortMulti(we,re.sort.map(De=>({col:De.col,dir:De.dir})),Uint32Array.from({length:ue.length},(De,pe)=>pe),{});ue=Array.from(ve,De=>de[De])}return ue}function F(Q){return JSON.stringify({filters:Q.filters||null,sort:Q.sort||[],quick:Q.quick||"",groupBy:Q.groupBy||[],groupPath:Q.groupPath||[],context:Q.context??null})}function $(Q){if(!Q||typeof Q!="object")return 16;let re="";try{re=JSON.stringify(Q)}catch{return 200}return re.length*2+64}function W(Q){const re=Q||{};return{enabled:!!re.enabled,maxRows:Number.isFinite(re.maxRows)?re.maxRows:1e6,maxBytesEstimate:Number.isFinite(re.maxBytesEstimate)?re.maxBytesEstimate:512*1024*1024}}const K=5e4;function I(Q){return Number.isFinite(Q)&&Q>=0?Q:K}function B(Q){return!!Q&&_(Q.then)}async function J(Q){if(!Q||Q.total!==void 0||!B(Q.pendingTotal))return Q;const re=await Q.pendingTotal,{pendingTotal:ie,...ue}=Q;return typeof re=="number"?{...ue,total:re}:ue}function te(Q={}){const re=Q.adapter;if(!re||!_(re.execute))return x("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...Q,mode:"remote",fetch:async()=>({rows:[],total:0})};const ie=y(re.capabilities),ue=re.capabilities&&Object.getOwnPropertyDescriptor(re.capabilities,"operators");ue&&_(ue.get)&&Object.defineProperty(ie,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(re.capabilities.operators||[]),set:()=>{}});const ke=re.name||"adapter";let de=null;const we=()=>_(re.ready)?(de||(de=Promise.resolve(re.ready()).then(()=>{Object.assign(ie,y(re.capabilities))},ae=>{throw de=null,ae})),de):null,ve=W(Q.fullDataset),De=!!Q.allowPartialResults,pe=I(Q.whereRowLimit);let oe=null;const be=Q.aggregates;let fe=null,le=null,ye=null,Ne=null,je=null,$e=null,Re=0,Se=null;const Ve=()=>!ve.enabled||!fe?null:(Se!==fe.key&&(Re++,Se=fe.key),{rows:fe.rows,version:Re}),Fe=async ae=>{const Pe=ae.where&&ae.where.active?ae.where:null;if(!Pe)return{request:ae,probe:null};if(Pe.conditioned){const ut=T(ae,ie,ve.enabled);if(ut.grouped||ut.pivoted)return{request:ae,probe:null}}const{where:Te,...xe}=ae,_e=T(xe,ie,ve.enabled);if(_e.needsAll)return{request:ae,probe:null};const Ye=F(_e.pushed);let Qe=null;return(!oe||oe.key!==Ye)&&(ie.total?(i(ae),Qe=await J(await re.execute(_e.pushed,ae)),oe={key:Ye,size:Qe&&typeof Qe.total=="number"?Qe.total:null}):oe={key:Ye,size:null}),oe.size!==null&&oe.size<pe?{request:ae,probe:null}:(k(Pe.names,ke,oe.size,pe),{request:xe,probe:Qe})},Ce=async(ae,Pe)=>{$e=null;const Te=A(ae.pushed);ye={engine:Te.engine,client:Te.client,groupBy:ae.pushed.groupBy},Te.client.length&&x(`source.pushdown.group.totals.${ke}.${Te.client.map(Ye=>Ye.id).join(".")}`,`the ${ke} adapter cannot compute the group subtotal for ${Te.client.map(Ye=>`"${Ye.id}" (${Ye.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 xe=await re.executeGroupLevel(ae.pushed,Te.engine,Pe)||{};let _e=xe.rows||[];return!ie.range&&Pe.range&&(_e=_e.slice(Pe.range.start,Pe.range.end)),Ke(xe),xe.total===void 0?{rows:_e}:{rows:_e,total:xe.total}},Ee=new Map,Ie=64,Be=async(ae,Pe)=>{$e=null;const Te=ae.pushed,xe=Te.groupBy,_e=Array.isArray(Te.groupValues)?Te.groupValues:[],Ye=_e.length,Qe=[...Te.filters?[Te.filters]:[],...xe.slice(0,Ye).map((ot,gt)=>({col:ot,op:"eq",value:_e[gt]===void 0?null:_e[gt],caseSensitive:!0}))],ut=Qe.length===0?null:Qe.length===1?Qe[0]:{op:"and",conditions:Qe},mt=Pe.range?Pe.range.start:0;if(Ye>=xe.length){const ot={...Te,filters:ut,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},gt=await J(await re.execute(ot,Pe))||{};let xt=gt.rows||[];return!ie.range&&Pe.range&&(xt=xt.slice(Pe.range.start,Pe.range.end)),typeof gt.total=="number"?{rows:xt,total:gt.total}:{rows:xt}}const bt=xe[Ye],Rt=A(Te),Dt=v(ie),Ct=Rt.engine.filter(ot=>Dt.has(ot.fn)),_t=[...Rt.engine.filter(ot=>!Dt.has(ot.fn)).map(ot=>({id:ot.id,fn:ot.fn,class:ot.class,reason:`the ${ke} adapter does not compute "${ot.fn}"`})),...Rt.client];ye={engine:Ct,client:_t,groupBy:xe},_t.length&&x(`source.pushdown.group.totals.${ke}.${_t.map(ot=>ot.id).join(".")}`,`the ${ke} adapter cannot compute the group subtotal for ${_t.map(ot=>`"${ot.id}" (${ot.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const tn=[...Ct.map(ot=>({id:ot.id,col:ot.col,fn:ot.fn,...ot.p!==void 0?{p:ot.p}:{}})),{id:w,col:bt,fn:"count"}],Ht={...Te,filters:ut,range:null},Xt=JSON.stringify([F(Ht),_e,bt,tn]);let Je=mt>0?Ee.get(Xt):void 0;if(!Je){for(Je=Promise.resolve(re.executeGroupedAggregates(Ht,[bt],tn)),Ee.delete(Xt),Ee.set(Xt,Je);Ee.size>Ie;)Ee.delete(Ee.keys().next().value);Je.catch(()=>{Ee.get(Xt)===Je&&Ee.delete(Xt)})}const at=await Je||[];i(Pe);const St=ot=>{const gt={};for(const xt of Ct)gt[xt.id]=ot?ot[xt.id]:void 0;return gt},wt=(Te.sort||[]).find(ot=>ot&&ot.col===bt),vt=wt&&wt.dir==="desc"?-1:1,Xe=at.filter(ot=>ot&&ot.level===1).map(ot=>({[bt]:ot.keys[0]===void 0?null:ot.keys[0],leafCount:Number(ot.values&&ot.values[w])||0,totals:St(ot.values)})).sort((ot,gt)=>vt*P(ot[bt],gt[bt]));if(Ye===0){const ot=at.find(xt=>xt&&xt.level===0),gt=ot?Number(ot.values&&ot.values[w]):NaN;Ke({matchCount:Number.isFinite(gt)?gt:Xe.reduce((xt,Lt)=>xt+Lt.leafCount,0),...ot?{grand:St(ot.values)}:{}})}const ht=Pe.range?Pe.range.end:Xe.length;return{rows:Xe.slice(mt,ht),total:Xe.length}},Ke=ae=>{typeof ae.matchCount=="number"&&(Ne=ae.matchCount,je=ae.grand?{totals:ae.grand,leafCount:ae.matchCount}:null)},qe=async(ae,Pe)=>{$e=null;const Te=A(ae.pushed);ye={engine:Te.engine,client:Te.client,groupBy:ae.pushed.groupBy,pivotBy:ae.pushed.pivotBy},Te.client.length&&x(`source.pushdown.pivot.totals.${ke}.${Te.client.map(ut=>ut.id).join(".")}`,`the ${ke} adapter cannot compute the pivot cells for ${Te.client.map(ut=>`"${ut.id}" (${ut.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 xe=await re.executePivotLevel(ae.pushed,Te.engine,Pe)||{};let _e=xe.rows||[];!ie.range&&Pe.range&&(_e=_e.slice(Pe.range.start,Pe.range.end)),Ke(xe);const Ye=xe.pivot&&typeof xe.pivot=="object"?xe.pivot:{},Qe={cells:Array.isArray(Ye.cells)?Ye.cells:[],...Array.isArray(Ye.axis)?{axis:Ye.axis}:{}};return xe.total===void 0?{rows:_e,pivot:Qe}:{rows:_e,total:xe.total,pivot:Qe}},rt=ae=>{x(`source.pushdown.pivot.${ke}.${ae}`,`pushdown:pivot-unsupported: the ${ke} adapter cannot pivot this query because ${ae}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const Pe=new Error(`[lattice] ${G}: the ${ke} adapter cannot pivot this query because ${ae}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw Pe.code=G,Pe.reason=ae,Pe},nt=(ae,Pe)=>{const Te={key:Pe,state:"pending",value:null};return $e=Te,ae.then(xe=>($e===Te&&($e={key:Pe,state:"settled",value:typeof xe=="number"?xe:null}),xe),xe=>{throw $e===Te&&($e={key:Pe,state:"failed",value:null}),xe})};let dt=0,Pt=[];const Nt=()=>dt===0?null:new Promise(ae=>{const Pe=setTimeout(ae,g);Pt.push(()=>{clearTimeout(Pe),ae()})});let it;const ct=async ae=>{const Pe=we();Pe&&await Pe;const xe=ae&&ae.pivotMode!==!1&&Array.isArray(ae.pivotBy)&&ae.pivotBy.length>0?{request:ae,probe:null}:await Fe(ae);i(ae);let _e=T(xe.request,ie,ve.enabled);if(ie.group&&_e.grouped&&!_e.pivoted&&!_(re.executeGroupLevel)&&(x(`source.pushdown.group.method.${ke}`,`the ${ke} 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.`),_e=T(xe.request,{...ie,group:!1,aggregates:null},ve.enabled)),_e.pivoted&&!_(re.executePivotLevel)&&(_e=T(xe.request,{...ie,pivot:!1},ve.enabled),_e.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),_e.grouped&&!_e.pivoted&&!ie.group&&!_(re.executeGroupedAggregates)&&(x(`source.pushdown.group.aggregates.method.${ke}`,`the ${ke} 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\`.`),_e=T(xe.request,{...ie,aggregates:null},ve.enabled)),le=_e,_e.pivoted)return qe(_e,ae);if(_e.pivotReason&&rt(_e.pivotReason),_e.grouped)return ie.group?Ce(_e,ae):Be(_e,ae);const Qe=!!_e.groupReason&&!_e.full;Qe?x(`source.pushdown.group-unsupported.${ke}.${_e.groupReason}`,`pushdown:group-unsupported: the ${ke} adapter was not asked to group this query because ${_e.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.`):_e.groupReason&&x(`source.pushdown.group.${ke}.${_e.groupReason}`,`the ${ke} adapter was not asked to group this query because ${_e.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 ut=Ht=>Qe?{...Ht,[M]:!0}:Ht;if(!_e.needsAll){const Ht=xe.probe||await re.execute(_e.pushed,ae),Xt=Ht.rows||[];return B(Ht.pendingTotal)&&Ht.total===void 0?ut({rows:Xt,pendingTotal:nt(Ht.pendingTotal,F(_e.pushed))}):($e=null,!ie.total&&Ht.total===void 0?ut({rows:Xt}):ut({rows:Xt,total:Ht.total??Xt.length}))}const mt=_e.unpushed.filter(Ht=>!(Ht==="where"&&_e.residual.where&&_e.residual.where.anyConditioned));mt.length&&x(`source.pushdown.residual.${ke}.${mt.join(".")}`,`the ${ke} adapter cannot push ${mt.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 bt=F(_e.pushed);if(!fe||fe.key!==bt){const Ht=await J(await re.execute(_e.pushed,ae));$e=null;const Xt=Ht.rows||[];if(_e.full){const Je=typeof Ht.total=="number"?Math.max(Ht.total,Xt.length):Xt.length;if(Je>ve.maxRows)throw new Error(`[lattice] fullDataset refused: the ${ke} adapter's matching set is ${Je.toLocaleString()} rows, past the configured maxRows of ${ve.maxRows.toLocaleString()}. The whole set cannot be held client-side, so it is refused rather than truncated — a fraction shown as the whole would make every total and statistic silently wrong. Narrow the filter or raise maxRows.`);const at=Xt.length*$(Xt[0]);if(at>ve.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${ke} adapter's matching set is an estimated ${Math.round(at/(1024*1024)).toLocaleString()} MB across ${Xt.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(ve.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 Ht.total=="number"&&Xt.length<Ht.total){const Je=!!(_e.residual.filters||_e.residual.quick||_e.residual.sort&&_e.residual.sort.length);if(Je&&!De)throw new Error(`[lattice] the ${ke} adapter returned ${Xt.length} of ${Ht.total} matching rows when asked for the whole result, and the query has residual ${_e.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.`);Je?x(`source.pushdown.partial.residual.${ke}`,`the ${ke} adapter returned ${Xt.length} of ${Ht.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.${ke}`,`the ${ke} adapter returned ${Xt.length} of ${Ht.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}fe={key:bt,rows:Xt,total:typeof Ht.total=="number"?Ht.total:null}}let Rt=_e;if(_e.residual.where){const Ht=fe.total??fe.rows.length;if(Ht>=pe){k(_e.residual.where.names,ke,Ht,pe);const{where:Xt,...Je}=xe.request;Rt=T(Je,ie,ve.enabled),le=Rt}}const Dt=fe.total!==null&&fe.rows.length>=fe.total,Ct=S(fe.rows,{...Rt.residual,whole:Dt},Q.compute||{}),_t=ae.range?ae.range.start:0,tn=ae.range?ae.range.end:Ct.length;return ut({rows:Ct.slice(_t,tn),total:Ct.length})},ft=async(ae,Pe,Te)=>{const _e=Te&&Te.waitForPage&&it&&_(it.pageForegroundIdle)?it.pageForegroundIdle():Nt();_e&&await _e;const Ye=we();Ye&&await Ye;const Qe=T(ae,ie,ve.enabled);le=Qe;const ut=h(Pe,be),mt=Array.isArray(ae.groupBy)?ae.groupBy:[],bt=mt.length>0,Rt=!Qe.residual.filters&&!Qe.residual.quick,Dt=!bt||r(mt,ie.buckets);let Ct=ut.engine,_t=ut.client;if(ie.aggregates&&Ct.length){const at=ie.aggregates instanceof Set?ie.aggregates:new Set(Z(ie.aggregates)),St=Ct.filter(wt=>!at.has(wt.fn));St.length&&(Ct=Ct.filter(wt=>at.has(wt.fn)),_t=[...St.map(wt=>({...wt,reason:`the ${ke} adapter does not compute "${wt.fn}"`})),..._t])}const tn=at=>{_t=[...Ct.map(St=>({...St,reason:at})),..._t],Ct=[]};let Ht="";if(Ct.length&&!Rt){const at=Qe.residual.quick&&!Qe.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)";tn(at),bt&&(Ht=at)}else if(Ct.length&&!Dt){const at="a grouping key the engine cannot form forces all-client (no mixed provenance)";tn(at),Ht=at}let Xt={},Je;if(Ct.length&&(_(bt?re.executeGroupedAggregates:re.executeAggregates)?bt?Je=await re.executeGroupedAggregates(Qe.pushed,mt,Ct)||[]:Xt=await re.executeAggregates(Qe.pushed,Ct)||{}:(x(`source.pushdown.aggregates.${ke}${bt?".grouped":""}`,`the ${ke} adapter cannot compute ${bt?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),tn(`adapter cannot compute ${bt?"grouped ":""}aggregates`),bt&&(Ht=`the ${ke} adapter cannot compute grouped aggregates`))),bt){const at=Je!==void 0;at!==Qe.grouped&&(le={...Qe,grouped:at,groupReason:at?"":Ht||Qe.groupReason,unpushed:at?Qe.unpushed.filter(St=>St!=="group"):Qe.unpushed.includes("group")?Qe.unpushed:[...Qe.unpushed,"group"]})}return ye={engine:Ct,client:_t,...bt?{groupBy:mt}:{}},{values:Xt,engine:Ct,client:_t,...Je!==void 0?{groups:Je}:{}}},Tt=async ae=>{dt++;try{return await ct(ae)}finally{if(dt--,dt===0&&Pt.length){const Pe=Pt;Pt=[];for(const Te of Pe)Te()}}},pt=l(Q.edit),Oe=Q.edit&&typeof Q.edit=="object"&&_(Q.edit.commit);let Ae=Q.edit;if(pt&&!Oe)if(ie.mutate&&ie.mutate.update){const ae=Pe=>{if(!ie.mutate||!ie.mutate.update)throw new Error(`[lattice] the ${ke} 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 Te={kind:"update",key:String(Pe.key),patch:{[Pe.colId]:Pe.value}};return re.mutate(Te,Pe.request||{})};Ae={...Q.edit===!0?{}:Q.edit,commit:ae}}else x(`source.pushdown.readonly.${ke}`,`edit is enabled but the ${ke} adapter declares mutate: ${ie.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 ge=pt&&ie.mutate&&(ie.mutate.append||ie.mutate.delete)?{append:ie.mutate.append===!0,remove:ie.mutate.delete===!0,returning:ie.mutate.returning,mutate:(ae,Pe)=>re.mutate(ae,Pe||{})}:null,Le=async ae=>{const Pe=we();Pe&&await Pe;const{range:Te,signal:xe,export:_e,...Ye}=ae||{},Qe={...Ye,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:T(Qe,ie,ve.enabled),signal:xe}};async function*Me(ae,Pe={}){const{plan:Te,signal:xe}=await Le(ae),_e=Math.max(1,Math.floor(Number(Pe.pageSize))||5e3),Ye={signal:xe,stream:!0},Qe=ae&&ae.range&&Number.isFinite(Number(ae.range.start))&&Number.isFinite(Number(ae.range.end))?{start:Math.max(0,Number(ae.range.start)),end:Math.max(0,Number(ae.range.end))}:null;if(!Te.needsAll){const bt=Qe?Qe.start:0,Rt=Qe?Qe.end:1/0;for(let Dt=bt;Dt<Rt;Dt+=_e){i(Ye);const Ct=Math.min(Dt+_e,Rt),_t=await re.execute({...Te.pushed,range:{start:Dt,end:Ct}},Ye);_t&&B(_t.pendingTotal)&&_t.pendingTotal.then(null,()=>{});const tn=_t&&_t.rows||[];if(tn.length&&(yield tn),tn.length<Ct-Dt)return}return}i(Ye);const ut=await J(await re.execute({...Te.pushed,range:void 0},Ye));let mt=S(ut&&ut.rows||[],{...Te.residual,whole:!0},Q.compute||{});Qe&&(mt=mt.slice(Qe.start,Qe.end));for(let bt=0;bt<mt.length;bt+=_e)yield mt.slice(bt,bt+_e)}const He=async ae=>{const{plan:Pe,signal:Te}=await Le(ae);if(!Pe.needsAll&&ie.total){i({signal:Te});const _e=await J(await re.execute({...Pe.pushed,range:{start:0,end:0}},{signal:Te}));if(_e&&typeof _e.total=="number")return _e.total}let xe=0;for await(const _e of Me({...ae,range:void 0}))xe+=_e.length;return xe},ce=async ae=>{await we();const Pe=b(ae.filters||null,{tz:Q.timeZone,weekStartsOn:Q.weekStartsOn}),Te=ae.quick?String(ae.quick):"";return m(Pe,ie).residual||Te&&!ie.quick?null:re.facets({...ae,filters:Pe,quick:Te})};return it={...Q,edit:Ae,rowMutate:ge,mode:"remote",fetch:Tt,foregroundIdle:Nt,facetProvider:_(re.facets)?ce:void 0,aggregate:ft,countMatching:He,streamMatching:Me,capabilitiesOf:y,planQuery:T,wireFilters:b,resolveAggregatePlan:ae=>h(ae,be),STAT_PUSHDOWN:t,lastPlan:()=>le?{...le,...ye?{aggregates:N(ye)}:{},...$e?{total:{deferred:!0,state:$e.state,value:$e.value}}:{}}:null,fullFrame:Ve,counts:()=>({match:Ne,total:Ne,pending:!!$e&&$e.state==="pending"}),grandTotals:()=>je},it}}),We("packages/core/src/source/remote.js",function(e,D){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return N}});const P=D("packages/core/src/internal/lru.js").Lru,_=D("packages/core/src/internal/predicates.js").isFunction,Z=D("packages/core/src/internal/warn.js").warnOnce,x=D("packages/core/src/internal/schedule.js").settleDebounce,X=D("packages/core/src/source/abort.js"),U=X.createAbortScope,j=X.isAbortError,k=D("packages/core/src/source/blockcache.js"),b=k.BlockCache,a=k.DEFAULT_PAGE_SIZE,h=k.DEFAULT_MAX_CACHED_PAGES,r=D("packages/core/src/source/rows.js"),t=r.createRowFactory,o=r.groupKey,u=D("packages/core/src/source/filterwire.js"),d=u.wireFilters,s=u.querySignature,g=u.warnHostFilterNotApplied,n=D("packages/core/src/source/pagewindow.js").pageWindow,p=D("packages/core/src/source/memory.js").MemorySource,y=D("packages/core/src/compute/handle.js").valueComparator,c=D("packages/core/src/compute/pivot.js"),m=c.pivotKey,w=c.joinPath,v=c.DEFAULT_PATH_SEPARATOR,V=D("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,G=1,q=120,M=1e3;function O(C,S,F){for(let $=0;$<Math.max(C.length,S.length);$++){const W=C[$],K=S[$],I=W==null,B=K==null;if(I||B){if(I&&B)continue;return I?1:-1}const J=F(W,K);if(J!==0)return J}return 0}function T(C,S){return new N(C,S)}class A{constructor(S,F,$,W){this.path=S,this.keyPath=W||S,this.values=[],this.level=F,this.key=o(this.keyPath),this.cache=new b($),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 N{mode="remote";#e;#t;#n;#r;#s=new Map;#i=new Set;#o=U();#l;#a;#c=new Map;#u=[];#d=null;#f="";#h;#p=!1;#m=!1;#g=[];#b=!1;#y=0;#O="";#w=null;#A=-1;constructor(S,F){this.#e=S||{mode:"remote"},this.#t=F||{},_(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#D(),this.unfilteredIndices=()=>this.#W(),this.handleFor=J=>this.#V(J),this.display=()=>this.#x(),this.grandTotalRow=()=>this.#B(),this.unfilteredRows=()=>this.#I(),this.facetIndices=J=>this.#q(J));const $=this.#e.counts;_($)&&(this.matchCount=()=>this.#Y("match"),this.totalCount=()=>this.#Y("total"));const W=this.#e.grandTotals;_(W)&&(this.grandTotalRow=()=>this.#G());const K=this.#e.foregroundIdle;_(K)&&(this.foregroundIdle=()=>this.#he(K),this.#e.pageForegroundIdle=()=>this.#b?this.#he(K):null);const I=this.#e.facetProvider;_(I)&&(this.facetProvider=I);const B=this.#e;_(B.countMatching)&&_(B.streamMatching)&&(this.selectionQuery=()=>this.#H(),this.countMatching=J=>B.countMatching(J),this.streamMatching=(J,te)=>B.streamMatching(J,te),this.loadedRows=()=>this.#be(),this.resident=()=>this.#N()!==null),this.#n={pageSize:this.#e.pageSize||a,maxCachedPages:this.#e.maxCachedPages||h},this.#l=t(this.#t),this.#a=new P(this.#n.pageSize*4),this.#h=x((J,te)=>this.#T(J,te),q),this.#r=new A([],0,this.#n),this.#s.set(this.#r.key,this.#r),this.#f=this.#ve(),_(this.#e.fetch)||Z("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#me()}count(){const S=this.#S();return S?S.length:this.#v()}#v(){const S=this.#N();return S?S.count():(this.#ee(),this.#xe(this.#r))}#P(){if(this.#N())return!0;const S=F=>{if(F.count===null&&!F.complete)return!1;for(const $ of F.children.values())if(this.#ke($.key,this.#Te($))&&!S($))return!1;return!0};return S(this.#r)}pageInfo(){const S=this.#S(),F=this.totalPending();if(!S){const $=this.#v();return{page:0,pageSize:0,total:this.#P()?$:null,pageCount:1,counting:F}}return{page:S.page,pageSize:S.pageSize,total:S.total,pageCount:S.pageCount,counting:F||S.total===null&&this.#o.size>0&&this.#r.cache.loadedExtent()===0}}#S(){const S=this.#v(),F=n(this.#$("pageSize",0),this.#$("page",0),S,this.#P());if(!F)return this.#O="",null;const $=`${this.#y}:${F.offset}:${F.length}`;return $!==this.#O&&!this.#p&&(this.#O=$,F.length>0&&!this.#N()&&this.#T(F.offset,F.offset+F.length-1)),F}at(S){const F=this.#S();if(F){if(S<0||S>=F.length)return;const $=this.#C(F.offset+S);return $&&($.index=S),$}return this.#C(S)}#C(S){const F=this.#N();if(F)return F.at(S);if(this.#ee(),S<0||S>=this.#v())return;const $=this.#Z(this.#r,S);if(!$)return;const W=this.#z($.node,$.local);return W&&(W.index=S),W||this.#l.skeleton(S,$.node.level,$.node.cache.erroredAt($.local))}byKey(S){const F=this.#N();if(F)return F.byKey(S);const $=this.#c.get(S);if(!$)return;const W=$.lastIndexOf(":"),K=this.#s.get($.slice(0,W));return K&&this.#z(K,Number($.slice(W+1)))||void 0}loaded(S){const F=this.#S();if(F){if(S<0||S>=F.length)return!1;S+=F.offset}const $=this.#N();if($)return $.loaded(S);if(S<0||S>=this.#v())return!1;const W=this.#Z(this.#r,S);return!!W&&W.node.cache.rowLoaded(W.local)}hint(S,F){if(this.#p)return;this.#b=!0;const $=this.#ee();let W=Math.max(0,Math.floor(S)),K=Math.max(W,Math.floor(F));const I=this.#S();if(I){if(I.length===0)return;W=I.offset,K=I.offset+I.length-1}for(const[B,J]of this.#E(W,K)){B.cache.protect(J.min,J.max);for(const te of B.cache.evict())this.#Ee(B,te)}this.#h(W,K),$&&this.#h.flush()}#E(S,F){const $=this.#v(),W=new Map;for(let K=S;K<=F&&K<$;K++){const I=this.#Z(this.#r,K);if(!I)continue;const B=W.get(I.node);B?(B.min=Math.min(B.min,I.local),B.max=Math.max(B.max,I.local)):W.set(I.node,{min:I.local,max:I.local})}return W.size||W.set(this.#r,{min:S,max:S}),W}#T(S,F){if(!this.#p)for(const[$,W]of this.#E(S,F)){$.cache.protect(W.min,W.max);const K=$.cache.blockOf(W.min),I=$.cache.blockOf(W.max);for(let B=K;B<=I&&!($.count!==null&&B*$.cache.pageSize>=$.count);B++)$.cache.has(B)||this.#de($,B)}}apply(S){const F={added:[],updated:[],removed:[]};if(!S)return F;if(S.update)for(const $ of S.update){const W=this.#c.get(this.#l.keyOf($,-1));if(!W)continue;this.#a.delete(W);const K=W.lastIndexOf(":"),I=this.#s.get(W.slice(0,K));if(!I)continue;const B=Number(W.slice(K+1)),J=I.cache.blockOf(B);if(!I.cache.loaded(J))continue;const{start:te}=I.cache.rangeOf(J),Q=[];for(let ie=te;ie<te+I.cache.pageSize;ie++){const ue=I.cache.rowAt(ie);if(ue===void 0)break;Q.push(ie===B?$:ue)}I.cache.fill(J,Q);const re=this.#z(I,B);re&&F.updated.push(re)}return(S.add&&S.add.length||S.remove&&S.remove.length)&&this.reload({keepExpanded:!0}),F}reload(S){this.#o.abortAll("reload"),this.#h.cancel(),S&&S.keepExpanded===!1&&this.#i.clear(),this.#pe(),this.#_("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#o.abortAll("destroyed"),this.#pe(),this.#s.clear(),this.#i.clear(),this.#w&&_(this.#w.destroy)&&this.#w.destroy(),this.#w=null}expand(S){this.#i.has(S)||(this.#i.add(S),this.#_("group:toggled",{key:S,expanded:!0}),this.#_("model:changed",{reason:"expand",key:S}))}collapse(S){this.#i.delete(S)&&(this.#_("group:toggled",{key:S,expanded:!1}),this.#_("model:changed",{reason:"collapse",key:S}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#u}pivot(){this.#ee();const S=this.#d;if(!S||!S.keys.size||!this.#$("pivotBy",[]).length)return null;if(!S.result){const F=y((this.#t.config||{}).locale),$=[...S.keys.entries()].sort((K,I)=>O(K[1],I[1],F)),W=$.map(([K])=>K);S.result={keys:$.map(([,K])=>K),paths:W,fields:this.#Pe(W),groupPaths:[],columns:W.length*Math.max(1,this.#ye().length),values:S.cells,cells:S.cells,error:null}}return S.result}invalidateHandles(){this.#w&&(_(this.#w.invalidateHandles)&&this.#w.invalidateHandles(),_(this.#w.invalidate)&&this.#w.invalidate("filter"))}#M(){const S=this.#e.fullFrame;return _(S)?S():null}#N(){const S=this.#M();return S?(this.#w||(this.#w=new p({mode:"memory"},this.#R())),S.version!==this.#A&&(this.#w.setRows(S.rows),this.#A=S.version),this.#w):null}#R(){const S=this.#t,F=S.state||{};return{...S,state:{...F,page:()=>0,pageSize:()=>0}}}#D(){const S=this.#N();return S?S.filteredIndices():new Uint32Array(0)}#W(){const S=this.#N();return S?S.unfilteredIndices():new Uint32Array(0)}#V(S){const F=this.#N();return F?F.handleFor(S):void 0}#x(){const S=this.#N();return S?S.display():[]}#q(S){const F=this.#N();return F&&_(F.facetIndices)?F.facetIndices(S):new Uint32Array(0)}#B(){const S=this.#N();return S&&_(S.grandTotalRow)?S.grandTotalRow():null}#Y(S){const F=this.#N();if(F){const I=S==="match"?F.matchCount:F.totalCount;if(_(I))return I.call(F)}const $=this.#e.counts,W=_($)?$():null,K=W?W[S]:null;return typeof K=="number"?K:this.#v()}#G(){const S=this.#N();if(S&&_(S.grandTotalRow))return S.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const $=this.#e.grandTotals,W=_($)?$():null;return!W||!W.totals?null:this.#l.grandTotal(W.totals,W.leafCount||0)}#I(){const S=this.#N();if(S&&_(S.unfilteredRows))return S.unfilteredRows();const F=[],$=this.count();for(let W=0;W<$;W++){const K=this.at(W);K&&F.push(K)}return F}#H(){const S=this.#$("quick",""),F={protocol:G,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:d(this.#$("filters",null),this.#fe()),sort:this.#$("sort",[]),context:this.#$("context",null)};S&&(F.quick=S);const $=this.#$("where",null);return $&&$.active&&(F.where=$),F}#be(){const S=this.#$("groupBy",[]).length,F=[];for(const $ of this.#s.values())if(!($.level!==S&&!$.flat))for(const W of $.cache.ids()){if(!$.cache.loaded(W))continue;const{start:K,end:I}=$.cache.rangeOf(W);for(let B=K;B<I&&$.cache.rowLoaded(B);B++){const J=this.#z($,B);J&&!J.group&&F.push(J)}}return F}loadedCount(){const S=this.#N();if(S){const W=S.matchCount();return typeof W=="number"?W:S.count()}this.#ee();const F=this.#$("groupBy",[]).length;let $=0;for(const W of this.#s.values())if(!(W.level!==F&&!W.flat))for(const K of W.cache.ids()){if(!W.cache.loaded(K))continue;const I=W.cache.fillOf(K);typeof I=="number"&&($+=I)}return $}residentRows(){const S=this.#N();return S?S.display():this.#$("groupBy",[]).length>0?null:(this.#ee(),this.#be())}#ce(S,F,$){const{start:W,end:K}=S.cache.rangeOf(F),I=this.#$("groupBy",[]),B=this.#$("pivotBy",[]),J=this.#$("quick",""),te=this.#ye(),Q={protocol:G,range:{start:W,end:K},groupPath:S.path,groupValues:S.values,groupBy:I,totals:te,totalFns:this.#Ae(te),pivotBy:B,pivotMode:B.length>0,filters:d(this.#$("filters",null),this.#fe()),sort:this.#$("sort",[]),context:this.#$("context",null),signal:$};J&&(Q.quick=J);const re=this.#$("where",null);return re&&re.active&&(Q.where=re),Q}async#de(S,F){if(!_(this.#e.fetch))return;if(!this.#m){this.#m=!0;const I=this.#g;this.#g=[],queueMicrotask(()=>{for(const B of I)B()})}const $=this.#o.begin(`${S.key}:${F}`);S.cache.begin(F,$);const W=this.#f,{start:K}=S.cache.rangeOf(F);try{const I=await this.#e.fetch(this.#ce(S,F,$.signal));if(!$.current||W!==this.#f||this.#p)return;$.settle();const B=I&&I.rows||[];if(!!(I&&I[V])&&!S.flat){S.flat=!0,S.children.clear();for(const[re,ie]of[...this.#c])ie.startsWith(`${S.key}:`)&&(this.#a.delete(ie),this.#c.delete(re))}S.cache.fill(F,B),S.failed=!1;for(let re=0;re<B.length;re++)this.#a.delete(`${S.key}:${K+re}`);const te=I&&typeof I.count=="number"?I.count:I&&typeof I.total=="number"?I.total:null,Q=I&&_(I.pendingTotal?.then)?I.pendingTotal:null;te!==null?(S.count=te,S.complete=!0):B.length<S.cache.pageSize?(S.count=K+B.length,S.complete=!0):Q&&(S.counting=!0,S.announced=null),I&&Array.isArray(I.pivotFields)&&this.#Re(I.pivotFields),I&&I.pivot&&typeof I.pivot=="object"&&this.#se(I.pivot),this.#_("model:changed",{reason:"page",groupPath:S.path,block:F}),this.#_("rows:changed",{companion:!0,reason:"page",groupPath:S.path,block:F}),this.#re(S),Q&&this.#Me(S,Q,W)}catch(I){if($.settle(),j(I))return;S.cache.failed(F,I),S.failed=!0;const{end:B}=S.cache.rangeOf(F);for(let J=K;J<B;J++)this.#a.delete(`${S.key}:${J}`);this.#_("model:changed",{reason:"page-error",groupPath:S.path,block:F}),this.#_("source:error",{error:I,groupPath:S.path,block:F})}}async#Me(S,F,$){let W;try{W=await F}catch(K){if($!==this.#f||this.#p)return;S.counting=!1,j(K)||(S.failed=!0),j(K)||this.#_("source:error",{error:K,groupPath:S.path});return}$!==this.#f||this.#p||(S.counting=!1,typeof W=="number"&&(S.count=W,S.complete=!0,this.#re(S),this.#_("model:changed",{reason:"total",count:W,groupPath:S.path})))}#re(S){typeof S.count!="number"||!S.complete||S.announced!==S.count&&(S.announced=S.count,this.#_("source:total",{total:S.count,groupPath:S.path}))}#he(S){if(this.#p)return null;this.#ee();const F=this.#m?null:new Promise(B=>{this.#g.push(B),setTimeout(B,M)}),$=S();if(!F&&!$)return null;const W=(async()=>{F&&await F;for(let B=S();B;B=S())await B})();let K;const I=new Promise(B=>{K=setTimeout(B,M)});return Promise.race([W,I]).then(()=>clearTimeout(K))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#N())return!1;this.#ee();const S=this.#r;return S.count===null&&!S.complete&&S.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#Re(S){S.length===this.#u.length&&S.every((F,$)=>F===this.#u[$])||(this.#u=S,this.#_("column:pivoted",{pivotFields:S,remote:!0}))}#_e(){const S=this.#t.config||{};return S.pivot&&S.pivot.separator||v}#Pe(S){const F=this.#_e(),$=this.#ye();if(!$.length)return S.slice();const W=[];for(const K of S)for(const I of $)W.push(`${K}${F}${I}`);return W}#se(S){const F=this.#_e();this.#d||(this.#d={keys:new Map,cells:new Map,result:null});const $=this.#d;let W=!1;const K=B=>{const J=Array.isArray(B)?B:[B],te=w(J,F);return $.keys.has(te)||($.keys.set(te,J),W=!0),te},I=this.#$("groupBy",[]).length>0;for(const B of Array.isArray(S.axis)?S.axis:[])K(B);for(const B of Array.isArray(S.cells)?S.cells:[]){if(!B||typeof B!="object")continue;const J=K(B.pivot);if(I&&!(Array.isArray(B.group)&&B.group.length))continue;const te=w(Array.isArray(B.group)?B.group:[],F);for(const[Q,re]of Object.entries(B.values||{}))$.cells.set(m(te,J,Q),re)}$.result=null,W&&this.#Re((this.pivot()||{fields:[]}).fields)}#xe(S){let F=this.#oe(S);for(const $ of S.children.values())this.#ke($.key,this.#Te($))&&(F+=this.#xe($));return F}#oe(S){if(S.count!==null)return S.count;const F=S.cache.loadedExtent();return S.complete?F:S.row&&S.row.leafCount>0?S.level>=this.#$("groupBy",[]).length?Math.max(F,S.row.leafCount):F===0?1:Math.min(F+S.cache.pageSize,Math.max(F,S.row.leafCount)):F+S.cache.pageSize}#Z(S,F){let $=F,W=0;const K=[...S.children.entries()].filter(([,B])=>this.#ke(B.key,this.#Te(B))).sort((B,J)=>B[0]-J[0]);for(const[B,J]of K){const te=B-W+1;if($<te)return{node:S,local:W+$};$-=te,W=B+1;const Q=this.#xe(J);if($<Q)return this.#Z(J,$);$-=Q}const I=this.#oe(S);return W+$<I?{node:S,local:W+$}:null}#z(S,F){const $=`${S.key}:${F}`,W=this.#a.get($);if(W)return W.group===!0?this.#J(W):W;const K=S.cache.rowAt(F);if(K===void 0)return null;const I=this.#$("groupBy",[]);let B;if(S.level<I.length&&!S.flat){const J=I[S.level],te=this.#d!==null&&S.level===I.length-1&&this.#$("pivotBy",[]).length>0,Q=this.#te(K,J),re=Q==null,ie=[...S.path,re?"":String(Q)],ue=[...S.keyPath,re?null:String(Q)];if(B=this.#l.group({path:ie,keyPath:ue,column:J,value:Q,level:S.level,parent:S.row,leafCount:Number(K.leafCount)||0,expanded:te?!1:this.#ke(o(ue),{key:o(ue),column:J,value:Q,level:S.level,path:ie}),...te?{hasChildren:!1}:{}}),B.totals=this.#U(K),B.data=K,!te){let ke=this.#s.get(B.key);ke?ke.row=B:(ke=new A(ie,S.level+1,this.#n,ue),ke.row=B,this.#s.set(ke.key,ke)),ke.values=[...S.values,Q],S.children.set(F,ke)}}else B=this.#l.leaf(K,F,S.level,S.row);return this.#a.set($,B),this.#c.set(B.key,$),B}#U(S){const F=S||{};if(F.totals&&typeof F.totals=="object")return F.totals;const $={};for(const W of this.#ye())Object.hasOwn(F,W)&&($[W]=F[W]);return $}#J(S){const F=this.#s.get(S.key);if(!F||F.row!==S||S.hasChildren===!1)return S;const $=this.#ke(S.key,this.#Te(F));return S.expanded!==$&&(S.expanded=$),S}#Ee(S,F){const{start:$,end:W}=S.cache.rangeOf(F);for(let K=$;K<W;K++){const I=`${S.key}:${K}`,B=this.#a.peek(I);B&&this.#c.delete(B.key),this.#a.delete(I)}}#ee(){const S=this.#ve();return S===this.#f?!1:(this.#f=S,this.#o.abortAll("query"),this.#pe(),this.#m=!1,this.#_("model:changed",{reason:"query"}),!0)}#pe(){for(const S of this.#s.values())S.cache.clear(),S.count=null,S.complete=!1,S.announced=null,S.counting=!1,S.failed=!1,S.children.clear(),S.flat=!1;this.#a.clear(),this.#c.clear(),this.#y++,this.#d=null}#ve(){const S=this.#$("where",null);return`${s({filters:this.#$("filters",null),sort:this.#$("sort",[]),quick:this.#$("quick",""),groupBy:this.#$("groupBy",[]),pivotBy:this.#$("pivotBy",[]),context:this.#$("context",null)})}|${S?S.version:0}`}#ke(S,F){const $=this.#$("expanded",null);return $?_($.has)?$.has(S,F):Array.prototype.includes.call($,S):this.#i.has(S)}#Te(S){if(S.row)return{key:S.key,column:S.row.column,value:S.row.value,level:S.level-1,path:S.path}}#ye(){const S=this.#$("totals",[]);if(S&&S.length)return[...S];const F=this.#t.columns;return!F||!_(F.all)?[]:F.all().filter($=>!!$.total).map($=>$.id)}#Ae(S){const F=this.#t.columns,$={};if(!F||!_(F.get))return $;for(const W of S){const K=F.get(W);if(!K)continue;const I=K.groupTotal!=null?K.groupTotal:K.total;typeof I=="string"?$[W]=I:I&&typeof I=="object"&&typeof I.fn=="string"&&($[W]={...I})}return $}#te(S,F){const $=this.#t.columns,W=$&&_($.get)?$.get(F):void 0;return W&&_(W.getValue)?W.getValue(S):S?.[F]}#me(){g(this.#t)}#fe(){const S=this.#t.config||{};return{tz:S.timeZone,weekStartsOn:S.weekStartsOn}}#$(S,F){const $=this.#t.state;if($&&_($[S])){const W=$[S]();return W??F}return F}#_(S,F){const $=this.#t.emit;_($)&&$(S,F)}}}),We("packages/core/src/source/gapbuffer.js",function(e,D){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return P}});const ne=64;class P{#e;#t=0;#n=0;constructor(_=ne){this.#e=new Uint32Array(Math.max(1,_)),this.#n=this.#e.length}static from(_,L=ne){const Z=new P(_.length+Math.max(1,L));return Z.#e.set(_,0),Z.#t=_.length,Z.#n=Z.#e.length,Z}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(_){return _<0||_>=this.length?0:_<this.#t?this.#e[_]:this.#e[_+(this.#n-this.#t)]}insert(_,L){const Z=_<0?0:_>this.length?this.length:_;this.#r(Z),this.#t===this.#n&&this.#s(),this.#e[this.#t++]=L}push(_){this.insert(this.length,_)}removeAt(_){return!Number.isInteger(_)||_<0||_>=this.length?!1:(this.#r(_),this.#n++,!0)}toArray(){const _=new Uint32Array(this.length);return _.set(this.#e.subarray(0,this.#t),0),_.set(this.#e.subarray(this.#n),this.#t),_}clear(){this.#t=0,this.#n=this.#e.length}#r(_){if(_!==this.#t)if(_<this.#t){const L=this.#t-_;this.#e.copyWithin(this.#n-L,_,this.#t),this.#t=_,this.#n-=L}else{const L=_-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+L),this.#t=_,this.#n+=L}}#s(){const _=this.#e.length-this.#n,L=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+ne));L.set(this.#e.subarray(0,this.#t),0),L.set(this.#e.subarray(this.#n),L.length-_),this.#e=L,this.#n=L.length-_}}}),We("packages/core/src/store/ingest.js",function(e,D){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return d}});const ne=D("packages/core/src/internal/schedule.js"),P=ne.now,Y=ne.nextFrame,_=D("packages/core/src/internal/warn.js"),L=_.infoOnce,Z=_.warnOnce,x=D("packages/core/src/internal/predicates.js").isFunction,U=D("packages/core/src/internal/paths.js").pathGetter,k=D("packages/core/src/store/columnstore.js").ColumnStore,b=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function a(s,g={}){if(g.multi)return"multi";if(s.length===0)return"object";let i=0,n=0,f=0,p=0,l=0;for(let c=0;c<s.length;c++){const m=s[c];typeof m=="number"?i++:typeof m=="boolean"?n++:typeof m=="string"?f++:m instanceof Date?p++:Array.isArray(m)&&l++}const y=s.length;return i===y?"float64":n===y?"bitset":p===y?"float64":f===y?"text":l===y?"multi":"object"}function h(s,g,i){return g<=0||s<i*g?"dictionary":"object"}function r(s,g,i){const n=new Map,f=new Map;for(const G of s){if(G.computed)continue;const q=x(G.read)?G.read:U(G.field||G.id);f.set(G.id,q),n.set(G.id,q)}const p=g?.order??[],l=g?.fns??{},y=g?.deps??{},c=g?.wrapDeps??null,m=p.filter(G=>x(l[G])),w=m.some(G=>y[G]==="*");let v=new WeakMap;const E=G=>{const q={};if(w)for(const[M,O]of f)q[M]=O(G);for(const M of m){const O=y[M];let T;if(O==="*")T=q;else{T={};const A=O||[];for(let N=0;N<A.length;N++){const C=A[N];T[C]=C in q?q[C]:f.get(C)?.(G)}}q[M]=l[M](c?c(T,M):T,{data:G,row:null,column:null,grid:null,context:i})}return q},V=G=>{if(G===null||typeof G!="object"&&typeof G!="function")return E(G);let q=v.get(G);return q===void 0&&(q=E(G),v.set(G,q)),q};for(const G of m)n.set(G,q=>V(q)[G]);return{readers:n,reset(){v=new WeakMap}}}class t{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(g,i){this.spec=g,this.read=i,this.kind="object",this.inferred=!1,this.nullable=g.nullable!==!1}}class o{#e;#t=[];#n=null;#r;#s=0;#i;#o=!1;#l=!1;#a=0;#c;constructor(g,i={},n={}){this.#e=Array.isArray(g)?g:Array.from(g||[]),this.#i={...b,...n};const f=i.columns??[];this.#r=r(f,i.computed??null,i.context),this.#c=this.#e.length>=this.#i.columnarBelow,this.#u(f,i.computed??null),this.#n=new k(this.#t.map(p=>({id:p.spec.id,kind:p.kind,nullable:p.nullable,read:p.read,dictionary:p.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#o||this.#l}get progress(){return this.#s}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const g=P(),{chunkMs:i,chunkRows:n}=this.#i,f=this.#e.length;do{const p=Math.min(this.#s+n,f);this.#n.append(this.#e.slice(this.#s,p)),this.#d(this.#s,p),this.#s=p,this.#r.reset(),this.#h(!1)}while(this.#s<f&&P()-g<i);return this.#a+=P()-g,this.#i.onProgress?.({loaded:this.#s,total:f}),this.#s>=f?(this.#h(!0),this.#o=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(g=>({id:g.spec.id,kind:g.kind,nullable:g.nullable,read:g.read,dictionary:g.spec.dictionary})),decisions:this.#t.map(g=>({id:g.spec.id,kind:g.kind,nullable:g.nullable,inferred:g.inferred,distinct:g.candidate||g.change?this.#f(g):null,change:g.change,reason:g.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#u(g,i){const n=this.#e,f=Math.min(this.#i.sampleSize,n.length),p=this.#i.dictionaryRatio,l=i?.pure instanceof Set?i.pure:new Set(i?.pure??i?.order??[]);for(const y of g){if(!y||!y.id)continue;if(y.computed&&(y.pure===!1||i&&!l.has(y.id))){Z(`ingest.impure.${y.id}`,`column "${y.id}" is an impure computed column and is not materialised into the store`);continue}const c=this.#r.readers.get(y.id)??(x(y.read)?y.read:U(y.field||y.id)),m=new t(y,c);if(y.kind)m.kind=y.kind,m.reason="declared by the caller";else if(y.dictionary)m.kind=y.multi?"multi":"dictionary",m.reason="value table supplied (lookup column)";else{const w=[];for(let E=0;E<f&&w.length<this.#i.sampleSize;E++){const V=c(n[E]);V!=null&&w.push(V)}m.inferred=!0;const v=a(w,{multi:y.multi});if(v==="text"){const E=new Set(w).size;m.kind=h(E,w.length,p),m.candidate=this.#c,m.reason=`sampled ${E} distinct in ${w.length}`}else m.kind=v,m.reason=`inferred from ${w.length} sampled values`,v==="object"&&w.length&&L(`ingest.mixed.${y.id}`,`column "${y.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);m.kind==="object"&&m.candidate&&(m.distinct=new Set(w))}this.#t.push(m)}}#d(g,i){const n=this.#e;for(const f of this.#t){if(!f.candidate||!f.distinct)continue;const p=f.distinct;for(let l=g;l<i;l++){const y=f.read(n[l]);y!=null&&p.add(y)}}}#f(g){if(g.distinct)return g.distinct.size;const i=this.#n.column(g.spec.id);return i?.dict?i.dict.size:0}#h(g){const i=this.#i.dictionaryRatio,n=this.#e.length;for(const f of this.#t){if(!f.candidate)continue;const p=this.#f(f);if(f.kind==="dictionary"&&p>=i*n){const l=this.#n.column(f.spec.id);f.distinct=new Set(l?.dict?l.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${p} distinct values is at or above ${i*100}% of ${n} rows`;continue}if(f.kind==="object"&&p>=i*n){f.candidate=!1,f.distinct=null,f.reason=`${p} distinct values is at or above ${i*100}% of ${n} rows`;continue}g&&f.kind==="object"&&p<i*n&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${p} distinct values is below ${i*100}% of ${n} rows`,f.distinct=null),g&&(f.candidate=!1)}}}async function u(s,g={},i={}){const n=new o(s,g,i),f=i.scheduler?.frame??Y;for(;n.slice();)await new Promise(p=>{f(p)});return n.result()}function d(s,g={},i={}){const n=new o(s,g,{...i,chunkMs:1/0});for(;n.slice(););return n.result()}}),We("packages/core/src/store/columnpack.js",function(e,D){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return h}});const P=D("packages/core/src/internal/paths.js").pathGetter,Y=D("packages/core/src/store/ingest.js"),_=Y.inferKind,L=Y.decideText,Z=Y.INGEST_DEFAULTS,x=D("packages/core/src/store/columnstore.js").toFloat,X=new Set(["float64","int32","bitset","dictionary","object","multi"]);function U(r){if(!Array.isArray(r)||r.length===0)return!1;for(const t of r)if(!t||typeof t.id!="string"||typeof t.field!="string"||t.field===""||t.kind&&!X.has(t.kind))return!1;return!0}function j(r){const t=x(r);return Number.isFinite(t)?t|0:0}function k(r){return r==null?[]:Array.isArray(r)?r:[r]}function b(r,t,o,u){if(r.kind)return r.kind;const d=[];for(let i=0;i<t.length&&d.length<Z.sampleSize;i++){const n=t[i];n!=null&&d.push(n)}const s=_(d,{multi:r.multi});if(s!=="text")return s;const g=new Set(d).size;return L(g,d.length,u)}function a(r,t,o={}){const u=t.length|0,d=o.dictionaryRatio??Z.dictionaryRatio,s=[];for(const g of r){const i=P(g.field||g.id),n=g.nullable!==!1,f=new Array(u);for(let m=0;m<u;m++){const w=i(t[m]);f[m]=w===void 0?null:w}const p=b(g,f,u,d),l=n?new Uint8Array(u+7>>3):null,y=m=>{l&&(l[m>>3]|=1<<(m&7))};let c;switch(p){case"float64":{const m=new Float64Array(u);for(let w=0;w<u;w++){const v=f[w],E=v===null;E||y(w),m[w]=E?NaN:x(v)}c={id:g.id,kind:p,nullable:n,values:m,presence:l,offsets:null,table:null};break}case"int32":{const m=new Int32Array(u);for(let w=0;w<u;w++){const v=f[w],E=v===null;E||y(w),m[w]=E?0:j(v)}c={id:g.id,kind:p,nullable:n,values:m,presence:l,offsets:null,table:null};break}case"bitset":{const m=new Uint8Array(u+7>>3);for(let w=0;w<u;w++){const v=f[w],E=v===null;E||y(w),!E&&v&&(m[w>>3]|=1<<(w&7))}c={id:g.id,kind:p,nullable:n,values:m,presence:l,offsets:null,table:null};break}case"dictionary":{const m=new Uint32Array(u),w=[],v=new Map;for(let E=0;E<u;E++){const V=f[E];if(V===null){m[E]=0;continue}y(E);let G=v.get(V);G===void 0&&(G=w.length,w.push(V),v.set(V,G)),m[E]=G}c={id:g.id,kind:p,nullable:n,values:m,presence:l,offsets:null,table:w};break}case"multi":{const m=[],w=new Map,v=new Uint32Array(u+1),E=[];for(let V=0;V<u;V++){const G=f[V];v[V]=E.length,G===null||y(V);const M=k(G);for(let O=0;O<M.length;O++){const T=M[O];let A=w.get(T);A===void 0&&(A=m.length,m.push(T),w.set(T,A)),E.push(A)}}v[u]=E.length,c={id:g.id,kind:p,nullable:n,values:Int32Array.from(E),presence:l,offsets:v,table:m};break}default:{const m=new Array(u);for(let w=0;w<u;w++){const v=f[w];v!==null&&y(w),m[w]=v}c={id:g.id,kind:"object",nullable:n,values:m,presence:l,offsets:null,table:null};break}}s.push(c)}return{count:u,columns:s}}function h(r){const t=[];if(!r||!Array.isArray(r.columns))return t;const o=u=>{ArrayBuffer.isView(u)&&u.buffer&&!t.includes(u.buffer)&&t.push(u.buffer)};for(const u of r.columns)o(u.values),o(u.presence),o(u.offsets);return t}}),We("packages/core/src/source/stream.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return A}});const P=D("packages/core/src/internal/lru.js").Lru,_=D("packages/core/src/internal/predicates.js").isFunction,L=D("packages/core/src/internal/schedule.js"),Z=L.now,H=L.nextFrame,x=L.cancelFrame,X=L.whenIdle,j=D("packages/core/src/internal/compare.js").defaultCompare,k=D("packages/core/src/internal/warn.js"),b=k.warnOnce,a=k.infoOnce,r=D("packages/core/src/internal/paths.js").getPath,t=D("packages/core/src/source/abort.js"),o=t.createAbortScope,u=t.isAbortError,d=D("packages/core/src/source/rows.js"),s=d.createRowFactory,g=d.lazyRowView,n=D("packages/core/src/source/gapbuffer.js").GapBuffer,p=D("packages/core/src/source/memory.js").createMemorySource,y=D("packages/core/src/source/filterwire.js").querySignature,m=D("packages/core/src/store/columnpack.js").isPortableSchema,w=25e4,v=Symbol("lattice.stream.storeBacked"),E=8,V=.1,G=1e3,q=50;function M(N){return Math.min(G,Math.max(q,Math.floor(N/4)))}function O(N){if(N instanceof Date)return N.getTime();if(typeof N=="number")return Number.isFinite(N)?N:NaN;if(typeof N=="string"){const C=N.trim();if(!C)return NaN;const S=Date.parse(C);return Number.isNaN(S)?Number(C):S}return NaN}function T(N,C){return new A(N,C)}class A{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#s=[];#i=null;#o;#l;#a=new Map;#c=o();#u={loaded:0,estimated:void 0};#d=null;#f=0;#h=0;#p=0;#m=0;#g=null;#b=null;#y=null;#O=!1;#w=!1;#A=!1;#v=!1;#P="";#S=0;#C=0;#E=0;#T=null;#M=1/0;#N=!1;#R=null;#D=null;#W=null;#V=null;#x=!1;#q=0;#B=0;#Y=!1;constructor(C,S){this.#e=C||{mode:"stream"},this.#t=S||{},this.#o=s(this.#t),this.#l=new P(4096),this.#P=this.#Xe();const F=(this.#t.config||{}).ingest;this.#x=!!F&&F.retainSource===!1,_(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 $=Number(this.#e.poll);Number.isFinite($)&&$>0&&(this.#V=setInterval(()=>{this.#v||this.reload()},$),this.#V&&_(this.#V.unref)&&this.#V.unref()),this.#I()}#G(){const C=Number(this.#e.maxAge);return Number.isFinite(C)&&C>0?C:0}#I(){const C=this.#G();if(!C)return;const S=this.#e.ageBy;_(S)?this.#D=S:typeof S=="string"&&S?this.#D=F=>r(F,S):this.#D=null,this.#T=[],this.#R=setInterval(()=>{this.#v||this.#H()&&(this.#Ee(),this.#_())},M(C)),this.#R&&_(this.#R.unref)&&this.#R.unref()}#H(){const C=this.#G();return!C||!this.#T?!1:this.#N?!0:this.#M<Date.now()-C*(1+V)}#be(C,S){if(!this.#T)return;const F=this.#D?O(this.#D(S)):Date.now();this.#T[C]=F,Number.isNaN(F)||(F<this.#M&&(this.#M=F),F<Date.now()-this.#G()&&(this.#N=!0))}#ce(){return this.#Oe("groupBy",[]).length>0?!0:!!this.#Oe("pivotMode",!1)&&this.#Oe("pivotBy",[]).length>0}#de(){if(this.#g||this.#v)return;const C=this.#ce();if(C&&!this.#b){this.#b=p({mode:"memory",rows:this.#n},this.#Me()),this.#O=!1;return}!C&&this.#b&&(this.#b.destroy(),this.#b=null)}#Me(){if(this.#y)return this.#y;const C=this,S={liveIndices:()=>C.#re(),live:F=>C.#n[F]!==void 0,source:F=>C.#ie(F),get physical(){return C.#n.length}};return this.#x&&(S.column=F=>{const $=C.#t.store;return $&&_($.column)?$.column(F):void 0}),this.#y=Object.create(this.#t,{store:{value:S,enumerable:!0,configurable:!0}}),this.#y}#re(){const C=new Uint32Array(this.#n.length);let S=0;for(let F=0;F<this.#n.length;F++)this.#n[F]!==void 0&&(C[S++]=F);return C.subarray(0,S)}#he(){return this.#g?this.#g:this.#b?(this.#O&&(this.#O=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(C="filter"){if(this.#g){this.#g.invalidate(C);return}this.#de(),this.#b&&this.#b.invalidate(C),(C==="filter"||C==="sort")&&this.#ke()}count(){const C=this.#he();return C?C.count():this.#r?this.#r.length:this.#S}matchCount(){const C=this.#he();return C&&_(C.matchCount)?C.matchCount():this.#r?this.#r.length:this.#S}totalCount(){const C=this.#he();return C&&_(C.totalCount)?C.totalCount():this.#S}unfilteredRows(){const C=this.#he();if(C&&_(C.unfilteredRows))return C.unfilteredRows();const S=[];for(let F=0;F<this.#n.length;F++){if(!this.#n[F])continue;const $=this.#je(F);$&&S.push($)}return S}at(C){const S=this.#he();if(S)return S.at(C);if(C<0||C>=this.count())return;const F=this.#r?this.#r.at(C):C,$=this.#je(F);return $.index=C,$}byKey(C){const S=this.#he();if(S)return S.byKey(C);const F=this.#a.get(C);return F===void 0?void 0:this.#je(F)}leavesOf(C){const S=this.#he();return S&&_(S.leavesOf)?S.leavesOf(C):[]}loaded(C){return C>=0&&C<this.count()}hint(C,S){if(this.#g){this.#g.hint(C,S);return}this.#Re(),this.#p=Math.max(0,Math.floor(C))}#Re(){this.#v||this.#Xe()===this.#P||this.reload()}display(){const C=this.#he();return C?C.display():g(()=>this.count(),S=>this.at(S))}apply(C){if(this.#g)return this.#g.apply(C);const S={added:[],updated:[],removed:[]};if(!C)return S;if(C.update){let F=!1;for(const $ of C.update){const W=this.#a.get(this.#o.keyOf($,-1));if(W===void 0)continue;const K=this.#Ae(W);this.#x?this.#We(W,$):this.#n[W]=$,this.#l.delete(W),this.#te(W,K),this.#T&&(this.#be(W,$),F=!0),this.#O=!0,S.updated.push(this.#je(W))}F&&this.#Ee()}if(C.add&&C.add.length){const F=this.#U(C.add);for(const $ of F)S.added.push(this.#je($))}return C.remove&&C.remove.length&&b("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#_(),S}reload(C){this.#c.abortAll("reload"),this.#Ve(),this.#b&&(this.#b.destroy(),this.#b=null),this.#O=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#S=0,this.#C=0,this.#E=0,this.#T&&(this.#T=[]),this.#M=1/0,this.#N=!1,this.#w=!1,this.#A=!1,this.#u={loaded:0,estimated:void 0},this.#P=this.#Xe(),this.#Se("model:changed",{reason:"reload"}),this.start()}destroy(){this.#v=!0,this.#V!==null&&(clearInterval(this.#V),this.#V=null),this.#R!==null&&(clearInterval(this.#R),this.#R=null),this.#T=null,this.#c.abortAll("destroyed"),this.#Ve(),this.#d!==null&&(this.#we(this.#d),this.#d=null),this.#b&&(this.#b.destroy(),this.#b=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#A||this.#v||!_(this.#e.open))return;this.#A=!0;const C=this.#c.begin("stream");this.#ke(),this.#de();let S;try{S=this.#e.open({sort:this.#Oe("sort",[]),filters:this.#Oe("filters",null),quick:this.#Oe("quick","")||void 0,context:this.#Oe("context",null),signal:C.signal})}catch($){this.#Se("source:error",{error:$});return}const F=_(S[Symbol.asyncIterator])?S[Symbol.asyncIterator]():S[Symbol.iterator]();this.#W=F;try{for(;;){const $=await F.next();if(!C.current||this.#v)return;if($.done){this.#$();return}if(await this.#_e($.value,C),!C.current||this.#v)return;if($.value&&$.value.done){this.#$();return}if(await this.#ue(),!C.current||this.#v)return}}catch($){if(u($))return;this.#Se("source:error",{error:$})}finally{C.settle()}}progress(){return{loaded:this.#u.loaded,estimated:this.#u.estimated,done:this.#w,live:this.#S,evicted:this.#C}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const C=this.#he();C&&(_(C.invalidateHandles)&&C.invalidateHandles(),_(C.invalidate)&&C.invalidate("sort"))}renderCount(){return this.#f}ingestStats(){return{worker:this.#q,inline:this.#B,storeBacked:this.#x}}#_e(C,S){if(!C)return;const F=C.rows;if(F&&F.length&&this.#se(F))return this.#oe(C,S);const $=Z();F&&F.length&&(this.#U(F),this.#B++),this.#Pe(C),this.#h+=Z()-$,this.#_()}#Pe(C){this.#u.loaded=C.progress&&typeof C.progress.loaded=="number"?C.progress.loaded:this.#n.length,C.progress&&typeof C.progress.estimated=="number"&&(this.#u.estimated=C.progress.estimated)}#se(C){if(this.#Y||this.#g)return!1;const S=this.#Z();if(!S)return!1;const F=this.#t.store;if(!F||!_(F.appendPacked))return!1;const $=this.#z();return!$||!m($)?(this.#Y=!0,a("source.stream.ingest-worker","stream ingest.useWorker is on but a column reads through a closure (a computed or date column); columnizing on the main thread instead."),!1):C.length<S.threshold?!1:!this.#xe(C)}#xe(C){if(!this.#o.keyed)return!1;const S=new Set;for(let F=0;F<C.length;F++){const $=this.#o.keyOf(C[F],this.#n.length+F);if($!=null){if(S.has($)||this.#a.has($))return!0;S.add($)}}return!1}async#oe(C,S){const F=C.rows,$=this.#Z(),W=this.#z();let K;try{K=await $.columnize(W,F,{key:"ingest:stream",signal:S&&S.signal})}catch(Q){if(u(Q)||(b("source.stream.columnize","worker columnization failed; columnizing on the main thread",Q),this.#Y=!0,S&&(!S.current||this.#v)))return;this.#U(F),this.#B++,this.#Pe(C),this.#_();return}if(S&&(!S.current||this.#v))return;const I=this.#t.store,B=this.#x?void 0:F,{from:J}=I.appendPacked(K,B),te=K.count|0;for(let Q=0;Q<te;Q++){const re=J+Q,ie=F[Q],ue=this.#o.keyed?this.#o.keyOf(ie,re):null;if(this.#n[re]=this.#x?v:ie,this.#S++,this.#be(re,ie),ue!==null&&this.#a.set(ue,re),!this.#r||!this.#Te(re))continue;const ke=this.#me(re);this.#r.insert(ke,re),ke<=this.#p&&this.#m++}this.#O=!0,this.#Ee(),this.#q++,this.#Pe(C),this.#_()}#Z(){const C=this.#t.ingestWorker;return _(C)?C():null}#z(){const C=this.#t.storeSchema;return _(C)?C():null}#U(C){const S=[],F=this.#t.store,$=new Array(C.length),W=[],K=new Set;for(let B=0;B<C.length;B++){const J=this.#o.keyed?this.#o.keyOf(C[B],this.#n.length+W.length):null;$[B]=J,!(J!==null&&(this.#a.has(J)||K.has(J)))&&(J!==null&&K.add(J),W.push(C[B]))}let I=W.length&&F&&_(F.append)?F.append(W).from:this.#n.length;for(let B=0;B<C.length;B++){const J=C[B],te=$[B];if(te!==null&&this.#a.has(te)){const ie=this.#a.get(te),ue=this.#Ae(ie);this.#x||(this.#n[ie]=J,F&&_(F.setSource)&&F.setSource(ie,J)),this.#We(ie,J),this.#l.delete(ie),this.#be(ie,J),this.#te(ie,ue);continue}const Q=I++;if(this.#n[Q]=this.#x?v:J,this.#S++,this.#be(Q,J),te!==null&&this.#a.set(te,Q),S.push(Q),!this.#r||!this.#Te(Q))continue;const re=this.#me(Q);this.#r.insert(re,Q),re<=this.#p&&this.#m++}return this.#O=!0,this.#Ee(),S}#J(C){const S=this.#n[C];let F=!1;if(this.#r){const I=this.#ve(C);I>=0&&I<=this.#p&&(F=!0)}else C<=this.#p&&(F=!0);const $=S===v?this.#ie(C):S,W=this.#o.keyed?this.#o.keyOf($,C):null;W!==null&&this.#a.get(W)===C&&this.#a.delete(W),this.#n[C]=void 0,this.#T&&(this.#T[C]=NaN),this.#l.delete(C);const K=this.#t.store;return K&&_(K.remove)&&K.remove(C),this.#S--,F}#Ee(){let C=0,S=0;const F=this.#pe();C+=F.dropped,S+=F.aboveAnchor;const $=this.#ee();C+=$.dropped,S+=$.aboveAnchor,C&&(this.#O=!0,this.#C+=C,this.#ke(),this.#m-=S,this.#Se("stream:evicted",{evicted:C,total:this.#C,live:this.#S}))}#ee(){const C=this.#e.maxRows;if(!Number.isFinite(C)||C<=0||this.#S<=C)return{dropped:0,aboveAnchor:0};const S=Math.max(1,Math.floor(C*(1-V)));let F=0,$=0;for(;this.#S>S&&this.#E<this.#n.length;){const W=this.#E++;this.#n[W]!==void 0&&(this.#J(W)&&$++,F++)}return{dropped:F,aboveAnchor:$}}#pe(){const C=this.#G();if(!C||!this.#T||!this.#H())return{dropped:0,aboveAnchor:0};const S=Date.now()-C;let F=0,$=0,W=1/0;for(let K=this.#E;K<this.#n.length;K++){if(this.#n[K]===void 0)continue;const I=this.#T[K];if(!(Number.isNaN(I)||I===void 0)){if(I>=S){I<W&&(W=I);continue}this.#J(K)&&$++,F++}}for(this.#M=W,this.#N=!1;this.#E<this.#n.length&&this.#n[this.#E]===void 0;)this.#E++;return{dropped:F,aboveAnchor:$}}#ve(C){if(!this.#r)return C;for(let S=0;S<this.#r.length;S++)if(this.#r.at(S)===C)return S;return-1}#ke(){this.#s=this.#Oe("sort",[]),this.#i=this.#Oe("filters",null);const C=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#G()>0,S=this.#Oe("where",null),F=(this.#t.config||{}).hostFilter,$=!!(S&&S.active)||!!(F&&_(F.active)&&F.active());if(!(C||this.#s.length>0||!!this.#i||!!this.#Oe("quick","")||$)){this.#r=null;return}this.#r=new n(Math.max(64,this.#n.length+64));for(let K=0;K<this.#n.length;K++)this.#n[K]!==void 0&&this.#Te(K)&&this.#r.insert(this.#me(K),K)}#Te(C){const S=this.#ie(C);if(this.#i&&!this.#ye(this.#i,S))return!1;const F=String(this.#Oe("quick","")||"").toLowerCase();if(F&&!this.#k(S).includes(F))return!1;const $=(this.#t.config||{}).hostFilter;if($&&_($.active)&&$.active()&&!$.passes(this.#je(C)))return!1;const W=this.#Oe("where",null);if(W&&W.active){const K=this.#je(C);if(!W.passes(K.data,K.key))return!1}return!0}#ye(C,S){if(!C)return!0;const F=C;if(Array.isArray(F.conditions))return F.op==="or"?F.conditions.some(K=>this.#ye(K,S)):F.op==="not"?!F.conditions.some(K=>this.#ye(K,S)):F.conditions.every(K=>this.#ye(K,S));const $=C,W=(this.#t.compute||{}).testValue;return _(W)?!!W(this.#Ue(S,$.col),$,(this.#t.config||{}).locale):(b("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#Ae(C){if(!this.#r)return-1;if(!this.#s.length)return this.#ve(C);let S=0,F=this.#r.length;for(;S<F;){const $=S+F>>>1;this.#fe(this.#r.at($),C)<0?S=$+1:F=$}for(let $=S;$<this.#r.length;$++){const W=this.#r.at($);if(W===C)return $;if(this.#fe(W,C)>0)break}return this.#ve(C)}#te(C,S){if(!this.#r||!this.#s.length)return;const F=this.#Te(C);if(S>=0&&this.#r.at(S)===C)this.#r.removeAt(S),S<=this.#p&&this.#m--;else if(S>=0)return;if(!F)return;const $=this.#me(C);this.#r.insert($,C),$<=this.#p&&this.#m++}#me(C){if(!this.#r||!this.#s.length)return this.#r?this.#r.length:0;let S=0,F=this.#r.length;for(;S<F;){const $=S+F>>>1;this.#fe(C,this.#r.at($))<0?F=$:S=$+1}return S}#fe(C,S){const F=this.#ie(C),$=this.#ie(S);for(const W of this.#s){const K=this.#Le(W.col),I=this.#Ue(F,W.col),B=this.#Ue($,W.col),te=(K&&K.value&&_(K.value.compare)?K.value.compare:j)(I,B);if(te!==0)return W.dir==="desc"?-te:te}return 0}#$(){this.#w=!0,this.#u.loaded=this.#u.loaded||this.#n.length;const C=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:w;!this.#x&&this.#n.length<C&&(this.#g=p({mode:"memory",rows:this.#n},this.#t),this.#R!==null&&(clearInterval(this.#R),this.#R=null),this.#b&&(this.#b.destroy(),this.#b=null)),this.#_(),this.#Se("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:C})}#_(){this.#d!==null||this.#v||(this.#d=this.#F(()=>{this.#d=null,this.#f++;const C=this.#m;this.#m=0,this.#h=0,this.#Se("stream:chunk",{loaded:this.#u.loaded,estimated:this.#u.estimated,count:this.count(),renders:this.#f}),this.#Se("model:changed",{reason:"stream",shiftAboveViewport:C,anchor:this.#p}),this.#Se("rows:changed",{companion:!0,reason:"stream"})}))}#ue(){return this.#f===0||this.#h<this.#ae()?Promise.resolve():(this.#h=0,new Promise(C=>{const S=(this.#t.scheduler||{}).idle;_(S)?S(()=>C()):X(()=>C())}))}#ae(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:E}#F(C){const S=this.#t.scheduler||{};return _(S.frame)?S.frame(C):H(C)}#we(C){const S=this.#t.scheduler||{};_(S.cancel)?S.cancel(C):x(C)}#ie(C){const S=this.#n[C];if(S!==void 0&&S!==v)return S;if(S===void 0)return;const F=this.#t.store;return F&&_(F.source)?F.source(C):void 0}#We(C,S){const F=this.#t.store;if(!F||!_(F.set))return;const $=this.#z();if(Array.isArray($))for(const W of $){if(!W||!W.id)continue;const K=_(W.read)?W.read:I=>r(I,W.field||W.id);F.set(W.id,C,K(S))}}#je(C){let S=this.#l.get(C);return S||(S=this.#o.leaf(this.#ie(C),C),this.#l.set(C,S)),S}#Ue(C,S){const F=this.#Le(S);return F&&_(F.getValue)?F.getValue(C):C?.[S]}#k(C){const S=this.#t.columns,F=S&&_(S.all)?S.all():[],$=[];for(const W of F){const K=_(W.getValue)?W.getValue(C):void 0;K!=null&&K!==""&&$.push(String(K))}return $.join(" ").toLowerCase()}#Le(C){const S=this.#t.columns;return S&&_(S.get)?S.get(C):void 0}#Ve(){const C=this.#W;if(this.#W=null,C&&_(C.return))try{C.return()}catch{}}#Xe(){return y({context:this.#Oe("context",null)})}#Oe(C,S){const F=this.#t.state;if(F&&_(F[C])){const $=F[C]();return $??S}return S}#Se(C,S){const F=this.#t.emit;_(F)&&F(C,S)}}}),We("packages/core/src/source/url.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return b}});const P=D("packages/core/src/internal/warn.js").warnOnce,Y=D("packages/core/src/internal/predicates.js"),_=Y.isObject,L=Y.isFunction,H=D("packages/core/src/internal/paths.js").getPath,X=D("packages/core/src/source/abort.js").isAbortError,U=500,j=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),k=Symbol("lattice.url.skip");function b(l,y={}){const c=_(y)?y:{},m=L(c.fetch)?c.fetch:typeof globalThis<"u"&&L(globalThis.fetch)?globalThis.fetch:null,w=c.format==="json"||c.format==="ndjson"?c.format:void 0,v=typeof c.rowsPath=="string"&&c.rowsPath?c.rowsPath:void 0,E=L(c.map)?c.map:void 0,V=_(c.headers)?c.headers:void 0,G=Number.isFinite(c.batchSize)&&c.batchSize>0?Math.floor(c.batchSize):U,q=c.lenient===!0,M=Number.isFinite(c.poll)&&c.poll>0?Math.floor(c.poll):void 0,O=typeof l=="string"&&l.length>0;O||P("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*T(N={}){if(!O)return;if(!m)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const C=N&&N.signal;let S;try{S=await m(l,V?{signal:C,headers:V}:{signal:C})}catch(W){throw X(W)?W:new Error(`[lattice] createUrlSource: request to ${l} failed — ${W&&W.message||W}`)}if(!S||!S.ok){const W=S?S.status:"no response";throw new Error(`[lattice] createUrlSource: ${W} for ${l}`)}const F=a(l,w,S),$=S.body&&L(S.body.getReader)?S.body.getReader():null;try{if(!$){const I=await S.text();(F||t(I,l))==="ndjson"?yield*i(null,null,I,0,S,l,G,q):yield*g(I,l,v,E);return}const W=new TextDecoder("utf-8");if(F==="json"){yield*g(await s($,W,""),l,v,E);return}if(F==="ndjson"){yield*i($,W,"",0,S,l,G,q);return}const K=await o($,W,l);K.format==="json"?yield*g(await s($,W,K.seed),l,v,E):yield*i($,W,K.seed,K.bytes,S,l,G,q)}finally{if($&&L($.cancel))try{await $.cancel()}catch{}}}const A={mode:"stream",open:T,autoStart:c.autoStart!==!1};return M!==void 0&&(A.poll=M),Number.isFinite(c.maxRows)&&(A.maxRows=c.maxRows),Number.isFinite(c.maxAge)&&(A.maxAge=c.maxAge),(typeof c.ageBy=="string"||L(c.ageBy))&&(A.ageBy=c.ageBy),Number.isFinite(c.coalesceMs)&&(A.coalesceMs=c.coalesceMs),Number.isFinite(c.promoteToMemoryBelow)&&(A.promoteToMemoryBelow=c.promoteToMemoryBelow),A}function a(l,y,c){if(y)return y;const m=h(l);if(m)return m;const w=c&&c.headers&&L(c.headers.get)?c.headers.get("content-type"):null;return r(w)}function h(l){const y=String(l).split(/[?#]/)[0].toLowerCase();if(y.endsWith(".ndjson")||y.endsWith(".jsonl"))return"ndjson";if(y.endsWith(".json"))return"json"}function r(l){if(!l)return;const y=l.split(";")[0].trim().toLowerCase();if(j.has(y))return"ndjson";if(y==="application/json"||y==="text/json"||y.endsWith("+json"))return"json"}function t(l,y){const c=l.replace(/^\s+/,""),m=u(c);if(m==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${y} — pass opts.format: 'json' | 'ndjson'.`);return m}async function o(l,y,c){let m="",w=0;for(;;){const{value:E,done:V}=await l.read();if(E&&(w+=E.byteLength,m+=y.decode(E,{stream:!0})),V){m+=y.decode();break}const G=m.replace(/^\s+/,"");if(G){if(G[0]==="[")return{format:"json",seed:m,bytes:w};if(G[0]!=="{"||m.indexOf(`
|
|
7
|
+
`||g==="\r"){s++;continue}if(g>="0"&&g<="9"){s=k(u,s,d);continue}if(g==="."&&u[s+1]>="0"&&u[s+1]<="9"){s=k(u,s,d);continue}if(g==='"'||g==="'"){s=b(u,s,d);continue}if(g==="["){const n=u.indexOf("]",s+1);if(n<0)throw new X("a [column reference] was opened and never closed",s);d.push({kind:Y,value:u.slice(s+1,n).trim(),at:s}),s=n+1;continue}if(j(g)){s=a(u,s,d);continue}const i=u.slice(s,s+2);if(H.includes(i)){d.push({kind:L,value:i==="!="?"<>":i,at:s}),s+=2;continue}if(x.includes(g)){d.push({kind:L,value:g,at:s}),s++;continue}throw new X(`unexpected character ${JSON.stringify(g)}`,s)}return d.push({kind:Z,value:null,at:u.length}),d}function j(u){return/[A-Za-z_À-]/.test(u)}function k(u,d,s){let g=d,i=!1;for(;g<u.length;){const n=u[g];if(n>="0"&&n<="9"){g++;continue}if(n==="."&&!i){i=!0,g++;continue}if((n==="e"||n==="E")&&/[0-9+-]/.test(u[g+1]||"")){for(g+=2;g<u.length&&u[g]>="0"&&u[g]<="9";)g++;break}break}return s.push({kind:ne,value:Number(u.slice(d,g)),at:d}),g}function b(u,d,s){const g=u[d];let i=d+1,n="";for(;i<u.length;){if(u[i]===g){if(u[i+1]===g){n+=g,i+=2;continue}return s.push({kind:P,value:n,at:d}),i+1}n+=u[i],i++}throw new X("a string was opened and never closed",d)}function a(u,d,s){let g=d;for(;g<u.length&&/[A-Za-z0-9_.À-]/.test(u[g]);)g++;const i=u.slice(d,g);let n=g;for(;n<u.length&&u[n]===" ";)n++;return s.push({kind:u[n]==="("?_:Y,value:i,at:d}),g}const h={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function r(u){const d=String(u??"").replace(/^\s*=/,"");if(!d.trim())throw new X("the formula is empty");const s=U(d);let g=0;const i=()=>s[g],n=()=>s[g++],f=v=>{const E=i();if(E.kind!==L||E.value!==v)throw new X(`expected ${JSON.stringify(v)}`,E.at);g++},p=v=>{let E=l();for(;;){const V=i();if(V.kind!==L)break;const G=h[V.value];if(!G||G<v)break;g++;const q=p(V.value==="^"?G:G+1);E={kind:"bin",op:V.value,left:E,right:q}}return E},l=()=>{const v=i();return v.kind===L&&(v.value==="-"||v.value==="+")?(g++,{kind:"unary",op:v.value,arg:l()}):y()},y=()=>{let v=c();for(;i().kind===L&&i().value==="%";)g++,v={kind:"unary",op:"%",arg:v};return v},c=()=>{const v=n();if(v.kind===ne)return{kind:"num",value:v.value};if(v.kind===P)return{kind:"str",value:v.value};if(v.kind===Y)return{kind:"ref",name:v.value};if(v.kind===_){f("(");const E=[];if(!(i().kind===L&&i().value===")"))for(;;){if(E.push(p(1)),i().kind===L&&i().value===","){g++;continue}break}return f(")"),{kind:"call",name:String(v.value).toUpperCase(),args:E}}if(v.kind===L&&v.value==="("){const E=p(1);return f(")"),E}throw v.kind===Z?new X("the formula ends unexpectedly",v.at):new X(`unexpected ${JSON.stringify(v.value)}`,v.at)},m=p(1),w=i();if(w.kind!==Z)throw new X(`unexpected ${JSON.stringify(w.value)}: is an operator missing?`,w.at);return m}function t(u){const d=new Set,s=g=>{if(!(!g||typeof g!="object")){if(g.kind==="ref"){d.add(String(g.name));return}if(g.kind==="bin"){s(g.left),s(g.right);return}if(g.kind==="unary"){s(g.arg);return}if(g.kind==="call")for(const i of g.args)s(i)}};return s(u),[...d]}function o(u){return typeof u=="string"&&/^\s*=/.test(u)&&u.trim()!=="="}}),We("packages/core/src/formula/evaluate.js",function(e,D){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return k}});const P=D("packages/core/src/formula/parse.js").FormulaError;function Y(b){if(b==null||b==="")return 0;if(typeof b=="boolean")return b?1:0;if(b instanceof Date)return b.getTime();const a=typeof b=="number"?b:Number(String(b).replace(/[,\s]/g,""));if(!Number.isFinite(a))throw new P(`${JSON.stringify(b)} is not a number`);return a}function _(b){return b==null?"":String(b)}function L(b){if(typeof b=="boolean")return b;if(b==null||b==="")return!1;if(typeof b=="number")return b!==0;const a=String(b).trim().toLowerCase();return a==="false"||a==="no"||a==="0"?!1:a!==""}function Z(b){const a=[];for(const h of b){if(Array.isArray(h)){for(const r of h)r!=null&&r!==""&&a.push(Y(r));continue}h==null||h===""||a.push(Y(h))}return a}function H(b,a){const h=10**a,r=b*h;return Math.sign(r)*Math.round(Math.abs(r)+Number.EPSILON*Math.abs(r))/h}function x(b,a){if(!b.length)return 0;const h=b.slice().sort((u,d)=>u-d),r=(h.length-1)*Math.min(1,Math.max(0,a)),t=Math.floor(r),o=Math.ceil(r);return t===o?h[t]:h[t]+(r-t)*(h[o]-h[t])}function X(b,a){let h=0,r=0,t=0;for(const u of b){h++;const d=u-r;r+=d/h,t+=d*(u-r)}const o=a?h-1:h;return o>0?Math.sqrt(t/o):0}const U={SUM:b=>Z(b).reduce((a,h)=>a+h,0),AVERAGE:b=>{const a=Z(b);return a.length?a.reduce((h,r)=>h+r,0)/a.length:0},MIN:b=>{const a=Z(b);return a.length?Math.min(...a):0},MAX:b=>{const a=Z(b);return a.length?Math.max(...a):0},COUNT:b=>Z(b).length,PRODUCT:b=>Z(b).reduce((a,h)=>a*h,1),ROUND:b=>H(Y(b[0]),b.length>1?Y(b[1]):0),ROUNDDOWN:b=>{const a=10**(b.length>1?Y(b[1]):0),h=Y(b[0])*a;return(h<0?Math.ceil(h):Math.floor(h))/a},ROUNDUP:b=>{const a=10**(b.length>1?Y(b[1]):0),h=Y(b[0])*a;return(h<0?Math.floor(h):Math.ceil(h))/a},ABS:b=>Math.abs(Y(b[0])),FLOOR:b=>Math.floor(Y(b[0])),CEILING:b=>Math.ceil(Y(b[0])),SQRT:b=>Math.sqrt(Y(b[0])),POWER:b=>Y(b[0])**Y(b[1]),MOD:b=>{const a=Y(b[1]);if(a===0)throw new P("MOD by zero");return(Y(b[0])%a+a)%a},IF:b=>L(b[0])?b[1]:b.length>2?b[2]:!1,AND:b=>b.every(L),OR:b=>b.some(L),NOT:b=>!L(b[0]),COALESCE:b=>b.find(a=>a!=null&&a!=="")??null,CONCAT:b=>b.map(_).join(""),LEN:b=>_(b[0]).length,UPPER:b=>_(b[0]).toUpperCase(),LOWER:b=>_(b[0]).toLowerCase(),TRIM:b=>_(b[0]).trim(),LEFT:b=>_(b[0]).slice(0,b.length>1?Y(b[1]):1),RIGHT:b=>{const a=b.length>1?Y(b[1]):1;return a<=0?"":_(b[0]).slice(-a)},MEDIAN:b=>x(Z(b),.5),PERCENTILE:b=>{const a=Y(b[b.length-1]);return x(Z(b.slice(0,-1)),a>1?a/100:a)},QUARTILE1:b=>x(Z(b),.25),QUARTILE3:b=>x(Z(b),.75),STDEV:b=>X(Z(b),!0),STDEVP:b=>X(Z(b),!1),VAR:b=>{const a=X(Z(b),!0);return a*a},VARP:b=>{const a=X(Z(b),!1);return a*a},COUNTDISTINCT:b=>{const a=new Set;for(const h of b){const r=Array.isArray(h)?h:[h];for(const t of r)t!=null&&t!==""&&a.add(t)}return a.size},IQR:b=>{const a=Z(b);return x(a,.75)-x(a,.25)}};U.AVG=U.AVERAGE,U.CEIL=U.CEILING,U.POW=U.POWER,U.STDEVS=U.STDEV,U.PERCENTILEINC=U.PERCENTILE;function j(b,a){const h=Number(b),r=Number(a);if(b!==null&&b!==""&&a!==null&&a!==""&&Number.isFinite(h)&&Number.isFinite(r))return h<r?-1:h>r?1:0;const o=_(b).toLowerCase(),u=_(a).toLowerCase();return o<u?-1:o>u?1:0}function k(b,a={}){const h=typeof a.lookup=="function"?a.lookup:null,r=a.functions?{...U,...a.functions}:U,t=o=>{switch(o.kind){case"num":return o.value;case"str":return o.value;case"ref":{if(!h)throw new P(`there is no column called ${JSON.stringify(o.name)} here`);const u=h(String(o.name));if(u===void 0)throw new P(`there is no column called ${JSON.stringify(o.name)}`);return u}case"unary":{if(o.op==="%")return Y(t(o.arg))/100;const u=Y(t(o.arg));return o.op==="-"?-u:u}case"bin":{const u=o.op;if(u==="=")return j(t(o.left),t(o.right))===0;if(u==="<>")return j(t(o.left),t(o.right))!==0;if(u==="<")return j(t(o.left),t(o.right))<0;if(u==="<=")return j(t(o.left),t(o.right))<=0;if(u===">")return j(t(o.left),t(o.right))>0;if(u===">=")return j(t(o.left),t(o.right))>=0;const d=Y(t(o.left)),s=Y(t(o.right));if(u==="+")return d+s;if(u==="-")return d-s;if(u==="*")return d*s;if(u==="^")return d**s;if(u==="/"){if(s===0)throw new P("division by zero");return d/s}throw new P(`unknown operator ${JSON.stringify(u)}`)}case"call":{const u=a.lazy&&a.lazy[o.name];if(typeof u=="function")return u(o.args,t,a);const d=r[o.name];if(typeof d!="function")throw new P(`there is no function called ${o.name}`);return d(o.args.map(t),a)}default:throw new P("the formula could not be read")}};return t(b)}}),We("packages/core/src/formula/index.js",function(e,D){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return j}});const ne=D("packages/core/src/formula/parse.js"),P=ne.parseFormula,Y=ne.referencesOf,_=ne.looksLikeFormula,L=ne.FormulaError,Z=ne.tokenise,H=D("packages/core/src/formula/evaluate.js"),x=H.evaluateAst,X=H.FUNCTIONS;function U(k){const{grid:b,row:a,data:h}=k||{},r=s=>String(s).toLowerCase().replace(/[\s_-]/g,""),t=b&&b.columns&&typeof b.columns.all=="function"?b.columns.all():[],o=b&&b.permissions,u=o&&typeof o.isReadable=="function"?s=>o.isReadable(s):()=>!0,d=new Set;for(const s of t)u(s)||(d.add(r(s.id)),s.field&&d.add(r(s.field)),s.title&&d.add(r(s.title)));return s=>{const g=r(s);if(d.has(g))throw new L(`"${s}" cannot be read`);for(const i of t)if(r(i.id)===g||i.field&&r(i.field)===g||i.title&&r(i.title)===g)return a&&b.rows&&typeof b.rows.value=="function"?b.rows.value(a.key,i.id):h?h[i.field||i.id]:void 0;if(h&&typeof h=="object"){for(const i of Object.keys(h))if(r(i)===g){if(!u(i))throw new L(`"${s}" cannot be read`);return h[i]}}}}function j(k,b={}){try{const a=P(k);return{ok:!0,value:x(a,{lookup:U(b),functions:b.formulaFunctions}),references:Y(a)}}catch(a){return{ok:!1,error:a instanceof L?a.message:"the formula could not be read",at:a instanceof L?a.at:void 0}}}}),We("packages/core/src/internal/version.js",function(e,D){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return Y}});const ne="1.111.5";async function P(){return ne}const Y="1.111.5"}),We("packages/core/src/internal/merge.js",function(e,D){"use strict";Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return H}});const P=D("packages/core/src/internal/predicates.js").isObject;function Y(x,X,U){if(x!==void 0)return x===!0?{enabled:!0,...U}:x===!1?{enabled:!1}:P(x)?x:{[X]:x,enabled:!0}}function _(x){return x==null?[]:Array.isArray(x)?x:[x]}const L=Object.freeze(new Set(["__proto__","constructor","prototype"]));function Z(x,X){if(!P(x))return P(X)?{...X}:X;if(!P(X))return X===void 0?x:X;const U={...x};for(const j of Object.keys(X)){if(L.has(j))continue;const k=X[j];k!==void 0&&(U[j]=P(k)&&P(U[j])?Z(U[j],k):k)}return U}function H(x,X){if(!P(x)||!P(X)||x===X)return X;const U=Object.create(Object.getPrototypeOf(x));return Object.assign(U,x,X),U}}),We("packages/core/src/internal/schedule.js",function(e,D){"use strict";Object.defineProperty(e,"now",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return H}});function ne(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const P=typeof requestAnimationFrame=="function";function Y(x){return P?requestAnimationFrame(x):setTimeout(()=>x(ne()),16)}function _(x){x!=null&&(P?cancelAnimationFrame(x):clearTimeout(x))}function L(x){let X=null,U=null;const j=()=>{X=null;const b=U;U=null,x(...b||[])},k=(...b)=>{U=b,X===null&&(X=Y(j))};return k.cancel=()=>{_(X),X=null,U=null},k.flush=()=>{X!==null&&(_(X),j())},k}function Z(x,X){let U=null,j=null;const k=()=>{if(U=null,j===null)return;const h=j;j=null,x(...h),b()},b=()=>{U=setTimeout(k,X),typeof U?.unref=="function"&&U.unref()},a=(...h)=>{U===null?(x(...h),b()):(j=h,clearTimeout(U),b())};return a.flush=()=>{if(U!==null&&clearTimeout(U),U=null,j===null)return;const h=j;j=null,x(...h)},a.cancel=()=>{U!==null&&clearTimeout(U),U=null,j=null},a.pending=()=>U!==null||j!==null,a}function H(x,X=50){return typeof requestIdleCallback=="function"?requestIdleCallback(x,{timeout:X}):setTimeout(()=>x({timeRemaining:()=>0,didTimeout:!0}),1)}}),We("packages/core/src/internal/paths.js",function(e,D){"use strict";Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return Z}});const ne=new Map;function P(H){let x=ne.get(H);if(x)return x;if(!H.includes("."))x=X=>X?.[H];else{const X=H.split("."),U=X.length;x=j=>{let k=j;for(let b=0;b<U;b++){if(k==null)return;k=k[X[b]]}return k}}return ne.set(H,x),x}const Y=new Map;function _(H){let x=Y.get(H);if(x)return x;if(!H.includes("."))x=(X,U)=>{X!=null&&(X[H]=U)};else{const X=H.split("."),U=X.length-1;x=(j,k)=>{let b=j;for(let a=0;a<U;a++){if(b==null)return;const h=X[a];b[h]==null&&(b[h]={}),b=b[h]}b!=null&&(b[X[U]]=k)}}return Y.set(H,x),x}function L(H,x){return P(x)(H)}function Z(H,x,X){_(x)(H,X)}}),We("packages/core/src/internal/compare.js",function(e,D){"use strict";Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return Y}});const ne=new Map;function P(_,L){const Z=`${_||""}|${L?JSON.stringify(L):""}`;let H=ne.get(Z);return H||(H=new Intl.Collator(_||void 0,{numeric:!0,sensitivity:"variant",...L}),ne.set(Z,H)),H}function Y(_,L){if(_===L)return 0;if(_==null)return 1;if(L==null)return-1;if(typeof _=="number"&&typeof L=="number")return Number.isNaN(_)?Number.isNaN(L)?0:1:Number.isNaN(L)||_<L?-1:_>L?1:0;const Z=String(_),H=String(L);return Z<H?-1:Z>H?1:0}}),We("packages/core/src/defaults.js",function(e,D){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return j}});const P=D("packages/core/src/internal/predicates.js").isObject,_=D("packages/core/src/internal/merge.js").merge,Z=D("packages/core/src/internal/warn.js").warnOnce;let H=null;class x extends Error{}function X(k,b=new Set){if(Array.isArray(k)){if(b.has(k))throw new x;b.add(k);const h=k.map(r=>X(r,b));return b.delete(k),h}if(!P(k)||Object.getPrototypeOf(k)!==Object.prototype&&Object.getPrototypeOf(k)!==null)return k;if(b.has(k))throw new x;b.add(k);const a={};for(const[h,r]of Object.entries(k))a[h]=X(r,b);return b.delete(k),a}function U(k){if(k===void 0)return X(H??{});if(k===null)return H=null,{};if(!P(k))return Z("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(k)?"an array":typeof k}. The call was ignored and the defaults are unchanged.`),X(H??{});try{H=X(k)}catch(b){if(!(b instanceof x))throw b;return Z("defaults:cyclic","defaults() expects a configuration object with no circular references, but the object passed refers back to itself. The call was ignored and the defaults are unchanged."),X(H??{})}return X(H)}function j(k){return H===null?k:_(X(H),k)}}),We("packages/core/src/internal/uid.js",function(e,D){"use strict";Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return P}});let ne=0;function P(Y="l"){return`${Y}${(++ne).toString(36)}`}}),We("packages/core/src/events/names.js",function(e,D){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return Y}});const ne=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","beforeRowDrop","rowDrop:cancelled","rowDrop","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:compareGroups:open","column:menu:open","explain:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","totals: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"]),P=new Set(ne);function Y(_){return _==="*"||P.has(_)}}),We("packages/core/src/events/bus.js",function(e,D){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return h}});const ne=D("packages/core/src/internal/warn.js"),P=ne.warnOnce,Y=ne.DEV,L=D("packages/core/src/internal/uid.js").uid,H=D("packages/core/src/events/names.js").isKnownEvent,x="*";function X(r,t){!Y||H(t)||P(`bus.unknown:${t}`,`${r}('${t}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const U=new Set(["api","user","init","ai"]),j=new WeakMap;function k(r){let t=j.get(r);return t||(t=L("h"),j.set(r,t)),t}function b(){return typeof performance=="object"&&performance?performance.now():Date.now()}function a(r){if(!r||typeof r!="object")return{};const t={};for(const[o,u]of Object.entries(r))o!=="grid"&&(u==null?t[o]=String(u):Array.isArray(u)?t[o]=`[${u.length}]`:typeof u=="object"?t[o]=u.key?`row ${u.key}`:"{…}":typeof u=="function"?t[o]="[function]":t[o]=String(u).slice(0,60));return t}class h{#e=new Map;#t=!1;#n=[];#r=200;#s=new Map;#i=null;#o=!1;#l=0;constructor(t=null){this.#i=t}attach(t){this.#i=t}get grid(){return this.#i}get destroyed(){return this.#o}on(t,o){if(typeof o!="function")return P(`bus.handler:${t}`,`on('${t}') needs a function; ignored.`),()=>{};X("on",t);let u=this.#e.get(t);return u||(u=[],this.#e.set(t,u)),u.push(o),()=>this.off(t,o)}once(t,o){if(typeof o!="function")return P(`bus.handler:${t}`,`once('${t}') needs a function; ignored.`),()=>{};X("once",t);const u=d=>{this.off(t,o),o(d)};return this.#s.set(o,u),this.on(t,u)}off(t,o){if(o===void 0){this.#e.delete(t);return}const u=this.#e.get(t);if(!u)return;const d=this.#s.get(o),s=d&&u.includes(d)?d:o,g=u.indexOf(s);g>=0&&u.splice(g,1),d&&s===d&&this.#s.delete(o),u.length===0&&this.#e.delete(t)}count(t){const o=this.#e.get(t),u=t===x?null:this.#e.get(x);return(o?o.length:0)+(u?u.length:0)}#a(t,o,u,d,s){this.#n.push({type:t,origin:o,listeners:(d?d.length:0)+(s?s.length:0),payload:a(u),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(t,o){this.#t=!!t,Number.isFinite(o)&&o>0&&(this.#r=Math.floor(o)),t||(this.#n=[])}eventLog(){return this.#n.map(t=>({...t}))}clearEventLog(){this.#n=[]}counts(){const t={};for(const[o,u]of this.#e)t[o]=u.length;return t}emit(t,o,u){const d=u??(o&&o.origin),s=U.has(d)?d:"api",g={...o||null,type:t,origin:s,grid:this.#i};if(this.#o)return g;const i=this.#e.get(t),n=t===x?void 0:this.#e.get(x);if(this.#t&&this.#a(t,s,o,i,n),!i&&!n)return g;const f=this.#t?b():0;this.#l++;try{i&&this.#c(i.slice(),g,t),n&&this.#c(n.slice(),g,x)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=b()-f)}return g}emitBefore(t,o,u){const d=u??(o&&o.origin),s=U.has(d)?d:"user";let g=!1,i=null;const n=m=>{g=!0,m!=null&&i===null&&(i=String(m))},f={...o||null,type:t,origin:s,grid:this.#i,get defaultPrevented(){return g},get reason(){return i},preventDefault(m){n(m)}};if(this.#o)return!0;const p=this.#e.get(t);this.#t&&this.#a(t,s,o,p,void 0);const l=p?p.slice():[];if(l.length===0)return!0;const y=()=>(g&&i===null&&(i="prevented"),g&&o&&typeof o=="object"&&(o.reason=i),!g),c=[];for(const m of l)try{const w=m(f);w&&typeof w.then=="function"?c.push(w):w===!1&&n("prevented")}catch(w){n("error"),P(`bus.beforeThrow:${t}:${k(m)}`,`a '${t}' before-handler threw; the action was cancelled.`,w)}return c.length===0?y():Promise.allSettled(c).then(m=>{for(const w of m)w.status==="rejected"?(n("error"),P(`bus.beforeReject:${t}`,`a '${t}' before-handler rejected; the action was cancelled.`,w.reason)):w.value===!1&&n("prevented");return y()})}#c(t,o,u){for(let d=0;d<t.length;d++)try{t[d](o)}catch(s){P(`bus.throw:${u}:${k(t[d])}`,`a '${u}' handler threw; other handlers were unaffected.`,s)}}clear(){this.#e.clear(),this.#s.clear()}destroy(){this.clear(),this.#o=!0,this.#i=null}}}),We("packages/core/src/registry/free-tier-notice.js",function(e,D){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"WATERMARK_TEXT",{enumerable:!0,get:function(){return P}});const ne="Free for non-commercial use: latticegrid.dev/free",P="Unlicensed: Lattice Grid trial"}),We("packages/core/src/registry/licence.js",function(e,D){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return O}});const P=D("packages/core/src/internal/warn.js").warnOnce,Y=D("packages/core/src/registry/free-tier-notice.js"),_=Y.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return Y.FREE_TIER_NOTICE}});const L="lattice-grid",Z=1,H="LG1",x=64,X="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",U="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",j=(()=>{const T=new Int16Array(128).fill(-1);for(let A=0;A<U.length;A++)T[U.charCodeAt(A)]=A;return T[43]=62,T[47]=63,T})();function k(T){if(typeof T!="string")return null;let A="";for(let W=0;W<T.length;W++){const K=T.charCodeAt(W);if(K!==61){if(K>127||j[K]<0)return null;A+=T[W]}}const N=A.length;if(N%4===1)return null;const C=new Uint8Array(Math.floor(N*3/4));let S=0,F=0,$=0;for(let W=0;W<N;W++)S=S<<6|j[A.charCodeAt(W)],F+=6,F>=8&&(F-=8,C[$++]=S>>F&255);return $===C.length?C:C.subarray(0,$)}function b(T){let A="",N=0;for(;N+2<T.length;N+=3){const S=T[N]<<16|T[N+1]<<8|T[N+2];A+=U[S>>18&63]+U[S>>12&63]+U[S>>6&63]+U[S&63]}const C=T.length-N;if(C===1){const S=T[N]<<16;A+=U[S>>18&63]+U[S>>12&63]}else if(C===2){const S=T[N]<<16|T[N+1]<<8;A+=U[S>>18&63]+U[S>>12&63]+U[S>>6&63]}return A}function a(T){const A=new Uint8Array(T.length);for(let N=0;N<T.length;N++)A[N]=T.charCodeAt(N)&127;return A}function h(T){if(typeof TextDecoder=="function")return new TextDecoder().decode(T);let A="";for(let N=0;N<T.length;N++)A+=String.fromCharCode(T[N]);return A}function r(T){const A={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof T=="string"?T:""};if(typeof T!="string"||T.length===0)return{...A,reason:"missing"};const N=T.trim(),C=N.split(".");if(C.length!==3)return A;const[S,F,$]=C;if(S!==H)return{...A,reason:"prefix"};const W=k(F),K=k($);if(!W||!K)return A;let I;try{I=JSON.parse(h(W))}catch{return A}return I===null||typeof I!="object"?A:{ok:!0,reason:null,product:typeof I.p=="string"?I.p:null,issuedTo:typeof I.t=="string"?I.t:null,expires:typeof I.e=="string"?I.e:null,terms:typeof I.terms=="string"?I.terms:null,features:Array.isArray(I.f)?I.f.slice():[],deployments:Array.isArray(I.d)?I.d.slice():[],version:typeof I.v=="number"?I.v:0,message:a(F),signature:K,raw:N}}function t(T,A){if(!T)return!1;const N=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(T)?`${T}T23:59:59.999Z`:T);return Number.isNaN(N)?!0:A>N}function o(T){return T==="non-commercial"?"non-commercial":"commercial"}let u=null,d=null,s=null;function g(){const T=globalThis.crypto;return T&&T.subtle?T.subtle:null}async function i(T){if(u&&d===T)return u;const A=g();if(!A)return null;const N=k(T);if(!N)return null;try{const C=await A.importKey("raw",N,{name:"Ed25519"},!1,["verify"]);return u=C,d=T,C}catch{return null}}async function n(){return s!==null||(s=await i(X)!==null),s}async function f(T,A={}){const N=A.warn!==!1,C=A.product||L,S=A.publicKey||X,F=A.now??Date.now(),$=A.host??l(),W=p($)?"":` ${_}`,K=r(T);if(!K.ok){const Q=K.reason==="missing"?"missing":"malformed";return N&&P(`licence.${Q}`,Q==="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.${W}`:`licence key could not be read. The grid will render with a watermark.${W}`),{valid:!1,reason:Q,terms:"commercial"}}const I={product:K.product||void 0,issuedTo:K.issuedTo||void 0,expires:K.expires||void 0,terms:o(K.terms)};if(K.product!==C)return N&&P("licence.product",`licence key is for '${K.product}', not '${C}'. The grid will render with a watermark.`),{valid:!1,...I,reason:"product"};if(t(K.expires,F))return N&&P("licence.expired",`licence expired on ${K.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...I,reason:"expired"};const B=K.deployments||[];if(B.length&&$&&!p($)&&!y($,B))return N&&P("licence.domain",`licence key is not valid for ${$}; it covers ${B.join(", ")}. The grid will render with a watermark.`),{valid:!1,...I,reason:"domain"};const J=await i(S);if(!J){const Q=!!K.signature&&K.signature.length===x;return N&&P("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),Q?{valid:!0,...I,reason:"unverified"}:{valid:!1,...I,reason:"signature"}}let te=!1;try{te=await g().verify({name:"Ed25519"},J,K.signature,K.message)}catch{te=!1}return te?{valid:!0,...I}:(N&&P("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...I,reason:"signature"})}function p(T){const A=String(T??l()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!A||A==="localhost"||A.endsWith(".localhost")||A==="::1"||A==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(A)}function l(){const T=globalThis.location;return T&&typeof T.hostname=="string"?T.hostname:null}function y(T,A){const N=c(T);return!N||!Array.isArray(A)?!1:A.some(C=>{const S=c(C);if(!S)return!1;if(S==="*")return!0;if(S.startsWith("*.")){const F=S.slice(2);return N===F||N.endsWith(`.${F}`)}return N===S})}function c(T){return String(T??"").trim().toLowerCase().replace(/\.$/,"")}class m{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#s;#i=new Set;constructor(A={}){this.#s=A}set(A){this.#e=typeof A=="string"?A.trim():"";const N=r(this.#e);return this.#t=N.ok?{valid:!t(N.expires,Date.now())&&N.product===(this.#s.product||L),product:N.product||void 0,issuedTo:N.issuedTo||void 0,expires:N.expires||void 0,terms:o(N.terms),reason:"pending"}:{valid:!1,reason:N.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const A=this.#e;return this.#n=f(A,this.#s).then(N=>{if(this.#e===A){this.#t=N;for(const C of this.#i)C(N)}return N}),this.#n}onSettled(A){return this.#i.add(A),()=>this.#i.delete(A)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!p(this.#r)}setHost(A){this.#r=A}state(){return this.#t.valid?"licensed":p(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#i.clear()}}const w=Symbol.for("lattice-grid/licence/holder");function v(){const T=globalThis,A=T&&T[w];if(A&&typeof A.set=="function"&&typeof A.watermark=="function")return A;const N=new m;if(T)try{T[w]=N}catch{}return N}const E=v();function V(T){return E.set(T)}function G(){return E.info()}function q(){return E.watermark()}function M(){return E.state()}function O(){return E}}),We("packages/core/src/registry/registry.js",function(e,D){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return u}});const ne=D("packages/core/src/internal/warn.js"),P=ne.warnOnce,Y=ne.DEV,L=D("packages/core/src/internal/predicates.js").isFunction,Z=D("packages/core/src/registry/licence.js"),H=Z.LicenceHolder,x=Z.sharedLicence,X=["renderer","editor","filter","dataType","totalFn","pipe","component"],U=["all","header","body","totals","panels"];class j{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#s;#i=null;#o=null;#l=new Set;#a=new Map;constructor(s={}){for(const g of X)this.#t.set(g,new Map);this.#s=s.holder||x(),this.#o=s.grid??null,this.#i=this.#s.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),s.licence&&this.setLicence(s.licence)}registerModules(s,g={}){g.licence&&this.setLicence(g.licence),g.grid!==void 0&&(this.#o=g.grid);const i=Array.isArray(s)?s:[s],n=[];for(const f of i){if(!f||typeof f!="object"||typeof f.name!="string"||!f.name){P("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(f.name)){Y&&this.#u(this.#e.get(f.name),f);continue}if(!L(f.install)){P(`registry.module.install:${f.name}`,`module '${f.name}' has no install() and was ignored.`);continue}const p={registry:this,grid:this.#o};try{f.install(p)}catch(l){P(`registry.module.throw:${f.name}`,`module '${f.name}' threw during install; it was not registered.`,l);continue}this.#e.set(f.name,f);for(const l of k(f))this.#n.add(l);n.push(f.name),this.#d({reason:"module",name:f.name,capabilities:this.capabilities(),regions:h(f)})}return n}unregisterModule(s){const g=this.#e.get(s);if(!g)return!1;if(L(g.uninstall))try{g.uninstall({registry:this,grid:this.#o})}catch(i){P(`registry.module.uninstall:${s}`,`module '${s}' threw during uninstall.`,i)}return this.#e.delete(s),this.#c(),this.#d({reason:"unmodule",name:s,capabilities:this.capabilities(),regions:h(g)}),!0}modules(){return[...this.#e.values()]}has(s){return this.#e.has(s)}#c(){this.#n.clear();for(const s of this.#e.values())for(const g of k(s))this.#n.add(g)}#u(s,g){!s||s===g||b(s,g)||P(`registry.module.reconfigure:${g.name}`,`module '${g.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(s){return this.#n.has(s)}onChange(s){return L(s)?(this.#r.add(s),this.#a.set(s,this.#o),()=>{this.#r.delete(s),this.#a.delete(s)}):()=>{}}#d(s){for(const g of[...this.#r])try{g(s)}catch(i){P("registry.onChange.throw","a registry change handler threw.",i)}}register(s,g,i){const n=this.#t.get(s);if(!n){P(`registry.kind:${s}`,`unknown registry kind '${s}'; expected one of ${X.join(", ")}.`);return}if(!g||typeof g!="string"){P(`registry.name:${s}`,`register('${s}', ...) needs a name.`);return}n.has(g)&&n.get(g)!==i&&P(`registry.replace:${s}:${g}`,`'${g}' was already registered as a ${s} and has been replaced.`),n.set(g,i),this.#d({reason:"register",name:g,kind:s,capabilities:this.capabilities(),regions:r(s)})}registerAll(s,g){if(g)for(const i of Object.keys(g))this.register(s,i,g[i])}get(s,g){const i=this.#t.get(s);return i?i.get(g):void 0}names(s){const g=this.#t.get(s);return g?[...g.keys()]:[]}#f(s,g){const i=this.#t.get(s).get(g);return i!==void 0?i:this.#t.get("component").get(g)}renderer(s){return this.#f("renderer",s)}editor(s){return this.#f("editor",s)}filter(s){return this.#f("filter",s)}dataType(s){return this.get("dataType",s)}totalFn(s){return this.get("totalFn",s)}pipe(s){return this.get("pipe",s)}setLicence(s){return this.#s.set(s)}licence(){return this.#s.info()}licenceVerified(){return this.#s.verify()}watermark(){return this.#s.watermark()}attach(s){s!=null&&(this.#l.add(s),this.#o=s)}detach(s){if(s!=null){this.#l.delete(s);for(const[g,i]of[...this.#a])i===s&&(this.#r.delete(g),this.#a.delete(g));if(this.#o===s){const g=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#o=g}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(s){if(s!=null){this.detach(s);return}for(const g of[...this.#e.keys()])this.unregisterModule(g);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#o=null}}function k(d){const s=d.capabilities,g=Array.isArray(s)?s.filter(i=>typeof i=="string"):[];return[d.name,...g]}function b(d,s){return d.install!==s.install||d.uninstall!==s.uninstall||(d.version||"")!==(s.version||"")?!1:a(k(d),k(s))&&a(h(d),h(s))}function a(d,s){const g=new Set(d),i=new Set(s);if(g.size!==i.size)return!1;for(const n of g)if(!i.has(n))return!1;return!0}function h(d){const s=d.regions;return!Array.isArray(s)||s.length===0?["all"]:s.filter(g=>U.includes(g))}function r(d){switch(d){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const t=new j;function o(){return t}function u(d,s={}){return t.registerModules(d,s)}}),We("packages/core/src/internal/text.js",function(e,D){"use strict";Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return _}});function ne(L){return L?(L.includes(".")?L.slice(L.lastIndexOf(".")+1):L).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(/^./,H=>H.toUpperCase()):""}const P={"&":"&","<":"<",">":">",'"':""","'":"'"};function Y(L){const Z=L==null?"":String(L);return/[&<>"']/.test(Z)?Z.replace(/[&<>"']/g,H=>P[H]):Z}function _(L){return String(L).replace(/\w\S*/g,Z=>Z[0].toUpperCase()+Z.slice(1).toLowerCase())}}),We("packages/core/src/format/mask.js",function(e,D){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return Z}});const ne=new Set(["0","#","?",",","."]),P="\0";function Y(x){const X=[];let U="",j=!1;for(let k=0;k<x.length;k++){const b=x[k];if(b==="\\"){U+=b+(x[k+1]??""),k+=1;continue}if(b==='"'){j=!j,U+=b;continue}if(b===";"&&!j){X.push(U),U="";continue}U+=b}return X.push(U),X}function _(x){let X="",U="",j="",k=1,b=!1,a=!1;const h=n=>{a?U+=n:X+=n};for(let n=0;n<x.length;n++){const f=x[n];if(f==="\\"){h(x[n+1]??""),n+=1;continue}if(f==='"'){const p=x.indexOf('"',n+1);h(p===-1?x.slice(n+1):x.slice(n+1,p)),n=p===-1?x.length:p;continue}if(f==="%"){k*=100,h("%");continue}if(f==="@"){b=!0,h("\0");continue}if(ne.has(f)){j+=f,a=!0;continue}h(f)}let r=-1;for(let n=j.length-1;n>=0;n--){const f=j[n];if(f==="0"||f==="#"||f==="?"){r=n;break}}let t=!1,o="";for(let n=0;n<j.length;n++){const f=j[n];if(f===","){n>r?k/=1e3:t=!0;continue}o+=f}const u=o.indexOf("."),d=u===-1?o:o.slice(0,u),s=u===-1?"":o.slice(u+1);let g=0;for(const n of d)n==="0"&&(g+=1);let i=0;for(const n of s)n==="0"&&(i+=1);return{prefix:X,suffix:U,minInt:g,minDec:i,maxDec:s.length,grouping:t,scale:k,hasNumber:r!==-1,isText:b}}function L(x,X){const U=new Intl.NumberFormat(X,{minimumIntegerDigits:Math.max(x.minInt,1),minimumFractionDigits:x.minDec,maximumFractionDigits:Math.max(x.maxDec,x.minDec),useGrouping:x.grouping}),{prefix:j,suffix:k,scale:b,hasNumber:a}=x;return h=>{if(!a)return j+k;const r=b===1?h:h*b;return j+U.format(r)+k}}function Z(x,X){const j=Y(String(x)).map(_),k=j.map(o=>L(o,X)),b=0,a=j.length>1?1:-1,h=j.length>2?2:-1,r=j.length>3?3:-1,t=o=>{if(o==null||o==="")return"";if(typeof o!="number"||Number.isNaN(o)){const u=Number(o);if(Number.isNaN(u))return r===-1?String(o):(j[r].prefix+j[r].suffix).split("\0").join(String(o));o=u}return o===0&&h!==-1?k[h](0):o<0&&a!==-1?k[a](-o):k[b](o)};return t.spec={mask:x},{format:t,ooxml:H(String(x))}}function H(x){return x.trim()}}),We("packages/core/src/format/pattern.js",function(e,D){"use strict";Object.defineProperty(e,"parseNumberPattern",{enumerable:!0,get:function(){return L}});const P=D("packages/core/src/format/mask.js").splitSections;function Y(Z){let H="",x="",X="",U="",j=!1,k=!1,b=!1,a=!1;const h=t=>{b?x+=t:H+=t};for(let t=0;t<Z.length;t++){const o=Z[t];if(o==="\\"){h(Z[t+1]??""),t+=1;continue}if(o==='"'){const u=Z.indexOf('"',t+1);h(u===-1?Z.slice(t+1):Z.slice(t+1,u)),t=u===-1?Z.length:u;continue}if(o==="%"){k=!0;continue}if(o==="0"||o==="#"){b=!0,a?U+=o:X+=o;continue}if(o===","){a||(j=!0);continue}if(o==="."&&!a){a=!0;continue}h(o)}if(!b)return{hasDigit:!1,prefix:H,suffix:x,minDec:0,maxDec:0,grouping:!1,percent:k};let r=0;for(const t of U)t==="0"&&(r+=1);return{hasDigit:!0,prefix:H,suffix:x,minDec:r,maxDec:U.length,grouping:j,percent:k}}function _(Z,H){const x=H.trim(),X=Z.trim();return x.startsWith("(")&&x.endsWith(")")&&x.slice(1,-1).trim()===X?"parentheses":x.endsWith("-")?"suffix":"minus"}function L(Z){if(typeof Z!="string")return null;const H=P(Z);if(H.length===0)return null;const x=Y(H[0]);if(!x.hasDigit)return null;const X={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(H.length>1&&(X.negative=_(H[0],H[1])),H.length>2){const U=Y(H[2]);U.hasDigit||(X.zeroDisplay=U.prefix+U.suffix)}return X}}),We("packages/core/src/format/number.js",function(e,D){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return H}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/internal/warn.js").warnOnce,Z=D("packages/core/src/format/pattern.js").parseNumberPattern;function H(x,X){const U=typeof x=="string"?{pattern:x}:x||{};let j=U;if(typeof U.pattern=="string"){const v=Z(U.pattern);if(v){const{pattern:E,...V}=U;j={...v,...V}}else _(`format:pattern:${U.pattern}`,`invalid number format pattern "${U.pattern}"; the value will use the default number format`)}const k=j.locale||X||void 0,b=j.style||"decimal",a=typeof j.scale=="number"?j.scale:1,h=j.nullDisplay??"",r=j.zeroDisplay,t=j.prefix||"",o=j.suffix||"",u=j.negative||"minus",d=j.signed===!0,s={style:b,notation:j.notation||"standard"};b==="currency"&&(s.currency=j.currency||"USD",j.currencyDisplay&&(s.currencyDisplay=j.currencyDisplay)),typeof j.decimals=="number"?(s.minimumFractionDigits=j.decimals,s.maximumFractionDigits=j.decimals):(typeof j.minDecimals=="number"&&(s.minimumFractionDigits=j.minDecimals),typeof j.maxDecimals=="number"&&(s.maximumFractionDigits=j.maxDecimals),s.minimumFractionDigits>(s.maximumFractionDigits??20)&&(s.maximumFractionDigits=s.minimumFractionDigits)),j.thousandsSeparator===!1&&(s.useGrouping=!1),s.notation==="compact"&&(s.compactDisplay=j.compactDisplay||"short");const g=new Intl.NumberFormat(k,s),i=typeof j.thousandsSeparator=="string"?j.thousandsSeparator:null,n=typeof j.decimalSeparator=="string"?j.decimalSeparator:null;let f=",",p=".";if(i||n)for(const v of g.formatToParts(12345.6))v.type==="group"?f=v.value:v.type==="decimal"&&(p=v.value);const l=v=>{let E=v;return i&&(E=E.split(f).join("")),n&&(E=E.split(p).join("")),i&&(E=E.split("").join(i)),n&&(E=E.split("").join(n)),E},y=!!(i||n),c=t!==""&&b==="currency",m=v=>{let E;if(c){const V=g.formatToParts(v);let G=!1;E="";for(const q of V)E+=q.value,!G&&q.type==="currency"&&(E+=t,G=!0);G||(E=t+E)}else E=t+g.format(v);return y&&(E=l(E)),E+o},w=v=>{if(P(v)||v==="")return h;const E=typeof v=="number"?v:Number(v);if(Number.isNaN(E))return h;const V=a===1?E:E*a;return V===0&&r!==void 0?r:V<0?u==="parentheses"?`(${m(-V)})`:u==="suffix"?`${m(-V)}-`:m(V):d&&V>0?`+${m(V)}`:m(V)};return w.negativeClass=j.negativeClass||null,w.spec=j,w}}),We("packages/core/src/format/date.js",function(e,D){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return Z}}),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 a}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return o}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/internal/warn.js").warnOnce,L=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function Z(u){const d=[];let s=0,g="";const i=()=>{g&&(d.push({token:null,text:g}),g="")};for(;s<u.length;){const n=u[s];if(n==="'"){if(u[s+1]==="'"){g+="'",s+=2;continue}const p=u.indexOf("'",s+1);if(p===-1){g+=u.slice(s+1),s=u.length;continue}g+=u.slice(s+1,p),s=p+1;continue}const f=L.find(p=>u.startsWith(p,s));if(f){i(),d.push({token:f,text:f}),s+=f.length;continue}/[A-Za-z]/.test(n)&&_(`date.pattern.token:${n}`,`the date pattern "${u}" contains '${n}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${L.join(" ")}.`),g+=n,s+=1}return i(),d}const H=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function x(u){if(P(u)||u==="")return null;if(u instanceof Date)return Number.isNaN(u.getTime())?null:u;if(typeof u=="number")return Number.isNaN(u)?null:new Date(u);if(typeof u=="string"){const d=H.exec(u.trim());if(d){const[,g,i,n,f="0",p="0",l="0"]=d;return new Date(+g,+i-1,+n,+f,+p,+l)}const s=new Date(u);return Number.isNaN(s.getTime())?null:s}return null}function X(u,d){return String(u).padStart(d,"0")}function U(u){if(!u)return g=>({year:g.getFullYear(),month:g.getMonth()+1,day:g.getDate(),hour:g.getHours(),minute:g.getMinutes(),second:g.getSeconds(),ms:g.getMilliseconds(),weekday:g.getDay()});const d=new Intl.DateTimeFormat("en-US",{timeZone:u,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),s={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return g=>{const i={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:g.getMilliseconds(),weekday:0};for(const n of d.formatToParts(g))switch(n.type){case"year":i.year=Number(n.value);break;case"month":i.month=Number(n.value);break;case"day":i.day=Number(n.value);break;case"hour":i.hour=Number(n.value)%24;break;case"minute":i.minute=Number(n.value);break;case"second":i.second=Number(n.value);break;case"weekday":i.weekday=s[n.value]??0;break;default:break}return i}}function j(u,d,s){const g=Z(u),i=U(s),n=new Set(g.filter(c=>c.token).map(c=>c.token)),f=n.has("MMM")?new Intl.DateTimeFormat(d,{month:"short",timeZone:s}):null,p=n.has("MMMM")?new Intl.DateTimeFormat(d,{month:"long",timeZone:s}):null,l=n.has("EEE")?new Intl.DateTimeFormat(d,{weekday:"short",timeZone:s}):null,y=n.has("EEEE")?new Intl.DateTimeFormat(d,{weekday:"long",timeZone:s}):null;return c=>{const m=i(c);let w="";for(const v of g){if(!v.token){w+=v.text;continue}switch(v.token){case"yyyy":w+=X(m.year,4);break;case"yy":w+=X(m.year%100,2);break;case"MMMM":w+=p.format(c);break;case"MMM":w+=f.format(c);break;case"MM":w+=X(m.month,2);break;case"M":w+=String(m.month);break;case"dd":w+=X(m.day,2);break;case"d":w+=String(m.day);break;case"EEEE":w+=y.format(c);break;case"EEE":w+=l.format(c);break;case"HH":w+=X(m.hour,2);break;case"H":w+=String(m.hour);break;case"hh":w+=X(m.hour%12===0?12:m.hour%12,2);break;case"h":w+=String(m.hour%12===0?12:m.hour%12);break;case"mm":w+=X(m.minute,2);break;case"m":w+=String(m.minute);break;case"ss":w+=X(m.second,2);break;case"s":w+=String(m.second);break;case"SSS":w+=X(m.ms,3);break;case"a":w+=m.hour<12?"AM":"PM";break;default:w+=v.text;break}}return w}}const k=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function b(u,d){const s=u||{},g=s.locale||d||void 0,i=s.nullDisplay??"",n=s.timeZone;let f;if(s.pattern)f=j(s.pattern,g,n);else if(s.dateStyle||s.timeStyle){const m={timeZone:n};s.dateStyle&&(m.dateStyle=s.dateStyle),s.timeStyle&&(m.timeStyle=s.timeStyle);const w=new Intl.DateTimeFormat(g,m);f=v=>w.format(v)}else{const m=new Intl.DateTimeFormat(g,{dateStyle:"medium",timeZone:n});f=w=>m.format(w)}const p=s.relative?new Intl.RelativeTimeFormat(g,{numeric:"auto"}):null,y=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,c=(m,w)=>{const v=x(m);if(!v)return i;if(p){const E=w&&typeof w.now=="number"?w.now:Date.now(),V=v.getTime()-E;if(Math.abs(V)<y){for(const[G,q]of k)if(Math.abs(V)>=q||G==="second")return p.format(Math.round(V/q),G)}}return f(v)};return c.spec=s,c}function a(u){if(P(u)||u==="")return null;if(typeof u=="string"){const g=/^(\d{4}-\d{2}-\d{2})/.exec(u.trim());if(g)return g[1];const i=x(u);return i?a(i):null}const d=x(u);if(!d)return null;const s=g=>String(g).padStart(2,"0");return`${d.getFullYear()}-${s(d.getMonth()+1)}-${s(d.getDate())}`}function h(u,d){if(P(u)||u==="")return null;if(typeof u=="string"){const g=u.trim();if(r.test(g)){const f=x(g);return f?t(f,d):null}const i=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(g);if(i){const[,f,p,l,y]=i;return`${f}T${p}:${l}${y&&y!=="00"?`:${y}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(g))return`${g}T00:00`;const n=x(g);return n?h(n):null}const s=x(u);return s?t(s,d):null}const r=/(?:Z|[+-]\d{2}:?\d{2})$/i;function t(u,d){const s=f=>String(f).padStart(2,"0");if(d)try{const f=new Intl.DateTimeFormat("en-CA",{timeZone:d,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(u).reduce((y,c)=>(c.type!=="literal"&&(y[c.type]=c.value),y),{}),p=f.hour==="24"?"00":f.hour,l=Number(f.second);return`${f.year}-${f.month}-${f.day}T${p}:${f.minute}`+(l?`:${f.second}`:"")}catch{}const g=`${u.getFullYear()}-${s(u.getMonth()+1)}-${s(u.getDate())}`,i=u.getSeconds(),n=`${s(u.getHours())}:${s(u.getMinutes())}${i?`:${s(i)}`:""}`;return`${g}T${n}`}function o(u,d){const s=P(u)||u===""?null:String(u),g=P(d)||d===""?null:String(d);return s===null?g===null?0:1:g===null||s<g?-1:s>g?1:0}}),We("packages/core/src/format/boolean.js",function(e,D){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return Z}});const P=D("packages/core/src/internal/predicates.js").isNil,Y={true:"☑",false:"☐",null:""},_={true:"◉",false:"◯",null:""};function L(H){if(P(H)||H==="")return null;if(typeof H=="boolean")return H;if(typeof H=="number")return H!==0;const x=String(H).trim().toLowerCase();return x==="true"||x==="yes"||x==="y"||x==="1"?!0:x==="false"||x==="no"||x==="n"||x==="0"?!1:null}function Z(H,x){const X=H||{},U=X.display||"text",j=X.trueLabel??"Yes",k=X.falseLabel??"No",b=X.nullLabel??"";let a=j,h=k;const r=b;U==="checkbox"?(a=Y.true,h=Y.false):U==="switch"?(a=_.true,h=_.false):U==="icon"&&(a=X.trueIcon??j,h=X.falseIcon??k);const t=o=>{const u=L(o);return u===null?r:u?a:h};return t.display=U,t.labels={true:j,false:k,null:b},t.locale=x,t.spec=X,t}}),We("packages/core/src/format/text.js",function(e,D){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return L}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/internal/text.js").titleCase;function L(Z,H){const x=Z||{},X=x.locale||H||void 0,U=x.nullDisplay??"",j=x.emptyDisplay??"",k=x.transform||"none",b=typeof x.truncate=="number"?{chars:x.truncate}:x.truncate||null,a=b?b.chars:0,h=b?b.ellipsis??"…":"",r=o=>{switch(k){case"upper":return X?o.toLocaleUpperCase(X):o.toUpperCase();case"lower":return X?o.toLocaleLowerCase(X):o.toLowerCase();case"title":return _(o);default:return o}},t=o=>{if(P(o))return U;let u=typeof o=="string"?o:String(o);return u===""?j:(k!=="none"&&(u=r(u)),a>0&&u.length>a&&(u=u.slice(0,a)+h),u)};return t.spec=x,t}}),We("packages/core/src/format/shorthand.js",function(e,D){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return H}});const ne=["currency","number","percent","date","boolean","text","relative"],P=/[#0?@;"\\]/,Y=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function _(x){return typeof x!="string"||x===""||Z(x)?!1:P.test(x)}function L(x){return typeof x!="string"||x===""||Z(x)?!1:Y.test(x)}function Z(x){const X=x.indexOf(":"),U=X===-1?x:x.slice(0,X);return ne.includes(U)?U:null}function H(x){const X=Z(x);if(!X)return null;const U=x.indexOf(":"),j=U===-1?"":x.slice(U+1),k=j===""?[]:j.split(":");switch(X){case"currency":{const b={type:"number",style:"currency",currency:k[0]||"USD"};return k[1]!==void 0&&k[1]!==""&&(b.decimals=Number(k[1])),b}case"number":{const b={type:"number",style:"decimal"};return k[0]!==void 0&&k[0]!==""&&(b.decimals=Number(k[0])),b}case"percent":{const b={type:"number",style:"percent"};return k[0]!==void 0&&k[0]!==""&&(b.decimals=Number(k[0])),b}case"date":return{type:"date",pattern:j||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const b=j.split("/"),a={type:"boolean",display:"text"};return b[0]!==void 0&&b[0]!==""&&(a.trueLabel=b[0]),b[1]!==void 0&&b[1]!==""&&(a.falseLabel=b[1]),b[2]!==void 0&&(a.nullLabel=b[2]),a}case"text":{const b={type:"text"};return k[0]&&(b.transform=k[0]),k[1]!==void 0&&k[1]!==""&&(b.truncate=Number(k[1])),b}default:return null}}}),We("packages/core/src/format/index.js",function(e,D){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return E}});const ne=D("packages/core/src/internal/predicates.js"),P=ne.isFunction,Y=ne.isObject,L=D("packages/core/src/internal/warn.js").warnOnce,Z=D("packages/core/src/format/number.js"),H=Z.compileNumber,x=D("packages/core/src/format/date.js"),X=x.compileDate,U=x.scanPattern,j=D("packages/core/src/format/boolean.js"),k=j.compileBoolean,b=D("packages/core/src/format/text.js"),a=b.compileText,h=D("packages/core/src/format/mask.js"),r=h.compileMask,t=D("packages/core/src/format/shorthand.js"),o=t.parseShorthand,u=t.looksLikeMask,d=t.looksLikeDatePattern,g=D("packages/core/src/format/pattern.js").parseNumberPattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return Z.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 h.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return h.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return h.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return t.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return t.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return t.looksLikeDatePattern}});const i=new Set(["decimal","currency","percent","unit"]),n=new Set(["type","locale"]),f={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"])},p=new Set(["number","date","boolean","text"]);function l(M,O){const T=M.type;if(T===void 0||p.has(T)||!i.has(String(T)))return;const A=O?`"${O}"`:"with no id";L(`format:unknown-style-key:${O||""}:${T}`,`column ${A} has format: { type: "${T}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${T}" instead?`)}function y(M,O,T){const A=f[O],N=T?`"${T}"`:"with no id";for(const C of M){if(n.has(C)||A.has(C))continue;const S=Object.keys(f).find(F=>F!==O&&f[F].has(C));S?L(`format:inapplicable:${T||""}:${C}`,`column ${N} has format key "${C}", which applies to a ${S} column, not the ${O} column it was applied to; it is ignored.`):L(`format:unknown:${T||""}:${C}`,`column ${N} has an unrecognised format key "${C}" for its ${O} format; it is ignored.`)}}function c(M){if(M.type==="number"||M.type==="date"||M.type==="boolean"||M.type==="text")return!0;const O=i.has(String(M.style));return!!(M.pattern||M.dateStyle||M.timeStyle||M.relative||M.timeZone||M.trueLabel||M.falseLabel||M.display||M.trueIcon||M.falseIcon||M.transform||M.truncate||M.emptyDisplay||O||M.currency||M.decimals!==void 0||M.minDecimals!==void 0||M.maxDecimals!==void 0||M.notation||M.negative||M.scale!==void 0||M.prefix||M.suffix||M.zeroDisplay!==void 0)}function m(M,O){if(M.type==="number"||M.type==="date"||M.type==="boolean"||M.type==="text")return M.type;if(M.pattern){if(u(M.pattern))return"number";if(d(M.pattern))return"date"}if(M.dateStyle||M.timeStyle||M.relative||M.timeZone)return"date";if(M.trueLabel||M.falseLabel||M.display||M.trueIcon||M.falseIcon)return"boolean";if(M.transform||M.truncate||M.emptyDisplay)return"text";if(M.style||M.currency||M.decimals!==void 0||M.minDecimals!==void 0||M.maxDecimals!==void 0||M.notation||M.negative||M.scale!==void 0||M.prefix||M.suffix||M.zeroDisplay!==void 0)return"number";const T=O&&O.base;return T==="number"?"number":T==="date"||T==="dateString"?"date":T==="boolean"?"boolean":"text"}function w(M,O=null,T=void 0,A=void 0,N=void 0){if(M==null||M==="")return null;const C=Y(M)?Object.keys(M):null;if(typeof M=="function"){const $=(W,K)=>String(M({...K||{},value:W,locale:T})??"");return $.ooxml=O&&O.excel||"General",$}if(typeof M=="string"){if(u(M)){const{format:W,ooxml:K}=r(M,T);return W.ooxml=K,W}const $=o(M)||(d(M)?{type:"date",pattern:M}:null);return $?w($,O,T,A,N):(L(`format:${M}`,`unrecognised format string "${M}"; the value will be stringified`),null)}if(!Y(M))return L("format:shape","format must be a spec object or a string; ignoring",M),null;if(O&&P(O.format)&&!c(M)||O&&P(O.format)&&Array.isArray(O.formatPatterns)&&M.type===void 0)return null;const S=m(M,O);S==="date"&&A&&M.timeZone===void 0&&(M={...M,timeZone:A}),l(M,N),y(C||Object.keys(M),S,N);let F;switch(S){case"number":F=H(M,T);break;case"date":F=X(M,T);break;case"boolean":F=k(M,T);break;default:F=a(M,T);break}return F.ooxml=E(M,S,T,O),F.kind=S,F}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 E(M,O,T=void 0,A=null){if(O==="date"){if(M.pattern){let $="";for(const W of U(M.pattern))$+=W.token?v[W.token]??W.text:W.text;return $}return A&&A.excel||"yyyy-mm-dd"}if(O==="boolean")return"General";if(O==="text")return"@";if(typeof M.pattern=="string"&&g(M.pattern))return String(M.pattern).trim();if(M.notation==="compact"||M.notation==="scientific")return"General";const N=typeof M.decimals=="number"?M.decimals:typeof M.minDecimals=="number"?M.minDecimals:M.style==="currency"?2:0;let S=`${M.thousandsSeparator===!1?"":"#,#"}#0${N>0?`.${"0".repeat(N)}`:""}`,F="";return M.style==="currency"&&(F+=V(q(M.currency||"USD",T))),M.prefix&&(F+=V(M.prefix)),S=F+S,M.style==="percent"&&(S=`${S}%`),M.suffix&&(S+=V(M.suffix)),M.negative==="parentheses"?`${S};(${S})`:M.negative==="suffix"?`${S};${S}-`:S}function V(M){return`"${String(M).split('"').join("")}"`}const G=new Map;function q(M,O){const T=`${M}|${O||""}`;let A=G.get(T);if(A!==void 0)return A;A=M;try{const C=new Intl.NumberFormat(O,{style:"currency",currency:M}).formatToParts(0).find(S=>S.type==="currency");C&&(A=C.value)}catch{}return G.set(T,A),A}}),We("packages/core/src/columns/types/temporal.js",function(e,D){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Re}});const ne=D("packages/core/src/internal/predicates.js"),P=ne.isNil,Y=ne.isFunction,_=D("packages/core/src/format/date.js"),L=_.toDate,Z=_.compilePattern,H=_.compileDate,x=_.toIsoDateTime,X=_.compareIso,U=864e5,j=Object.freeze({}),k=1e3,b=60*k,a=60*b,h=24*a,r=7*h,t=new WeakMap;function o(Se,Ve){const Fe=Se&&Se.locale||"",Ce=Se&&Se.column;if(!Ce)return Fe?{locale:Fe}:j;const Ee=t.get(Ce);if(Ee&&Ee.locale===Fe)return Ee.bag;const Ie=Ce.typeOptions||Ce[Ve]||(u(Ce.format)?Ce.format:null),Be={...Ie||j,locale:Ie&&Ie.locale||Fe||void 0};return t.set(Ce,{locale:Fe,bag:Be}),Be}function u(Se){return Se!==null&&typeof Se=="object"&&!Array.isArray(Se)&&!(Se instanceof Date)}function d(Se,Ve){const Fe=Se===null||Number.isNaN(Se)?null:Se,Ce=Ve===null||Number.isNaN(Ve)?null:Ve;return Fe===null?Ce===null?0:1:Ce===null||Fe<Ce?-1:Fe>Ce?1:0}const s=/^(\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,g=/^(\d{3,6})$/;function i(Se,Ve,Fe,Ce){return!(Se>=0&&Se<=23)||!(Ve>=0&&Ve<=59)||!(Fe>=0&&Fe<=59)||!(Ce>=0&&Ce<=999)?null:Se*a+Ve*b+Fe*k+Ce}function n(Se){if(P(Se))return null;const Ve=String(Se).trim();if(Ve==="")return null;const Fe=g.exec(Ve);if(Fe){const rt=Fe[1];if(rt.length===5)return null;const nt=rt.length===3?1:2;return i(Number(rt.slice(0,nt)),Number(rt.slice(nt,nt+2)),Number(rt.slice(nt+2,nt+4)||0),0)}const Ce=s.exec(Ve);if(!Ce)return null;let Ee=Number(Ce[1]);const Ie=Number(Ce[2]||0),Be=Number(Ce[3]||0),Ke=Ce[4]?Number(Ce[4].padEnd(3,"0")):0,qe=Ce[5]?Ce[5][0].toLowerCase():null;if(qe){if(Ee<1||Ee>12)return null;Ee=Ee%12,qe==="p"&&(Ee+=12)}return i(Ee,Ie,Be,Ke)}function f(Se){return P(Se)||Se===""?null:typeof Se=="number"?Number.isFinite(Se)?(Se%h+h)%h:null:Se instanceof Date?Number.isNaN(Se.getTime())?null:Se.getHours()*a+Se.getMinutes()*b+Se.getSeconds()*k+Se.getMilliseconds():n(Se)}const p=new Map;function l(Se){const Ve=Se.pattern||"",Fe=Se.timeStyle||(Se.seconds?"medium":"short"),Ce=`${Se.locale||""}|${Ve}|${Fe}`;let Ee=p.get(Ce);if(Ee)return Ee;if(Ve)Ee=Z(Ve,Se.locale||void 0,"UTC");else{const Ie=new Intl.DateTimeFormat(Se.locale||void 0,{timeStyle:Fe,timeZone:"UTC"});Ee=Be=>Ie.format(Be)}return p.set(Ce,Ee),Ee}function y(Se,Ve){const Fe=Ve||j;if(Se==null||typeof Se!="number"||!Number.isFinite(Se))return Fe.nullDisplay??"";const Ce=(Se%h+h)%h;return l(Fe)(new Date(Ce))}function c(Se){return Se instanceof Date?!Number.isNaN(Se.getTime()):typeof Se=="number"?Number.isFinite(Se)&&Se>=0&&Se<h:typeof Se!="string"||!Se.includes(":")?!1:n(Se)!==null}function m(Se){const Ve=f(Se);return Ve==null?"":y(Ve,{pattern:Ve%k===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const w=new Map;function v(Se){const Ve=Se||"";let Fe=w.get(Ve);return Fe||(Fe=new Intl.DateTimeFormat("en-GB",{timeZone:Se||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),w.set(Ve,Fe)),Fe}function E(Se,Ve){const Fe={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Ce of v(Ve).formatToParts(new Date(Se)))Ce.type==="year"?Fe.year=Number(Ce.value):Ce.type==="month"?Fe.month=Number(Ce.value):Ce.type==="day"?Fe.day=Number(Ce.value):Ce.type==="hour"?Fe.hour=Number(Ce.value)%24:Ce.type==="minute"?Fe.minute=Number(Ce.value):Ce.type==="second"&&(Fe.second=Number(Ce.value));return Fe}function V(Se,Ve){const Fe=E(Se,Ve);return Date.UTC(Fe.year,Fe.month-1,Fe.day,Fe.hour,Fe.minute,Fe.second,0)-Math.floor(Se/1e3)*1e3}function G(Se,Ve){const Fe=Se.hour||0,Ce=Se.minute||0,Ee=Se.second||0,Ie=Se.ms||0;if(!Ve)return new Date(Se.year,Se.month-1,Se.day,Fe,Ce,Ee,Ie).getTime();const Be=Date.UTC(Se.year,Se.month-1,Se.day,Fe,Ce,Ee,Ie);let Ke=Be-V(Be,Ve);return Ke=Be-V(Ke,Ve),Ke}const q=/(?:Z|[+-]\d{2}:?\d{2})$/i,M=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function O(Se,Ve){if(P(Se))return null;const Fe=String(Se).trim();if(Fe==="")return null;const Ce=Ve&&Ve.timeZone||void 0;if(!q.test(Fe)){const Ee=M.exec(Fe);if(Ee){const Ie=(Ee[4]||"").trim(),Be=Ie===""?0:n(Ie);if(Be===null)return null;const Ke=G({year:Number(Ee[1]),month:Number(Ee[2]),day:Number(Ee[3]),hour:Math.floor(Be/a),minute:Math.floor(Be/b)%60,second:Math.floor(Be/k)%60,ms:Be%k},Ce);return Number.isNaN(Ke)?null:new Date(Ke)}}return L(Fe)}function T(Se){if(typeof Se=="number")return Number.isFinite(Se)?Se:null;const Ve=L(Se);return Ve?Ve.getTime():null}const A=new Map;function N(Se){const Ve=[Se.locale||"",Se.pattern||"",Se.dateStyle||"",Se.timeStyle||"",Se.timeZone||"",Se.seconds?"1":""].join("|");let Fe=A.get(Ve);if(Fe)return Fe;const Ce=Se.pattern?{type:"date",pattern:Se.pattern,timeZone:Se.timeZone}:{type:"date",dateStyle:Se.dateStyle||"medium",timeStyle:Se.timeStyle||(Se.seconds?"medium":"short"),timeZone:Se.timeZone};return Fe=H(Ce,Se.locale||void 0),A.set(Ve,Fe),Fe}function C(Se,Ve){const Fe=Ve||j,Ce=T(Se);return Ce==null?Fe.nullDisplay??"":N(Fe)(Ce)}function S(Se){return Se instanceof Date?!Number.isNaN(Se.getTime()):typeof Se!="string"||!M.test(Se.trim())?!1:O(Se)!==null}const F=Object.freeze([{key:"w",ms:r,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:h,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:a,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:k,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),$=new Map;for(const Se of F)for(const Ve of Se.names)$.set(Ve,Se);const W=Object.freeze(F.filter(Se=>Se.key!=="w")),K=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,I=/^\d+(?:\.\d+)?$/,B=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function J(Se){const Ve=Se&&Se.defaultUnit?$.get(String(Se.defaultUnit).toLowerCase()):null;return Ve?Ve.ms:b}function te(Se){return(Se&&Se.defaultUnit?$.get(String(Se.defaultUnit).toLowerCase()):null)||$.get("m")}function Q(Se,Ve){if(P(Se))return null;let Fe=String(Se).trim().toLowerCase();if(Fe==="")return null;let Ce=1;if(Fe[0]==="-"?(Ce=-1,Fe=Fe.slice(1).trim()):Fe[0]==="+"&&(Fe=Fe.slice(1).trim()),Fe==="")return null;const Ee=B.exec(Fe);if(Ee){const qe=Ee[3]!==void 0,rt=Number(Ee[1])*a+Number(Ee[2])*b+(qe?Number(Ee[3])*k:0)+(Ee[4]?Number(Ee[4].padEnd(3,"0")):0);return Ce*rt}if(I.test(Fe))return Math.round(Ce*Number(Fe)*J(Ve||j));let Ie=Fe,Be=0,Ke=0;for(;Ie!=="";){const qe=K.exec(Ie);if(!qe)return null;const rt=$.get(qe[2]);if(!rt)return null;Be+=Number(qe[1])*rt.ms,Ie=Ie.slice(qe[0].length),Ke++}return Ke===0?null:Math.round(Ce*Be)}function re(Se){return P(Se)||Se===""?null:typeof Se=="number"?Number.isFinite(Se)?Se:null:Q(Se)}const ie=new Map;function ue(Se,Ve,Fe){const Ce=`${Fe||""}|${Ve.intl}`;let Ee=ie.get(Ce);if(Ee===void 0){try{Ee=new Intl.NumberFormat(Fe||void 0,{style:"unit",unit:Ve.intl,unitDisplay:"long"})}catch{Ee=null}ie.set(Ce,Ee)}return Ee?Ee.format(Se):`${Se} ${Se===1?Ve.long[0]:Ve.long[1]}`}function ke(Se,Ve){return String(Se).padStart(Ve,"0")}function de(Se,Ve){const Fe=Ve||j;if(Se==null||typeof Se!="number"||!Number.isFinite(Se))return Fe.nullDisplay??"";const Ce=Fe.style||"short",Ee=Se<0;let Ie=Math.round(Math.abs(Se));const Be=Ee?"-":"";if(Ie===0&&Fe.zeroDisplay!=null)return Fe.zeroDisplay;if(Ce==="clock"){const nt=Math.floor(Ie/a),dt=Math.floor(Ie/b)%60,Pt=Math.floor(Ie/k)%60;return`${Be}${ke(nt,2)}:${ke(dt,2)}:${ke(Pt,2)}`}if(Ie===0){const nt=te(Fe);return Ce==="long"?ue(0,nt,Fe.locale):`0${nt.key}`}const Ke=Fe.weeks===!0?F:W,qe=typeof Fe.maxUnits=="number"&&Fe.maxUnits>0?Fe.maxUnits:Fe.maxUnits===void 0?2:1/0,rt=[];for(const nt of Ke){if(rt.length>=qe)break;const dt=Math.floor(Ie/nt.ms);dt!==0&&(Ie-=dt*nt.ms,rt.push(Ce==="long"?ue(dt,nt,Fe.locale):`${dt}${nt.key}`))}return Be+rt.join(" ")}function we(Se){if(typeof Se!="string")return!1;const Ve=Se.trim();return Ve===""||B.test(Ve)||!/[a-z]/i.test(Ve)?!1:Q(Ve)!==null}const ve=Date.UTC(1899,11,30),De=new Map;function pe(Se,Ve){const Fe=Se||"";let Ce=De.get(Fe);Ce||(Ce=new Intl.DateTimeFormat("en-GB",{timeZone:Se||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),De.set(Fe,Ce));const Ee=typeof Ve=="number"?Ve:Date.now();for(const Ie of Ce.formatToParts(new Date(Ee)))if(Ie.type==="timeZoneName")return Ie.value;return""}function oe(Se){if(Se)return Se;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function be(Se,Ve){const Fe=oe(Se),Ce=pe(Se,Ve);return Ce?`${Fe} (${Ce})`:Fe}function fe(Se,Ve){if(Se&&Se.timeZone)return Se.timeZone;const Fe=Ve&&Ve.grid;return(Fe&&Y(Fe.get)?Fe.get("timeZone"):void 0)||void 0}function le(Se,Ve){const Fe=Ve||j,Ce=T(Se);if(Ce==null)return Fe.nullDisplay??"";const Ee=N(Fe)(Ce);if(!Fe.showOrigin)return Ee;const Ie=Fe.originZone;return Ie?Ie===(Fe.timeZone||oe(Fe.timeZone))?Ee:`${Ee} (${be(Ie,Ce)})`:`${Ee} (no origin recorded)`}function ye(Se,Ve,Fe,Ce){if(Ve==="instant"||!Ve)return Se;const Ee=E(Se,Fe);if(Ve==="month")return G({year:Ee.year,month:Ee.month,day:1},Fe);if(Ve==="week"){const Ie=Ce>=1&&Ce<=7?Ce:1,Ke=((new Date(Date.UTC(Ee.year,Ee.month-1,Ee.day)).getUTCDay()+6)%7+1-Ie+7)%7,qe=new Date(Date.UTC(Ee.year,Ee.month-1,Ee.day-Ke));return G({year:qe.getUTCFullYear(),month:qe.getUTCMonth()+1,day:qe.getUTCDate()},Fe)}return G({year:Ee.year,month:Ee.month,day:Ee.day},Fe)}function Ne(Se,Ve){const Fe=Se&&Se.group,Ce=Fe&&Fe.granularity||"day";if(Ce==="instant")return null;const Ee=Fe&&Fe.weekStart;return Ie=>typeof Ie=="number"?ye(Ie,Ce,Ve,Ee):Ie}const je={time:{base:"number",storage:"float64",matches:c,format:Se=>y(f(Se.value),o(Se,"time")),parse:Se=>n(Se.text),compare:(Se,Ve)=>d(f(Se),f(Ve)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Se=>{const Ve=f(Se);return Ve===null?null:Ve/U},toStorage:Se=>f(Se),toClipboard:m,fromClipboard:n},datetime:{base:"dateString",storage:"dictionary",matches:S,format:Se=>C(Se.value,o(Se,"datetime")),parse:Se=>x(O(Se.text,o(Se,"datetime"))??Se.text),compare:X,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Se,Ve)=>x(Se,Ve&&Ve.timeZone),toClipboard:Se=>P(Se)?"":String(Se),fromClipboard:Se=>x(Se)},duration:{base:"number",storage:"float64",matches:we,format:Se=>de(re(Se.value),o(Se,"duration")),parse:Se=>Q(Se.text,o(Se,"duration")),compare:(Se,Ve)=>d(re(Se),re(Ve)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Se=>{const Ve=re(Se);return Ve===null?null:Ve/U},toStorage:Se=>re(Se),toClipboard:Se=>de(re(Se),{style:"short",maxUnits:-1}),fromClipboard:Se=>Q(Se)},timestamp:{base:"number",storage:"float64",format:Se=>{const Ve=o(Se,"timestamp");return le(Se.value,{...Ve,timeZone:fe(Ve,Se)})},parse:Se=>{const Ve=o(Se,"timestamp"),Fe=O(Se.text,{timeZone:fe(Ve,Se)});return Fe?Fe.getTime():null},compare:(Se,Ve)=>d(T(Se),T(Ve)),groupProjector:(Se,Ve)=>Ne(Se,Ve),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Se,Ve)=>{const Fe=T(Se);if(Fe==null)return null;const Ce=E(Fe,Ve&&Ve.timeZone||void 0);return(Date.UTC(Ce.year,Ce.month-1,Ce.day,Ce.hour,Ce.minute,Ce.second)-ve)/U},toStorage:Se=>T(Se),toClipboard:Se=>{const Ve=T(Se);return Ve==null?"":new Date(Ve).toISOString()},fromClipboard:Se=>T(Se)}},$e=["datetime","time","duration"],Re=je}),We("packages/core/src/internal/lru.js",function(e,D){"use strict";Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return ne}});class ne{#e;#t=new Map;#n;constructor(Y=256,_=null){this.#e=Y,this.#n=_}get size(){return this.#t.size}get max(){return this.#e}set max(Y){this.#e=Y,this.#r()}has(Y){return this.#t.has(Y)}get(Y){const _=this.#t;if(!_.has(Y))return;const L=_.get(Y);return _.delete(Y),_.set(Y,L),L}peek(Y){return this.#t.get(Y)}set(Y,_){const L=this.#t;return L.has(Y)&&L.delete(Y),L.set(Y,_),this.#r(),_}delete(Y){const _=this.#t.get(Y);return this.#t.delete(Y)&&this.#n&&this.#n(_,Y),_}clear(){if(this.#n)for(const[Y,_]of this.#t)this.#n(_,Y);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const Y=this.#t;for(;Y.size>this.#e;){const _=Y.keys().next().value,L=Y.get(_);Y.delete(_),this.#n&&this.#n(L,_)}}}}),We("packages/core/src/columns/types/network.js",function(e,D){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/internal/lru.js").Lru,L=4294967295,Z=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function H(A){if(P(A))return null;if(typeof A=="string")return x(A);const N=Number(A);return Number.isFinite(N)?N<0?N<-2147483648?null:N>>>0:N>L?null:Math.trunc(N)>>>0:null}function x(A){if(P(A))return null;const N=String(A).trim();if(N==="")return null;const C=Z.exec(N);if(!C)return null;let S=0;for(let F=1;F<=4;F++){const $=C[F];if($.length>1&&$.charCodeAt(0)===48)return null;const W=Number($);if(W>255)return null;S=S*256+W}return S}function X(A){const N=H(A);return N===null?"":`${N>>>24&255}.${N>>>16&255}.${N>>>8&255}.${N&255}`}function U(A){return typeof A=="string"&&x(A)!==null}function j(A,N){const C=H(A),S=H(N);return C===null?S===null?0:1:S===null||C<S?-1:C>S?1:0}const k=64,b=L*k+32,a=/^(?:0|[1-9]\d?)$/;function h(A,N){return A*k+N}function r(A){if(P(A))return null;if(typeof A=="string"){const S=t(A);return S===null?null:r(S)}if(typeof A=="object"){const S=H(A.address),F=Number(A.prefix);return S===null||!Number.isInteger(F)||F<0||F>32?null:{address:S,prefix:F}}const N=Number(A);if(!Number.isInteger(N)||N<0||N>b)return null;const C=N%k;return C>32?null:{address:(N-C)/k,prefix:C}}function t(A){if(P(A))return null;const N=String(A).trim();if(N==="")return null;const C=N.indexOf("/");if(C<0)return null;const S=x(N.slice(0,C));if(S===null)return null;const F=N.slice(C+1).trim();if(!a.test(F))return null;const $=Number(F);return $>32?null:h(S,$)}function o(A){const N=r(A);return N?`${X(N.address)}/${N.prefix}`:""}function u(A){return typeof A=="string"&&t(A)!==null}function d(A,N){const C=r(A),S=r(N);return C?S?C.address!==S.address?C.address<S.address?-1:1:C.prefix-S.prefix:-1:S?1:0}function s(A){return A===0?0:4294967295<<32-A>>>0}function g(A){const N=r(A);return N?(N.address&s(N.prefix))>>>0:null}function i(A){const N=r(A);return N?(N.address&s(N.prefix)|~s(N.prefix)>>>0)>>>0:null}function n(A){const N=r(A);return N?2**(32-N.prefix):null}function f(A){const N=r(A);return N?N.prefix===32?1:N.prefix===31?2:2**(32-N.prefix)-2:null}function p(A,N){const C=r(A);if(!C)return!1;const S=H(N);if(S===null)return!1;const F=s(C.prefix);return(S&F)>>>0===(C.address&F)>>>0}function l(A,N){const C=g(A),S=g(N);return C===null||S===null?!1:C<=i(N)&&S<=i(A)}const y=/^[0-9a-fA-F]{1,4}$/,c=new _(512);function m(A){if(P(A))return null;let N=String(A).trim();if(N==="")return null;const C=N.indexOf("%");if(C>=0&&(N=N.slice(0,C)),N==="")return null;if(N.indexOf(".")>=0){const I=N.lastIndexOf(":");if(I<0)return null;const B=x(N.slice(I+1));if(B===null)return null;N=`${N.slice(0,I+1)}${(B>>>16&65535).toString(16)}:${(B&65535).toString(16)}`}const S=N.split("::");if(S.length>2)return null;const F=w(S[0]);if(F===null)return null;if(S.length===1)return F.length===8?F:null;const $=w(S[1]);if($===null)return null;const W=8-F.length-$.length;if(W<1)return null;const K=F.slice();for(let I=0;I<W;I++)K.push(0);for(const I of $)K.push(I);return K}function w(A){if(A==="")return[];const N=[];for(const C of A.split(":")){if(!y.test(C))return null;N.push(parseInt(C,16))}return N}function v(A){if(typeof A!="string")return m(A);if(c.has(A))return c.get(A);const N=m(A);return c.set(A,N),N}function E(A){if(A[0]===0&&A[1]===0&&A[2]===0&&A[3]===0&&A[4]===0&&A[5]===65535)return`::ffff:${X((A[6]<<16|A[7])>>>0)}`;let N=-1,C=0,S=-1,F=0;for(let K=0;K<8;K++)A[K]===0?(S<0?(S=K,F=1):F++,F>C&&(C=F,N=S)):(S=-1,F=0);if(C<2)return A.map(K=>K.toString(16)).join(":");const $=A.slice(0,N).map(K=>K.toString(16)).join(":"),W=A.slice(N+C).map(K=>K.toString(16)).join(":");return`${$}::${W}`}function V(A){const N=m(A);return N===null?null:E(N)}function G(A){return V(A)??""}function q(A){return typeof A=="string"&&A.indexOf(":")>=0&&m(A)!==null}function M(A,N){const C=v(A),S=v(N);if(!C)return S?1:0;if(!S)return-1;for(let F=0;F<8;F++)if(C[F]!==S[F])return C[F]<S[F]?-1:1;return 0}const O=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:U,parse:A=>x(A.text),compare:j,format:A=>X(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:A=>H(A),toClipboard:A=>X(A),fromClipboard:A=>x(A)},cidr:{base:"number",storage:"float64",matches:u,parse:A=>t(A.text),compare:d,format:A=>o(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:A=>{const N=r(A);return N===null?null:h(N.address,N.prefix)},toClipboard:A=>o(A),fromClipboard:A=>t(A)},ipv6:{base:"text",storage:"dictionary",matches:q,parse:A=>V(A.text),compare:M,format:A=>G(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:A=>V(A),toClipboard:A=>G(A),fromClipboard:A=>V(A)}}),T=O}),We("packages/core/src/i18n/catalogue.js",function(e,D){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return L}});const ne=D("packages/core/src/registry/free-tier-notice.js"),P=ne.FREE_TIER_NOTICE,Y=ne.WATERMARK_TEXT,_=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","rowCap.more":"+ {count} more","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","stat.target":"target {target}","meter.target":"target {value}","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","panel.compareGroups":"Compare groups","panel.explain":"Explain","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.","compareGroups.noTest":"Not enough readings, or no variation, in at least one group.","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","explain.column":"Value","explain.by":"Break down by","explain.byRow":"Each row","explain.noColumns":"No numeric columns to explain","explain.unavailable":"Nothing to explain in this column","explain.total":"{fn}: {total}","explain.weighted":"weighted effects","explain.single":"one contributor","explain.delta":"was {before}, now {after} (Δ {delta})","explain.breakdown":"Contributors","explain.contributor":"Contributor","explain.count":"Rows","explain.value":"Value","explain.contribution":"Contribution","explain.share":"Share","explain.change":"Change","explain.before":"Before","explain.after":"After","explain.effect":"Effect","explain.kind.new":"New","explain.kind.dropped":"Dropped","explain.kind.changed":"Changed","explain.narrative":"Explanation","explain.narrative.lead":"{top} accounts for {share}; the {fn} is {total}.","explain.narrative.next":"{next} follows at {share}.","explain.narrative.driver":"The change of {delta} was driven most by {top} ({effect}).","explain.narrative.driverNext":"{next} ({kind}) moved it {effect}.","explain.narrative.none":"Nothing contributed to this total.","explain.narrative.noChange":"Nothing changed between the two states.","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.compareGroups":"Compare groups","menu.explain":"Explain this number","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","listview.pullToRefresh.pull":"Pull to refresh","listview.pullToRefresh.release":"Release to refresh","listview.pullToRefresh.refreshing":"Refreshing…","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","dataview.label":"Items","dataview.empty":"No items","dataview.reorder.sorted":"Items cannot be reordered while the view is sorted","dataview.reorder.filtered":"Items cannot be reordered while a filter is applied","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.tree.dropRefusedDescendant":"A row cannot be dropped into one of its own descendants; the row stays where it was","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.explain":"Explain the focused column","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.","form.grid.cellInvalid":"Row {row}, {column}: {message}","form.grid.required":"Add at least one row.","form.grid.addRow":"Add row","form.grid.deleteRow":"Delete row","form.grid.total":"Total","form.grid.rowControls":"Row controls","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","panel.tabActiveCount":{one:"{title}, {count} active",other:"{title}, {count} active"},"panel.tabActive":"{title}, active","views.default":"Default","views.namePlaceholder":"Name this view…","views.nameLabel":"Name for the current layout","views.save":"Save view","licence.watermark":Y,"licence.watermark.free":P,"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.suppressed.unavailable":"Histogram unavailable","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}","views.shared":"View copied to the clipboard","views.sharedDownload":"Clipboard unavailable; the view was downloaded as {name}","views.sharedFailed":"The view could not be copied or downloaded","views.rename":"Rename","views.ownedBy":"Owned by {name}","views.ownerOnlyReason":"Only {name} or an admin can do that","views.noOwnerReason":"Only an admin can do that — this view has no recorded owner","views.unshare":"Unshare","views.unshareTitle":"Stop sharing {name}","views.duplicate":"Duplicate","views.duplicateTitle":"Duplicate {name}","views.copyName":"{name} (copy)","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","sidebar.nav":"Main navigation","sidebar.search":"Search","sidebar.collapse":"Collapse sidebar","sidebar.expand":"Expand sidebar","toolbar.more":"More"}),L=Object.freeze(Object.keys(_))}),We("packages/core/src/i18n/format.js",function(e,D){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return k}});const P=D("packages/core/src/internal/predicates.js").isFunction,Y=/\{(\w+)\}/g,_=new Map,L=new Map;function Z(b){const a=b||"";if(_.has(a))return _.get(a);let h=null;try{h=new Intl.PluralRules(b||void 0)}catch{h=null}return _.set(a,h),h}function H(b,a,h="conjunction"){const r=Array.isArray(b)?b.filter(u=>u!=null&&u!==""):[];if(r.length===0)return"";if(r.length===1)return String(r[0]);const t=`${a||""}|${h}`;let o=L.get(t);if(o===void 0){try{o=new Intl.ListFormat(a||void 0,{style:"long",type:h})}catch{o=null}L.set(t,o)}return o?o.format(r.map(String)):r.map(String).join(", ")}function x(b,a){return b==null?"":typeof b=="number"?Number.isFinite(b)?b.toLocaleString(a||void 0,{maximumFractionDigits:20}):"":String(b)}function X(b,a,h){if(typeof b=="string")return b;if(!b||typeof b!="object")return"";const r=a&&typeof a.count=="number"?a.count:null;if(r===null)return b.other??"";const t=Z(h),o=t?t.select(r):r===1?"one":"other";return b[o]??b.other??""}function U(b,a={},h){const r=X(b,a,h);return r?r.replace(Y,(t,o)=>Object.prototype.hasOwnProperty.call(a,o)?x(a[o],h):t):""}function j(b,a,h="en-GB"){return typeof b=="string"&&b?b:typeof a=="string"&&a?a:h}function k(b,a){const h=b?b[a]:void 0;return h==null||P(h)?a:h}}),We("packages/core/src/i18n/registry.js",function(e,D){"use strict";Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"localeCatalogue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"registeredTags",{enumerable:!0,get:function(){return Z}});const P=D("packages/core/src/i18n/catalogue.js").EN_GB,Y=new Map([["en-gb",P]]);function _(H,x){const X=typeof H=="string"?H.toLowerCase():"";return!X||!x||typeof x!="object"?!1:(Y.set(X,x),!0)}function L(H){if(typeof H!="string"||!H)return null;const x=H.toLowerCase(),X=Y.get(x);if(X)return X;const U=x.split("-")[0],j=Y.get(U);if(j)return j;for(const[k,b]of Y)if(k.split("-")[0]===U)return b;return null}function Z(){return[...Y.keys()]}}),We("packages/core/src/i18n/index.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return d}});const ne=D("packages/core/src/i18n/catalogue.js"),P=ne.EN_GB,Y=ne.MESSAGE_KEYS,_=D("packages/core/src/i18n/format.js"),L=_.formatMessage,Z=_.formatList,H=_.lookup,x=_.resolveLocale,U=D("packages/core/src/internal/predicates.js").isFunction,k=D("packages/core/src/internal/warn.js").warnOnce,b=D("packages/core/src/i18n/registry.js"),a=b.registerLocale,h=b.localeCatalogue;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return ne.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return ne.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return _.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return _.resolveLocale}}),Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return b.registerLocale}});const r="en-GB";class t{#e=r;#t=P;constructor(g={}){this.configure(g)}configure(g={}){this.#e=x(g.locale,g.declared,r);const i=g.messages,n=h(this.#e);if(!n&&this.#e.toLowerCase()!=="en-gb"&&(!i||typeof i!="object")&&k(`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.`),!i||typeof i!="object"){this.#t=n?{...P,...n}:P;return}const p=Object.keys(i).filter(l=>!(l in P));p.length&&k(`i18n:unknown:${p[0]}`,`message keys not in the catalogue and so ignored: ${p.slice(0,5).join(", ")}${p.length>5?`, and ${p.length-5} more`:""}`),this.#t={...P,...n||{},...i}}get locale(){return this.#e}t(g,i){return L(H(this.#t,g),i||{},this.#e)}list(g,i){return Z(g,this.#e,i)}number(g,i){const n=Number(g);return Number.isFinite(n)?n.toLocaleString(this.#e,i||{maximumFractionDigits:20}):""}}const o=new t;function u(s){return s instanceof t?s:new t(s||{})}function d(s){const g=s&&typeof s=="object"?s:{},i=Y.filter(f=>{const p=g[f];return p==null||p===""||U(p)}),n=Object.keys(g).filter(f=>!(f in P));return{missing:i,unknown:n}}}),We("packages/core/src/columns/types/structured.js",function(e,D){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return U}}),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 h}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const ne=D("packages/core/src/internal/predicates.js"),P=ne.isNil,Y=ne.isObject,L=D("packages/core/src/i18n/index.js").defaultMessages,Z=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function H(t,o){const u=o||{},d=u.emptyDisplay??Z.emptyDisplay;if(P(t)||t==="")return d;const g=[...typeof u.char=="string"&&u.char!==""?u.char:Z.char][0]||Z.char,i=u.fixedLength??Z.fixedLength,n=Number.isFinite(u.length)&&Number(u.length)>0?Math.floor(Number(u.length)):Z.length,f=typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):null;let p=0;if(f!==null){const l=Number.isFinite(u.lastVisible)?Math.floor(Number(u.lastVisible)):Z.lastVisible,y=[...f];if(p=l>0&&l<y.length?l:0,p>0){const c=y.slice(y.length-p).join(""),m=Math.max(1,(i?n:y.length)-p);return g.repeat(m)+c}return g.repeat(i?n:Math.max(1,y.length))}return g.repeat(n)}const x=48;function X(t){try{const o=JSON.stringify(t);return o===void 0?null:o}catch{return null}}function U(t,o){if(P(t))return"";const u=Number.isFinite(o&&o.inlineLimit)?Number(o.inlineLimit):x;if(typeof t=="string")return t.length>u?`${t.slice(0,u-1)}…`:t;if(typeof t!="object")return String(t);const d=X(t);if(d!==null&&d.length<=u)return d;if(Array.isArray(t)){const g=t.length;return`[${L.t("count.items",{count:g})}]`}const s=Object.keys(t).length;return`{${L.t("count.keys",{count:s})}}`}function j(t,o){if(t==null)return"null";const u=typeof t;if(u==="number"||u==="boolean"||u==="bigint")return String(t);if(u==="string")return JSON.stringify(t);if(u!=="object")return JSON.stringify(String(t));const d=o||new WeakSet;return d.has(t)?'"[circular]"':(d.add(t),t instanceof Date?JSON.stringify(t.toISOString()):Array.isArray(t)?`[${t.map(i=>j(i,d)).join(",")}]`:`{${Object.keys(t).sort().map(i=>`${JSON.stringify(i)}:${j(t[i],d)}`).join(",")}}`)}function k(t,o){if(P(t))return P(o)?0:1;if(P(o))return-1;const u=j(t),d=j(o);return u<d?-1:u>d?1:0}function b(t){if(P(t))return null;const o=String(t);if(o.trim()==="")return null;try{return JSON.parse(o)}catch{return o}}function a(t){const o=t&&t.cell&&t.cell.props;return Y(o)?o:{}}const h=Object.freeze({json:{base:"object",storage:"object",format:t=>U(t&&t.value,a(t&&t.column)),parse:t=>b(t&&t.text),compare:k,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:t=>{if(P(t))return"";if(typeof t=="string")return t;try{const o=JSON.stringify(t,null,2);return o===void 0?String(t):o}catch{return String(t)}},fromClipboard:t=>b(t)},secret:{base:"text",storage:"object",format:t=>H(t&&t.value,a(t&&t.column)),parse:t=>{const o=t&&t.text;return P(o)||String(o)===""?null:String(o)},compare:(t,o)=>{const u=P(t)||t==="",d=P(o)||o==="";return u===d?0:u?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:t=>H(t),fromClipboard:t=>P(t)||String(t)===""?null:String(t)}}),r=h}),We("packages/core/src/columns/types/unit.js",function(e,D){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/internal/warn.js").warnOnce;function L(F,$,W,K){return Object.freeze({symbol:F,factor:$,aliases:Object.freeze(W||[]),binary:!!(K&&K.binary),prefix:K&&K.prefix||null,auto:!(K&&K.auto===!1)})}function Z(F,$,W,K){return L(F,$,W,K)}const H=Object.freeze({data:Object.freeze([L("B",1,["byte","bytes"]),L("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),L("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),L("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),L("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),L("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),L("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),L("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),L("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),L("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([L("bps",1,["bit","bits","bit/s","b/s"]),L("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),L("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),L("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),L("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([L("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),L("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),L("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),L("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),L("in",.0254,["inch","inches"],{auto:!1}),L("ft",.3048,["foot","feet"],{auto:!1}),L("yd",.9144,["yard","yards"],{auto:!1}),L("m",1,["metre","metres","meter","meters"]),L("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),L("mi",1609.344,["mile","miles"],{auto:!1}),L("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([L("mg",.001,["milligram","milligrams"]),L("g",1,["gram","grams"]),L("oz",28.349523125,["ounce","ounces"],{auto:!1}),L("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),L("kg",1e3,["kilogram","kilograms"]),L("st",6350.29318,["stone"],{auto:!1}),L("t",1e6,["tonne","tonnes","ton"],{auto:!1}),L("ton (US)",907184.74,["ton","shortton"],{auto:!1}),L("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([L("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),L("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),L("ms",.001,["msec","msecs","millisecond","milliseconds"]),L("s",1,["sec","secs","second","seconds"]),L("m",60,["min","mins","minute","minutes"]),L("h",3600,["hr","hrs","hour","hours"]),L("d",86400,["day","days"])]),speed:Object.freeze([L("mm/s",.001,["millimetre/s","millimeter/s"]),L("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),L("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),L("mph",.44704,["mile/h","miles/h"],{auto:!1}),L("kn",1852/3600,["knot","knots"],{auto:!1}),L("m/s",1,["metre/s","meter/s","mps"]),L("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([L("mm/s²",.001,["mm/s2"]),L("ft/s²",.3048,["ft/s2"],{auto:!1}),L("m/s²",1,["m/s2","metre/s2","meter/s2"]),L("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([L("mm²",1e-6,["mm2"]),L("cm²",1e-4,["cm2"]),L("in²",64516e-8,["in2","sqin"],{auto:!1}),L("ft²",.09290304,["ft2","sqft"],{auto:!1}),L("yd²",.83612736,["yd2","sqyd"],{auto:!1}),L("m²",1,["m2","sqm"]),L("ha",1e4,["hectare","hectares"],{auto:!1}),L("ac",4046.8564224,["acre","acres"],{auto:!1}),L("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([L("µL",1e-6,["ul","microlitre","microliter"]),L("mL",.001,["millilitre","milliliter"]),L("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),L("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),L("L",1,["litre","litres","liter","liters"]),L("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),L("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),L("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),L("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([L("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),L("J",1,["joule","joules"]),L("cal",4.184,["calorie","calories"],{auto:!1}),L("kJ",1e3,["kilojoule","kilojoules"]),L("BTU",1055.05585262,["btu"],{auto:!1}),L("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),L("MJ",1e6,["megajoule","megajoules"]),L("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),L("GJ",1e9,["gigajoule","gigajoules"]),L("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([L("mW",.001,["milliwatt","milliwatts"]),L("W",1,["watt","watts"]),L("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),L("kW",1e3,["kilowatt","kilowatts"]),L("hp",745.6998715822702,["horsepower"],{auto:!1}),L("MW",1e6,["megawatt","megawatts"]),L("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([L("mN",.001,["millinewton","millinewtons"]),L("N",1,["newton","newtons"]),L("lbf",4.4482216152605,["poundforce"],{auto:!1}),L("kgf",9.80665,["kilogramforce"],{auto:!1}),L("kN",1e3,["kilonewton","kilonewtons"]),L("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([L("Pa",1,["pascal","pascals"]),L("mbar",100,["millibar"],{auto:!1}),L("inH₂O",249.0889,["inh2o"],{auto:!1}),L("mmHg",133.322387415,["torr"],{auto:!1}),L("kPa",1e3,["kilopascal","kilopascals"]),L("inHg",3386.388640341,["inhg"],{auto:!1}),L("psi",6894.757293168361,["lbf/in2"],{auto:!1}),L("bar",1e5,[],{auto:!1}),L("atm",101325,["atmosphere","atmospheres"],{auto:!1}),L("MPa",1e6,["megapascal","megapascals"]),L("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([L("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),L("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),L("kN·m",1e3,["knm","kn.m"],{auto:!1}),L("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([L("kg/m³",1,["kg/m3"]),L("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),L("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),L("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([L("L/min",1/6e4,["lpm","l/min"],{auto:!1}),L("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),L("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),L("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),L("cfm",.0004719474432,["ft3/min"],{auto:!1}),L("L/s",.001,["lps","l/s"],{auto:!1}),L("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([L("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),L("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),L("mrad",.001,["milliradian","milliradians"],{auto:!1}),L("mil",Math.PI/3200,["nato-mil"],{auto:!1}),L("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),L("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),L("rad",1,["radian","radians"]),L("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([L("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),L("rad/s",1,["radps","radians/s"]),L("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),L("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([L("ppt",1e-12,["partspertrillion"],{auto:!1}),L("ppb",1e-9,["partsperbillion"]),L("ppm",1e-6,["partspermillion"]),L("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),L("‰",.001,["permille","permil"],{auto:!1}),L("%",.01,["pct","percent"]),L("×",1,["x","ratio","times"])]),molarity:Object.freeze([L("pM",1e-12,["picomolar","picomolarity"]),L("nM",1e-9,["nanomolar","nanomolarity"]),L("µM",1e-6,["um-molar","micromolar","micromolarity"]),L("mM",.001,["millimolar","millimolarity"]),L("M",1,["molar","mol/l","mol/L","molarity"]),L("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([L("mg/s",1e-6,["milligrams/s"]),L("g/s",.001,["grams/s"]),L("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),L("kg/s",1,["kilograms/s","kgps"]),L("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),L("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),L("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([L("µPa·s",1e-6,["upas","micropascalsecond"]),L("cP",.001,["centipoise"],{auto:!1}),L("mPa·s",.001,["mpas","millipascalsecond"]),L("P",.1,["poise"],{auto:!1}),L("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([L("cSt",1e-6,["centistokes","centistoke"]),L("mm²/s",1e-6,["mm2/s"],{auto:!1}),L("St",1e-4,["stokes","stoke"],{auto:!1}),L("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([L("mW/(m·K)",.001,["mw/mk"]),L("W/(m·K)",1,["w/mk","wmk"]),L("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),L("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([L("J/(kg·K)",1,["j/kgk","jkgk"]),L("kJ/(kg·K)",1e3,["kj/kgk"]),L("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([L("nSv/h",1e-9,["nsvh"]),L("µSv/h",1e-6,["usv/h","usvh"]),L("mSv/h",.001,["msvh"]),L("Sv/h",1,["svh"]),L("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),x=Symbol("ambiguous"),X=new Map,U=new Map;function j(F,$){const W=String(F||"").trim();if(!W)throw new Error("[lattice] a unit system needs a name");if(H[W]||U.has(W))throw new Error(`[lattice] unit system "${W}" already exists`);const K=[...$||[]];if(!K.length)throw new Error(`[lattice] unit system "${W}" has no units`);if(!K.some(B=>B.factor===1))throw new Error(`[lattice] unit system "${W}" has no base unit (none with factor 1)`);const I=new Set;for(const B of K){if(I.has(B.symbol))throw new Error(`[lattice] unit system "${W}" declares "${B.symbol}" twice`);I.add(B.symbol)}return U.set(W,Object.freeze(K)),X.delete(W),W}function k(){return[...Object.keys(H),...U.keys()]}function b(F){const $=a(F);return $?$.units:[]}function a(F){const $=String(F||""),W=X.get($);if(W!==void 0)return W;const K=H[$]||U.get($);if(!K)return X.set($,null),null;const I=Object.freeze([...K].sort((re,ie)=>re.factor-ie.factor)),B=new Map,J=new Map,te=(re,ie)=>{const ue=B.get(re);ue===void 0?B.set(re,ie):ue!==ie&&B.set(re,x)};for(const re of I){te(re.symbol.toLowerCase(),re);for(const ie of re.aliases)te(ie.toLowerCase(),re);if(re.prefix){const ie=J.get(re.prefix)||[];ie.push(re),J.set(re.prefix,ie)}}const Q={units:I,byToken:B,byPrefix:J,decimal:I.filter(re=>!re.binary&&re.auto),binary:I.some(re=>re.binary)?I.filter(re=>(re.binary||re.factor===1)&&re.auto):null};return X.set($,Q),Q}function h(F,$){return $&&F.binary||F.decimal}function r(F,$){const W=a(F);if(!W||P($))return null;const K=W.units.find(B=>B.symbol===String($));if(K)return K;const I=W.byToken.get(String($).trim().toLowerCase());return I&&I!==x?I:null}const t=new WeakMap;function o(F){const $=F||{};if(typeof $=="object"&&$!==null){const B=t.get($);if(B!==void 0)return B}const W=$.system||"data",K=a(W);let I=null;if(!K)_(`unit:system:${W}`,`unknown unit system "${W}"; known systems are ${k().join(", ")}`);else{let B=$.unit?r(W,$.unit):null;B||($.unit&&_(`unit:unit:${W}:${$.unit}`,`unknown unit "${$.unit}" in system "${W}"; falling back to ${K.units[0].symbol}`),B=K.units.find(J=>J.factor===1)||K.units[0]),I={index:K,base:B,binary:$.binary===!0}}return typeof $=="object"&&$!==null&&t.set($,I),I}const u=new WeakMap;function d(F,$){if(!F||!$||!Array.isArray(F.compound)||F.compound.length===0)return null;const W=u.get(F);if(W!==void 0)return W;const K=new Set,I=[];for(const J of F.compound){const te=r(F.system||"data",J);if(!te){_(`unit:compound:${F.system}:${J}`,`unknown compound unit "${J}" in system "${F.system||"data"}"; ignoring it`);continue}K.has(te.symbol)||(K.add(te.symbol),I.push(te))}I.sort((J,te)=>te.factor-J.factor);const B=I.length>=2?I:null;return u.set(F,B),B}function s(F,$,W){return $===W||$.factor===W.factor?F:F*$.factor/W.factor}const g=new Map;function i(F){const $=F||"",W=g.get($);if(W)return W;const K={group:",",decimal:"."};try{for(const I of new Intl.NumberFormat(F||void 0).formatToParts(12345.6))I.type==="group"?K.group=I.value:I.type==="decimal"&&(K.decimal=I.value)}catch{}return g.set($,K),K}const n=/[\s ]/g,f=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,p=/^[^\d+\-(.,\s]+\s*/,l=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function y(F,$){const{group:W,decimal:K}=i($);let I=String(F).replace(n,"");if(I==="")return null;const B=K?I.indexOf(K):-1;if(W&&W!==K){if(B>=0&&I.indexOf(W,B+K.length)>=0)return null;I=I.split(W).join("")}if(K&&K!=="."&&(I=I.split(K).join(".")),!l.test(I))return null;const J=Number(I);return Number.isFinite(J)?J:null}function c(F,$,W){const K=String(F).trim().replace(/\.$/,"");if(K==="")return null;const I=$.units.find(ie=>ie.symbol===K);if(I)return I;const B=K.toLowerCase(),J=$.byToken.get(B);if(J===x)return null;if(J)return J;const te=$.byPrefix.get(B);if(!te||!te.length)return null;const Q=h($,W),re=te.filter(ie=>Q.includes(ie));return re.length===1?re[0]:null}function m(F,$,W,K){let I=F,B=0,J=!1,te=!1;for(;I!=="";){const Q=f.exec(I)[0];if(Q==="")return null;const re=y(Q,K&&K.locale);if(re===null)return null;I=I.slice(Q.length).trim();const ie=I.search(/[+-]?[\d]/),ue=(ie>=0?I.slice(0,ie):I).trim();if(I=ie>=0?I.slice(ie).trim():"",ue===""){if(J)return null;te=!0,B+=s(re,W[0],$.base)}else{const ke=c(ue,$.index,$.binary);if(!ke)return null;B+=s(re,ke,$.base)}if(J=!0,te&&I!=="")return null}return J?B:null}function w(F,$){if(P(F))return null;if(typeof F=="number")return Number.isFinite(F)?F:null;const W=o($);if(!W)return null;let K=String(F).trim();if(K==="")return null;let I=!1;K.startsWith("(")&&K.endsWith(")")&&(I=!0,K=K.slice(1,-1).trim());const B=d($,W);if(B){K.startsWith("-")&&(I=!0,K=K.slice(1).trim());const de=m(K,W,B,$);return de===null?null:I?-de:de}let J=null;const te=p.exec(K);if(te&&te[0]){const de=c(te[0].trim(),W.index,W.binary);de&&(J=de,K=K.slice(te[0].length).trim())}const Q=f.exec(K)[0],re=y(Q,$&&$.locale);if(re===null)return null;const ie=K.slice(Q.length).trim();if(J&&ie!=="")return null;const ue=J||(ie===""?W.base:c(ie,W.index,W.binary));if(!ue)return null;const ke=s(re,ue,W.base);return I?-ke:ke}const v=new Map;function E(F,$,W,K){const I=`${F||""}|${$}|${W}|${K?1:0}`;let B=v.get(I);return B||(B=new Intl.NumberFormat(F||void 0,{minimumFractionDigits:$,maximumFractionDigits:W,useGrouping:K}),v.set(I,B)),B}function V(F,$){if(!Number.isFinite(F)||F===0)return Math.max(0,$-1);const W=Math.floor(Math.log10(Math.abs(F)));return Math.min(20,Math.max(0,$-1-W))}function G(F,$){if(!Number.isFinite(F)||F===0)return F;const W=Math.ceil(Math.log10(Math.abs(F))),K=10**($-W);return Math.round(F*K)/K}function q(F,$,W){if(!W||W===$.base.symbol)return $.base;if(W!=="auto")return M($,W);if(F===0||!Number.isFinite(F))return $.base;const K=Math.abs(F)*$.base.factor,I=h($.index,$.binary);let B=I[0];for(const Q of I)K>=Q.factor&&(B=Q);if(K>=B.factor)return B;let J=B;for(const Q of $.index.units)Q.binary!==$.binary&&Q.factor!==1||Q.factor<=K&&Q.factor>(J===B?0:J.factor)&&(J=Q);if(J!==B)return J;let te=B;for(const Q of $.index.units)Q.binary!==$.binary&&Q.factor!==1||Q.factor<te.factor&&(te=Q);return te.factor<$.base.factor?te:$.base}function M(F,$){const W=F.index.units.find(I=>I.symbol===$);if(W)return W;const K=F.index.byToken.get(String($).toLowerCase());return K&&K!==x?K:(_(`unit:display:${$}`,`unknown display unit "${$}"; rendering in ${F.base.symbol}`),F.base)}function O(F,$,W,K){const I=F<0;let B=Math.abs(F)*$.base.factor;const J=typeof K.decimals=="number"?K.decimals:K.minDecimals??0,te=typeof K.decimals=="number"?K.decimals:K.maxDecimals??Math.max(J,2),Q=K.space??" ",re=[];for(let ue=0;ue<W.length;ue++){const ke=W[ue],de=ue===W.length-1;let we=de?B/ke.factor:Math.floor(B/ke.factor);if(B-=we*ke.factor,de){const De=10**te;we=Math.round(we*De)/De+0}const ve=de?E(K.locale,J,te,K.group!==!1):E(K.locale,0,0,K.group!==!1);re.push(`${ve.format(we)}${Q}${ke.symbol}`)}const ie=re.join(" ");return I?`-${ie}`:ie}function T(F,$){const W=$||{},K=W.nullDisplay??"";if(P(F)||F==="")return K;const I=typeof F=="number"?F:Number(F);if(!Number.isFinite(I))return K;const B=o(W);if(!B)return String(I);const J=d(W,B);if(J)return O(I,B,J,W);const te=typeof W.significantFigures=="number"&&W.significantFigures>0?W.significantFigures:0,Q=te?G(I,te):I,re=q(Q,B,W.display),ie=s(Q,B.base,re);let ue=typeof W.decimals=="number"?W.decimals:W.minDecimals??0,ke=typeof W.decimals=="number"?W.decimals:W.maxDecimals??Math.max(ue,2);te&&(ue=V(ie,te),ke=ue);const de=E(W.locale,ue,ke,W.group!==!1).format(ie),we=W.space??" ";return W.placement==="prefix"?`${re.symbol}${W.space??""}${de}`:`${de}${we}${re.symbol}`}function A(F,$){const W=P(F)||Number.isNaN(F)?null:Number(F),K=P($)||Number.isNaN($)?null:Number($);return W===null||Number.isNaN(W)?K===null||Number.isNaN(K)?0:1:K===null||Number.isNaN(K)||W<K?-1:W>K?1:0}function N(F){const $=typeof F.decimals=="number"&&F.decimals>0?`.${"0".repeat(F.decimals)}`:"";return`${typeof F.decimals=="number"?`#,##0${$}`:"#,##0.##"}" ${F.symbol}"`}function C(F){const $={system:"data",...F||{}},W=o($),K=W?W.base.symbol:String($.unit||""),I=Object.freeze({...$,unit:K}),B=Object.freeze({...I,display:K,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[I.locale||"",I]]),te=Q=>{const re=Q||"";let ie=J.get(re);return ie||(ie=Object.freeze({...I,locale:Q||void 0}),J.set(re,ie)),ie};return{base:"number",extends:"number",storage:"float64",unitConfig:I,format:Q=>T(Q.value,Q.locale?te(Q.locale):I),parse:Q=>w(Q.text,Q.locale?te(Q.locale):I),compare:A,defaults:{filter:"number",editor:"unit",align:"end",total:$.total||"sum"},...$.totals?{totals:$.totals}:{},excel:$.excel||N({decimals:$.decimals,symbol:K}),toStorage:Q=>typeof Q=="number"?Number.isFinite(Q)?Q:null:typeof Q=="string"?w(Q,I):P(Q)?null:w(String(Q),I),toClipboard:Q=>T(Q,B),fromClipboard:Q=>w(Q,I)}}const S=C}),We("packages/core/src/columns/types/engineering.js",function(e,D){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return L}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/columns/types/unit.js").createUnitType;function L(x){const X=2*Math.PI/x;return U=>{let j=0,k=0,b=0;for(const h of U||[]){if(P(h))continue;const r=Number(h);Number.isFinite(r)&&(j+=Math.cos(r*X),k+=Math.sin(r*X),b+=1)}return!b||Math.hypot(j,k)/b<1e-12?null:(Math.atan2(k,j)/X%x+x)%x}}function Z(x){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:L(x)}}}const H=Object.freeze({metres:_({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:_({system:"length",unit:"mm",maxDecimals:2}),kilometres:_({system:"length",unit:"km",maxDecimals:3}),grams:_({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:_({system:"mass",unit:"kg",maxDecimals:3}),tonnes:_({system:"mass",unit:"t",maxDecimals:3}),seconds:_({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:_({system:"duration",unit:"ms",maxDecimals:3}),hours:_({system:"duration",unit:"h",maxDecimals:2}),speed:_({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:_({system:"speed",unit:"km/h",maxDecimals:1}),mph:_({system:"speed",unit:"mph",maxDecimals:1}),knots:_({system:"speed",unit:"kn",maxDecimals:1}),acceleration:_({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:_({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:_({system:"area",unit:"ha",maxDecimals:4}),volume:_({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:_({system:"volume",unit:"m³",maxDecimals:3}),energy:_({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:_({system:"energy",unit:"kWh",maxDecimals:2}),power:_({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:_({system:"power",unit:"kW",maxDecimals:2}),force:_({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:_({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:_({system:"pressure",unit:"bar",maxDecimals:3}),psi:_({system:"pressure",unit:"psi",maxDecimals:1}),torque:_({system:"torque",unit:"N·m",maxDecimals:2}),density:_({system:"density",unit:"kg/m³",maxDecimals:2}),flow:_({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:_({system:"flow",unit:"L/min",maxDecimals:1}),radians:_({system:"angle",unit:"rad",maxDecimals:4,totals:Z(2*Math.PI)}),degrees:_({system:"angle",unit:"°",maxDecimals:2,totals:Z(360)}),rpm:_({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:_({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:_({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:_({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:_({system:"fraction",unit:"bp",maxDecimals:1}),molarity:_({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:_({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:_({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:_({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:_({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:_({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:_({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:_({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),We("packages/core/src/columns/types/si.js",function(e,D){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return j}});const ne=D("packages/core/src/columns/types/unit.js"),P=ne.defineUnit,Y=ne.registerUnitSystem,_=ne.createUnitType,L=Object.freeze([Object.freeze({symbol:"f",name:"femto",factor:1e-15}),Object.freeze({symbol:"p",name:"pico",factor:1e-12}),Object.freeze({symbol:"n",name:"nano",factor:1e-9}),Object.freeze({symbol:"µ",name:"micro",factor:1e-6}),Object.freeze({symbol:"m",name:"milli",factor:.001}),Object.freeze({symbol:"c",name:"centi",factor:.01}),Object.freeze({symbol:"",name:"",factor:1}),Object.freeze({symbol:"k",name:"kilo",factor:1e3}),Object.freeze({symbol:"M",name:"mega",factor:1e6}),Object.freeze({symbol:"G",name:"giga",factor:1e9}),Object.freeze({symbol:"T",name:"tera",factor:1e12}),Object.freeze({symbol:"P",name:"peta",factor:1e15})]),Z=Object.freeze(["p","n","µ","m","","k","M","G"]);function H(k){const b=String(k.base),a=new Set([...k.prefixes||Z,""]),h=[];for(const r of L){if(!a.has(r.symbol))continue;const t=`${r.symbol}${b}`,o=[];if(k.name){o.push(`${r.name}${k.name}`,`${r.name}${k.name}s`);const u=r.name.slice(-1);if(u&&k.name.startsWith(u)){const d=`${r.name.slice(0,-1)}${k.name}`;o.push(d,`${d}s`)}}r.symbol==="µ"&&o.push(`u${b}`),r.factor===1&&k.aliases&&o.push(...k.aliases),h.push(P(t,r.factor,o))}for(const r of k.extra||[])h.push(r);return h}function x(k,b){const a=H(b);return Y(k,a)}function X(k,b,a){return x(k,b),_({system:k,unit:b.base,display:"auto",maxDecimals:3,...a||{}})}const U=Object.freeze({voltage:X("voltage",{base:"V",name:"volt"}),current:X("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:X("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:X("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:X("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:X("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[P("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),P("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:X("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:X("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[P("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:X("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:X("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:X("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:X("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:X("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:X("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:X("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[P("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:X("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),j=X}),We("packages/core/src/columns/types/temperature.js",function(e,D){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return L}}),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 k}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const P=D("packages/core/src/internal/predicates.js").isNil,Y=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:h=>h+273.15,fromKelvin:h=>h-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:h=>(h+459.67)*(5/9),fromKelvin:h=>h*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:h=>h,fromKelvin:h=>h}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:h=>h*(5/9),fromKelvin:h=>h*(9/5)})});function _(h){if(P(h))return null;const r=String(h).trim();if(r==="")return null;for(const[o,u]of Object.entries(Y))if(r===o||r===u.symbol)return{key:o,scale:u};const t=r.toLowerCase();for(const[o,u]of Object.entries(Y))if(u.aliases.includes(t))return{key:o,scale:u};return null}function L(h,r,t){const o=_(r),u=_(t);return!o||!u||!Number.isFinite(Number(h))?null:o.key===u.key?Number(h):u.scale.fromKelvin(o.scale.toKelvin(Number(h)))}const Z=new Map;function H(h,r,t){const o=`${h||""}|${r}|${t}`;let u=Z.get(o);return u||(u=new Intl.NumberFormat(h||void 0,{minimumFractionDigits:r,maximumFractionDigits:t}),Z.set(o,u)),u}function x(h,r){const t=r||{},o=t.nullDisplay??"";if(P(h)||h==="")return o;const u=Number(h);if(!Number.isFinite(u))return o;const d=_(t.scale||"C");if(!d)return String(u);const s=_(t.display||t.scale||"C")||d,g=s.key===d.key?u:s.scale.fromKelvin(d.scale.toKelvin(u)),i=typeof t.decimals=="number"?t.decimals:null,n=i??t.minDecimals??0,f=i??t.maxDecimals??1;return`${H(t.locale,n,f).format(g)}${t.space??" "}${s.scale.symbol}`}const X=/^[+-]?[\d\s., ]*\d/;function U(h,r){const t=String(h).trim();if(t==="")return null;const o=new Intl.NumberFormat(r||void 0).formatToParts(1.1).find(g=>g.type==="decimal")?.value||".",u=o===","?".":",",d=t.split(u).join("").split(/[\s ]/).join("").replace(o,"."),s=Number(d);return Number.isFinite(s)?s:null}function j(h,r){if(P(h))return null;const t=r||{},o=_(t.scale||"C");if(!o)return null;if(typeof h=="number")return Number.isFinite(h)?h:null;let u=String(h).trim();if(u==="")return null;let d=!1;u.startsWith("(")&&u.endsWith(")")&&(d=!0,u=u.slice(1,-1).trim());const s=X.exec(u);if(!s)return null;const g=U(s[0],t.locale);if(g===null)return null;const i=u.slice(s[0].length).trim();if(i==="")return d?-g:g;const n=_(i);if(!n)return null;const f=n.key===o.key?g:o.scale.fromKelvin(n.scale.toKelvin(g));return d?-f:f}function k(h){const r=Object.freeze({scale:"C",...h||{}}),o=(_(r.scale)||_("C")).scale.symbol,u=Object.freeze({...r,display:r.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),d=new Map([[r.locale||"",r]]),s=g=>{const i=g||"";let n=d.get(i);return n||(n=Object.freeze({...r,locale:g||void 0}),d.set(i,n)),n};return{base:"number",extends:"number",storage:"float64",temperatureConfig:r,format:g=>x(g.value,g.locale?s(g.locale):r),parse:g=>j(g.text,g.locale?s(g.locale):r),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:r.excel||`#,##0${typeof r.decimals=="number"&&r.decimals>0?`.${"0".repeat(r.decimals)}`:".#"}" ${o}"`,toStorage:g=>typeof g=="number"?Number.isFinite(g)?g:null:typeof g=="string"?j(g,r):P(g)?null:j(String(g),r),toClipboard:g=>x(g,u),fromClipboard:g=>j(g,r)}}const b=Object.freeze({celsius:k({scale:"C"}),fahrenheit:k({scale:"F"}),kelvin:k({scale:"K"})}),a=k}),We("packages/core/src/columns/types/radix.js",function(e,D){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const P=D("packages/core/src/internal/predicates.js").isNil,_=D("packages/core/src/internal/warn.js").warnOnce,L=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),Z=Object.freeze({2:1,8:3,16:4}),H=Object.freeze({2:"0b",8:"0o",16:"0x"}),x=Object.freeze({2:4,8:3,16:2}),X=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),U=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),j=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),k=/[\s\u00a0\u202f_,']/g,b=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,a=Object.freeze([8,16,32,53]),h=new WeakSet,r=new WeakMap,t=new Map,o=new WeakMap,u=new WeakMap,d=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 s(T){if(T==null)return 16;const A=typeof T=="string"?T.toLowerCase():T,N=L[A];return N||(_(`radix:base:${String(T)}`,`unsupported radix ${String(T)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function g(T,A){return Math.ceil(T/Z[A])}function i(T,A){if(!T)return A?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!A)return{min:0,max:2**T-1};const N=2**(T-1);return{min:-N,max:N-1}}function n(T){return U[T]||"hexadecimal"}function f(T){if(typeof T=="string"){const A=d[T];return A||_(`radix:preset:${T}`,`unknown radix preset "${T}"; known presets are ${Object.keys(d).join(", ")}`),{...A||{}}}if(T&&typeof T.preset=="string"){const A=d[T.preset];return A||_(`radix:preset:${T.preset}`,`unknown radix preset "${T.preset}"; known presets are ${Object.keys(d).join(", ")}`),{...A||{},...T}}return T||{}}function p(T){const A=f(T),N=s(A.radix),C=Z[N];let S=null;if(A.bitWidth!==void 0&&A.bitWidth!==null&&A.bitWidth!==!1){const Q=Number(A.bitWidth);a.includes(Q)?S=Q:_(`radix:width:${String(A.bitWidth)}`,`unsupported bitWidth ${String(A.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let F=A.signed!==!1;!F&&S===null&&(_("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),S=32);const $=A.prefix===void 0||A.prefix===!0?H[N]:A.prefix===!1?"":String(A.prefix);let W=0;A.pad===!0?W=S?g(S,N):0:typeof A.pad=="number"&&A.pad>0&&(W=Math.floor(A.pad));let K=0;A.group===!0?K=x[N]:typeof A.group=="number"&&A.group>0&&(K=Math.floor(A.group));const I=i(S,F),B=typeof A.min=="number"?Math.max(I.min,A.min):I.min,J=typeof A.max=="number"?Math.min(I.max,A.max):I.max,te=Object.freeze({radix:N,bits:C,prefix:$,uppercase:A.uppercase!==!1,pad:W,group:K,groupSeparator:typeof A.groupSeparator=="string"?A.groupSeparator:" ",bitWidth:S,signed:F,min:B,max:J<B?B:J,nullDisplay:typeof A.nullDisplay=="string"?A.nullDisplay:"",name:n(N)});return h.add(te),te}function l(T){if(T&&h.has(T))return T;if(typeof T=="string"){let A=t.get(T);return A||(A=p(T),t.set(T,A)),A}if(T&&typeof T=="object"){let A=r.get(T);return A||(A=p(T),r.set(T,A)),A}return l("hex")}function y(T){return T<0?-Math.round(-T):Math.round(T)}function c(T,A,N){if(A<=0||T.length<=A)return T;const C=T.length%A||A,S=[T.slice(0,C)];for(let F=C;F<T.length;F+=A)S.push(T.slice(F,F+A));return S.join(N)}function m(T){const A=l(T),{radix:N,prefix:C,uppercase:S,pad:F,group:$,groupSeparator:W,signed:K,bitWidth:I,nullDisplay:B}=A,J=I?2**I:0,te=Q=>{if(P(Q)||Q==="")return B;const re=typeof Q=="number"?Q:Number(Q);if(!Number.isFinite(re))return B;const ie=y(re);let ue="",ke=ie;ie<0&&(K?(ue="-",ke=-ie):ke=(ie%J+J)%J);let de=ke.toString(N);return de=S?de.toUpperCase():de.toLowerCase(),F>0&&de.length<F&&(de=de.padStart(F,"0")),$>0&&(de=c(de,$,W)),ue+C+de};return te.options=A,te}function w(T,A){const N=l(A);let C=o.get(N);return C||(C=m(N),o.set(N,C)),C(T)}function v(T){const A=l(T),{radix:N,groupSeparator:C,signed:S,min:F,max:$}=A,W=X[N],K=I=>{if(P(I))return{ok:!0,value:null,reason:"blank"};let B=String(I);if(C&&C!==""&&(B=B.split(C).join("")),B=B.replace(k,""),B==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((B[0]==="-"||B[0]==="+")&&(J=B[0]==="-",B=B.slice(1)),B==="")return{ok:!1,value:null,reason:"digits"};let te=null;for(const[re,ie]of j){const ue=re.exec(B);if(!ue)continue;const ke=B.slice(ue[0].length);if(ke==="")break;if(!X[ie].test(ke))return{ok:!1,value:null,reason:"digits"};te=parseInt(ke,ie);break}if(te===null)if(W.test(B))te=parseInt(B,N);else if(b.test(B))te=Number(B);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(te))return{ok:!1,value:null,reason:"digits"};const Q=y(J?-te:te);return!S&&Q<0?{ok:!1,value:Q,reason:"negative"}:Q<F||Q>$?{ok:!1,value:Q,reason:"range"}:{ok:!0,value:Q,reason:"ok"}};return K.options=A,K}function E(T,A){const N=l(A);let C=u.get(N);return C||(C=v(N),u.set(N,C)),C(T)}function V(T,A){const N=E(T,A);return N.ok?N.value:null}function G(T,A){const N=P(T)||Number.isNaN(T)?null:Number(T),C=P(A)||Number.isNaN(A)?null:Number(A);return N===null?C===null?0:1:C===null||N<C?-1:N>C?1:0}function q(T){const A=T.min>=-2147483648&&T.max<=2147483647;return T.bitWidth&&A?"int32":"float64"}function M(T){const A=p(T),N=m(A),C=v(A);return{base:"number",extends:"number",storage:q(A),matches:null,format:S=>N(S.value),parse:S=>{const F=C(S.text);return F.ok?F.value:null},compare:G,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:S=>N(S),fromClipboard:S=>{const F=C(S);return F.ok?F.value:null},radix:A,formatValue:N,parseText:C}}const O=M}),We("packages/core/src/columns/types/aggregable.js",function(e,D){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return L}});const P=D("packages/core/src/internal/predicates.js").isNil;function Y(U){const j=[];for(const k of U||[]){if(P(k))continue;const b=Number(k);Number.isFinite(b)&&j.push(b)}return j}function _(U){return j=>{const k=Y(j);if(!k.length)return null;let b=0;for(const a of k)b+=10**(a/U);return U*Math.log10(b)}}function L(U){return j=>{const k=Y(j);if(!k.length)return null;let b=0;for(const a of k)b+=10**(a/U);return U*Math.log10(b/k.length)}}function Z(U,j){const k=j&&j.column,a=(k&&k.typeOptions||{}).weight,h=j&&j.valueAt;if(!a||typeof h!="function")return null;let r=0,t=0;for(let o=0;o<U.length;o++){if(P(U[o]))continue;const u=Number(U[o]);if(!Number.isFinite(u))continue;const d=h(a,o);if(P(d))continue;const s=Number(d);!Number.isFinite(s)||s<=0||(r+=u*s,t+=s)}return t===0?null:r/t}function H(U={}){const j=U.factor===20?20:10,k=typeof U.suffix=="string"?U.suffix:"",b=Number.isInteger(U.decimals)?U.decimals:1;return{base:"number",storage:"float64",name:U.name||"logarithmic",format:a=>{const h=a&&a.value;return P(h)||!Number.isFinite(Number(h))?"":`${Number(h).toFixed(b)}${k}`},parse:a=>{const h=String((a&&a.text)??"").replace(k,"").trim();if(!h)return null;const r=Number(h);return Number.isFinite(r)?r:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:_(j),avg:L(j)}}}}function x(U={}){const j=Number.isInteger(U.decimals)?U.decimals:1,k=U.percent===!0;return{base:"number",storage:"float64",name:U.name||"ratio",format:b=>{const a=b&&b.value;return P(a)||!Number.isFinite(Number(a))?"":k?`${Number(a).toFixed(j)}%`:Number(a).toFixed(j)},parse:b=>{const a=String((b&&b.text)??"").replace("%","").trim();if(!a)return null;const h=Number(a);return Number.isFinite(h)?h:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:Z}}}}const X=Object.freeze({decibel:H({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:H({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:x({name:"ratio"}),percentRate:x({name:"percentRate",percent:!0})})}),We("packages/core/src/columns/types/currency.js",function(e,D){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const P=D("packages/core/src/internal/predicates.js").isNil,Y="⚠ no rate";function _(g){if(P(g))return null;const i=String(g).trim().toUpperCase();return i===""?null:i}function L(g){if(P(g))return null;if(typeof g=="object"&&!Array.isArray(g)){const i=Number(g.amount),n=_(g.code);return!n||!Number.isFinite(i)?null:{amount:i,code:n}}if(Array.isArray(g)&&g.length===2){const i=Number(g[0]),n=_(g[1]);return!n||!Number.isFinite(i)?null:{amount:i,code:n}}return null}const Z=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),H=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),x=/[+-]?[\d\s., ]*\d/;function X(g,i){const n=String(g).trim();if(n==="")return null;const f=new Intl.NumberFormat(i||void 0).formatToParts(1.1).find(c=>c.type==="decimal")?.value||".",p=f===","?".":",",l=n.split(p).join("").split(/[\s ]/).join("").replace(f,"."),y=Number(l);return Number.isFinite(y)?y:null}function U(g,i){const n=i||{},f=_(n.code);if(P(g))return null;const p=L(g);if(p)return p;if(typeof g=="number")return Number.isFinite(g)&&f?{amount:g,code:f}:null;let l=String(g).trim();if(l==="")return null;let y=!1;l.startsWith("(")&&l.endsWith(")")&&(y=!0,l=l.slice(1,-1).trim());let c=null;for(const[G,q]of Object.entries(Z)){if(l.startsWith(G)){c=q,l=l.slice(G.length).trim();break}if(l.endsWith(G)){c=q,l=l.slice(0,-G.length).trim();break}}const m=x.exec(l);if(!m)return null;const w=X(m[0],n.locale);if(w===null)return null;const v=(l.slice(0,m.index)+" "+l.slice(m.index+m[0].length)).trim();!c&&v!==""&&(c=_(v));const E=c||f;return E?{amount:y?-w:w,code:E}:null}function j(g,i){if(typeof g=="function")return(n,f)=>{if(n===f)return 1;const p=g(n,f);return typeof p=="number"&&Number.isFinite(p)&&p>0?p:null};if(g&&typeof g=="object"){const n=g;return(f,p)=>{if(f===p)return 1;const l=Number(n[f]),y=Number(n[p]);return!Number.isFinite(l)||!Number.isFinite(y)||l<=0||y<=0?null:y/l}}return(n,f)=>n===f?1:null}function k(g,i,n){if(!g)return null;if(g.code===i)return g.amount;const f=n(g.code,i);return f===null?null:g.amount*f}const b=new Map;function a(g,i,n){const f=`${g||""}|${i}|${n??""}`;let p=b.get(f);if(!p){const l={style:"currency",currency:i};typeof n=="number"&&(l.minimumFractionDigits=n,l.maximumFractionDigits=n);try{p={fmt:new Intl.NumberFormat(g||void 0,l),currency:!0}}catch{p={fmt:new Intl.NumberFormat(g||void 0,typeof n=="number"?{minimumFractionDigits:n,maximumFractionDigits:n}:{}),currency:!1}}b.set(f,p)}return p}function h(g,i){const n=i||{},f=n.nullDisplay??"",p=L(g);if(!p)return f;const l=_(n.display)||p.code;let y=p.amount,c=p.code;if(l!==p.code){const v=n.rateFn||j(n.rates,n.rateBase),E=k(p,l,v);if(E===null)return`${n.missingRate??Y} ${p.code}→${l}`;y=E,c=l}const{fmt:m,currency:w}=a(n.locale,c,n.decimals);return w?m.format(y):`${m.format(y)} ${c}`}function r(g){const i=L(g);return i?`${i.amount} ${i.code}`:""}function t(g){const i=g||{},n=_(i.display),f=i.rateFn||j(i.rates,i.rateBase);return(p,l)=>{const y=L(p),c=L(l);if(!y&&!c)return 0;if(!y)return 1;if(!c)return-1;if(n){const m=k(y,n,f),w=k(c,n,f);if(m!==null&&w!==null)return m===w?0:m<w?-1:1}return y.code===c.code?y.amount===c.amount?0:y.amount<c.amount?-1:1:y.code<c.code?-1:1}}function o(g){const i=g||{},n=(p,l)=>{const y=[];for(const E of p||[]){const V=L(E);V&&y.push(V)}if(!y.length)return null;if(new Set(y.map(E=>E.code)).size===1){const E=y[0].code;return{amount:l(y.map(V=>V.amount)),code:E}}const m=_(i.display);if(!m)return`${i.missingRate??Y}: mixed currencies, no display currency set`;const w=i.rateFn||j(i.rates,i.rateBase),v=[];for(const E of y){const V=k(E,m,w);if(V===null)return`${i.missingRate??Y}: ${E.code}→${m}`;v.push(V)}return{amount:l(v),code:m}},f=p=>p.reduce((l,y)=>l+y,0);return{sum:p=>n(p,f),avg:p=>n(p,l=>f(l)/l.length),min:p=>n(p,l=>Math.min(...l)),max:p=>n(p,l=>Math.max(...l))}}function u(g){const i=Object.freeze({code:"USD",...g||{}}),n=j(i.rates,i.rateBase),f=Object.freeze({...i,rateFn:n}),p=o(f),l=t(f),y=new Map([[i.locale||"",f]]),c=v=>{const E=v||"";let V=y.get(E);return V||(V=Object.freeze({...f,locale:v||void 0}),y.set(E,V)),V},m=H[_(i.display||i.code)]||"",w=typeof i.decimals=="number"&&i.decimals>0?`.${"0".repeat(i.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:f,format:v=>h(v.value,v.locale?c(v.locale):f),parse:v=>U(v.text,v.locale?c(v.locale):f),compare:l,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:p},excel:i.excel||(m?`"${m}"#,##0${w}`:`#,##0${w}`),toStorage:v=>{const E=L(v);return E||(typeof v=="string"||typeof v=="number"?U(v,f):null)},toClipboard:v=>r(v),fromClipboard:v=>U(v,f)}}const d=Object.freeze({currency:u({code:"USD"}),usd:u({code:"USD"}),eur:u({code:"EUR"}),gbp:u({code:"GBP"}),jpy:u({code:"JPY",decimals:0})}),s=u}),We("packages/core/src/columns/types/index.js",function(e,D){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return G}});const ne=D("packages/core/src/columns/types/temporal.js"),P=ne.TEMPORAL_TYPES,Y=D("packages/core/src/columns/types/network.js"),_=Y.NETWORK_TYPES,L=D("packages/core/src/columns/types/structured.js"),Z=L.STRUCTURED_TYPES,H=D("packages/core/src/columns/types/unit.js"),x=H.createUnitType,X=H.UNIT_SYSTEMS,U=H.parseUnit,j=H.formatUnit,k=H.registerUnitSystem,b=H.unitSystemNames,a=H.unitsOf,h=H.defineUnit,r=D("packages/core/src/columns/types/engineering.js"),t=r.ENGINEERING_TYPES,o=D("packages/core/src/columns/types/si.js"),u=o.SI_TYPES,d=o.createSiType,s=o.createSiSystem,g=o.siUnits,i=o.SI_PREFIXES,n=D("packages/core/src/columns/types/temperature.js"),f=n.TEMPERATURE_TYPES,p=n.createTemperatureType,l=n.convertTemperature,y=n.formatTemperature,c=n.parseTemperature,m=n.TEMPERATURE_SCALES,w=D("packages/core/src/columns/types/radix.js"),v=w.createRadixType,E=w.RADIX_PRESETS,V=w.parseRadix,G=w.formatRadix,q=D("packages/core/src/columns/types/aggregable.js"),M=q.AGGREGABLE_TYPES,O=D("packages/core/src/columns/types/currency.js"),T=O.CURRENCY_TYPES,A=O.createCurrencyType,N=O.parseMoney,C=O.formatMoney,S=O.convertMoney,F=O.toMoney,$=O.rateFunction,W=O.moneyComparator,K=O.normaliseCode,I=O.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return H.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return r.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return r.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return n.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return n.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return n.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return n.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return n.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return n.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return n.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return O.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return O.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return O.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return O.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return O.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return O.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return O.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return O.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return O.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return O.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return ne.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return Y.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return L.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return q.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return q.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return q.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return ne.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return ne.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return ne.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return ne.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ne.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ne.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return Y.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return Y.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return Y.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return Y.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return Y.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return Y.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return Y.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return Y.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return Y.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return Y.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return Y.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return L.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return L.summariseJson}});const B=Object.freeze({...P,..._,...Z,...M,hex:v(E.hex),hex8:v(E.hex8),hex16:v(E.hex16),hex32:v(E.hex32),binary:v(E.binary),binary8:v(E.binary8),octal:v(E.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"}),...t,...u,...f,...T});{const J=new Set;for(const te of[P,_,Z,M,t,u,f,T])for(const Q of Object.keys(te)){if(J.has(Q))throw new Error(`[lattice] data type "${Q}" is declared twice`);J.add(Q)}}}),We("packages/core/src/compute/handle.js",function(e,D){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return u}});const ne=D("packages/core/src/internal/compare.js"),P=ne.collator,Y=ne.defaultCompare,L=D("packages/core/src/internal/warn.js").warnOnce;function Z(d){const s=new Uint32Array(d);for(let g=0;g<d;g++)s[g]=g;return s}function H(d,s){if(s&&typeof s.count=="number")return s.count;if(!d)return 0;if(typeof d.count=="number")return d.count;if(typeof d.length=="number")return d.length;const g=d.values;return d.kind==="multi"&&d.offsets?Math.max(0,d.offsets.length-1):g?d.kind==="bitset"?typeof g.size=="number"?g.size:d.presence&&typeof d.presence.size=="number"?d.presence.size:(L(`count:${d.id}`,`column "${d.id}" is bitset-backed with no declared row count; assuming ${g.length*8}`),g.length*8):g.length:d.presence&&typeof d.presence.size=="number"?d.presence.size:0}const x=new WeakMap;function X(d){const s=d.constructor;if(!s)return"unknown";const g=x.get(s);if(g)return g;let i="unknown";try{let n=null;typeof s.from=="function"?n=s.from([!1,!0]):(n=new s(8),n.set(1));const f=n&&n.words;f&&f.length&&(f[0]===2?i="lsb":f[0]===64&&(i="msb"))}catch{i="unknown"}return x.set(s,i),i}function U(d){if(!d)return()=>0;const s=d instanceof Uint8Array?d:d.words;if(s instanceof Uint8Array){const g=d instanceof Uint8Array?"lsb":X(d);if(g==="lsb")return i=>s[i>>>3]>>>(i&7)&1;if(g==="msb")return i=>s[i>>>3]>>>7-(i&7)&1}return typeof d.get=="function"?g=>d.get(g)?1:0:()=>0}function j(d){return!d||!d.presence?null:U(d.presence)}function k(d){return d?typeof d.size=="number"?d.size:typeof d.values=="function"?d.values().length:0:0}function b(d,s){return d?typeof d.valueOf=="function"?d.valueOf(s):typeof d.values=="function"?d.values()[s]:null:null}function a(d,s){const g=d.offsets,i=d.values;if(!g||!i)return[];const n=g[s],f=g[s+1];if(!(f>n))return[];const p=d.dict,l=new Array(f-n);for(let y=n;y<f;y++)l[y-n]=p?b(p,i[y]):i[y];return l}function h(d){if(!d)return()=>{};const s=d.values,g=j(d),i=d.kind;if(i==="dictionary"){const n=d.dict;return g?f=>g(f)?b(n,s[f]):null:f=>b(n,s[f])}if(i==="bitset"){const n=U(s);return g?f=>g(f)?n(f)===1:null:f=>n(f)===1}if(i==="multi")return g?n=>g(n)?a(d,n):null:n=>a(d,n);if(!s&&typeof d.get=="function"){const n=d.get.bind(d);return f=>{const p=n(f);return p===void 0?null:p}}return g?n=>{if(!g(n))return null;const f=s[n];return f===void 0?null:f}:n=>{const f=s[n];return f===void 0?null:f}}function r(d,s){if(d<s)return-1;if(d>s)return 1;if(d===s){const n=Object.is(d,-0),f=Object.is(s,-0);return n===f?0:n?-1:1}const g=Number.isNaN(d),i=Number.isNaN(s);return g&&i?0:g?1:-1}function t(d){const s=P(d);return(g,i)=>{if(g===i)return 0;const n=typeof g,f=typeof i;if(n==="string"&&f==="string")return s.compare(g,i);if(n==="number"&&f==="number")return r(g,i);if(n==="boolean"&&f==="boolean")return g===i?0:g?1:-1;if(g instanceof Date||i instanceof Date){const p=g instanceof Date?g.getTime():Number(g),l=i instanceof Date?i.getTime():Number(i);return r(p,l)}return Y(g,i)}}function o(d,s){if(d&&typeof d.ranks=="function")return d.ranks(s);const g=d&&typeof d.values=="function"?d.values():[],i=g.length,n=t(s),f=new Array(i);for(let l=0;l<i;l++)f[l]=l;f.sort((l,y)=>n(g[l],g[y])||l-y);const p=new Uint32Array(i);for(let l=0;l<i;l++)p[f[l]]=l;return p}function u(d){return d==null||typeof d=="number"&&Number.isNaN(d)}}),We("packages/core/src/compute/filter.js",function(e,D){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return ke}});const P=D("packages/core/src/internal/predicates.js").isBlank,_=D("packages/core/src/internal/merge.js").toArray,Z=D("packages/core/src/internal/warn.js").warnOnce,H=D("packages/core/src/format/date.js"),x=H.toDate,X=H.toIsoDate,U=D("packages/core/src/compute/handle.js"),j=U.bitReader,k=U.dictSize,b=U.dictValue,a=U.presenceReader,h=U.valueComparator,r=U.valueReader,t=/^\d{4}-\d{2}-\d{2}$/,o="\0null\0";function u(de,we){const ve=de&&de.pool;if(ve){const De=ve.mask||ve.acquireMask||ve.acquire||ve.take;if(typeof De=="function"){const pe=De.call(ve,we);if(pe&&pe.length>=we)return pe}}return new Uint8Array(we)}function d(de,we){const ve=de&&de.pool;if(!ve||!we)return;const De=ve.release||ve.releaseMask||ve.free||ve.recycle;typeof De=="function"&&De.call(ve,we)}function s(de,we,ve){return de.fill(ve,0,we),de}function g(de){return de==null||typeof de=="number"&&Number.isNaN(de)}function i(de,we){if(de==null)return de;if(we==="number")return typeof de=="number"?de:Number(de);if(we==="date"||we==="dateString"){const ve=X(de);return ve===null?n(de):ve}return we==="boolean"?typeof de=="boolean"?de:de==="true"||de===1?!0:de==="false"||de===0?!1:!!de:de}function n(de){return de instanceof Date?de.getTime():typeof de=="number"?de:Date.parse(String(de))}function f(de){return typeof de=="number"?de:de instanceof Date?de.getTime():de==null||de===""?NaN:Number(de)}function p(de,we){const ve=typeof de=="string"?de:String(de);return we?ve:ve.toLowerCase()}function l(de,we){return de==null?o:typeof de=="string"?we?de:de.toLowerCase():de instanceof Date?de.getTime():de}function y(de,we,ve){const De=new Set;for(const pe of _(de)){const oe=i(pe,ve);De.add(l(oe,we)),typeof oe=="string"&&oe!==""&&Number.isFinite(Number(oe))?De.add(Number(oe)):typeof oe=="number"&&Number.isFinite(oe)&&De.add(l(String(oe),we))}return De}function c(de,we,ve){if(de==null||we===null||we===void 0)return de==null&&we==null;const De=typeof de,pe=typeof we;return De==="string"&&pe==="string"?ve?de===we:de.toLowerCase()===we.toLowerCase():de instanceof Date||we instanceof Date?n(de)===n(we):De==="number"&&pe==="number"?de===we||Number.isNaN(de)&&Number.isNaN(we):De==="number"&&pe==="string"?de===Number(we):De==="string"&&pe==="number"?Number(de)===we:De==="boolean"||pe==="boolean"?de===we:Array.isArray(de)&&Array.isArray(we)?de.length===we.length&&de.every((oe,be)=>c(oe,we[be],ve)):de===we}function m(de,we){try{if(de instanceof RegExp){const ve=de.flags.replace(/[gy]/g,"");return new RegExp(de.source,we||ve.includes("i")?ve:`${ve}i`)}return new RegExp(String(de),we?"":"i")}catch(ve){return Z(`regex:${String(de)}`,`filter operator "matches" received an invalid pattern: ${String(de)}`,ve),null}}function w(de,we){if(de&&de.type==="datetime"&&v.has(de.op))return M(de,we);const ve=O(de,we),De=de&&de.type;return De!=="date"&&De!=="dateString"?ve:pe=>ve(typeof pe=="string"&&t.test(pe)?pe:X(pe)??pe)}const v=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),E=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,V=new Map;function G(de,we){let ve=V.get(we);if(ve===void 0){try{ve=new Intl.DateTimeFormat("en-CA",{timeZone:we,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{ve=null}V.set(we,ve)}if(!ve)return null;const De={};for(const pe of ve.formatToParts(de))pe.type!=="literal"&&(De[pe.type]=pe.value);return De}function q(de,we){if(de==null||de==="")return null;if(typeof de=="string"){const oe=E.exec(de.trim());if(oe)return Date.UTC(+oe[1],+oe[2]-1,+oe[3],+(oe[4]||0),+(oe[5]||0),+(oe[6]||0),+(oe[7]||"0").padEnd(3,"0"))}const ve=x(de);if(!ve)return null;const De=ve.getUTCMilliseconds(),pe=we?G(ve,we):null;return pe?Date.UTC(+pe.year,+pe.month-1,+pe.day,pe.hour==="24"?0:+pe.hour,+pe.minute,+pe.second,De):Date.UTC(ve.getFullYear(),ve.getMonth(),ve.getDate(),ve.getHours(),ve.getMinutes(),ve.getSeconds(),De)}function M(de,we){const ve=typeof de.timeZone=="string"&&de.timeZone?de.timeZone:void 0,De=be=>q(be,ve),pe=Array.isArray(de.value)?de.value.map(De):De(de.value),oe=O({...de,type:"number",value:pe},we);return be=>oe(q(be))}function O(de,we){const ve=de&&de.op,De=!!(de&&de.caseSensitive),pe=de&&de.type,oe=h(we),be=fe=>le=>!fe(le);switch(ve){case"eq":{const fe=i(de.value,pe);return le=>c(le,fe,De)}case"ne":{const fe=i(de.value,pe);return le=>!c(le,fe,De)}case"lt":case"lte":case"gt":case"gte":{const fe=i(de.value,pe);if(g(fe))return()=>!1;const le=ve==="lt"?-1:ve==="lte"?0:ve==="gt"?1:2;return ye=>{if(g(ye))return!1;const Ne=oe(ye,fe);return le===-1?Ne<0:le===0?Ne<=0:le===1?Ne>0:Ne>=0}}case"between":case"notBetween":{const fe=_(de.value),le=i(fe[0],pe),ye=i(fe[1],pe),Ne=de.bounds||"[]",je=Ne.charAt(0)!=="(",$e=Ne.charAt(1)!==")";if(g(le)||g(ye))return ve==="between"?()=>!1:()=>!0;const Re=Se=>{if(g(Se))return!1;const Ve=oe(Se,le),Fe=oe(Se,ye);return(je?Ve>=0:Ve>0)&&($e?Fe<=0:Fe<0)};return ve==="between"?Re:be(Re)}case"in":case"notIn":{const fe=y(de.value,De,pe),le=ye=>fe.has(l(ye,De));return ve==="in"?le:be(le)}case"contains":case"notContains":{const fe=p(i(de.value,pe),De),le=ye=>ye==null?!1:p(ye,De).includes(fe);return ve==="contains"?le:be(le)}case"startsWith":{const fe=p(i(de.value,pe),De);return le=>le==null?!1:p(le,De).startsWith(fe)}case"endsWith":{const fe=p(i(de.value,pe),De);return le=>le==null?!1:p(le,De).endsWith(fe)}case"matches":{const fe=m(de.value,De);return fe?le=>le==null?!1:fe.test(String(le)):()=>!1}case"blank":case"notBlank":{const fe=de.trim===!0,le=ye=>P(ye)||Array.isArray(ye)&&ye.length===0||fe&&typeof ye=="string"&&ye.trim()==="";return ve==="blank"?le:ye=>!le(ye)}case"containsAny":case"containsNone":{const fe=y(de.value,De,pe),le=ye=>{const Ne=ye==null?[]:_(ye);for(let je=0;je<Ne.length;je++)if(fe.has(l(Ne[je],De)))return!0;return!1};return ve==="containsAny"?le:be(le)}case"containsAll":{const fe=_(de.value).map(le=>l(i(le,pe),De));return le=>{const ye=le==null?[]:_(le);if(fe.length===0)return!0;const Ne=new Set(ye.map(je=>l(je,De)));for(let je=0;je<fe.length;je++)if(!Ne.has(fe[je]))return!1;return!0}}default:{const fe=ke(ve);return fe?fe.compile(de.value):(Z(`op:${String(ve)}`,`unknown filter operator "${String(ve)}"; the condition is refused rather than matching every row`),()=>!1)}}}function T(de,we,ve){return w(we,ve)(de)}const A=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),N=new Set(["containsAny","containsAll","containsNone"]);function C(de,we,ve){const De=de&&de.op,pe=A[De]||De,oe=w({...de,op:pe,type:we.type},ve),be=we.items,fe=le=>{const ye=be(le);if(!ye)return!1;for(let Ne=0;Ne<ye.length;Ne++)if(oe(ye[Ne]))return!0;return!1};return A[De]?le=>!fe(le):fe}function S(de,we,ve,De,pe){const oe=pe?null:a(de);if(oe){const le=we?1:0;for(let ye=0;ye<De;ye++)ve[ye]=oe(ye)===le?1:0;return ve}const be=de.kind;if(be==="float64"||be==="int32"||be==="bitset")return s(ve,De,we?1:0);const fe=r(de);for(let le=0;le<De;le++){const ye=fe(le),Ne=P(ye)||Array.isArray(ye)&&ye.length===0||pe&&typeof ye=="string"&&ye.trim()==="";ve[le]=Ne===we?0:1}return ve}function F(de,we,ve,De){const pe=de.dict,oe=k(pe),be=new Uint8Array(oe);for(let Ne=0;Ne<oe;Ne++)be[Ne]=we(b(pe,Ne))?1:0;const fe=de.values,le=a(de);if(!le){for(let Ne=0;Ne<De;Ne++)ve[Ne]=be[fe[Ne]];return ve}const ye=we(null)?1:0;for(let Ne=0;Ne<De;Ne++)ve[Ne]=le(Ne)===1?be[fe[Ne]]:ye;return ve}function $(de,we,ve,De){const pe=j(de.values),oe=we(!0)?1:0,be=we(!1)?1:0,fe=a(de);if(!fe){for(let ye=0;ye<De;ye++)ve[ye]=pe(ye)===1?oe:be;return ve}const le=we(null)?1:0;for(let ye=0;ye<De;ye++)ve[ye]=fe(ye)===0?le:pe(ye)===1?oe:be;return ve}function W(de,we,ve,De,pe){const oe=de.values,be=we.type,fe=we.op;let le=!0;switch(fe){case"eq":case"ne":{const Ne=f(i(we.value,be)),je=typeof we.value=="number"&&Number.isNaN(we.value),$e=fe==="ne"?1:0;if(je)for(let Re=0;Re<pe;Re++)De[Re]=(Number.isNaN(oe[Re])?1:0)^$e;else for(let Re=0;Re<pe;Re++)De[Re]=(oe[Re]===Ne?1:0)^$e;break}case"lt":{const Ne=f(i(we.value,be));for(let je=0;je<pe;je++)De[je]=oe[je]<Ne?1:0;break}case"lte":{const Ne=f(i(we.value,be));for(let je=0;je<pe;je++)De[je]=oe[je]<=Ne?1:0;break}case"gt":{const Ne=f(i(we.value,be));for(let je=0;je<pe;je++)De[je]=oe[je]>Ne?1:0;break}case"gte":{const Ne=f(i(we.value,be));for(let je=0;je<pe;je++)De[je]=oe[je]>=Ne?1:0;break}case"between":case"notBetween":{const Ne=_(we.value),je=f(i(Ne[0],be)),$e=f(i(Ne[1],be)),Re=we.bounds||"[]",Se=Re.charAt(0)!=="(",Ve=Re.charAt(1)!==")",Fe=fe==="notBetween"?1:0;if(Se&&Ve)for(let Ce=0;Ce<pe;Ce++)De[Ce]=(oe[Ce]>=je&oe[Ce]<=$e?1:0)^Fe;else if(Se)for(let Ce=0;Ce<pe;Ce++)De[Ce]=(oe[Ce]>=je&oe[Ce]<$e?1:0)^Fe;else if(Ve)for(let Ce=0;Ce<pe;Ce++)De[Ce]=(oe[Ce]>je&oe[Ce]<=$e?1:0)^Fe;else for(let Ce=0;Ce<pe;Ce++)De[Ce]=(oe[Ce]>je&oe[Ce]<$e?1:0)^Fe;break}case"in":case"notIn":{const Ne=new Set;for(const $e of _(we.value)){const Re=f(i($e,be));Number.isNaN(Re)||Ne.add(Re)}const je=fe==="notIn"?1:0;for(let $e=0;$e<pe;$e++)De[$e]=(Ne.has(oe[$e])?1:0)^je;break}default:le=!1;break}if(!le)return!1;const ye=a(de);if(ye){const Ne=ve(null)?1:0;for(let je=0;je<pe;je++)ye(je)===0&&(De[je]=Ne)}return!0}function K(de,we,ve,De){const pe=r(de);for(let oe=0;oe<De;oe++)ve[oe]=we(pe(oe))?1:0;return ve}function I(de,we,ve){const De=we.count|0,pe=ve||u(we,De);if(!de)return s(pe,De,1);const oe=typeof we.handle=="function"?we.handle(de.col):void 0,be=typeof we.custom=="function"?we.custom:null;if(!oe){if(be){for(let Ne=0;Ne<De;Ne++)pe[Ne]=be(de,Ne)?1:0;return pe}return Z(`filter:col:${String(de.col)}`,`filter references unknown column "${String(de.col)}"; the condition is refused rather than matching every row`),s(pe,De,0)}const fe=de.op;if(fe==="blank"||fe==="notBlank")return S(oe,fe==="notBlank",pe,De,de.trim===!0);const le=typeof we.itemwise=="function"?we.itemwise(de.col):null;if(le&&!ke(fe)&&!N.has(fe))return K(oe,C(de,le,we.locale),pe,De);const ye=w(de,we.locale);switch(oe.kind){case"dictionary":return F(oe,ye,pe,De);case"bitset":return $(oe,ye,pe,De);case"float64":case"int32":return W(oe,de,ye,pe,De)?pe:K(oe,ye,pe,De);default:return K(oe,ye,pe,De)}}function B(de,we,ve){if(!de)return s(u(we,ve),ve,1);if(Array.isArray(de.conditions)){const De=de.conditions.filter(be=>be!=null),pe=de.op==="or"?"or":de.op==="not"?"not":"and";if(De.length===0)return s(u(we,ve),ve,1);const oe=B(De[0],we,ve);for(let be=1;be<De.length;be++){const fe=B(De[be],we,ve);if(pe==="or")for(let le=0;le<ve;le++)oe[le]|=fe[le];else for(let le=0;le<ve;le++)oe[le]&=fe[le];d(we,fe)}if(pe==="not")for(let be=0;be<ve;be++)oe[be]^=1;return oe}return I(de,we,u(we,ve))}function J(de,we){return B(de,we,we.count|0)}function te(de,we){if(!de||!we)return de||null;const ve=de;if(Array.isArray(ve.conditions)){if((ve.op==="or"?"or":ve.op==="not"?"not":"and")!=="and")return Q(ve,we)?null:de;const pe=[];for(const oe of ve.conditions){const be=te(oe,we);be&&pe.push(be)}return pe.length?{...ve,op:"and",conditions:pe}:null}return ve.col===we?null:de}function Q(de,we){if(!de||typeof de!="object")return!1;const ve=de;if(ve.col===we)return!0;if(Array.isArray(ve.conditions)){for(const De of ve.conditions)if(Q(De,we))return!0}return!1}function re(de,we,ve){if(ve&&ve.length>=we){let be=0;for(let fe=0;fe<we;fe++)de[fe]&&(ve[be++]=fe);return ve.subarray(0,be)}let De=0;for(let be=0;be<we;be++)De+=de[be]?1:0;const pe=new Uint32Array(De);let oe=0;for(let be=0;be<we;be++)de[be]&&(pe[oe++]=be);return pe}const ie=new Map;function ue(de){if(!(!de||typeof de!="object"))for(const[we,ve]of Object.entries(de))ve&&typeof ve.compile=="function"&&ie.set(we,ve)}function ke(de){return typeof de=="string"?ie.get(de):void 0}}),We("packages/core/src/columns/datatypes.js",function(e,D){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return C}});const ne=D("packages/core/src/internal/compare.js"),P=ne.collator,Y=ne.defaultCompare,_=D("packages/core/src/internal/predicates.js"),L=_.isNil,Z=_.isObject,H=_.isFunction,X=D("packages/core/src/internal/warn.js").fail,j=D("packages/core/src/internal/text.js").titleCase,k=D("packages/core/src/format/date.js"),b=k.toDate,a=k.toIsoDate,h=k.compareIso,t=D("packages/core/src/format/boolean.js").toTriState,u=D("packages/core/src/columns/types/index.js").EXTENDED_TYPES,d=D("packages/core/src/formula/index.js"),s=d.evaluateFormula,g=d.looksLikeFormula,n=D("packages/core/src/compute/filter.js").declareOperators,f=/^\d{4}-\d{2}-\d{2}$/;function p(S){return S.getHours()===0&&S.getMinutes()===0&&S.getSeconds()===0&&S.getMilliseconds()===0}const l=new Map;function y(S){const F=S||"",$=l.get(F);if($)return $;const W={group:",",decimal:"."};try{for(const K of new Intl.NumberFormat(S||void 0).formatToParts(12345.6))K.type==="group"?W.group=K.value:K.type==="decimal"&&(W.decimal=K.value)}catch{}return l.set(F,W),W}const c=/\d\s*[*/^]\s*[\d.(]/;function m(S,F){if(L(S))return null;let $=String(S).trim();if($===""||$.startsWith("=")||c.test($))return null;let W=1;$.startsWith("(")&&$.endsWith(")")&&(W=-1,$=$.slice(1,-1));const K=$.endsWith("%"),{group:I,decimal:B}=y(F);if($=$.replace(/[\s\u00a0\u202f\u2009']/g,""),I&&I!=="."&&I!==","&&($=$.split(I).join("")),$=$.replace(/[^0-9eE+\-.,]/g,""),B===","?$=$.split(".").join("").replace(",","."):$=$.split(",").join(""),$===""||$==="-"||$==="+")return null;const J=Number($);return Number.isNaN(J)?null:W*(K?J/100:J)}function w(S,F){const $=L(S)||Number.isNaN(S)?null:Number(S),W=L(F)||Number.isNaN(F)?null:Number(F);return $===null?W===null?0:1:W===null||$<W?-1:$>W?1:0}function v(S,F){const $=t(S),W=t(F);return $===null?W===null?0:1:W===null?-1:$===W?0:$?1:-1}function E(S,F){const $=b(S),W=b(F);if(!$)return W?1:0;if(!W)return-1;const K=$.getTime(),I=W.getTime();return K<I?-1:K>I?1:0}const V=new Map;function G(S){const F=b(S.value);if(!F)return"";const $=S.locale||"";let W=V.get($);return W||(W=new Intl.DateTimeFormat(S.locale||void 0,{dateStyle:"medium"}),V.set($,W)),W.format(F)}const q={boolean:{base:"boolean",storage:"bitset",matches:S=>typeof S=="boolean",parse:S=>t(S.text),compare:v,format:S=>t(S.value)===null?"":t(S.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:S=>t(S)===null?"":String(t(S)),fromClipboard:S=>t(S)},number:{base:"number",storage:"float64",matches:S=>typeof S=="number"&&!Number.isNaN(S),parse:S=>{if(g(S.text)){const F=s(S.text,S);if(!F.ok)return null;const $=Number(F.value);return Number.isFinite($)?$:null}return m(S.text,S.locale)},compare:w,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:S=>L(S)?"":String(S),fromClipboard:(S,F)=>m(S,F&&F.locale)},date:{base:"dateString",storage:"dictionary",matches:S=>typeof S=="string"&&f.test(S)&&!Number.isNaN(Date.parse(S))||S instanceof Date&&!Number.isNaN(S.getTime())&&p(S),parse:S=>a(S.text),compare:h,format:G,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:S=>a(S),toClipboard:S=>L(S)?"":String(S),fromClipboard:S=>a(S)},dateString:{base:"dateString",storage:"dictionary",matches:S=>typeof S=="string"&&f.test(S)&&!Number.isNaN(Date.parse(S)),parse:S=>a(S.text),compare:h,format:G,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:S=>a(S),toClipboard:S=>L(S)?"":String(S),fromClipboard:S=>a(S)},text:{base:"text",storage:"dictionary",matches:S=>typeof S=="string",parse:S=>S.text===""?null:String(S.text),compare:(S,F)=>L(S)?L(F)?0:1:L(F)?-1:P().compare(String(S),String(F)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:S=>L(S)?"":String(S),fromClipboard:S=>S},image:{base:"text",storage:"dictionary",parse:S=>S.text===""||S.text==null?null:String(S.text).trim(),compare:(S,F)=>L(S)?L(F)?0:1:L(F)?-1:P().compare(String(S),String(F)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:S=>L(S)?"":String(S),fromClipboard:S=>S},lookup:{base:"text",storage:"dictionary",parse:S=>{if(S.text===""||S.text==null)return null;const F=S.column&&S.column.lookup,$=F&&H(F.options)?F.options():null;if(!$)return S.text;const W=String(S.text),K=$.find(J=>String(J.id)===W);if(K)return K.id;const I=W.trim().toLowerCase(),B=$.find(J=>String(J.label).toLowerCase()===I);return B?B.id:S.text},compare:Y,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:S=>L(S)?"":String(S),fromClipboard:S=>S},object:{base:"object",storage:"object",matches:S=>S!==null&&typeof S=="object"&&!(S instanceof Date),parse:S=>{try{return S.text===""?null:JSON.parse(S.text)}catch{return S.text}},compare:(S,F)=>Y(S,F),format:S=>{const F=S.value;if(L(F))return"";if(typeof F=="string")return F;try{return JSON.stringify(F)}catch{return String(F)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:S=>L(S)?"":typeof S=="string"?S:JSON.stringify(S),fromClipboard:S=>S}},M=["boolean","number","date","dateString","datetime","text","object"];function O(S,F,$,W){const K=$.get(S);if(K)return K;W.includes(S)&&X(`circular data type extends chain: ${[...W,S].join(" → ")}`);const I=F[S];I||X(`unknown data type "${S}"`);let B=null;I.extends&&(B=O(I.extends,F,$,[...W,S]));const J={...B||{},...I,name:S,defaults:{...B&&B.defaults||{},...I.defaults||{}}};return J.base||(J.base=B&&B.base||"text"),J.storage||(J.storage=B&&B.storage||"object"),$.set(S,J),J}function T(S,F){const $={...q,...u};if(F&&typeof F.dataType=="function"&&typeof F.names=="function")for(const K of F.names("dataType")){const I=F.dataType(K);I&&($[K]=I)}if(Z(S))for(const[K,I]of Object.entries(S))$[K]=I;const W=new Map;for(const K of M)O(K,$,W,[]);O("lookup",$,W,[]);for(const K of Object.keys($))O(K,$,W,[]);for(const K of W.values())n(K.operators);return W}function A(S,F){if(S.base==="text"&&(!S.compare||S.compare===q.text.compare)){const $=P(F);return(W,K)=>L(W)?L(K)?0:1:L(K)?-1:$.compare(String(W),String(K))}return S.compare||Y}function N(S,F){return F?S.multiStorage||"multi":S.storage||"object"}function C(S){return j(String(S).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),We("packages/core/src/columns/infer.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return H}});const P=D("packages/core/src/internal/warn.js").infoOnce,_=D("packages/core/src/internal/predicates.js").isNil,L=100;function Z(x,X,U={}){const j=U.sampleSize??L,k=[];for(let b=0;b<x.length&&k.length<j;b++){const a=x[b];_(a)||typeof a=="number"&&Number.isNaN(a)||k.push(a)}if(k.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[b,a]of X){if(typeof a.matches!="function")continue;let h=!0;for(let r=0;r<k.length;r++)if(!a.matches(k[r])){h=!1;break}if(h)return{type:b,unanimous:!0,sampled:k.length}}return U.quiet||P(`infer:${U.colId||"?"}`,`column "${U.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:k.length}}function H(x,X,U,j,k={}){const b=k.sampleSize??L,a=[];for(let h=0;h<X.length&&a.length<b;h++){const r=U(X[h]);_(r)||typeof r=="number"&&Number.isNaN(r)||a.push(r)}return Z(a,j,{...k,colId:x}).type}}),We("packages/core/src/columns/graph.js",function(e,D){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return j}});const ne=D("packages/core/src/internal/warn.js"),P=ne.DEV,Y=ne.fail,_=ne.warnOnce,Z=D("packages/core/src/internal/predicates.js").isFunction,H="*";function x(k){const b=k.value||{};if(!Z(b.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const h=b.pure!==!1;return b.deps===H?{computed:!0,wholeRow:!0,deps:[],pure:h}:Array.isArray(b.deps)?{computed:!0,wholeRow:!1,deps:b.deps.slice(),pure:h}:(_(`deps:missing:${k.id}`,`computed column "${k.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:h})}function X(k){const b=new Map;for(const f of k)b.set(f.id,f);const a=new Map,h=new Map,r=new Set,t=new Set,o=new Set,u=new Set;for(const f of k){const p=x(f);if(!p.computed){a.set(f.id,[]);continue}t.add(f.id),(p.pure?o:u).add(f.id),p.wholeRow&&r.add(f.id);const l=[],y=[];for(const c of p.deps)(b.has(c)?l:y).push(c);a.set(f.id,l),y.length&&h.set(f.id,y)}for(const f of o)for(const p of a.get(f))u.has(p)&&Y(`pure computed column "${f}" depends on impure column "${p}". Mark it \`value.pure: false\` or make the dependency pure.`);const d=[],s=new Map,g=[],i=f=>{const p=s.get(f);if(p!=="done"){if(p==="open"){const l=g.indexOf(f);Y(`circular column dependency: ${[...g.slice(l),f].join(" → ")}`)}s.set(f,"open"),g.push(f);for(const l of a.get(f)||[])b.has(l)&&i(l);g.pop(),s.set(f,"done"),d.push(f)}};for(const f of k)i(f.id);const n=new Map;for(const f of k)n.set(f.id,[]);for(const f of k)for(const p of a.get(f.id)||[]){const l=n.get(p);l&&!l.includes(f.id)&&l.push(f.id)}if(r.size)for(const f of k){if(t.has(f.id))continue;const p=n.get(f.id);for(const l of r)p.includes(l)||p.push(l)}return{order:d,dependents:n,pure:o,impure:u,computed:t,deps:a,wholeRow:r,external:h,index:b}}function U(k,b){const a=Array.isArray(b)?b:[b],h=new Set,r=[...a];for(;r.length;){const t=r.shift();for(const o of k.dependents.get(t)||[])h.has(o)||(h.add(o),r.push(o))}for(const t of a)h.delete(t);return k.order.filter(t=>h.has(t))}function j(k,b,a){if(!P)return k;const h=b instanceof Set?b:new Set(b);return new Proxy(k,{get(r,t){return typeof t=="string"&&!h.has(t)&&!Object.hasOwn(r,t)&&_(`undeclared:${a}:${t}`,`computed column "${a}" read undeclared dependency "${t}". Add it to \`value.deps\` or the value will go stale.`),r[t]}})}}),We("packages/core/src/model/rowkey.js",function(e,D){"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 k}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return t}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/internal/paths.js").pathGetter,L=D("packages/core/src/internal/predicates.js"),Z=L.isFunction,H=L.isBlank,x=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],X="";function U(o){if(o===null)return"\0n";if(o===void 0)return"\0u";const u=typeof o;if(u==="string")return o;if(u==="number"||u==="bigint"||u==="boolean")return String(o);if(o instanceof Date)return`\0d${o.getTime()}`;try{return`\0o${JSON.stringify(o)}`}catch{return"\0o?"}}function j(o){if(o.length===1)return U(o[0]);let u="";for(let d=0;d<o.length;d++)d&&(u+=X),u+=U(o[d]);return u}function k(o,u={}){const d=u.warn!==!1;if(Z(o)){const s=o;return{stable:!0,fields:[],disabled:[],key(g,i){try{const n=s(g);return Array.isArray(n)?j(n):U(n)}catch(n){return P("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",n),`#${i??-1}`}},keyEmpty(g){try{const i=s(g);return Array.isArray(i)?i.length===0||i.some(H):H(i)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(o)&&o.length>0){const s=o.filter(n=>typeof n=="string"),g=s.map(n=>_(n)),i=g.length;return{stable:!0,fields:s,disabled:[],key(n){const f=new Array(i);for(let p=0;p<i;p++)f[p]=g[p](n);return j(f)},keyEmpty(n){for(let f=0;f<i;f++)if(H(g[f](n)))return!0;return!1},missingFields(n){const f=[];for(let p=0;p<i;p++)H(g[p](n))&&f.push(s[p]);return f}}}if(typeof o=="string"&&o.length>0){const s=_(o);return{stable:!0,fields:[o],disabled:[],key(g){return U(s(g))},keyEmpty(g){return H(s(g))},missingFields(g){return H(s(g))?[o]:[]}}}return d&&P("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(s,g){if(s===null||typeof s!="object")return`#${g??0}:${String(s)}`;let i=b.get(s);return i===void 0&&(i=`#${a++}`,b.set(s,i)),i}}}const b=new WeakMap;let a=0;function h(o,u){if(!o||o.stable===!1||!Z(o.keyEmpty)||!Array.isArray(u)||u.length===0)return;let d=0,s=null,g;for(let p=0;p<u.length;p++){const l=u[p];o.keyEmpty(l)&&(d++,s===null&&(s=Z(o.missingFields)?o.missingFields(l):[],g=l))}if(d===0)return;const i=o.fields.length?o.fields.join(","):"(function)",n=s&&s.length?s.join(", "):o.fields.length?o.fields.join(", "):"the rowKey function",f=g!==null&&typeof g=="object"?Object.keys(g).join(", ")||"(no fields)":String(g);P(`rowKey.emptyValue:${i}`,`rowKey ${n} is missing on ${d} of ${u.length} rows; the first such row has: ${f}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function r(o){return j(o)}function t(o){return o.split(X)}}),We("packages/core/src/columns/lookup.js",function(e,D){"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 a}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return o}});const ne=D("packages/core/src/internal/compare.js"),P=ne.collator,Y=ne.defaultCompare,_=D("packages/core/src/internal/predicates.js"),L=_.isFunction,Z=_.isNil,x=D("packages/core/src/internal/warn.js").warnOnce,U=D("packages/core/src/model/rowkey.js").compositeKey,j=", ",k="";function b(u,d,s,g){if(u===null||typeof u!="object")return{id:u,label:u==null?"":String(u)};const i=u[d],n=u[s],f={id:i,label:n==null?String(i??""):String(n)};u.disabled&&(f.disabled=!0),u.variant&&(f.variant=u.variant),u.icon&&(f.icon=u.icon);const p=g?u[g]:u.group;return p!==void 0&&(f.group=p),f}function a(u,d,s=0,g=[],i=[]){for(const n of u||[]){const f=n&&typeof n=="object"?n[d]:null;if(i.push({raw:n,depth:s,path:g}),Array.isArray(f)&&f.length){const p=String(n&&typeof n=="object"?n.label??n.name??n.id??"":n);a(f,d,s+1,[...g,p],i)}}return i}function h(u){return!!u&&typeof u=="object"&&!Array.isArray(u)&&L(u.router&&u.router.subscribe)}class r{#e;#t;#n;#r;#s=[];#i=new Map;#o=new Map;#l=0;#a="idle";#c=null;#u;#d=null;#f=new Map;constructor(d,s={}){this.#e=d||{},this.#t=s.colId||"?",this.#n=s.locale,this.#r=s.onChange||null,this.#u=P(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.#s}setLocale(d){this.#n=d,this.#u=P(d)}#h(d){const s=this.#e,g=s.valueKey||"id",i=s.labelKey||"label",n=s.childrenKey||"children";this.#s=a(d,n).map(f=>{const p=b(f.raw,g,i,s.groupKey);return f.depth&&(p.depth=f.depth,p.path=f.path),p}),this.#i=new Map,this.#o=new Map,this.#s.forEach((f,p)=>{this.#i.set(f.id,f),this.#o.set(f.id,p)}),this.#a="ready",this.#l+=1}load(){if(this.#c)return this.#c;const d=this.#e.options;if(Array.isArray(d)||d===void 0)return this.#c=Promise.resolve(this.#s),this.#c;if(h(d))return this.#c=this.#p(d),this.#c;if(!L(d))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 s;try{s=d()}catch(g){return this.#a="error",x(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,g),this.#c=Promise.resolve([]),this.#c}return!s||!L(s.then)?(this.#h(s),this.#c=Promise.resolve(this.#s),this.#r&&this.#r(this),this.#c):(this.#c=s.then(g=>(this.#h(g),this.#r&&this.#r(this),this.#s),g=>(this.#a="error",x(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,g),[])),this.#c)}refresh(){return this.#c=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#s)):this.load()}#p(d){if(this.#d)return Promise.resolve(this.#s);const s=this.#e,g=s.valueKey||"id",i=s.labelKey||"label",n=s.groupKey,f=L(d.map)?d.map:null,p=y=>b(f?f(y):y,g,i,n).id,l=y=>this.#m(y,f,g,i,n);return d.router.subscribe(d.predicate,l,{rowKey:p}),this.#d=()=>{L(d.router.detach)&&d.router.detach(l)},this.#a="ready",Promise.resolve(this.#s)}#m(d,s,g,i,n){const f=d&&d.add||[],p=d&&d.update||[],l=d&&d.remove||[];if(!(!f.length&&!p.length&&!l.length)){for(const y of f)this.#g(y,s,g,i,n);for(const y of p)this.#g(y,s,g,i,n);for(const y of l){if(!this.#f.has(y))continue;const c=this.#f.get(y);this.#f.delete(y),this.#i.delete(c);const m=this.#s.findIndex(w=>w.id===c);m>=0&&this.#s.splice(m,1)}this.#o=new Map(this.#s.map((y,c)=>[y.id,c])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(d,s,g,i,n){const f=b(s?s(d):d,g,i,n);this.#f.set(U([f.id]),f.id);const p=this.#s.findIndex(l=>l.id===f.id);p>=0?this.#s[p]=f:this.#s.push(f),this.#i.set(f.id,f)}destroy(){this.#d&&(this.#d(),this.#d=null)}search(d,s){const g=this.#e;if(!L(g.search)){const f=String(d||"").toLowerCase();return Promise.resolve(f===""?this.#s:this.#s.filter(p=>p.label.toLowerCase().includes(f)))}const i=g.valueKey||"id",n=g.labelKey||"label";return Promise.resolve(g.search(d,s)).then(f=>(f||[]).map(p=>b(p,i,n,g.groupKey)))}option(d){return this.#i.get(d)}has(d){return this.#i.has(d)}label(d){if(Z(d)||d==="")return"";const s=this.#i.get(d);if(s)return s.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||x(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(d)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const g=this.#e.unknownLabel;return L(g)?String(g(d)??""):typeof g=="string"?g:String(d)}text(d){if(this.multiple){const s=t(d);return s.length===0?"":s.map(g=>this.label(g)).join(this.separator)}return this.label(d)}dictionary(){return this.#s.map(d=>d.id)}sorted(){const d=this.sortBy;if(d==="optionOrder"||d==="count")return this.#s.slice();if(d==="value")return this.#s.slice().sort((g,i)=>Y(g.id,i.id));const s=this.#u;return this.#s.slice().sort((g,i)=>s.compare(g.label,i.label))}comparator(){const d=this.sortBy,s=this.multiple,g=this.#u,i=this.#o;if(s&&d==="count")return(f,p)=>t(f).length-t(p).length;const n=s?f=>t(f)[0]:f=>f;return d==="value"?(f,p)=>Y(n(f),n(p)):d==="optionOrder"?(f,p)=>{const l=i.has(n(f))?i.get(n(f)):Number.MAX_SAFE_INTEGER,y=i.has(n(p))?i.get(n(p)):Number.MAX_SAFE_INTEGER;return l-y}:(f,p)=>{const l=n(f),y=n(p);return Z(l)?Z(y)?0:1:Z(y)?-1:g.compare(this.label(l),this.label(y))}}groupKey(d){return this.multiple?t(d).map(g=>String(g)).sort().join(k):Z(d)?"":String(d)}countValues(d){return this.multiple?t(d).length:Z(d)?0:1}contains(d,s,g){const i=this.multiple?t(d):Z(d)?[]:[d],n=Array.isArray(s)?s:[s];switch(g){case"containsAll":return n.every(f=>i.includes(f));case"containsNone":return!n.some(f=>i.includes(f));default:return n.some(f=>i.includes(f))}}exportText(d,s="label"){return s==="value"?this.multiple?t(d).join(this.separator):Z(d)?"":String(d):this.text(d)}exportColumns(){const d=this.multiple;return this.#s.map(s=>({id:s.id,label:s.label,has:g=>d?t(g).includes(s.id):g===s.id}))}}function t(u){return Array.isArray(u)?u:Z(u)||u===""?[]:[u]}function o(u,d={}){const s=u.lookup;if(!s)return null;const g=new r(s,{colId:u.id,locale:d.locale,onChange:d.onChange});return!Array.isArray(s.options)&&s.options!==void 0&&g.load(),g}}),We("packages/core/src/columns/value.js",function(e,D){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return u}});const P=D("packages/core/src/internal/paths.js").getPath,Y=D("packages/core/src/internal/predicates.js"),_=Y.isFunction,L=Y.isNil,Z=Y.isObject,x=D("packages/core/src/internal/lru.js").Lru,U=D("packages/core/src/internal/warn.js").warnOnce,k=D("packages/core/src/format/number.js").compileNumber,a=D("packages/core/src/columns/graph.js").depsProxy,h="\0";function r(i,n={}){const f=n.locale,p=n.grid??null,l=n.context,y=i.value&&i.value.format,c=i.formatter||null,m=i.dataType&&i.dataType.format,w=i.lookup||null,v=(E,V,G)=>({value:E,data:G,row:V,column:i,colId:i.id,grid:p,context:l,locale:f});if(_(y))return(E,V,G)=>{const q=y(v(E,V,G));return q==null?"":String(q)};if(c){if(w){const E=c.kind==="text";return(V,G,q)=>c(E?w.text(V):V,v(V,G,q))}return(E,V,G)=>c(E,v(E,V,G))}if(_(m))return(E,V,G)=>{const q=m(v(E,V,G));return q==null?"":String(q)};if(i.dataType&&i.dataType.base==="number"&&Z(i.typeOptions)&&typeof i.typeOptions.decimals=="number"){const E=k({decimals:i.typeOptions.decimals},f);return V=>E(V)}return w?E=>w.text(E):E=>L(E)?"":typeof E=="string"?E:String(E)}function t(i,n){!i||!i.value||i.value.pure!==!1||U(`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 o{#e;#t;#n;#r;#s;#i;#o=new x(4096);constructor(n){this.#e=n.columns instanceof Map?n.columns:new Map((n.columns||[]).map(f=>[f.id,f])),this.#t=n.graph,this.#n=n.grid??null,this.#r=n.context,this.#i=n.stored||null,this.#s=n.rowKey||u}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 f=n&&n.rows?new Set([...n.rows].map(String)):null,p=n&&n.columns?[...n.columns]:null;if(!f&&!p){this.#o.clear();return}const l=p?this.#l(p):null;for(const y of[...this.#o.keys()]){const c=String(y).split(h);c.length===3&&(f&&!f.has(c[0])||l&&!l.has(c[2])||this.#o.delete(y))}}#l(n){const f=new Set,p=this.#t,l=[...n];for(;l.length;){const y=l.pop();if(!f.has(y)){f.add(y);for(const c of p?p.dependents.get(y)||[]:[])l.push(c)}}return f}value(n,f,p){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return;if(!l.computed)return this.#c(l,f,p);if(l.value.pure!==!1&&this.#i&&p&&p.physical!=null&&this.#i.has(l.id))return this.#i.get(l.id,p.physical);if(l.volatile)return this.compute(l,f,p);if(l.value.pure===!1)return this.compute(l,f,p);const y=`${this.#a(f,p)}${h}${l.id}`;if(this.#o.has(y))return this.#o.get(y);const c=this.compute(l,f,p);return this.#o.set(y,c),c}#a(n,f){return`${this.#s(n,f)}${h}${d(n)}`}#c(n,f,p){if(this.#i&&p&&p.physical!=null&&this.#i.has(n.id))return this.#i.get(n.id,p.physical);if(n.field)return n.read?n.read(f):P(f,n.field)}compute(n,f,p){const l=this.#t,y=l&&l.wholeRow.has(n.id);let c;if(y)c=f??{};else{c={};const w=l&&l.deps.get(n.id)||[];for(const E of w)c[E]=this.value(E,f,p);const v=l&&l.external.get(n.id)||[];for(const E of v)c[E]=P(f,E);c=a(c,[...w,...v],n.id)}const m={data:f,row:p,column:n,grid:this.#n,context:this.#r};return n.value.compute(c,m)}values(n,f){const p={},l=this.#t?this.#t.order:[...this.#e.keys()];for(const y of l)p[y]=this.value(y,n,f);return p}text(n,f,p){const l=typeof n=="string"?this.#e.get(n):n;return l?l.formatValue(this.value(l,f,p),p,f):""}key(n,f,p){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return"";const y=this.value(l,f,p);return _(l.value.key)?String(l.value.key(this.#u(l,y,f,p))):l.lookup?l.lookup.groupKey(y):L(y)?"":String(y)}quickFilterText(n,f,p){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return"";if(_(l.value.quickFilterText)){const y=this.value(l,f,p);return String(l.value.quickFilterText(this.#u(l,y,f,p))??"")}return this.text(l,f,p)}#u(n,f,p,l){return{value:f,data:p,row:l,column:n,colId:n.id,grid:this.#n,context:this.#r}}parse(n,f,p,l){const y=typeof n=="string"?this.#e.get(n):n;if(!y)return f;const c={text:f,value:this.value(y,p,l),data:p,row:l,column:y,grid:this.#n,context:this.#r,locale:this.#n&&_(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&_(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return _(y.value.parse)?y.value.parse(c):y.dataType&&_(y.dataType.parse)?y.dataType.parse(c):f}validate(n,f,p,l,y){const c=typeof n=="string"?this.#e.get(n):n;if(!c||!_(c.edit.validate))return!0;const m=c.edit.validate({value:f,oldValue:p,data:l,row:y,column:c,grid:this.#n,context:this.#r});return m===!0||m===void 0?!0:String(m)}apply(n,f,p,l){const y=typeof n=="string"?this.#e.get(n):n;if(!y)return!1;const c=this.value(y,p,l);if(_(y.value.apply)){const m=y.value.apply({value:f,oldValue:c,data:p,row:l,column:y,grid:this.#n,context:this.#r});return this.#d(y,p,l),m!==!1}return y.field?c===f?!1:(y.write(p,f),this.#d(y,p,l),!0):(U(`apply:${y.id}`,`column "${y.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(n,f,p,l){const y=typeof n=="string"?this.#e.get(n):n;if(!y)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const c=this.value(y,p,l),m=this.parse(y,f,p,l),w=this.validate(y,m,c,p,l);if(w!==!0)return{ok:!1,value:m,oldValue:c,changed:!1,error:w};const v=this.apply(y,m,p,l);return{ok:!0,value:m,oldValue:c,changed:v}}#d(n,f,p){if(this.#o.size===0)return;const l=this.#a(f,p);this.#o.delete(`${l}${h}${n.id}`);for(const y of this.#t?this.#t.dependents.get(n.id)||[]:[])this.#o.delete(`${l}${h}${y}`)}}function u(i,n){return n&&n.key!=null?String(n.key):d(i)}function d(i){if(i&&typeof i=="object"){let n=s.get(i);return n===void 0&&(n=`#${g++}`,s.set(i,n)),n}return String(i)}const s=new WeakMap;let g=0}),We("packages/core/src/model/shadow.js",function(e,D){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"CLUSTER_SHADOW_KINDS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return n}});const P=D("packages/core/src/internal/warn.js").warnOnce,Y=2e5,_=20,L=1e3,Z=50;function H(f){return Math.min(L,Math.max(Z,Math.floor(f)))}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","cluster","clusterDistance"]),X=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),U=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),j=Object.freeze(["cluster","clusterDistance"]),k=.6745,b=3.5,a=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),h=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),r=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",cluster:"Cluster",clusterDistance:"Cluster distance"});function t(f,p){if(!p)return null;const l=Number.isFinite(Number(p.lower))?Number(p.lower):null,y=Number.isFinite(Number(p.upper))?Number(p.upper):null;if(l===null&&y===null||!Number.isFinite(f))return null;if(l!==null&&f<l||y!==null&&f>y)return a.FAIL;const c=Number.isFinite(Number(p.warnLower))?Number(p.warnLower):null,m=Number.isFinite(Number(p.warnUpper))?Number(p.warnUpper):null;return c!==null&&f<c||m!==null&&f>m?a.WARN:a.PASS}function o(f,p,l){if(!p||typeof p!="object")return null;if(p.kind!=="time")return p.kind!==void 0&&P(`shadow.history.window.kind:${f}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${p.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 y=p.minutes!=null?Number(p.minutes)*6e4:Number(p.span);if(!(y>0))return P(`shadow.history.window.span:${f}`,"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 c=Math.max(2,Math.floor(l)||_);return{span:y,bucketMs:Math.max(1,Math.floor(y/c))}}class u{#e;#t=new Map;#n=new Map;#r=new Map;#s=new Map;#i=new Map;#o=new Map;#l=0;#a;#c;#u;#d;#f=new Map;#h=null;#p=null;#m=null;constructor(p){this.#e=p.colId,this.#a=Math.max(2,p.depth||_),this.#c=Math.max(1,p.max||Y),this.#u=p.now||(()=>Date.now()),this.#d=o(this.#e,p.historyWindow,this.#a),this.#d&&(this.#h=Math.floor(this.#u()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(p,l){const y=i(l);if(y===null)return;if(!this.#n.has(p)){this.#p=null,this.#m=null,this.#g(),this.#t.set(p,y),this.#n.set(p,y),this.#r.set(p,0),this.#s.set(p,this.#u()),this.#i.set(p,[y]),this.#d&&this.#f.set(p,[y]),this.#o.set(p,0);return}const c=this.#n.get(p);if(c===y)return;this.#p=null,this.#m=null,this.#n.set(p,y),this.#r.set(p,(this.#r.get(p)||0)+1),this.#s.set(p,this.#u());const m=this.#i.get(p)||[];m.push(y),m.length>this.#a&&m.splice(0,m.length-this.#a),this.#i.set(p,m);const w=Math.sign(y-c),v=this.#o.get(p)||0;this.#o.set(p,Math.sign(v)===w?v+w:w)}#g(){if(this.#n.size<this.#c)return;const p=this.#n.keys().next().value;p!==void 0&&(this.#t.delete(p),this.#n.delete(p),this.#r.delete(p),this.#s.delete(p),this.#i.delete(p),this.#f.delete(p),this.#o.delete(p),this.#l++)}rebase(){for(const[p,l]of this.#n)this.#t.set(p,l);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#s.clear(),this.#i.clear(),this.#f.clear(),this.#o.clear(),this.#l=0,this.#p=null,this.#m=null,this.#d&&(this.#h=Math.floor(this.#u()/this.#d.bucketMs))}retain(p){const l=p instanceof Set?p:new Set(p);let y=0;for(const c of[...this.#n.keys()])l.has(c)||(this.#t.delete(c),this.#n.delete(c),this.#r.delete(c),this.#s.delete(c),this.#i.delete(c),this.#f.delete(c),this.#o.delete(c),y++);return y&&(this.#p=null,this.#m=null),y}advanceHistoryWindow(p=this.#u()){const l=this.#d;if(!l)return 0;const y=Math.floor(p/l.bucketMs),c=y-this.#h;if(!(c>0))return 0;const m=Math.min(c,this.#a);for(const[w,v]of this.#f){const E=this.#n.get(w);for(let V=0;V<m;V++)v.push(E);v.length>this.#a&&v.splice(0,v.length-this.#a)}return this.#h=y,c}read(p,l,y,c){switch(p){case"updates":return this.#r.has(l)?this.#r.get(l):0;case"updatedAt":{const m=this.#s.get(l);return m===void 0?null:new Date(m)}case"sinceUpdate":{const m=this.#s.get(l);return m===void 0?null:this.#u()-m}case"firstValue":return this.#t.has(l)?this.#t.get(l):null;case"delta":return this.#n.has(l)?this.#n.get(l)-this.#t.get(l):null;case"deltaPercent":{if(!this.#n.has(l))return null;const m=this.#t.get(l);return m?(this.#n.get(l)-m)/Math.abs(m)*100:null}case"rate":{const m=this.#i.get(l),w=this.#s.get(l);if(!m||m.length<2||w===void 0)return null;const v=this.#u()-w,E=m[m.length-1]-m[m.length-2];return v>0?E/v*1e3:E}case"history":return this.#d?this.#f.has(l)?[...this.#f.get(l)]:null:this.#i.has(l)?[...this.#i.get(l)]:null;case"streak":return this.#o.has(l)?this.#o.get(l):0;case"specStatus":return this.#n.has(l)?t(this.#n.get(l),c):null;default:return h.includes(p)?this.#O(p,l,y,c):null}}#b(p){if(p){if(this.#m&&this.#m.only===p)return this.#m.view;const l=this.#y(p);return this.#m={only:p,view:l},l}return this.#p?this.#p:(this.#p=this.#y(null),this.#p)}#y(p){const l=[];for(const[M,O]of this.#n)p&&!p.has(M)||l.push(O);const y=l.sort((M,O)=>M-O);let c=0,m=0,w=0,v=0;for(const M of y){v+=M,c++;const O=M-m;m+=O/c,w+=O*(M-m)}const E=[];for(const[M,O]of this.#t)p&&!p.has(M)||E.push(O);const V=c?d(y):0,G=y.map(M=>Math.abs(M-V)).sort((M,O)=>M-O),q=c?d(G):0;return{sorted:y,baseline:E.sort((M,O)=>M-O),sum:v,mean:c?m:0,sd:c>1?Math.sqrt(w/(c-1)):0,median:V,mad:q}}#O(p,l,y,c){if(!this.#n.has(l)||y&&!y.has(l))return null;const m=this.#n.get(l),w=this.#b(y),v=w.sorted.length;if(!v)return null;switch(p){case"rank":return v-g(w.sorted,m)+1;case"rankAsc":return s(w.sorted,m)+1;case"rankChange":{if(!this.#t.has(l)||!w.baseline.length)return null;const E=w.baseline.length-g(w.baseline,this.#t.get(l))+1,V=v-g(w.sorted,m)+1;return E-V}case"percentile":return g(w.sorted,m)/v*100;case"quartile":{const E=g(w.sorted,m)/v;return Math.min(4,Math.max(1,Math.ceil(E*4)))}case"zScore":return w.sd?(m-w.mean)/w.sd:null;case"anomalyScore":return w.mad?k*(m-w.median)/w.mad:null;case"anomalyFlag":{if(!w.mad)return null;const E=c&&Number.isFinite(Number(c.threshold))?Number(c.threshold):b;return Math.abs(k*(m-w.median)/w.mad)>E}case"shareOfTotal":return w.sum?m/w.sum*100:null;default:return null}}}function d(f){const p=f.length;if(!p)return 0;const l=(p-1)*.5,y=Math.floor(l),c=Math.ceil(l);return y===c?f[y]:f[y]+(l-y)*(f[c]-f[y])}function s(f,p){let l=0,y=f.length;for(;l<y;){const c=l+y>>1;f[c]<p?l=c+1:y=c}return l}function g(f,p){let l=0,y=f.length;for(;l<y;){const c=l+y>>1;f[c]<=p?l=c+1:y=c}return l}function i(f){if(f==null||f==="")return null;if(f instanceof Date){const l=f.getTime();return Number.isFinite(l)?l:null}const p=typeof f=="number"?f:Number(f);return Number.isFinite(p)?p:null}function n(f){const p=[];for(const l of f||[]){const y=l.shadow;if(!y)continue;const c=typeof y=="string"?{kind:y}:y,m=c.kind;x.includes(m)&&(X.includes(m)||U.includes(m)||j.includes(m)||p.push({colId:l.id||l.field,of:c.of||l.field||l.id,kind:m,depth:c.depth,historyWindow:m==="history"?c.window:void 0}))}return p}}),We("packages/core/src/columns/model.js",function(e,D){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return ve}});const ne=D("packages/core/src/internal/merge.js"),P=ne.expand,Y=ne.merge,_=ne.toArray,L=D("packages/core/src/internal/warn.js"),Z=L.fail,H=L.warnOnce,x=D("packages/core/src/internal/paths.js"),X=x.getPath,U=x.pathGetter,j=x.pathSetter,b=D("packages/core/src/internal/text.js").humanise,a=D("packages/core/src/internal/predicates.js"),h=a.isFunction,r=a.isObject,o=D("packages/core/src/internal/uid.js").uid,d=D("packages/core/src/format/index.js").compileFormat,s=D("packages/core/src/columns/datatypes.js"),g=s.comparatorFor,i=s.createTypeRegistry,n=s.storageKind,f=D("packages/core/src/columns/infer.js"),p=f.inferColumnType,l=f.DEFAULT_SAMPLE,y=D("packages/core/src/columns/graph.js"),c=y.buildGraph,m=y.affectedBy,v=D("packages/core/src/columns/lookup.js").createLookup,E=D("packages/core/src/columns/value.js"),V=E.compileDisplay,G=E.ValuePipeline,q=E.warnImpureUse,M=D("packages/core/src/model/shadow.js"),O=M.FIT_SHADOW_KINDS,T=M.CLUSTER_SHADOW_KINDS,A=Object.freeze({geometry:"geometry",list:"list"}),N={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},C={centre:"center"},S=new Set(["start","center","end","left","right"]);function F(pe){if(typeof pe!="string")return;const oe=pe.toLowerCase();return C[oe]?C[oe]:S.has(oe)?oe:void 0}function $(pe){if(typeof pe!="string")return;const oe=pe.toLowerCase();return oe==="center"||oe==="centre"?"middle":oe==="top"||oe==="middle"||oe==="bottom"?oe:void 0}const W=["cell","layout","header"];function K(pe){if(!r(pe))return{};const oe={...pe},be=(fe,le)=>{if(pe[fe]===void 0)return;const ye=P(pe[fe],le);ye&&W.includes(fe)&&!r(pe[fe])&&delete ye.enabled,oe[fe]=ye};return be("sort","direction"),be("filter","type"),be("cell","render"),be("edit","editor"),be("layout","width"),be("group","index"),be("pivot","index"),be("header","render"),be("facet","strategy"),oe}function I(pe,oe){const be={...pe||{}},fe=r(oe)&&r(oe.layout)&&oe.layout.width!==void 0;return be.fit==="content"&&!fe&&delete be.width,be}const B=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"]),J=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function te(pe,oe,be,fe){const le=be==="columnGroup"?"column group":"column";for(const ye of Object.keys(pe))if(!oe.has(ye)){if(ye==="timeZone"&&be==="column"){H("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${fe}". 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}H(`${be}.unknown:${ye}`,`'${ye}' is not a configuration key this grid recognises, so it had no effect on ${le} "${fe}". Check the spelling against the reference.`)}}function Q(pe){r(pe.cell)&&pe.cell.autoHeight!==void 0&&H("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${pe.id||pe.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function re(pe,oe){const be=oe&&h(pe.defaultsFor)?pe.defaultsFor(oe):null,fe={...pe.defaults||{},...r(be)?be:{}},le={};return fe.align&&(le.align=fe.align,le.cell={align:fe.align},le.header={align:fe.align}),fe.filter&&(le.filter=fe.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:fe.filter}),fe.editor&&(le.edit=fe.editor==="none"?{editor:null}:{editor:fe.editor}),fe.total&&(le.total=fe.total),fe.render&&(le.cell={...le.cell||{},render:fe.render}),pe.export&&(le.export={...pe.export}),le}function ie(pe){if(typeof pe=="string")return pe.trim()?[pe.trim()]:[];if(!Array.isArray(pe))return[];const oe=[];for(const be of pe){if(typeof be!="string")continue;const fe=be.trim();fe&&!oe.includes(fe)&&oe.push(fe)}return oe}class ue{#e=new Map;#t=[];#n=[];#r=new WeakMap;#s;#i;#o;#l;#a;#c;#u(oe,be,fe){if(oe&&typeof oe=="object"&&!h(oe)){const je=oe;return(typeof je.fn!="string"||!je.fn)&&Z(`column "${fe}": a total given as an object needs a \`fn\` name, such as { fn: 'percentile', p: 0.9 }.`),je.fn==="percentile"&&!(typeof je.p=="number"&&je.p>=0&&je.p<=1)&&Z(`column "${fe}": { fn: 'percentile' } needs \`p\`, a number from 0 to 1 (0.9 for the 90th percentile).`),this.#d(je.fn,be,fe),Object.freeze({...je})}const le=this.#d(oe,be,fe);if(typeof le!="string"||!this.#f)return le??null;const ye=be&&be.totals&&be.totals.implement;if(ye&&h(ye[le])){const je=ye[le];return je.totalName=le,je}const Ne=this.#f.totalFn?.(le);return h(Ne)?Ne:le}#d(oe,be,fe){if(typeof oe!="string")return oe;const le=be&&be.totals&&be.totals.supported;if(!Array.isArray(le)||le.includes(oe))return oe;const ye=le.length?le.join(", "):"none";return Z(`column "${fe}" is typed ${be.name||"a type"}, for which the total "${oe}" is not meaningful. Supported: ${ye}. Aggregating it anyway would produce a confident wrong number.`),oe}#f;#h;#p;#m;#g;#b;#y=!1;#O;#w;constructor(oe={}){this.#i=K(oe.columnDefaults||{}),this.#o=oe.columnPresets||{},this.#a=oe.locale,this.#l=oe.timeZone,this.#c=$(oe.verticalAlign),this.#f=oe.registry||null,this.#h=oe.grid||null,this.#p=oe.context,this.#O=oe.sampleSize??l,this.#w=oe.onChange||null,this.#b=h(oe.rowKey)?oe.rowKey:void 0,this.#s=i(oe.dataTypes,this.#f);const{leaves:be,groups:fe}=ve(oe.columns||[]);this.#n=fe;for(const le of be){le.facet!==void 0&&this.#r.set(le.def,le.facet);const ye=this.#A(le.def,null);if(ye.groupPath=le.path,this.#e.has(ye.id)){H(`columns.duplicate:${ye.id}`,`two columns resolve to the id '${ye.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}le.column=ye,this.#e.set(ye.id,ye),this.#t.push(ye.id)}this.#C(oe.stored||null)}#A(oe,be){te(oe,B,"column",oe.id||oe.field||"(unnamed)"),Q(oe);const fe=K(oe),le=_(oe.preset),ye=le.map(Be=>{const Ke=this.#o[Be];return Ke?K(Ke):(H(`preset:${Be}`,`unknown column preset "${Be}"; ignoring`),{})}),Ne=this.#S(fe,ye,be),je=this.#s.get(Ne)||this.#s.get("text");if(!this.#s.has(Ne)&&oe.type){const Be=A[Ne];H(`type:${Ne}`,`unknown data type "${Ne}"; falling back to "text"`+(Be?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Be}'.`:""))}const $e=h(je.items)?this.#P(fe,ye,oe.id||oe.field||"(unnamed)"):null;let Re=N;Re=Y(Re,this.#i),oe.type!==!1&&(Re=Y(Re,re(je,$e)));for(const Be of ye)Re=Y(Re,Be);this.#r.has(oe)&&(Re=Y(Re,K({facet:this.#r.get(oe)}))),Re=Y(Re,fe);const Se=Re.edit;Se&&Se.editor&&Se.enabled!==!0&&!h(Se.enabled)&&(oe.edit||{}).editor&&H(`column.editor-not-enabled:${oe.id||oe.field}`,`column '${oe.id||oe.field}' names the editor '${Se.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Ve=oe.id||oe.field||o("col");if(oe.shadow&&!h(Re.value&&Re.value.compute)){const Be=typeof oe.shadow=="string"?{kind:oe.shadow}:oe.shadow,Ke=Be.of||oe.field||Ve,qe=O.includes(Be.kind),rt=T.includes(Be.kind),nt=qe?Be.model||Be:null,dt=qe&&nt?[...Array.isArray(nt.predictors)?nt.predictors:[],nt.response].filter(Boolean):null,Pt=rt?(Array.isArray(Be.columns)?Be.columns:[]).filter(Boolean):null;Re.value={...Re.value||{},deps:Pt&&Pt.length?Pt:dt&&dt.length?dt:Be.orderBy&&Be.orderBy!==Ke?[Ke,Be.orderBy]:[Ke],pure:!1,compute:(Nt,it)=>{const ct=it.grid&&it.grid.statistics;if(!ct)return null;const ft=it.row&&it.row.key||ct.keyOf(it.data);if(!ft)return null;if(qe){if(!h(ct.fitShadow))return null;const Tt=Be.model?{...Be.model,threshold:Be.threshold}:Be;return ct.fitShadow(Be.kind,ft,Tt)}return rt?h(ct.clusterShadow)?ct.clusterShadow(Be.kind,ft,Be):null:ct.shadow(Ke,Be.kind,ft,Be.scope,Be)}}}if(oe.running&&!h(Re.value&&Re.value.compute)){const Be=typeof oe.running=="string"?{kind:oe.running}:oe.running,Ke=Be.of||oe.field||Ve;Re.value={...Re.value||{},deps:[Ke],pure:!1,compute:(qe,rt)=>{const nt=rt.grid&&rt.grid.statistics;if(!nt||!h(nt.running))return null;const dt=rt.row&&rt.row.key||nt.keyOf(rt.data);return dt?nt.running(Ke,Be.kind||"total",dt):null}},oe.sort===void 0&&(Re.sort={...Re.sort||{},enabled:!1})}const Fe=oe.field??(h(Re.value&&Re.value.compute)?null:oe.id??null),Ce=h(Re.value&&Re.value.compute),Ee={id:Ve,field:Fe,shadow:oe.shadow||null,running:oe.running||null,spec:oe.spec||null,validation:oe.validation||null,volatile:!!(oe.shadow||oe.running),title:Re.title??b(Fe||Ve),type:je.name,dataType:je,itemType:$e,nullable:Re.nullable!==!1,align:F(fe.cell&&fe.cell.align||fe.align||Re.cell&&Re.cell.align||Re.align||je.defaults&&je.defaults.align)||"start",verticalAlign:$(fe.cell&&fe.cell.verticalAlign||fe.verticalAlign||Re.cell&&Re.cell.verticalAlign||Re.verticalAlign)||this.#c,rowSpan:h(Re.rowSpan)?Re.rowSpan:null,colSpan:h(Re.colSpan)?Re.colSpan:null,value:{pure:!0,...Re.value||{}},cell:{...Re.cell||{}},edit:{...Re.edit||{}},sort:{...Re.sort||{}},filter:{...Re.filter||{}},group:{enabled:!1,index:-1,explode:!1,...Re.group||{}},pivot:{enabled:!1,index:-1,...Re.pivot||{}},total:this.#u(Re.total,je,oe.id||oe.field||"(unnamed)"),groupTotal:Re.groupTotal===void 0?null:this.#u(Re.groupTotal,je,oe.id||oe.field||"(unnamed)"),grandTotal:Re.grandTotal===void 0?null:this.#u(Re.grandTotal,je,oe.id||oe.field||"(unnamed)"),tags:ie(Re.tags),typeOptions:Re.typeOptions??null,...r(Re[Ne])?{[Ne]:Re[Ne]}:{},layout:I(Re.layout,fe),header:{...Re.header||{}},contextMenu:Re.contextMenu===void 0?null:Re.contextMenu,facet:{...Re.facet||{}},export:{...Re.export||{}},allowGroup:Re.allowGroup!==!1,allowPivot:Re.allowPivot!==!1,allowTotal:Re.allowTotal!==!1,quickFilter:Re.quickFilter!==!1,def:oe,format:Re.format,presets:le,inferred:be!=null&&!oe.type,computed:Ce,diff:oe.diff===void 0?void 0:!!oe.diff,read:Fe?U(Fe):null,write:Fe?j(Fe):null};Ee.cell.align=F(fe.cell&&fe.cell.align)||Ee.align,Ee.header.align=F(fe.header&&fe.header.align)||Ee.align;const Ie=Re.lookup||null;return Ee.lookup=Ie?v({id:Ve,lookup:Ie},{locale:this.#a,onChange:()=>{this.#w&&this.#w("lookup",{colId:Ve})}}):null,Ee.group.explode&&Ee.lookup&&Ee.lookup.multiple&&H(`explode:${Ve}`,`column "${Ve}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#v(Ee),Ee}#v(oe){oe.formatter=d(oe.format,oe.dataType,this.#a,this.#l,oe.id),oe.formatValue=V(oe,{locale:this.#a,grid:this.#h,context:this.#p}),oe.itemCompare=oe.itemType?g(oe.itemType,this.#a):null,oe.compare=h(oe.value.compare)?oe.value.compare:oe.lookup?oe.lookup.comparator():h(oe.dataType.compareFor)?oe.dataType.compareFor(oe):g(oe.dataType,this.#a),oe.excel=oe.formatter&&oe.formatter.ooxml||oe.dataType&&oe.dataType.excel||"General",oe.storeKind=n(oe.dataType,!!(oe.lookup&&oe.lookup.multiple))}#P(oe,be,fe){let le=r(oe.typeOptions)?oe.typeOptions:null;for(let $e=be.length-1;!le&&$e>=0;$e--)r(be[$e].typeOptions)&&(le=be[$e].typeOptions);!le&&r(this.#i.typeOptions)&&(le=this.#i.typeOptions);const ye=le&&le.of!==void 0?le.of:"text",Ne=typeof ye=="string"?this.#s.get(ye):void 0;return Ne&&!h(Ne.items)&&Ne.storage!=="object"?Ne:(H(`type:of:${String(ye)}`,`column "${fe}" names "${String(ye)}" as its item type (typeOptions.of), which is not ${Ne?"a scalar data type":"a known data type"}; its items are read as text.`),this.#s.get("text"))}#S(oe,be,fe){if(oe.type===!1)return"text";if(oe.type)return oe.type;for(let le=be.length-1;le>=0;le--)if(be[le].type)return be[le].type;if(this.#i.type)return this.#i.type;if(oe.shadow){const le=typeof oe.shadow=="string"?oe.shadow:oe.shadow.kind;if(le==="fitInfluence")return"boolean";if(le==="fitPredicted"||le==="fitResidual"||le==="fitStdResidual"||le==="fitLeverage"||le==="fitCooksD"||le==="tsTrend"||le==="tsSeasonal"||le==="tsResidual"||le==="tsCoverage"||le==="tsSmoothed"||le==="tsSmoothingAlpha"||le==="tsSmoothingBeta"||le==="cluster"||le==="clusterDistance")return"number"}return fe||(oe.lookup?"lookup":"text")}#C(oe){const be=this.all();this.#m=c(be),this.#g?this.#g.setGraph(this.#m):this.#g=new G({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:oe||null,rowKey:this.#b});const fe=this.#g;for(const le of be)le.getValue=(ye,Ne)=>fe.value(le,ye,Ne)}all(){return this.#t.map(oe=>this.#e.get(oe))}visible(){return this.all().filter(oe=>!oe.layout.hidden)}get(oe){return this.#e.get(oe)}groups(){const oe=be=>{const fe=[];for(const le of be)Array.isArray(le.columns)?fe.push({...le,columns:oe(le.columns)}):le.column&&fe.push(le.column);return fe};return oe(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#s}affectedBy(oe){return m(this.#m,oe)}value(oe,be,fe){return this.#g.value(oe,be,fe)}text(oe,be,fe){return this.#g.text(oe,be,fe)}checkImpure(oe,be){q(this.#e.get(oe),be)}setLocale(oe){this.#a=oe;for(const be of this.all())be.lookup&&be.lookup.setLocale(oe),this.#v(be);this.#w&&this.#w("locale",{locale:oe})}infer(oe){const be={};if(this.#y||!Array.isArray(oe)||oe.length===0)return be;this.#y=!0;let fe=!1;for(const le of this.all()){const ye=le.def;if(ye.type!==void 0||!le.field||le.computed||le.lookup||this.#E(le))continue;const Ne=le.read||(Re=>X(Re,le.field)),je=p(le.id,oe,Ne,this.#s,{sampleSize:this.#O});if(je===le.type)continue;be[le.id]=je;const $e=this.#A(ye,je);$e.groupPath=le.groupPath,$e.layout={...$e.layout,...ke(le.layout)},this.#e.set(le.id,$e),De(this.#n,le.id,$e),fe=!0}return fe&&this.#C(null),be}redecorate(oe,be,fe={}){const le=this.#e.get(oe);if(!le){H(`redecorate:${oe}`,`columns.decorate('${oe}', …): no column with id '${oe}'.`);return}const ye=le.def||{},Ne={...r(ye.cell)?ye.cell:{}};Ne.decoration=be??void 0,fe&&"variant"in fe&&(Ne.variant=fe.variant);const je={...ye,cell:Ne};this.#r.has(ye)&&this.#r.set(je,this.#r.get(ye));const $e=this.#A(je,le.type);return $e.groupPath=le.groupPath,$e.layout={...$e.layout,...ke(le.layout)},le.lookup&&le.lookup!==$e.lookup&&h(le.lookup.destroy)&&le.lookup.destroy(),this.#e.set(oe,$e),De(this.#n,oe,$e),this.#C(null),this.#w&&this.#w("decorate",{colId:oe}),$e}destroy(){for(const oe of this.#e.values())oe.lookup&&h(oe.lookup.destroy)&&oe.lookup.destroy()}#E(oe){for(const be of oe.presets){const fe=this.#o[be];if(fe&&fe.type)return!0}return!!this.#i.type}#T(oe){return!oe.computed&&h(oe.dataType&&oe.dataType.toStorage)}storeReader(oe){if(oe.computed)return be=>this.#g.value(oe,be,null);if(this.#T(oe)){const be=oe.dataType.toStorage,fe={timeZone:this.#l,colId:oe.id,itemType:oe.itemType||null};return le=>be(oe.read(le),fe)}return oe.read}storeValue(oe,be){if(!(!oe||oe.computed)&&h(oe.read))return this.storeReader(oe)(be)}storeSchema(){const oe=[];for(const be of this.all()){if(be.computed&&be.value.pure===!1||!be.computed&&!be.field)continue;const fe=this.storeReader(be);let le=null;!be.computed&&!this.#T(be)&&typeof be.field=="string"&&!be.lookup&&(le=be.field);const ye={id:be.id,kind:be.storeKind,nullable:be.nullable,read:fe};le!==null&&(ye.field=le),be.lookup&&(ye.dictionary=be.lookup.dictionary()),oe.push(ye)}return oe}state(){return this.all().map(oe=>({id:oe.id,width:oe.layout.width,flex:oe.layout.flex||void 0,hidden:!!oe.layout.hidden,headerWrap:oe.header?.wrap===!0?!0:void 0,headerOrientation:oe.header?.orientation==="vertical"?"vertical":void 0,pin:oe.layout.pin??null,sort:oe.sort.direction??null,sortIndex:oe.sort.direction?oe.sort.order??0:null,groupIndex:oe.group.enabled?oe.group.index??0:null,pivotIndex:oe.pivot.enabled?oe.pivot.index??0:null,total:typeof oe.total=="string"?oe.total:null,groupTotal:typeof oe.groupTotal=="string"?oe.groupTotal:void 0,grandTotal:typeof oe.grandTotal=="string"?oe.grandTotal:void 0,decoration:oe.cell&&oe.cell.decoration!=null?de(oe.cell.decoration):void 0,variant:oe.cell&&oe.cell.variant!=null?de(oe.cell.variant):void 0}))}applyState(oe,be={}){const fe={applied:[],skipped:[]},le=Array.isArray(oe)?oe:oe&&oe.columns||[],ye=!Array.isArray(oe)&&oe&&oe.columnOrder||null;for(const je of le){if(!je||!je.id){fe.skipped.push({key:"?",reason:"no id"});continue}let $e=this.#e.get(je.id);if(!$e){fe.skipped.push({key:je.id,reason:"unknown column"});continue}if(Object.hasOwn(je,"decoration")||Object.hasOwn(je,"variant")){const Re=$e.cell?$e.cell.decoration:void 0,Se=je.decoration??null,Ve=Object.hasOwn(je,"variant"),Fe=Ve&&!we($e.cell?$e.cell.variant:void 0,je.variant);(!we(Re,Se)||Fe)&&(this.redecorate(je.id,Se,Ve?{variant:je.variant??void 0}:{}),$e=this.#e.get(je.id)||$e)}je.width!=null&&($e.layout.width=je.width),je.flex!=null&&($e.layout.flex=je.flex),je.hidden!=null&&($e.layout.hidden=!!je.hidden),je.headerWrap!==void 0&&($e.header.wrap=!!je.headerWrap),je.headerOrientation!==void 0&&($e.header.orientation=je.headerOrientation==="vertical"?"vertical":"horizontal"),je.pin!==void 0&&($e.layout.pin=je.pin),je.sort!==void 0&&($e.sort.direction=je.sort),je.sortIndex!=null&&($e.sort.order=je.sortIndex),je.groupIndex!=null&&($e.group.enabled=!0,$e.group.index=je.groupIndex),je.pivotIndex!=null&&($e.pivot.enabled=!0,$e.pivot.index=je.pivotIndex),je.total!==void 0&&($e.total=je.total),je.groupTotal!==void 0&&($e.groupTotal=je.groupTotal),je.grandTotal!==void 0&&($e.grandTotal=je.grandTotal),fe.applied.push(je.id)}const Ne=ye||(be&&be.keepOrder?[]:le.map(je=>je&&je.id).filter(Boolean));if(Ne.length){const je=Ne.filter(Re=>this.#e.has(Re)),$e=this.#t.filter(Re=>!je.includes(Re));this.#t=[...je,...$e]}return this.#w&&this.#w("state",fe),fe}move(oe,be){this.#M(oe,be)&&(this.#R(),this.#w&&this.#w("move",{id:oe,to:be}))}reorder(oe){const be={applied:[],skipped:[]},fe=[];let le=0;for(const ye of Array.isArray(oe)?oe:[]){const Ne=le++;this.#M(ye,Ne)&&(be.applied.push(ye),fe.push({id:ye,to:Ne}))}if(!fe.length)return be;if(this.#R(),this.#w)for(const ye of fe)this.#w("move",ye);return be}#M(oe,be){const fe=this.#t.indexOf(oe);if(fe===-1||Math.max(0,Math.min(Number(be)||0,this.#t.length-1))===fe)return!1;const ye=this.#e.get(oe);if(ye.layout.movable===!1||ye.layout.lockPosition)return H(`move:${oe}`,`column "${oe}" is not movable; the move was ignored`),!1;const Ne=this.#N(oe,be);return Ne?(H(`move.married:${Ne}`,`band "${Ne}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(fe,1),this.#t.splice(Math.max(0,Math.min(be,this.#t.length)),0,oe),!0)}#N(oe,be){if(!this.#n||!this.#n.length)return null;const fe=this.#t.filter(je=>je!==oe),le=Math.max(0,Math.min(be,fe.length)),ye=(je,$e)=>{if(Array.isArray(je.columns)){for(const Se of je.columns)ye(Se,$e);return $e}const Re=je.column?je.column.id:je.id;return Re&&$e.push(Re),$e},Ne=je=>{for(const $e of je){if(!Array.isArray($e.columns))continue;if($e.marryChildren===!0){const Se=ye($e,[]),Ve=Se.includes(oe),Fe=Se.map(Ce=>fe.indexOf(Ce)).filter(Ce=>Ce>=0);if(Fe.length){const Ce=Math.min(...Fe),Ee=Math.max(...Fe);if(Ve?le<Ce||le>Ee+1:le>Ce&&le<=Ee)return $e.id}}const Re=Ne($e.columns);if(Re)return Re}return null};return Ne(this.#n)}#R(){const oe=new Map(this.#t.map((le,ye)=>[le,ye])),be=le=>{if(!Array.isArray(le.columns)){const Ne=le.column?le.column.id:le.id;return oe.has(Ne)?oe.get(Ne):1/0}let ye=1/0;for(const Ne of le.columns)ye=Math.min(ye,be(Ne));return ye},fe=le=>{le.sort((ye,Ne)=>be(ye)-be(Ne));for(const ye of le)Array.isArray(ye.columns)&&fe(ye.columns)};fe(this.#n)}#D(oe){const be=fe=>{for(let le=0;le<fe.length;le++){const ye=fe[le];if(Array.isArray(ye.columns)){const Ne=be(ye.columns);if(Ne)return Ne}else if(ye.column&&ye.column.id===oe)return fe.splice(le,1)[0]}return null};return be(this.#n)}#W(oe){const be=[];for(let fe=oe.length-1;fe>=0;fe--){const le=oe[fe];Array.isArray(le.columns)&&(be.push(...this.#W(le.columns)),le.columns.length===0&&(be.push(le.id),oe.splice(fe,1)))}return be}#V(){const oe=(be,fe,le)=>{for(const ye of be)Array.isArray(ye.columns)?oe(ye.columns,[...fe,ye.id]):ye.column&&(ye.column.groupPath=fe)};oe(this.#n,[])}#x(oe){const be=new Set(oe),fe=this.#t.filter(je=>be.has(je));if(!fe.length)return;const le=Math.min(...fe.map(je=>this.#t.indexOf(je))),ye=this.#t.slice(0,le).filter(je=>!be.has(je)),Ne=this.#t.slice(le).filter(je=>!be.has(je));this.#t=[...ye,...fe,...Ne]}#q(oe){const be=[],fe=le=>{if(Array.isArray(le.columns))for(const ye of le.columns)fe(ye);else le.column&&be.push(le.column.id)};return fe(oe),be}#B(oe){const be=fe=>{for(const le of fe){if(!Array.isArray(le.columns))continue;if(le.id===oe)return{node:le,parent:fe};const ye=be(le.columns);if(ye)return ye}return null};return be(this.#n)}groupColumns(oe,be={}){const fe=_(oe).filter($e=>this.#e.has($e));if(!fe.length)return H("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const $e of fe)if(this.#e.get($e).layout.lockPosition)return H(`columns.group.locked:${$e}`,`column "${$e}" is position-locked and cannot be grouped.`),null;const le=be.groupId?this.#B(be.groupId):null;if(be.groupId&&!le)return H(`columns.group.unknown:${be.groupId}`,`no band "${be.groupId}" to add to; nothing was grouped.`),null;let ye=null;if(!le&&be.id!=null&&(ye=String(be.id),this.#B(ye)||this.#e.has(ye)))return H(`columns.group.idtaken:${ye}`,`band id "${ye}" is already in use; nothing was grouped.`),null;const Ne=fe.map($e=>this.#D($e)).filter(Boolean);if(!Ne.length)return null;let je;if(le)le.node.columns.push(...Ne),je=le.node.id;else{const $e={id:ye||o("grp"),title:be.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Ne},Re=Number.isInteger(be.at)?Math.max(0,Math.min(be.at,this.#n.length)):this.#n.length;this.#n.splice(Re,0,$e),je=$e.id}return this.#W(this.#n),this.#x(fe),this.#V(),this.#R(),this.#w&&this.#w("columngroup",{action:"formed",groupId:je,ids:fe}),je}ungroupColumn(oe){const be=this.#e.get(oe);if(!be){H(`columns.ungroup.unknown:${oe}`,`no column "${oe}" to ungroup.`);return}const fe=be.groupPath||[];if(!fe.length)return;const le=fe[fe.length-1],ye=this.#B(le);if(!ye)return;const Ne=this.#D(oe);if(!Ne)return;const je=ye.parent.indexOf(ye.node);ye.parent.splice(je+1,0,Ne);const $e=this.#W(this.#n),Re=this.#q(ye.node);if(Re.length){this.#x(Re);const Se=Math.max(...Re.map(Fe=>this.#t.indexOf(Fe))),Ve=this.#t.filter(Fe=>Fe!==oe);Ve.splice(Se+1,0,oe),this.#t=Ve}this.#V(),this.#R(),this.#w&&this.#w("columngroup",{action:"removed",id:oe,dissolved:$e})}renameGroup(oe,be){const fe=this.#B(oe);if(!fe){H(`columns.group.rename:${oe}`,`no band "${oe}" to rename.`);return}fe.node.title=String(be??""),this.#w&&this.#w("columngroup",{action:"renamed",groupId:oe,title:fe.node.title})}dissolveGroup(oe){const be=this.#B(oe);if(!be){H(`columns.group.dissolve:${oe}`,`no band "${oe}" to dissolve.`);return}const fe=be.parent.indexOf(be.node);be.parent.splice(fe,1,...be.node.columns),this.#V(),this.#R(),this.#w&&this.#w("columngroup",{action:"dissolved",groupId:oe})}moveGroup(oe,be){const fe=this.#B(oe);if(!fe){H(`columns.group.move:${oe}`,`no band "${oe}" to move.`);return}const le=fe.parent,ye=le.indexOf(fe.node);ye!==-1&&(le.splice(ye,1),le.splice(Math.max(0,Math.min(be,le.length)),0,fe.node),this.#Y(),this.#V(),this.#w&&this.#w("columngroup",{action:"moved",groupId:oe,to:be}))}#Y(){const oe=[],be=le=>{for(const ye of le)Array.isArray(ye.columns)?be(ye.columns):ye.column&&oe.push(ye.column.id)};be(this.#n);const fe=new Set(oe);this.#t=[...oe,...this.#t.filter(le=>!fe.has(le))]}groupTree(){const oe=fe=>fe.map(le=>Array.isArray(le.columns)?{id:le.id,title:le.title||"",collapsible:!!le.collapsible,openByDefault:le.openByDefault!==!1,columns:oe(le.columns)}:le.column?le.column.id:null).filter(le=>le!==null),be=oe(this.#n);return be.some(fe=>fe&&typeof fe=="object")?be:[]}applyGroupTree(oe){if(!Array.isArray(oe))return;const be=new Set,fe=ye=>{const Ne=[];for(const je of ye)if(je&&typeof je=="object"&&Array.isArray(je.columns)){const $e=fe(je.columns);if(!$e.length)continue;Ne.push({id:je.id||o("grp"),title:je.title||"",collapsible:je.collapsible===!0,openByDefault:je.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:$e})}else if(typeof je=="string"){const $e=this.#e.get(je);$e&&!be.has(je)&&(be.add(je),Ne.push({column:$e,path:[]}))}return Ne},le=fe(oe);for(const ye of this.#t){if(be.has(ye))continue;const Ne=this.#e.get(ye);Ne&&le.push({column:Ne,path:[]})}this.#n=le,this.#V(),this.#R(),this.#w&&this.#w("columngroup",{action:"applied"})}show(oe){this.#G(oe,!1)}hide(oe){this.#G(oe,!0)}#G(oe,be){const fe=[];for(const le of _(oe)){const ye=this.#e.get(le);if(ye){if(be&&ye.layout.lockVisible){H(`lockVisible:${le}`,`column "${le}" is \`layout.lockVisible\` and cannot be hidden`);continue}ye.layout.hidden!==be&&(ye.layout.hidden=be,fe.push(le))}}fe.length&&this.#w&&this.#w("visible",{ids:fe,hidden:be})}pin(oe,be){const fe=this.#e.get(oe);fe&&(fe.layout.pin=be??null,this.#w&&this.#w("pin",{id:oe,side:fe.layout.pin}))}pinMany(oe){const be={};for(const[le,ye]of oe){const Ne=this.#e.get(le);Ne&&(Ne.layout.pin=ye??null,be[le]=Ne.layout.pin)}const fe=Object.keys(be);fe.length&&this.#w&&this.#w("pin",{ids:fe,pins:be})}#I(oe,be){const fe=oe.layout.min??0,le=oe.layout.max;let ye=Math.max(fe,be);return le!=null&&(ye=Math.min(le,ye)),oe.layout.width=ye,oe.layout.flex=0,ye}resize(oe,be){const fe=this.#e.get(oe);if(!fe)return;if(fe.layout.resizable===!1){H(`resize:${oe}`,`column "${oe}" is not resizable; the resize was ignored`);return}const le=this.#I(fe,be);this.#w&&this.#w("resize",{id:oe,width:le})}resizeMany(oe){const be={};for(const[le,ye]of oe){const Ne=this.#e.get(le);if(Ne){if(Ne.layout.resizable===!1){H(`resize:${le}`,`column "${le}" is not resizable; the resize was ignored`);continue}be[le]=this.#I(Ne,ye)}}const fe=Object.keys(be);fe.length&&this.#w&&this.#w("resize",{ids:fe,widths:be})}}function ke(pe){const oe={};return pe.width!=null&&(oe.width=pe.width),pe.hidden!=null&&(oe.hidden=pe.hidden),pe.pin!==void 0&&(oe.pin=pe.pin),oe}function de(pe){if(pe===null||typeof pe!="object")return pe;try{return structuredClone(pe)}catch{}try{return JSON.parse(JSON.stringify(pe))}catch{return pe}}function we(pe,oe){const be=pe??null,fe=oe??null;if(be===fe)return!0;if(be===null||fe===null)return!1;if(typeof be!="object"||typeof fe!="object")return be===fe;try{return JSON.stringify(be)===JSON.stringify(fe)}catch{return!1}}function ve(pe){const oe=[],be=(le,ye,Ne)=>{const je=[];for(const $e of le){if(!r($e)){Z("a column definition must be an object");continue}if(Array.isArray($e.columns)){te($e,J,"columnGroup",$e.title||$e.id||"(unnamed)");const Re={id:$e.id||o("grp"),title:$e.title||"",collapsible:$e.collapsible===!0,openByDefault:$e.openByDefault!==!1,showWhen:$e.showWhen||"always",marryChildren:$e.marryChildren===!0,header:$e.header||{},def:$e,columns:[]};Re.columns=be($e.columns,[...ye,Re.id],$e.facet!==void 0?$e.facet:Ne),je.push(Re)}else{const Re={def:$e,path:ye,facet:Ne};oe.push(Re),je.push(Re)}}return je},fe=be(pe,[],void 0);return{leaves:oe,groups:fe}}function De(pe,oe,be){for(const fe of pe){if(fe.columns){if(De(fe.columns,oe,be))return!0;continue}if(fe.column&&fe.column.id===oe)return fe.column=be,!0}return!1}}),We("packages/core/src/columns/autogroup.js",function(e,D){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return X}});const P=D("packages/core/src/internal/warn.js").warnOnce,Y="__lattice_group",_=240,L=.5;function Z(U){const j=U.def&&U.def.layout;return(typeof j=="number"||j&&j.width!=null||U.def&&U.def.width!=null)&&Number.isFinite(U.layout.width)?U.layout.width:null}function H(U){const j=U.def&&U.def.layout;return!!(j&&j.min!=null)||U.def&&U.def.minWidth!=null}function x(U){const{columns:j,groupBy:k}=U,b=k.map(u=>j.get(u)).filter(Boolean),a=b.length?b.map(u=>u.title||u.id).join(" > "):"Group",h=b.find(u=>Z(u)!=null),r=U.config&&U.config.autoGroupColumnWidth||(h?Z(h):_);let t=h&&H(h)?h.layout.min:120;h&&!H(h)&&(t=Math.min(t,r));const o=h&&h.layout.max!=null?h.layout.max:null;return{id:Y,field:null,title:a,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:k.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:r,min:t,max:o,pin:U.config&&U.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,d){return d&&d.group?d.groupValue:null},formatValue(u,d){if(!d||!d.group)return"";if(d.grandTotal)return U.config&&U.config.grandTotalLabel||"Total";const s=b[Math.min(d.level||0,b.length-1)];return s&&typeof s.formatValue=="function"?s.formatValue(u,d):u==null?"":String(u)}}}function X(U,j,k){!U.length||k<100||j<k*L||P(`grouping.cardinality:${U.join(",")}`,`grouping by ${U.join(", ")} produced ${j} groups for ${k} 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.`)}}),We("packages/core/src/columns/selectcolumn.js",function(e,D){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const ne="__lattice_select",P=44;function Y(L){const Z=L.selection||{},H=L.config&&L.config.selectionColumnWidth||P;return{id:ne,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:H,min:H,max:H,pin:L.config&&L.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:Z.headerCheckbox===!0,def:{},getValue(x,X){return X?X.selected:!1},formatValue(){return""}}}const _=Y}),We("packages/core/src/columns/rownumbercolumn.js",function(e,D){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const P=D("packages/core/src/internal/predicates.js").isFunction,Y="__lattice_rownumber",_=40,L=9,Z=22;function H(U){const j=String(Math.max(1,Math.trunc(Math.abs(U))||1)).length;return Math.max(_,j*L+Z)}function x(U){const j=U.rowNumbers,k=j&&typeof j=="object"?j:{},b=Number.isFinite(k.start)?k.start:1,a=Number.isFinite(k.width)?k.width:H((U.maxNumber||0)+b),h=P(U.rank)?U.rank:()=>null;return{id:Y,field:null,title:typeof k.title=="string"?k.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:a,min:a,max:a,pin:"start",hidden:!1,resizable:k.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(r,t){const o=h(t);return o==null?null:o-1+b},formatValue(r){return r==null?"":String(r)}}}const X=x}),We("packages/core/src/model/detail.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const P=D("packages/core/src/internal/predicates.js").isFunction,_=D("packages/core/src/internal/warn.js").warnOnce,L=240,Z=10;function H(U){if(!U)return null;const j=U===!0?{}:U;return j.enabled===!1?null:!P(j.rows)&&!j.render?(_("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:P(j.rows)?j.rows:null,height:j.height??L,maxHeight:j.maxHeight??null,cacheLimit:Number.isFinite(j.cacheLimit)?Math.max(0,j.cacheLimit):Z,isMaster:P(j.isMaster)?j.isMaster:null,target:j.target||null,onCreate:P(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=P(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 k=this.#e.isMaster;return k?!!k(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 k=this.#e.height;return P(k)?Number(k(j))||L:k==="auto"?L:Number(k)||L}open(j){return this.#t.has(j)?!1:(this.inline||this.#t.clear(),this.#t.add(j),this.#s(),!0)}close(j){return this.#t.delete(j)?(this.#s(),!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.#s())}prune(j){if(!this.#t.size||!P(j))return;let k=!1;for(const b of[...this.#t])j(b)||(this.#t.delete(b),k=!0);k&&this.#s()}signature(){return`${this.#r}`}set(j){this.#t.clear();const k=Array.isArray(j)?j:[];for(const b of this.inline?k:k.slice(0,1))this.#t.add(b);this.#s()}#s(){this.#r++,this.#n()}}const X=x}),We("packages/core/src/compute/special.js",function(e,D){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return r}});const ne=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),P=3e-12,Y=1e-300;function _(t){if(t<.5)return Math.log(Math.PI/Math.sin(Math.PI*t))-_(1-t);const o=t-1;let u=.9999999999998099;const d=o+7.5;for(let s=0;s<ne.length;s++)u+=ne[s]/(o+s+1);return .5*Math.log(2*Math.PI)+(o+.5)*Math.log(d)-d+Math.log(u)}function L(t,o,u){const d=t+o,s=t+1,g=t-1;let i=1,n=1-d*u/s;Math.abs(n)<Y&&(n=Y),n=1/n;let f=n;for(let p=1;p<=300;p++){const l=2*p;let y=p*(o-p)*u/((g+l)*(t+l));n=1+y*n,Math.abs(n)<Y&&(n=Y),i=1+y/i,Math.abs(i)<Y&&(i=Y),n=1/n,f*=n*i,y=-(t+p)*(d+p)*u/((t+l)*(s+l)),n=1+y*n,Math.abs(n)<Y&&(n=Y),i=1+y/i,Math.abs(i)<Y&&(i=Y),n=1/n;const c=n*i;if(f*=c,Math.abs(c-1)<P)break}return f}function Z(t,o,u){if(!(t>0)||!(o>0)||!Number.isFinite(u))return Number.NaN;if(u<=0)return 0;if(u>=1)return 1;const d=Math.exp(_(t+o)-_(t)-_(o)+t*Math.log(u)+o*Math.log(1-u));return u<(t+1)/(t+o+2)?d*L(t,o,u)/t:1-d*L(o,t,1-u)/o}function H(t){if(!(t>0)||!(t<1))return t===0?-1/0:t===1?1/0:Number.NaN;const o=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],u=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],d=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],s=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],g=.02425;let i,n,f;t<g?(i=Math.sqrt(-2*Math.log(t)),f=(((((d[0]*i+d[1])*i+d[2])*i+d[3])*i+d[4])*i+d[5])/((((s[0]*i+s[1])*i+s[2])*i+s[3])*i+1)):t<=1-g?(i=t-.5,n=i*i,f=(((((o[0]*n+o[1])*n+o[2])*n+o[3])*n+o[4])*n+o[5])*i/(((((u[0]*n+u[1])*n+u[2])*n+u[3])*n+u[4])*n+1)):(i=Math.sqrt(-2*Math.log(1-t)),f=-(((((d[0]*i+d[1])*i+d[2])*i+d[3])*i+d[4])*i+d[5])/((((s[0]*i+s[1])*i+s[2])*i+s[3])*i+1));const l=(.5*x(-f/Math.SQRT2)-t)*Math.sqrt(2*Math.PI)*Math.exp(f*f/2);return f-l/(1+f*l/2)}function x(t){const o=Math.abs(t),u=2/(2+o),d=4*u-2,s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let g=0,i=0,n;for(let p=s.length-1;p>0;p--)n=i,i=d*i-g+s[p],g=n;const f=u*Math.exp(-o*o+.5*(s[0]+d*i)-g);return t>=0?f:2-f}function X(t){return .5*x(-t/Math.SQRT2)}function U(t,o){if(!(o>0)||!Number.isFinite(t))return Number.NaN;const u=.5*Z(o/2,.5,o/(o+t*t));return t>0?1-u:u}function j(t,o){if(!(t>0)||!(t<1)||!(o>0))return Number.NaN;if(o>1e7)return H(t);let u=-1e4,d=1e4,s=H(t);const g=_(o/2)+_(.5)-_((o+1)/2);for(let i=0;i<60;i++){const n=U(s,o);n<t?u=s:d=s;const f=Math.exp(-((o+1)/2)*Math.log(1+s*s/o)-g)/Math.sqrt(o),p=f>0?(n-t)/f:0;if(Math.abs(p)<1e-12)break;const l=s-p;if(s=l>u&&l<d&&Number.isFinite(l)?l:(u+d)/2,d-u<1e-12)break}return s}function k(t,o){let u=t,d=1/t,s=d;for(let g=0;g<300&&(u+=1,s*=o/u,d+=s,!(Math.abs(s)<Math.abs(d)*P));g++);return d*Math.exp(-o+t*Math.log(o)-_(t))}function b(t,o){let u=o+1-t,d=1/Y,s=1/u,g=s;for(let i=1;i<=300;i++){const n=-i*(i-t);u+=2,s=n*s+u,Math.abs(s)<Y&&(s=Y),d=u+n/d,Math.abs(d)<Y&&(d=Y),s=1/s;const f=s*d;if(g*=f,Math.abs(f-1)<P)break}return Math.exp(-o+t*Math.log(o)-_(t))*g}function a(t,o){return!(t>0)||!(o>=0)||!Number.isFinite(o)?Number.NaN:o===0?0:o<t+1?k(t,o):1-b(t,o)}function h(t,o){return o>0?a(o/2,t/2):Number.NaN}function r(t,o){const u=h(t,o);return Number.isNaN(u)?Number.NaN:Math.min(1,Math.max(0,1-u))}}),We("packages/core/src/compute/linalg.js",function(e,D){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return Z}});function ne(H){const x=H.length,X=Array.from({length:x},()=>new Array(x).fill(0));for(let U=0;U<x;U++)for(let j=0;j<=U;j++){let k=H[U][j];for(let b=0;b<j;b++)k-=X[U][b]*X[j][b];if(U===j){if(!(k>0))return null;X[U][j]=Math.sqrt(k)}else X[U][j]=k/X[j][j]}return X}function P(H,x){const X=H.length,U=new Array(X).fill(0);for(let k=0;k<X;k++){let b=x[k];for(let a=0;a<k;a++)b-=H[k][a]*U[a];U[k]=b/H[k][k]}const j=new Array(X).fill(0);for(let k=X-1;k>=0;k--){let b=U[k];for(let a=k+1;a<X;a++)b-=H[a][k]*j[a];j[k]=b/H[k][k]}return j}function Y(H){const x=H.length,X=Array.from({length:x},()=>new Array(x).fill(0));for(let U=0;U<x;U++){const j=new Array(x).fill(0);j[U]=1;const k=P(H,j);for(let b=0;b<x;b++)X[b][U]=k[b]}return X}function _(H,x,X){const U=H.length,j=U?H[0].length:0,k=Array.from({length:j},()=>new Array(j).fill(0)),b=new Array(j).fill(0);for(let a=0;a<U;a++){const h=X?X[a]:1,r=H[a];for(let t=0;t<j;t++){const o=h*r[t];b[t]+=o*x[a];for(let u=t;u<j;u++)k[t][u]+=o*r[u]}}for(let a=0;a<j;a++)for(let h=0;h<a;h++)k[a][h]=k[h][a];return{xtwx:k,xtwy:b}}function L(H,x){return H.map(X=>X.reduce((U,j,k)=>U+j*x[k],0))}function Z(H,x){let X=0;for(let U=0;U<H.length;U++){let j=0;for(let k=0;k<H.length;k++)j+=x[U][k]*H[k];X+=H[U]*j}return X}}),We("packages/core/src/compute/sketch.js",function(e,D){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});class ne{#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(a){if(!Number.isFinite(a))return;this.#e++;const h=a-this.#t;this.#t+=h/this.#e,this.#n+=h*(a-this.#t)}merge(a){if(a.#e===0)return;if(this.#e===0){this.#e=a.#e,this.#t=a.#t,this.#n=a.#n;return}const h=this.#e+a.#e,r=a.#t-this.#t;this.#t+=r*(a.#e/h),this.#n+=a.#n+r*r*(this.#e*a.#e/h),this.#e=h}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 a=this.variance();return a===null?null:Math.sqrt(a)}stddevP(){const a=this.varianceP();return a===null?null:Math.sqrt(a)}}class P{#e=[];#t=0;#n;#r;constructor(a,h=Math.random){if(!(a>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(a),this.#r=h}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(a){if(!Number.isFinite(a))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(a);return}const h=Math.floor(this.#r()*this.#t);h<this.#n&&(this.#e[h]=a)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let a=0;for(const h of this.#e)a+=h;return a/this.#e.length}quantile(a){const h=this.#e.length;if(!h)return null;const r=this.#e.slice().sort((d,s)=>d-s);if(h===1)return r[0];const t=(h-1)*Math.min(1,Math.max(0,a)),o=Math.floor(t),u=Math.ceil(t);return o===u?r[o]:r[o]+(t-o)*(r[u]-r[o])}}function Y(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){if(typeof b=="number"){const r=new DataView(new ArrayBuffer(8));return r.setFloat64(0,b===0?0:b),Y(r.getUint32(0)^r.getUint32(4))}const a=typeof b=="string"?b:String(b);let h=2166136261;for(let r=0;r<a.length;r++)h^=a.charCodeAt(r),h=Math.imul(h,16777619);return Y(h)}class L{#e;#t;#n;constructor(a=14){const h=Math.floor(a);if(h<4||h>16)throw new RangeError("HLL precision must be 4..16");this.#e=h,this.#t=1<<h,this.#n=new Uint8Array(this.#t)}static errorBoundFor(a=14){const h=1<<Math.floor(a),r=1.04/Math.sqrt(h);return Object.freeze({kind:"probabilistic",metric:"relative",value:r,statement:`distinct count within ~${(r*100).toFixed(2)}% relative standard error (m=${h} buckets)`})}errorBound(){return L.errorBoundFor(this.#e)}add(a){const h=_(a),r=h&this.#t-1,t=h>>>this.#e|1<<32-this.#e;let o=1,u=t;for(;(u&1)===0;)o++,u>>>=1;o>this.#n[r]&&(this.#n[r]=o)}count(){const a=this.#t,h=32-this.#e,r=new Float64Array(h+2);for(let u=0;u<a;u++)r[this.#n[u]]++;let t=a*x(1-r[h+1]/a);for(let u=h;u>=1;u--)t=.5*(t+r[u]);t+=a*H(r[0]/a);const o=Z*a*a/t;return Math.round(o)}}const Z=.5/Math.log(2);function H(b){if(b===1)return 1/0;let a=1,h=b,r;do b*=b,r=h,h+=b*a,a+=a;while(h!==r);return h}function x(b){if(b===0||b===1)return 0;let a=1,h=1-b,r;do b=Math.sqrt(b),r=h,a*=.5,h-=(1-b)**2*a;while(h!==r);return h/3}class X{#e=new Map;#t;#n=0;constructor(a){if(!(a>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(a)}errorBoundFor(a){const h=a/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:h,statement:`each count overestimates the truth by at most N/m = ${h.toFixed(2)} (N=${a}, m=${this.#t})`})}get seen(){return this.#n}add(a){this.#n++;const h=this.#e.get(a);if(h){h.count++;return}if(this.#e.size<this.#t){this.#e.set(a,{count:1,error:0});return}let r,t=1/0;for(const[o,u]of this.#e)u.count<t&&(t=u.count,r=o);this.#e.delete(r),this.#e.set(a,{count:t+1,error:t})}top(a=this.#t){return[...this.#e.entries()].map(([r,t])=>({item:r,count:t.count,error:t.error})).sort((r,t)=>t.count-r.count).slice(0,Math.max(0,Math.floor(a)))}}class U{#e;#t=[[]];#n=0;#r;#s;constructor(a=200,h=Math.random){this.#e=Math.max(8,Math.floor(a)),this.#r=h,this.#s=2/3}static errorBoundFor(a=200){const h=1/Math.max(8,Math.floor(a));return Object.freeze({kind:"probabilistic",metric:"rank",value:h,statement:`queried quantile's true rank within ~${(h*100).toFixed(2)}% of N of the requested rank (k=${a})`})}errorBound(){return U.errorBoundFor(this.#e)}get count(){return this.#n}#i(a){const r=this.#t.length-1-a,t=Math.ceil(this.#e*this.#s**r);return Math.max(2,t)}add(a){Number.isFinite(a)&&(this.#n++,this.#t[0].push(a),this.#t[0].length>=this.#i(0)&&this.#o(0))}#o(a){const h=this.#t[a];h.sort((o,u)=>o-u),a+1>=this.#t.length&&this.#t.push([]);const r=this.#t[a+1],t=this.#r()<.5?0:1;for(let o=t;o<h.length;o+=2)r.push(h[o]);this.#t[a]=[];for(let o=0;o<this.#t.length;o++)if(this.#t[o].length>=this.#i(o)){this.#o(o);return}}#l(){const a=[];for(let h=0;h<this.#t.length;h++){const r=1<<h;for(const t of this.#t[h])a.push({v:t,w:r})}return a}quantile(a){const h=this.#l();if(!h.length)return null;h.sort((u,d)=>u.v-d.v);let r=0;for(const u of h)r+=u.w;const t=Math.min(1,Math.max(0,a))*r;let o=0;for(const u of h)if(o+=u.w,o>=t)return u.v;return h[h.length-1].v}rank(a){let h=0;for(let r=0;r<this.#t.length;r++){const t=1<<r;for(const o of this.#t[r])o<=a&&(h+=t)}return h}}const j=Object.freeze({distinct:L.errorBoundFor(14),median:U.errorBoundFor(200),p25:U.errorBoundFor(200),p75:U.errorBoundFor(200),p90:U.errorBoundFor(200),p95:U.errorBoundFor(200),p99:U.errorBoundFor(200),iqr:U.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),k={Welford:ne,Reservoir:P,HyperLogLog:L,SpaceSaving:X,KLL:U,hash32:_,SKETCH_BOUNDS:j}}),We("packages/core/src/compute/statistics.js",function(e,D){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return it}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return Ae}});const ne=D("packages/core/src/compute/handle.js"),P=ne.presenceReader,Y=ne.valueReader,_=D("packages/core/src/compute/special.js"),L=_.studentTQuantile,Z=_.studentT,H=_.normalQuantile,x=_.normalCdf,X=_.chiSquareUpperTail,U=D("packages/core/src/compute/linalg.js"),j=U.cholesky,k=U.choleskySolve,b=U.choleskyInverse,a=U.normalEquations,h=U.quadForm,t=D("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,o=5e3,u=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",percentile:"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"}),d=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:t.distinct}),median:Object.freeze({sketch:"KLL",bound:t.median}),p25:Object.freeze({sketch:"KLL",bound:t.p25}),p75:Object.freeze({sketch:"KLL",bound:t.p75}),p90:Object.freeze({sketch:"KLL",bound:t.p90}),p95:Object.freeze({sketch:"KLL",bound:t.p95}),p99:Object.freeze({sketch:"KLL",bound:t.p99}),iqr:Object.freeze({sketch:"KLL",bound:t.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK})});function s(ge){const Le=ge==="sum"||ge==="avg"||ge==="countValues"||ge==="min"||ge==="max"?"maintained":Object.prototype.hasOwnProperty.call(u,ge)?u[ge]:null,Me=Object.prototype.hasOwnProperty.call(d,ge)?d[ge]:null;return{stat:ge,exact:Le,approximate:Me}}function g(ge,Le){const Me=Le.length,He=new Float64Array(Me);let ce=0;if(ge&&(ge.kind==="float64"||ge.kind==="int32")){const Te=ge.values,xe=P(ge);for(let _e=0;_e<Me;_e++){const Ye=Le[_e];if(xe&&xe(Ye)!==1)continue;const Qe=Te[Ye];Number.isNaN(Qe)||(He[ce++]=Qe)}return He.subarray(0,ce)}const Pe=Y(ge);for(let Te=0;Te<Me;Te++){const xe=Pe(Le[Te]);if(xe==null||xe==="")continue;const _e=typeof xe=="number"?xe:Number(xe);Number.isFinite(_e)&&(He[ce++]=_e)}return He.subarray(0,ce)}function i(ge,Le){const Me=new Map,He=Y(ge);let ce=0;for(let Pe=0;Pe<Le.length;Pe++){const Te=He(Le[Pe]);if(Te==null||Te===""||typeof Te=="number"&&Number.isNaN(Te))continue;const xe=typeof Te=="object"?String(Te):Te;Me.set(xe,(Me.get(xe)||0)+1),ce++}const ae=[...Me.values()].sort((Pe,Te)=>Te-Pe);return{counts:ae,total:ce,distinct:ae.length}}function n(ge){return ge.total>0?ge.counts.map(Le=>Le/ge.total):[]}function f(ge,Le){const Me=i(ge,Le);if(!Me.total)return null;let He=0;for(const ce of n(Me))He+=ce*ce;return He}function p(ge,Le){const Me=i(ge,Le);if(!Me.total)return null;let He=0;for(const ce of n(Me))ce>0&&(He-=ce*Math.log2(ce));return He}function l(ge,Le){const Me=i(ge,Le);if(!Me.total||Me.distinct<2)return Me.total?1:null;let He=0;for(const ce of n(Me))ce>0&&(He-=ce*Math.log2(ce));return He/Math.log2(Me.distinct)}function y(ge,Le,Me=3){const He=i(ge,Le);if(!He.total)return null;const ce=Math.max(1,Math.floor(Me));let ae=0;for(let Pe=0;Pe<Math.min(ce,He.counts.length);Pe++)ae+=He.counts[Pe];return ae/He.total}function c(ge,Le){const Me=g(ge,Le),He=Me.length;if(!He)return null;const ce=Me.slice().sort();if(ce[0]<0)return null;let ae=0,Pe=0;for(let Te=0;Te<He;Te++)ae+=ce[Te],Pe+=(Te+1)*ce[Te];return ae===0?0:2*Pe/(He*ae)-(He+1)/He}function m(ge){let Le=0,Me=0,He=0;for(let ce=0;ce<ge.length;ce++){const ae=ge[ce];Le++;const Pe=ae-Me;Me+=Pe/Le,He+=Pe*(ae-Me)}return{n:Le,mean:Me,m2:He}}function w(ge,Le){const Me=ge.length;if(!Me)return NaN;if(Me===1)return ge[0];const He=(Me-1)*Math.min(1,Math.max(0,Le)),ce=Math.floor(He),ae=Math.ceil(He);return ce===ae?ge[ce]:ge[ce]+(He-ce)*(ge[ae]-ge[ce])}function v(ge,Le){if(!ge.length)return NaN;const Me=ge.slice().sort();return w(Me,Le)}function E(ge,Le){const Me=Y(ge);let He=0,ce=0,ae=0;for(let Pe=0;Pe<Le.length;Pe++){const Te=Me(Le[Pe]);if(Te==null||Te==="")continue;const xe=String(Te).toUpperCase();xe==="PASS"?He++:xe==="FAIL"?ce++:xe==="WARN"&&ae++}return{pass:He+ae,fail:ce,warn:ae,judged:He+ae+ce}}const V=Object.freeze({hhi:(ge,Le)=>f(ge,Le),entropy:(ge,Le)=>p(ge,Le),evenness:(ge,Le)=>l(ge,Le),top3Share:(ge,Le)=>y(ge,Le,3),top10Share:(ge,Le)=>y(ge,Le,10),gini:(ge,Le)=>c(ge,Le),trimmedMean:(ge,Le)=>T(g(ge,Le),.1),winsorizedMean:(ge,Le)=>A(g(ge,Le),.1),robustOutliers:(ge,Le)=>N(g(ge,Le),3.5),jarqueBera:(ge,Le)=>C(g(ge,Le)),variance:(ge,Le)=>{const{n:Me,m2:He}=m(g(ge,Le));return Me>1?He/(Me-1):null},varianceP:(ge,Le)=>{const{n:Me,m2:He}=m(g(ge,Le));return Me>0?He/Me:null},stddev:(ge,Le)=>{const{n:Me,m2:He}=m(g(ge,Le));return Me>1?Math.sqrt(He/(Me-1)):null},stddevP:(ge,Le)=>{const{n:Me,m2:He}=m(g(ge,Le));return Me>0?Math.sqrt(He/Me):null},median:(ge,Le)=>{const Me=g(ge,Le);return Me.length?v(Me,.5):null},percentile:(ge,Le,Me)=>{const He=Me?Me.p:void 0;if(typeof He!="number"||!(He>=0&&He<=1))return null;const ce=g(ge,Le);return ce.length?v(ce,He):null},p25:(ge,Le)=>{const Me=g(ge,Le);return Me.length?v(Me,.25):null},p75:(ge,Le)=>{const Me=g(ge,Le);return Me.length?v(Me,.75):null},p90:(ge,Le)=>{const Me=g(ge,Le);return Me.length?v(Me,.9):null},p95:(ge,Le)=>{const Me=g(ge,Le);return Me.length?v(Me,.95):null},p99:(ge,Le)=>{const Me=g(ge,Le);return Me.length?v(Me,.99):null},iqr:(ge,Le)=>{const Me=g(ge,Le);if(!Me.length)return null;const He=Me.slice().sort();return w(He,.75)-w(He,.25)},mad:(ge,Le)=>{const Me=g(ge,Le);if(!Me.length)return null;const He=v(Me,.5),ce=new Float64Array(Me.length);for(let ae=0;ae<Me.length;ae++)ce[ae]=Math.abs(Me[ae]-He);return v(ce,.5)},range:(ge,Le)=>{const Me=g(ge,Le);if(!Me.length)return null;let He=1/0,ce=-1/0;for(let ae=0;ae<Me.length;ae++)Me[ae]<He&&(He=Me[ae]),Me[ae]>ce&&(ce=Me[ae]);return ce-He},distinct:(ge,Le)=>{const Me=Y(ge),He=new Set;for(let ce=0;ce<Le.length;ce++){const ae=Me(Le[ce]);ae==null||ae===""||He.add(ae instanceof Date?ae.getTime():ae)}return He.size},mode:(ge,Le)=>{const Me=Y(ge),He=new Map;for(let Pe=0;Pe<Le.length;Pe++){const Te=Me(Le[Pe]);if(Te==null||Te==="")continue;const xe=Te instanceof Date?Te.getTime():Te;He.set(xe,(He.get(xe)||0)+1)}let ce=null,ae=1;for(const[Pe,Te]of He)Te>ae&&(ae=Te,ce=Pe);return ce},skewness:(ge,Le)=>{const Me=g(ge,Le),{n:He,mean:ce,m2:ae}=m(Me);if(He<3||ae<=0)return null;const Pe=Math.sqrt(ae/(He-1));let Te=0;for(let xe=0;xe<Me.length;xe++)Te+=((Me[xe]-ce)/Pe)**3;return He/((He-1)*(He-2))*Te},kurtosis:(ge,Le)=>{const Me=g(ge,Le),{n:He,mean:ce,m2:ae}=m(Me);if(He<4||ae<=0)return null;const Pe=Math.sqrt(ae/(He-1));let Te=0;for(let Ye=0;Ye<Me.length;Ye++)Te+=((Me[Ye]-ce)/Pe)**4;const xe=He*(He+1)/((He-1)*(He-2)*(He-3)),_e=3*(He-1)**2/((He-2)*(He-3));return xe*Te-_e},geomean:(ge,Le)=>{const Me=g(ge,Le);if(!Me.length)return null;let He=0;for(let ce=0;ce<Me.length;ce++){if(Me[ce]<=0)return null;He+=Math.log(Me[ce])}return Math.exp(He/Me.length)},harmean:(ge,Le)=>{const Me=g(ge,Le);if(!Me.length)return null;let He=0;for(let ce=0;ce<Me.length;ce++){if(Me[ce]===0)return null;He+=1/Me[ce]}return Me.length/He},sumSquares:(ge,Le)=>{const Me=g(ge,Le);let He=0;for(let ce=0;ce<Me.length;ce++)He+=Me[ce]*Me[ce];return He},passRate:(ge,Le)=>{const{pass:Me,judged:He}=E(ge,Le);return He?Me/He:null},failureCount:(ge,Le)=>E(ge,Le).fail}),G=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",percentile:"Percentile",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function q(ge,Le,Me){const He=Y(ge),ce=Y(Le);let ae=0,Pe=0;for(let Te=0;Te<Me.length;Te++){const xe=Me[Te],_e=Number(He(xe)),Ye=Number(ce(xe));!Number.isFinite(_e)||!Number.isFinite(Ye)||(ae+=_e*Ye,Pe+=Ye)}return Pe===0?null:ae/Pe}function M(ge,Le,Me){const He=Y(ge);let ce=null,ae=Me?-1/0:1/0;for(let Pe=0;Pe<Le.length;Pe++){const Te=Le[Pe],xe=Number(He(Te));Number.isFinite(xe)&&(Me?xe>ae:xe<ae)&&(ae=xe,ce=Te)}return ce}function O(ge,Le,Me){const He=Y(ge),ce=Y(Le);let ae=0,Pe=0,Te=0,xe=0,_e=0,Ye=0;for(let bt=0;bt<Me.length;bt++){const Rt=Me[bt],Dt=Number(He(Rt)),Ct=Number(ce(Rt));!Number.isFinite(Dt)||!Number.isFinite(Ct)||(ae++,Pe+=Dt,Te+=Ct,xe+=Dt*Dt,_e+=Ct*Ct,Ye+=Dt*Ct)}if(ae<2)return null;const Qe=ae*Ye-Pe*Te,ut=Math.sqrt((ae*xe-Pe*Pe)*(ae*_e-Te*Te));if(ut===0)return null;const mt=Qe/ut;return Math.max(-1,Math.min(1,mt))}function T(ge,Le=.1){const Me=ge.length;if(!Me)return null;const He=Array.from(ge).sort((Te,xe)=>Te-xe),ce=Math.floor(Me*Math.min(.49,Math.max(0,Le))),ae=He.slice(ce,Me-ce);if(!ae.length)return w(He,.5);let Pe=0;for(const Te of ae)Pe+=Te;return Pe/ae.length}function A(ge,Le=.1){const Me=ge.length;if(!Me)return null;const He=Array.from(ge).sort((xe,_e)=>xe-_e),ce=Math.floor(Me*Math.min(.49,Math.max(0,Le))),ae=He[ce],Pe=He[Me-1-ce];let Te=0;for(const xe of He)Te+=Math.min(Pe,Math.max(ae,xe));return Te/Me}function N(ge,Le=3.5){if(!ge.length)return null;const He=Array.from(ge).sort((xe,_e)=>xe-_e),ce=w(He,.5),ae=He.map(xe=>Math.abs(xe-ce)).sort((xe,_e)=>xe-_e),Pe=w(ae,.5);if(Pe===0)return null;let Te=0;for(const xe of He)Math.abs(.6745*(xe-ce)/Pe)>Le&&Te++;return Te}function C(ge){const Le=ge.length;if(Le<8)return null;let Me=0;for(const xe of ge)Me+=xe;Me/=Le;let He=0,ce=0,ae=0;for(const xe of ge){const _e=xe-Me;He+=_e*_e,ce+=_e*_e*_e,ae+=_e*_e*_e*_e}if(He/=Le,ce/=Le,ae/=Le,He===0)return null;const Pe=ce/He**1.5,Te=ae/(He*He)-3;return Le/6*(Pe*Pe+Te*Te/4)}function S(ge,Le,Me){const He=[];let ce=0;for(let xe=0;xe<ge.length;xe++){const _e=Number(ge[xe]),Ye=Number(Le[xe]);!Number.isFinite(_e)||!Number.isFinite(Ye)||Ye<=0||(He.push([_e,Ye]),ce+=Ye)}if(!He.length||ce<=0)return null;if(He.sort((xe,_e)=>xe[0]-_e[0]),He.length===1)return He[0][0];const ae=[];let Pe=0;for(const[,xe]of He)ae.push((Pe+xe/2)/ce),Pe+=xe;const Te=Math.max(0,Math.min(1,Me));if(Te<=ae[0])return He[0][0];if(Te>=ae[ae.length-1])return He[He.length-1][0];for(let xe=1;xe<ae.length;xe++){if(Te>ae[xe])continue;const _e=ae[xe]-ae[xe-1],Ye=_e>0?(Te-ae[xe-1])/_e:0;return He[xe-1][0]+(He[xe][0]-He[xe-1][0])*Ye}return He[He.length-1][0]}function F(ge,Le,Me){const He=Y(ge),ce=Y(Le),ae=new Float64Array(Me.length),Pe=new Float64Array(Me.length);let Te=0;for(let xe=0;xe<Me.length;xe++){const _e=Me[xe],Ye=Number(He(_e)),Qe=Number(ce(_e));!Number.isFinite(Ye)||!Number.isFinite(Qe)||(ae[Te]=Ye,Pe[Te]=Qe,Te++)}return{xs:ae.subarray(0,Te),ys:Pe.subarray(0,Te),n:Te}}function $(ge,Le,Me,He=!1){const{xs:ce,ys:ae,n:Pe}=F(ge,Le,Me);if(Pe<2)return null;let Te=0,xe=0;for(let Ye=0;Ye<Pe;Ye++)Te+=ce[Ye],xe+=ae[Ye];Te/=Pe,xe/=Pe;let _e=0;for(let Ye=0;Ye<Pe;Ye++)_e+=(ce[Ye]-Te)*(ae[Ye]-xe);return _e/(He?Pe:Pe-1)}function W(ge,Le,Me){const{xs:He,ys:ce,n:ae}=F(ge,Le,Me);if(ae<2)return null;let Pe=0,Te=0;for(let Dt=0;Dt<ae;Dt++)Pe+=He[Dt],Te+=ce[Dt];Pe/=ae,Te/=ae;let xe=0,_e=0,Ye=0;for(let Dt=0;Dt<ae;Dt++){const Ct=He[Dt]-Pe,_t=ce[Dt]-Te;xe+=Ct*Ct,_e+=Ct*_t,Ye+=_t*_t}if(xe===0)return null;const Qe=_e/xe,ut=Te-Qe*Pe,mt=Ye===0?1:Math.max(0,Math.min(1,_e*_e/(xe*Ye))),bt=Math.max(0,Ye-Qe*_e),Rt=ae>2?Math.sqrt(bt/(ae-2)/xe):0;return{slope:Qe,intercept:ut,r2:mt,stdError:Rt,n:ae}}const K=new Set(["ols","wls","robust"]),I=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),J=1.345;function te(ge,Le,Me){const{xtwx:He,xtwy:ce}=a(ge,Le,Me),ae=j(He);if(!ae)return null;const Pe=k(ae,ce),Te=b(ae),xe=Q(ge,Pe),_e=Le.map((Ye,Qe)=>Ye-xe[Qe]);return{beta:Pe,cov:Te,fitted:xe,residuals:_e}}function Q(ge,Le){return ge.map(Me=>Me.reduce((He,ce,ae)=>He+ce*Le[ae],0))}function re(ge,Le){const Me=ge.length,He=ge.map(_e=>_e[Le]),ce=ge.map(_e=>[1,..._e.filter((Ye,Qe)=>Qe!==Le)]),ae=te(ce,He,null);if(!ae)return 1;const Pe=He.reduce((_e,Ye)=>_e+Ye,0)/Me;let Te=0,xe=0;for(let _e=0;_e<Me;_e++)Te+=ae.residuals[_e]**2,xe+=(He[_e]-Pe)**2;return xe===0?1:Math.max(0,Math.min(1,1-Te/xe))}function ie(ge){const Le=[...ge].sort((ce,ae)=>ce-ae),Me=ue(Le),He=ge.map(ce=>Math.abs(ce-Me)).sort((ce,ae)=>ce-ae);return ue(He)/.6745}function ue(ge){const Le=ge.length;if(!Le)return 0;const Me=Math.floor(Le/2);return Le%2?ge[Me]:(ge[Me-1]+ge[Me])/2}function ke(ge,Le,Me={}){const He=Me.method||"ols";if(B.has(He))throw new Error(`[lattice] regression method "${He}" is out of scope; use ols, wls or robust.`);if(I.has(He))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!K.has(He))throw new Error(`[lattice] unknown regression method "${He}"; use ols, wls or robust.`);const ce=Array.isArray(Le)?Le.length:0,ae=ce&&Array.isArray(ge[0])?ge[0].length:0,Pe=ae+1;if(!(ce>Pe))return null;for(let jt=0;jt<ce;jt++){if(!Number.isFinite(Le[jt])||!Array.isArray(ge[jt])||ge[jt].length!==ae)return null;for(let $t=0;$t<ae;$t++)if(!Number.isFinite(ge[jt][$t]))return null}let Te=null;if(He==="wls"){if(Te=Me.weights,!Array.isArray(Te)||Te.length!==ce)return null;for(let jt=0;jt<ce;jt++)if(!(Te[jt]>0)||!Number.isFinite(Te[jt]))return null}const xe=ge.map(jt=>[1,...jt]);let _e,Ye=null;if(He==="robust"){if(_e=te(xe,Le,null),!_e)return null;for(let jt=0;jt<50;jt++){const $t=ie(_e.residuals);if(!($t>0))break;const Vt=_e.residuals.map(Ut=>{const Gt=Math.abs(Ut/$t);return Gt<=J?1:J/Gt}),zt=te(xe,Le,Vt);if(!zt)return null;const Wt=zt.beta.reduce((Ut,Gt,It)=>Math.max(Ut,Math.abs(Gt-_e.beta[It])),0);if(_e=zt,Ye=Vt,Wt<1e-10)break}}else if(_e=te(xe,Le,Te),!_e)return null;const Qe=He==="robust"?Ye:Te,{beta:ut,cov:mt,fitted:bt,residuals:Rt}=_e;let Dt=0,Ct=0,_t=0;for(let jt=0;jt<ce;jt++){const $t=Qe?Qe[jt]:1;Dt+=$t*Rt[jt]**2,Ct+=$t,_t+=$t*Le[jt]}const tn=_t/Ct;let Ht=0;for(let jt=0;jt<ce;jt++){const $t=Qe?Qe[jt]:1;Ht+=$t*(Le[jt]-tn)**2}const Xt=ce-Pe,Je=Dt/Xt,at=Ht===0?1:Math.max(0,Math.min(1,1-Dt/Ht)),St=1-(1-at)*(ce-1)/Xt,wt=Array.isArray(Me.names)&&Me.names.length===ae?Me.names:ge[0].map((jt,$t)=>`x${$t+1}`),vt=qe(Me.confidence),Xe=Xt>0?L(1-(1-vt)/2,Xt):1/0,ht=ut.map((jt,$t)=>{const Vt=Math.sqrt(Math.max(0,Je*mt[$t][$t])),zt=Vt>0?jt/Vt:jt===0?0:1/0,Wt=Number.isFinite(zt)?2*(1-Z(Math.abs(zt),Xt)):0,Ut=Number.isFinite(Xe)?Xe*Vt:null;return{name:$t===0?"(intercept)":wt[$t-1],estimate:jt,stdError:Vt,t:zt,p:Math.max(0,Math.min(1,Wt)),lower:Ut===null?null:jt-Ut,upper:Ut===null?null:jt+Ut}}),ot=new Array(ce),gt=new Array(ce);for(let jt=0;jt<ce;jt++){const $t=Qe?Qe[jt]:1,Vt=Math.max(0,Math.min(1,$t*h(xe[jt],mt)));ot[jt]=Vt;const zt=(1-Vt)**2;gt[jt]=zt>0&&Je>0?Rt[jt]**2/(Pe*Je)*(Vt/zt):null}const xt=ge[0].map((jt,$t)=>{if(ae<2)return 1;const Vt=re(ge,$t);return Vt>=1?1/0:1/(1-Vt)});let Lt=null;{const jt=Rt.map(Vt=>Vt*Vt),$t=te(xe,jt,null);if($t){const Vt=jt.reduce((Jt,ln)=>Jt+ln,0)/ce;let zt=0,Wt=0;for(let Jt=0;Jt<ce;Jt++)zt+=$t.residuals[Jt]**2,Wt+=(jt[Jt]-Vt)**2;const Ut=Wt===0?0:Math.max(0,Math.min(1,1-zt/Wt)),Gt=ce*Ut,It=X(Gt,ae);Lt={statistic:Gt,df:ae,p:It,heteroscedastic:It<.05}}}let kt=null;if(ae===1){const jt=ge.map(($t,Vt)=>Vt).sort(($t,Vt)=>ge[$t][0]-ge[Vt][0]);kt={confidence:vt,points:jt.map($t=>{const Vt=xe[$t],zt=Math.sqrt(Math.max(0,Je*h(Vt,mt)));return{x:ge[$t][0],yhat:bt[$t],lower:bt[$t]-Xe*zt,upper:bt[$t]+Xe*zt}})}}return{method:He,coefficients:ht,r2:at,adjR2:St,n:ce,df:Xt,sigma2:Je,fitted:bt,residuals:Rt,leverage:ot,cooksD:gt,vif:xt,heteroscedasticity:Lt,band:kt,weights:Qe?[...Qe]:null}}function de(ge){const Le=ge.length,Me=Array.from({length:Le},(ae,Pe)=>Pe).sort((ae,Pe)=>ge[ae]-ge[Pe]),He=new Float64Array(Le);let ce=0;for(;ce<Le;){let ae=ce;for(;ae+1<Le&&ge[Me[ae+1]]===ge[Me[ce]];)ae++;const Pe=(ce+ae)/2+1;for(let Te=ce;Te<=ae;Te++)He[Me[Te]]=Pe;ce=ae+1}return He}const we=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function ve(ge){const Le=[.01,.05,.1],Me=[we["1%"],we["5%"],we["10%"]];if(ge<=Me[0]){const ae=(Math.log(Le[1])-Math.log(Le[0]))/(Me[1]-Me[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(Le[0])+ae*(ge-Me[0]))))}if(ge>=Me[2]){const ae=(Math.log(Le[2])-Math.log(Le[1]))/(Me[2]-Me[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(Le[2])+ae*(ge-Me[2]))))}const He=ge<Me[1]?0:1,ce=(ge-Me[He])/(Me[He+1]-Me[He]);return Math.exp(Math.log(Le[He])+ce*(Math.log(Le[He+1])-Math.log(Le[He])))}function De(ge,Le,Me,He){const ce=Me-He,ae=He+3,Pe=new Array(ce),Te=new Array(ce);let xe=!0,_e=He;for(let bt=0;bt<ce;bt++){const Rt=He+bt,Dt=new Float64Array(ae);Dt[0]=1,Dt[1]=bt+1,Dt[2]=ge[Rt];for(let Ct=1;Ct<=He;Ct++)Dt[2+Ct]=Le[Rt-Ct];for(let Ct=1;Ct<ae;Ct++)Number.isFinite(Dt[Ct])||(_e=Math.min(_e,Ct-3));Pe[bt]=Dt,Te[bt]=Le[Rt],Number.isFinite(Te[bt])||(xe=!1)}if(!xe)return 0;const{xtwx:Ye,xtwy:Qe}=a(Pe,Te,null);let ut=0,mt=1/0;for(let bt=0;bt<=_e;bt++){const Rt=bt+3;if(!(ce>Rt))continue;const Dt=new Array(Rt);for(let at=0;at<Rt;at++)Dt[at]=Ye[at].slice(0,Rt);const Ct=j(Dt);if(!Ct)continue;const _t=k(Ct,Qe.slice(0,Rt));let tn=0;for(let at=0;at<ce;at++){const St=Pe[at];let wt=0;for(let vt=0;vt<Rt;vt++)wt+=St[vt]*_t[vt];tn+=(Te[at]-wt)**2}const Xt=tn/(ce-Rt)*(ce-Rt);if(!(Xt>0))continue;const Je=ce*Math.log(Xt/ce)+2*Rt;Je<mt&&(mt=Je,ut=bt)}return ut}function pe(ge,Le={}){const Me=[];for(let mt=0;mt<ge.length;mt++){const bt=Number(ge[mt]);Number.isFinite(bt)&&Me.push(bt)}const He=Me.length,ce=He-1;if(He<8||ce<6)return null;const ae=new Array(ce);for(let mt=0;mt<ce;mt++)ae[mt]=Me[mt+1]-Me[mt];let Pe=Number.isFinite(Le.maxlag)?Math.floor(Le.maxlag):Math.ceil(12*(He/100)**.25);Pe=Math.max(0,Math.min(Pe,Math.floor((ce-5)/2)));const Te=(mt,bt)=>{const Rt=[],Dt=[];for(let Ct=bt;Ct<ce;Ct++){const _t=[Ct-bt+1,Me[Ct]];for(let tn=1;tn<=mt;tn++)_t.push(ae[Ct-tn]);Rt.push(_t),Dt.push(ae[Ct])}return ke(Rt,Dt,{method:"ols"})},xe=De(Me,ae,ce,Pe),_e=Te(xe,xe);if(!_e||!_e.coefficients[2])return null;const Ye=_e.coefficients[2].t,Qe=ve(Ye),ut=Ye<we["5%"];return{statistic:Ye,usedLag:xe,nobs:ce-xe,criticalValues:{...we},pValue:Qe,pApproximate:!0,stationary:ut,verdict:ut?"stationary":"non-stationary",regression:"ct"}}function oe(ge,Le={}){const Me=[];for(let ut=0;ut<ge.length;ut++){const mt=Number(ge[ut]);Number.isFinite(mt)&&Me.push(mt)}const He=Me.length;if(He<3)return null;let ce=Number.isFinite(Le.maxlag)?Math.floor(Le.maxlag):Math.min(10,He-1);ce=Math.max(1,Math.min(ce,He-1));let ae=0;for(const ut of Me)ae+=ut;ae/=He;const Pe=Me.map(ut=>ut-ae);let Te=0;for(const ut of Pe)Te+=ut*ut;Te/=He;const xe=new Array(ce+1).fill(0);xe[0]=1;for(let ut=1;ut<=ce;ut++){let mt=0;for(let bt=ut;bt<He;bt++)mt+=Pe[bt]*Pe[bt-ut];xe[ut]=Te>0?mt/He/Te:0}const _e=new Array(ce+1).fill(0);_e[0]=1;let Ye=[];for(let ut=1;ut<=ce;ut++){let mt=xe[ut];for(let Ct=1;Ct<ut;Ct++)mt-=Ye[Ct-1]*xe[ut-Ct];let bt=1;for(let Ct=1;Ct<ut;Ct++)bt-=Ye[Ct-1]*xe[Ct];const Rt=bt!==0?mt/bt:0,Dt=new Array(ut);for(let Ct=1;Ct<ut;Ct++)Dt[Ct-1]=Ye[Ct-1]-Rt*Ye[ut-1-Ct];Dt[ut-1]=Rt,_e[ut]=Rt,Ye=Dt}const Qe=1.96/Math.sqrt(He);return{acf:xe,pacf:_e,bounds:{upper:Qe,lower:-Qe},n:He,nlags:ce,approximate:!0}}function be(ge,Le,Me){const{xs:He,ys:ce,n:ae}=F(ge,Le,Me);if(ae<2)return null;const Pe=de(He),Te=de(ce);let xe=0,_e=0;for(let mt=0;mt<ae;mt++)xe+=Pe[mt],_e+=Te[mt];xe/=ae,_e/=ae;let Ye=0,Qe=0,ut=0;for(let mt=0;mt<ae;mt++){const bt=Pe[mt]-xe,Rt=Te[mt]-_e;Ye+=bt*Rt,Qe+=bt*bt,ut+=Rt*Rt}return Qe===0||ut===0?null:Math.max(-1,Math.min(1,Ye/Math.sqrt(Qe*ut)))}function fe(ge,Le,Me){const{xs:He,ys:ce,n:ae}=F(ge,Le,Me);if(ae<2||ae>o)return null;let Pe=0,Te=0,xe=0,_e=0;for(let ut=0;ut<ae;ut++)for(let mt=ut+1;mt<ae;mt++){const bt=Math.sign(He[ut]-He[mt]),Rt=Math.sign(ce[ut]-ce[mt]),Dt=bt*Rt;Dt>0?Pe++:Dt<0?Te++:bt===0&&Rt===0||(bt===0?xe++:_e++)}const Ye=Pe+Te+_e,Qe=Pe+Te+xe;return Ye===0||Qe===0?null:(Pe-Te)/Math.sqrt(Ye*Qe)}function le(ge,Le={}){const Me=ge.length;if(Me<2)return null;const He=ge[0],ce=ge[Me-1],ae=[];for(let Ct=1;Ct<Me;Ct++){const _t=ge[Ct-1];_t!==0&&ae.push((ge[Ct]-_t)/Math.abs(_t))}let Pe=null;if(ae.length>1){let Ct=0;for(const tn of ae)Ct+=tn;Ct/=ae.length;let _t=0;for(const tn of ae)_t+=(tn-Ct)**2;Pe=Math.sqrt(_t/(ae.length-1))}const Te=Number(Le.periodsPerYear)>0?Number(Le.periodsPerYear):null;let xe=ge[0],_e=0,Ye=0,Qe=0,ut=0;for(let Ct=1;Ct<Me;Ct++){if(ge[Ct]>xe){xe=ge[Ct],_e=Ct;continue}if(xe<=0)continue;const _t=(xe-ge[Ct])/xe;_t>Ye&&(Ye=_t,Qe=_e,ut=Ct)}let mt=null;if(Me>2){let Ct=0;for(let Ht=0;Ht<Me;Ht++)Ct+=ge[Ht];Ct/=Me;let _t=0,tn=0;for(let Ht=0;Ht<Me;Ht++){const Xt=ge[Ht]-Ct;tn+=Xt*Xt,Ht>0&&(_t+=Xt*(ge[Ht-1]-Ct))}mt=tn>0?_t/tn:null}let bt=0,Rt=0;for(const Ct of ae)Ct>0?bt++:Ct<0&&Rt++;let Dt=null;if(He>0&&ce>0){const Ct=(ce/He)**(1/(Me-1))-1;Dt=Te?(1+Ct)**Te-1:Ct}return{n:Me,first:He,last:ce,change:ce-He,changePercent:He===0?null:(ce-He)/Math.abs(He)*100,volatility:Pe,annualisedVolatility:Pe!==null&&Te?Pe*Math.sqrt(Te):null,growth:Dt,maxDrawdown:Ye,maxDrawdownFrom:Qe,maxDrawdownTo:ut,autocorrelation:mt,upDays:bt,downDays:Rt}}const ye=1.128,Ne=3.267;function je(ge){const Le=ge.length;if(Le<2)return null;const Me=[];for(let ce=1;ce<Le;ce++)Me.push(Math.abs(ge[ce]-ge[ce-1]));const He=Me.reduce((ce,ae)=>ce+ae,0)/Me.length;return{ranges:Me,centre:He,upper:Ne*He,lower:0}}function $e(ge){const Le=ge.length;if(Le<2)return null;let Me=0;for(let ce=1;ce<Le;ce++)Me+=Math.abs(ge[ce]-ge[ce-1]);const He=Me/(Le-1);return{sigma:He/ye,meanRange:He}}function Re(ge,Le){const Me=ge.length;if(Me<2||!Le)return null;const He=Number.isFinite(Number(Le.lower))?Number(Le.lower):null,ce=Number.isFinite(Number(Le.upper))?Number(Le.upper):null;if(He===null&&ce===null)return null;let ae=0;for(let bt=0;bt<Me;bt++)ae+=ge[bt];ae/=Me;let Pe=0;for(let bt=0;bt<Me;bt++)Pe+=(ge[bt]-ae)**2;const Te=Math.sqrt(Pe/(Me-1)),xe=$e(ge),_e=xe?xe.sigma:null,Ye=bt=>{if(!bt||bt<=0)return{index:null,k:null};const Dt=He!==null&&ce!==null?(ce-He)/(6*bt):null,Ct=ce!==null?(ce-ae)/(3*bt):1/0,_t=He!==null?(ae-He)/(3*bt):1/0;return{index:Dt,k:Math.min(Ct,_t)}},Qe=Ye(_e),ut=Ye(Te);let mt=0;for(let bt=0;bt<Me;bt++){if(He!==null&&ge[bt]<He){mt++;continue}ce!==null&&ge[bt]>ce&&mt++}return{n:Me,mean:ae,lower:He,upper:ce,target:Number.isFinite(Number(Le.target))?Number(Le.target):null,sigmaWithin:_e,sigmaOverall:Te,cp:Qe.index,cpk:Qe.k,pp:ut.index,ppk:ut.k,outOfSpec:mt,defectRate:Me?mt/Me:null}}function Se(ge){const Le=ge.length;if(Le<2)return null;const Me=$e(ge);if(!Me||!(Me.sigma>0))return null;let He=0;for(let ce=0;ce<Le;ce++)He+=ge[ce];return He/=Le,{centre:He,sigma:Me.sigma,upper:He+3*Me.sigma,lower:He-3*Me.sigma}}function Ve(ge,Le){if(!Le||!(Le.sigma>0))return[];const Me=ge.length,{centre:He,sigma:ce}=Le,ae=Te=>(ge[Te]-He)/ce,Pe=[];for(let Te=0;Te<Me;Te++){if(Math.abs(ae(Te))>3&&Pe.push({index:Te,rule:1,description:"beyond three sigma"}),Te>=2)for(const xe of[1,-1]){let _e=0;for(let Ye=Te-2;Ye<=Te;Ye++)ae(Ye)*xe>2&&_e++;if(_e>=2){Pe.push({index:Te,rule:2,description:"two of three past two sigma"});break}}if(Te>=4)for(const xe of[1,-1]){let _e=0;for(let Ye=Te-4;Ye<=Te;Ye++)ae(Ye)*xe>1&&_e++;if(_e>=4){Pe.push({index:Te,rule:3,description:"four of five past one sigma"});break}}if(Te>=7)for(const xe of[1,-1]){let _e=!0;for(let Ye=Te-7;Ye<=Te;Ye++)if(ae(Ye)*xe<=0){_e=!1;break}if(_e){Pe.push({index:Te,rule:4,description:"eight in a row on one side"});break}}}return Pe}function Fe(ge,Le){if(!Le||!(Le.sigma>0))return[];const Me=ge.length,{centre:He,sigma:ce}=Le,ae=xe=>(ge[xe]-He)/ce,Pe=(xe,_e,Ye,Qe)=>{for(const ut of[1,-1]){let mt=0;for(let bt=xe;bt<=_e;bt++)ae(bt)*ut>Ye&&mt++;if(mt>=Qe)return!0}return!1},Te=[];for(let xe=0;xe<Me;xe++){if(Math.abs(ae(xe))>3&&Te.push({index:xe,rule:1,description:"beyond three sigma"}),xe>=8)for(const _e of[1,-1]){let Ye=!0;for(let Qe=xe-8;Qe<=xe;Qe++)if(ae(Qe)*_e<=0){Ye=!1;break}if(Ye){Te.push({index:xe,rule:2,description:"nine in a row on one side"});break}}if(xe>=5)for(const _e of[1,-1]){let Ye=!0;for(let Qe=xe-4;Qe<=xe;Qe++)if((ge[Qe]-ge[Qe-1])*_e<=0){Ye=!1;break}if(Ye){Te.push({index:xe,rule:3,description:_e>0?"six rising":"six falling"});break}}if(xe>=13){let _e=!0;for(let Ye=xe-12;Ye<=xe;Ye++){const Qe=ge[Ye]-ge[Ye-1],ut=ge[Ye+1<=xe?Ye+1:Ye]-ge[Ye];if(Ye+1>xe)break;if(Qe===0||ut===0||Qe>0==ut>0){_e=!1;break}}_e&&Te.push({index:xe,rule:4,description:"fourteen alternating"})}if(xe>=2&&Pe(xe-2,xe,2,2)&&Te.push({index:xe,rule:5,description:"two of three past two sigma"}),xe>=4&&Pe(xe-4,xe,1,4)&&Te.push({index:xe,rule:6,description:"four of five past one sigma"}),xe>=14){let _e=!0;for(let Ye=xe-14;Ye<=xe;Ye++)if(Math.abs(ae(Ye))>=1){_e=!1;break}_e&&Te.push({index:xe,rule:7,description:"fifteen within one sigma"})}if(xe>=7){let _e=!0;for(let Ye=xe-7;Ye<=xe;Ye++)if(Math.abs(ae(Ye))<=1){_e=!1;break}_e&&Te.push({index:xe,rule:8,description:"eight beyond one sigma"})}}return Te}const Ce=Object.freeze(["westernElectric","nelson"]);function Ee(ge,Le,Me="westernElectric"){return String(Me)==="nelson"?Fe(ge,Le):Ve(ge,Le)}function Ie(ge,Le,Me){let He=0;for(let ce=0;ce<ge.length;ce++)(ge[ce]<Le||ge[ce]>Me)&&He++;return He}function Be(ge,Le,Me,He=20){const ce=ge.length;if(!ce)return[];const ae=ge[0],Pe=ge[ce-1];if(Pe===ae)return[{from:ae,to:Pe,count:ce}];const Te=Me-Le,xe=1.5*Te;let _e=Te>0?Math.max(ae,Le-xe):ae,Ye=Te>0?Math.min(Pe,Me+xe):Pe;Ye>_e||(_e=ae,Ye=Pe);const Qe=Te>0?2*Te/Math.cbrt(ce):(Ye-_e)/(Math.ceil(Math.log2(ce))+1),ut=Qe>0?Math.min(He,Math.max(1,Math.ceil((Ye-_e)/Qe))):1,mt=(Ye-_e)/ut,bt=[];for(let Rt=0;Rt<ut;Rt++)bt.push({from:_e+Rt*mt,to:_e+(Rt+1)*mt,count:0});for(let Rt=0;Rt<ce;Rt++){const Dt=Math.min(ut-1,Math.max(0,Math.floor((ge[Rt]-_e)/mt)));bt[Dt].count++}return bt[0].from=ae,bt[ut-1].to=Pe,bt}const Ke=.95;function qe(ge){const Le=Number(ge);return Number.isFinite(Le)&&Le>0&&Le<1?Le:Ke}function rt(ge,Le=Ke){const Me=ge.length;if(Me<2)return null;let He=0;for(let Ye=0;Ye<Me;Ye++)He+=ge[Ye];const ce=He/Me;let ae=0;for(let Ye=0;Ye<Me;Ye++){const Qe=ge[Ye]-ce;ae+=Qe*Qe}const Pe=Math.sqrt(ae/(Me-1)),Te=qe(Le),_e=L(1-(1-Te)/2,Me-1)*Pe/Math.sqrt(Me);return{mean:ce,lower:ce-_e,upper:ce+_e,margin:_e,n:Me,confidence:Te}}function nt(ge,Le,Me=Ke){const He=Number(ge),ce=Number(Le);if(!(ce>0)||!(He>=0)||He>ce)return null;const ae=qe(Me),Pe=H(1-(1-ae)/2),Te=He/ce,xe=Pe*Pe,_e=1+xe/ce,Ye=(Te+xe/(2*ce))/_e,Qe=Pe/_e*Math.sqrt(Te*(1-Te)/ce+xe/(4*ce*ce));return{proportion:Te,lower:Math.max(0,Ye-Qe),upper:Math.min(1,Ye+Qe),n:ce,confidence:ae}}function dt(ge,Le=Ke){if(!ge||!(ge.n>2)||!Number.isFinite(ge.stdError))return null;const Me=qe(Le),ce=L(1-(1-Me)/2,ge.n-2)*ge.stdError;return{slope:ge.slope,lower:ge.slope-ce,upper:ge.slope+ce,margin:ce,confidence:Me}}function Pt(ge,Le,Me=Ke){const He=Number(ge),ce=Number(Le);if(!Number.isFinite(He)||!(ce>1))return null;const ae=qe(Me),Te=H(1-(1-ae)/2)*Math.sqrt(1/(9*ce)+He*He/(2*(ce-1)));return{index:He,lower:He-Te,upper:He+Te,margin:Te,n:ce,confidence:ae}}function Nt(ge,Le){return!ge||!(ge.sd>0)||!Number.isFinite(Le)||!Number.isFinite(ge.mean)?null:(Le-ge.mean)/ge.sd}function it(ge){return Number.isFinite(ge)?Math.min(1,Math.max(0,2*x(Math.abs(ge)/2)-1)):0}function ct(ge,Le){const Me=new Map,He=Y(ge);let ce=0;for(let ae=0;ae<Le.length;ae++){const Pe=He(Le[ae]);if(Pe==null||Pe===""||typeof Pe=="number"&&Number.isNaN(Pe))continue;const Te=Pe instanceof Date?Pe.getTime():typeof Pe=="object"?String(Pe):Pe;Me.set(Te,(Me.get(Te)||0)+1),ce++}return{map:Me,total:ce}}function ft(ge,Le,Me,He){if(!(Le>0)||!(He>0))return null;let ce=0;const ae=new Set(ge.keys());for(const Pe of Me.keys())ae.add(Pe);for(const Pe of ae){const Te=(ge.get(Pe)||0)/Le,xe=(Me.get(Pe)||0)/He;ce+=Math.abs(Te-xe)}return ce/2}const Tt=10;function pt(ge,Le,Me){if(Me&&Me.numeric){const Te=g(ge,Le),{n:xe,mean:_e}=m(Te),Ye=xe>0?Nt({mean:Me.mean,sd:Me.sd},_e):null;return{measure:"standardizedMeanDifference",magnitude:Ye,distance:Ye===null?0:it(Ye),direction:Ye===null?0:Math.sign(Ye),subsetN:xe,populationN:Me.n||0,reliable:xe>=Tt}}const{map:ce,total:ae}=ct(ge,Le),Pe=ft(ce,ae,Me.map,Me.total);return{measure:"categoricalTotalVariation",magnitude:Pe,distance:Pe===null?0:Pe,direction:0,subsetN:ae,populationN:Me.total||0,reliable:ae>=Tt}}function Oe(ge,Le){if(ge&&(ge.kind==="float64"||ge.kind==="int32"))return!0;const Me=Y(ge);let He=0,ce=0;for(let ae=0;ae<Le.length&&He<200;ae++){const Pe=Me(Le[ae]);if(Pe==null||Pe==="")continue;if(Pe instanceof Date)return!1;He++;const Te=typeof Pe=="number"?Pe:Number(Pe);Number.isFinite(Te)&&ce++}return He===0?!1:ce/He>=.9}function Ae(ge,Le){if(Oe(ge,Le)){const ce=g(ge,Le),{n:ae,mean:Pe,m2:Te}=m(ce);return{numeric:!0,mean:Pe,sd:ae>0?Math.sqrt(Te/ae):0,n:ae}}const{map:Me,total:He}=ct(ge,Le);return{numeric:!1,map:Me,total:He}}}),We("packages/core/src/compute/total.js",function(e,D){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return m}});const P=D("packages/core/src/internal/predicates.js").isFunction,_=D("packages/core/src/internal/warn.js").warnOnce,L=D("packages/core/src/compute/handle.js"),Z=L.presenceReader,H=L.valueComparator,x=L.valueReader,X=D("packages/core/src/compute/statistics.js"),U=X.STAT_FNS,j=X.STAT_LABELS;function k(w){return!!w&&(w.kind==="float64"||w.kind==="int32")}function b(w,v){const E=v.length;let V=0;if(k(w)){const q=w.values,M=Z(w);if(!M){for(let O=0;O<E;O++){const T=q[v[O]];Number.isNaN(T)||(V+=T)}return V}for(let O=0;O<E;O++){const T=v[O];if(M(T)===1){const A=q[T];Number.isNaN(A)||(V+=A)}}return V}const G=x(w);for(let q=0;q<E;q++){const M=g(G(v[q]));M!==null&&(V+=M)}return V}b.kernel=!0;function a(w,v){const E=v.length;let V=0;if(k(w)){const q=w.values,M=Z(w);if(!M){for(let O=0;O<E;O++)Number.isNaN(q[v[O]])||V++;return V}for(let O=0;O<E;O++){const T=v[O];M(T)===1&&!Number.isNaN(q[T])&&V++}return V}const G=x(w);for(let q=0;q<E;q++){const M=G(v[q]);M!=null&&!(typeof M=="number"&&Number.isNaN(M))&&V++}return V}a.kernel=!0;function h(w,v){return v.length}h.kernel=!0;function r(w,v){const E=a(w,v);return E===0?null:b(w,v)/E}r.kernel=!0;function t(w,v,E,V){const G=v.length;if(k(w)){const T=w.values,A=Z(w);let N=null;if(!A){for(let C=0;C<G;C++){const S=T[v[C]];Number.isNaN(S)||(N===null||(E<0?S<N:S>N))&&(N=S)}return N}for(let C=0;C<G;C++){const S=v[C];if(A(S)===0)continue;const F=T[S];Number.isNaN(F)||(N===null||(E<0?F<N:F>N))&&(N=F)}return N}const q=x(w),M=H(V);let O=null;for(let T=0;T<G;T++){const A=q(v[T]);A==null||typeof A=="number"&&Number.isNaN(A)||(O===null||(E<0?M(A,O)<0:M(A,O)>0))&&(O=A)}return O}function o(w,v,E){return t(w,v,-1,E&&E.locale)}o.kernel=!0;function u(w,v,E){return t(w,v,1,E&&E.locale)}u.kernel=!0;function d(w,v){return v.length===0?null:x(w)(v[0])}d.kernel=!0;function s(w,v){return v.length===0?null:x(w)(v[v.length-1])}s.kernel=!0;function g(w){if(typeof w=="number")return Number.isNaN(w)?null:w;if(w==null||w===""||typeof w=="boolean")return null;if(w instanceof Date)return w.getTime();const v=Number(w);return Number.isNaN(v)?null:v}const i={sum:b,min:o,max:u,avg:r,count:h,first:d,last:s,countValues:a,...U},n=Object.freeze({...j,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function f(w){return w?typeof w=="string"?n[w]||w:"Total":""}const p=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function l(w){const v=w&&w.dataType&&w.dataType.totals&&w.dataType.totals.supported;if(Array.isArray(v))return v.slice();const E=p.filter(V=>V in i);for(const V of Object.keys(i))E.includes(V)||E.push(V);return E}function y(w,v){return typeof v!="string"?!0:l(w).includes(v)}function c(w,v){const E=x(w),V=[];for(let G=0;G<v.length;G++){const q=E(v[G]);q!=null&&V.push(q)}return V}function m(w,v,E,V){const G=v||[];if(E&&typeof E=="object"&&typeof E.fn=="string"){const{fn:q,...M}=E,O=i[q];return O?O(w,G,{...V,...M}):(_(`total:${q}`,`unknown total function "${q}"; register it in config.totalFns`),null)}if(typeof E=="string"){const q=i[E];return q?q(w,G,V):(_(`total:${E}`,`unknown total function "${E}"; register it in config.totalFns`),null)}return P(E)?E.kernel===!0?E(w,G,V):E(c(w,G),V||{}):null}}),We("packages/core/src/compute/windowed.js",function(e,D){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const P=D("packages/core/src/compute/sketch.js").Welford;class Y{#e;#t;#n=[];#r;#s;constructor(x,X=0,U=Date.now){if(x!=="count"&&x!=="time"&&x!=="session")throw new RangeError(`unknown window kind: ${x}`);if((x==="count"||x==="time")&&!(X>0))throw new RangeError(`a ${x} window needs a positive span`);this.#e=x,this.#t=Math.floor(X),this.#r=U,this.#s=U()}get size(){return this.#n.length}push(x,X=this.#r()){Number.isFinite(x)&&(this.#n.push({t:X,v:x}),this.#i(X))}#i(x){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const X=x-this.#t;for(;this.#n.length&&this.#n[0].t<X;)this.#n.shift()}}spec(){const x=this.#e==="session"?this.#r()-this.#s: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 X=new P;let U=0,j=1/0,k=-1/0;for(const{v:b}of this.#n)U+=b,b<j&&(j=b),b>k&&(k=b),X.add(b);return{over:x,count:this.#n.length,sum:U,mean:X.mean(),min:j,max:k,variance:X.variance(),stddev:X.stddev()}}reduce(x){const X=this.aggregate(),U={sum:X.sum,avg:X.mean,mean:X.mean,min:X.min,max:X.max,count:X.count,variance:X.variance,stddev:X.stddev};if(!(x in U))throw new RangeError(`unknown windowed aggregate: ${x}`);return{value:U[x],over:X.over}}}const _=Object.freeze(["count","time","session"]);function L(H,x=Date.now){const X=H.kind==="time"&&H.minutes!=null?H.minutes*6e4:H.span??0;return new Y(H.kind,X,x)}const Z={Window:Y,WINDOW_KINDS:_,openWindow:L}}),We("packages/core/src/compute/rolling.js",function(e,D){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const P=D("packages/core/src/compute/windowed.js").openWindow,_=D("packages/core/src/compute/sketch.js").KLL,L=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function Z(i,n,f,p){if(i.kind==="count"){const l=Math.max(1,Math.floor(i.span||0));return{coverage:Math.min(1,n/l),partial:n<l}}if(i.kind==="time"){const l=i.minutes!=null?i.minutes*6e4:i.span||0;if(!(l>0))return{coverage:1,partial:!1};const y=f-p;return{coverage:Math.min(1,y/l),partial:y<l}}return{coverage:null,partial:!1}}function H(i,n){const f=P(n),p=new Map,l=i.length?i[0].at:0;for(let y=0;y<i.length;y++){const{key:c,at:m,value:w}=i[y];Number.isFinite(w)&&f.push(w,m);const v=f.aggregate(),E=Z(n,v.count,m,l);c!=null&&p.set(String(c),{sum:v.sum,avg:v.mean,min:v.min,max:v.max,count:v.count,coverage:E.coverage,partial:E.partial})}return p}function x(i){const n=new Map;let f=0;for(const{key:p,value:l}of i)Number.isFinite(l)&&(f+=l),p!=null&&n.set(String(p),f);return n}function X(i,n=1){const f=new Map,p=Math.max(1,Math.floor(n));for(let l=0;l<i.length;l++){const{key:y,value:c}=i[l];if(y==null)continue;const m=l>=p?i[l-p].value:null,w=Number.isFinite(c)?c:null,v=Number.isFinite(m)?m:null;f.set(String(y),w!==null&&v!==null?w-v:null)}return f}const U=4096;function j(i){let n=i>>>0;return()=>{n+=1831565813;let f=n;return f=Math.imul(f^f>>>15,f|1),f^=f+Math.imul(f^f>>>7,f|61),((f^f>>>14)>>>0)/4294967296}}function k(i,n){const f=i.length;if(f===1)return i[0];const p=(f-1)*n,l=Math.floor(p),y=Math.ceil(p);return l===y?i[l]:i[l]+(p-l)*(i[y]-i[l])}function b(i,n,f={}){const p=Math.min(1,Math.max(0,f.q==null?.5:f.q)),l=Math.max(1,Math.floor(f.cap==null?U:f.cap)),y=j(f.seed==null?2654435769:f.seed),c=new Map,m=i.length?i[0].at:0;if(n.kind==="session"){const v=new _(200,y);let E=0;for(const{key:V,value:G}of i)Number.isFinite(G)&&(v.add(G),E++),V!=null&&c.set(String(V),{value:E?v.quantile(p):null,approx:E>0,count:E,coverage:null,partial:!1});return c}const w=P(n);for(const{key:v,at:E,value:V}of i){Number.isFinite(V)&&w.push(V,E);const G=w.values(),q=G.length;let M=null,O=!1;if(q)if(q<=l)M=k([...G].sort((A,N)=>A-N),p);else{const A=new _(200,y);for(const N of G)A.add(N);M=A.quantile(p),O=!0}const T=Z(n,q,E,m);v!=null&&c.set(String(v),{value:M,approx:O,count:q,coverage:T.coverage,partial:T.partial})}return c}function a(i,n){const f=i.length,p=new Array(f).fill(null),l=Math.floor(n/2),y=n%2===0;for(let c=0;c<f;c++){if(c-l<0||c+l>=f)continue;let m=0,w=!0;if(y)for(let v=-l;v<=l;v++){const E=i[c+v];if(!Number.isFinite(E)){w=!1;break}m+=v===-l||v===l?E*.5:E}else for(let v=-l;v<=l;v++){const E=i[c+v];if(!Number.isFinite(E)){w=!1;break}m+=E}w&&(p[c]=m/n)}return p}function h(i,n){const f=new Map,p=Math.floor(Number(n&&n.period));if(!(p>=2))return f;const l=n&&n.model==="multiplicative",y=i.length,c=i.map(O=>Number.isFinite(O.value)?O.value:null),m=a(c,p),w=new Array(y).fill(null);for(let O=0;O<y;O++){const T=m[O],A=c[O];T===null||A===null||(l?T!==0&&(w[O]=A/T):w[O]=A-T)}const v=new Array(p).fill(0),E=new Array(p).fill(0);for(let O=0;O<y;O++){if(w[O]===null)continue;const T=O%p;v[T]+=w[O],E[T]+=1}const V=l?1:0,G=v.map((O,T)=>E[T]?O/E[T]:V),q=G.reduce((O,T)=>O+T,0)/p,M=l?G.map(O=>q!==0?O/q:1):G.map(O=>O-q);for(let O=0;O<y;O++){const{key:T}=i[O];if(T==null)continue;const A=m[O],N=M[O%p],C=c[O];let S=null;A!==null&&C!==null&&(S=l?A*N!==0?C/(A*N):null:C-A-N),f.set(String(T),{trend:A,seasonal:C===null?null:N,residual:S,coverage:A===null?0:1,partial:A===null})}return f}function r(i,n,f,p=80){const l=(Math.sqrt(5)-1)/2;let y=n,c=f,m=c-l*(c-y),w=y+l*(c-y),v=i(m),E=i(w);for(let V=0;V<p;V++)v<E?(c=w,w=m,E=v,m=c-l*(c-y),v=i(m)):(y=m,m=w,v=E,w=y+l*(c-y),E=i(w));return(y+c)/2}const t=1e-4,o=1-1e-4;function u(i,n){const f=i.length,p=new Array(f).fill(null),l=new Array(f).fill(null);let y=null,c=0;for(let m=0;m<f;m++){const w=i[m];if(!Number.isFinite(w)){y!==null&&(l[m]=y,p[m]=y);continue}if(y===null){y=w,l[m]=w,p[m]=w;continue}l[m]=y,c+=(w-y)**2,y=n*w+(1-n)*y,p[m]=y}return{smoothed:p,fitted:l,sse:c}}function d(i,n,f){const p=i.length,l=new Array(p).fill(null),y=new Array(p).fill(null);let c=null,m=null,w=0;for(let v=0;v<p;v++){const E=i[v];if(!Number.isFinite(E)){c!==null&&(c+=m,l[v]=c);continue}if(c===null){c=E,l[v]=E;continue}if(m===null){m=E-c;const q=c+m;y[v]=q,w+=(E-q)**2;const M=c;c=n*E+(1-n)*(M+m),m=f*(c-M)+(1-f)*m,l[v]=c;continue}const V=c+m;y[v]=V,w+=(E-V)**2;const G=c;c=n*E+(1-n)*(G+m),m=f*(c-G)+(1-f)*m,l[v]=c}return{smoothed:l,fitted:y,sse:w}}function s(i,n={}){const f=new Map,p=n.method==="holt",l=i.map(V=>Number.isFinite(V.value)?V.value:null),y=l.filter(V=>V!==null).length,c=V=>Math.min(o,Math.max(t,V)),m=()=>{for(const{key:V}of i)V!=null&&f.set(String(V),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return f};if(y<(p?2:1))return m();let w=Number.isFinite(n.alpha)?c(n.alpha):null,v=p&&Number.isFinite(n.beta)?c(n.beta):null;if(p){if(w===null||v===null){let V=w===null?.5:w,G=v===null?.5:v;for(let q=0;q<6;q++)w===null&&(V=r(M=>d(l,M,G).sse,t,o)),v===null&&(G=r(M=>d(l,V,M).sse,t,o));w=w===null?V:w,v=v===null?G:v}}else w===null&&(w=r(V=>u(l,V).sse,t,o));const E=p?d(l,w,v):u(l,w);for(let V=0;V<i.length;V++){const{key:G}=i[V];G!=null&&f.set(String(G),{smoothed:E.smoothed[V],fitted:E.fitted[V],alpha:w,beta:p?v:null,sse:E.sse})}return f}const g={ROLLING_WINDOW_FIELDS:L,QUANTILE_SPAN_CAP:U,rollingWindow:H,rollingQuantile:b,cumulativeToDate:x,periodOverPeriod:X,seasonalDecompose:h,exponentialSmoothing:s}}),We("packages/core/src/compute/cluster.js",function(e,D){"use strict";Object.defineProperty(e,"CLUSTER_ROW_CAP",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"DBSCAN_ROW_CAP",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"DEFAULT_K",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DEFAULT_MIN_POINTS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"orderByCentre",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"kmeans",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"dbscan",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"autoK",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"standardise",{enumerable:!0,get:function(){return t}});const ne=1e5,P=2e4,Y=3,_=5,L=100;function Z(o){let u=o>>>0;return function(){u=u+1831565813|0;let s=Math.imul(u^u>>>15,1|u);return s=s+Math.imul(s^s>>>7,61|s)^s,((s^s>>>14)>>>0)/4294967296}}function H(o,u){let d=0;for(let s=0;s<o.length;s++){const g=o[s]-u[s];d+=g*g}return d}function x(o,u){return Math.sqrt(H(o,u))}function X(o,u){let d=-1,s=1/0;for(let g=0;g<u.length;g++){const i=H(o,u[g]);i<s&&(s=i,d=g)}return d}function U(o,u,d){const s=Z(d),g=o.length,i=[Array.from(o[Math.floor(s()*g)])],n=new Float64Array(g).fill(1/0);for(let f=1;f<u;f++){let p=0;for(let m=0;m<g;m++){const w=H(o[m],i[i.length-1]);w<n[m]&&(n[m]=w),p+=n[m]}const l=s()*(p||g);let y=0,c=g-1;for(let m=0;m<g;m++)if(y+=p?n[m]:1,y>=l){c=m;break}i.push(Array.from(o[c]))}return i}function j(o,u){for(let d=0;d<o.length;d++){const s=o[d]-u[d];if(s!==0)return s}return 0}function k(o,u,d,s){const g=u.map((n,f)=>({centre:n,i:f})).sort((n,f)=>j(n.centre,f.centre)),i=new Int32Array(u.length);for(let n=0;n<g.length;n++)i[g[n].i]=n;for(let n=0;n<o.length;n++)o[n]>=0&&(o[n]=i[o[n]]);return{assignments:o,centres:g.map(n=>n.centre),sizes:g.map(n=>d[n.i]),distances:s}}function b(o,u={}){const d=o.length,s=d?o[0].length:0,g=Math.floor(u.k||Y);if(!(d>=g)||g<1||s<1)return null;let i=U(o,g,u.seed===void 0?1:u.seed);const n=new Int32Array(d);let f=!0;for(let c=0;c<L&&f;c++){f=!1;for(let v=0;v<d;v++){const E=X(o[v],i);n[v]!==E&&(n[v]=E,f=!0)}const m=i.map(()=>new Float64Array(s)),w=new Array(g).fill(0);for(let v=0;v<d;v++){const E=n[v];for(let V=0;V<s;V++)m[E][V]+=o[v][V];w[E]++}for(let v=0;v<g;v++)if(w[v])for(let E=0;E<s;E++)i[v][E]=m[v][E]/w[v];else{let E=0,V=-1/0;for(let G=0;G<d;G++){const q=H(o[G],i[v]);q>V&&(V=q,E=G)}i[v]=Array.from(o[E]),f=!0}}const p=new Array(g).fill(0),l=new Float64Array(d);let y=0;for(let c=0;c<d;c++){const m=n[c];p[m]++;const w=H(o[c],i[m]);l[c]=Math.sqrt(w),y+=w}return{assignments:n,centres:i,sizes:p,inertia:y,distances:l}}function a(o,u={}){const d=o.length,s=d?o[0].length:0,g=Number(u.eps),i=Math.max(1,Math.floor(u.minPoints||_));if(!(g>0)||d===0||s<1)return null;const n=new Array(d);for(let w=0;w<d;w++){const v=[];for(let E=0;E<d;E++)w!==E&&x(o[w],o[E])<=g&&v.push(E);n[w]=v}const f=new Int32Array(d).fill(-1);let p=0;for(let w=0;w<d;w++){if(f[w]!==-1||n[w].length<i)continue;f[w]=p;const v=[...n[w]];for(let E=0;E<v.length;E++){const V=v[E];f[V]===-1&&(f[V]=p,n[V].length>=i&&v.push(...n[V]))}p++}if(!p)return{assignments:f,centres:[],sizes:[],distances:new Float64Array(d).fill(NaN)};const l=[],y=new Array(p).fill(0),c=Array.from({length:p},()=>new Float64Array(s));for(let w=0;w<d;w++){const v=f[w];if(!(v<0)){y[v]++;for(let E=0;E<s;E++)c[v][E]+=o[w][E]}}for(let w=0;w<p;w++){const v=new Array(s);for(let E=0;E<s;E++)v[E]=c[w][E]/y[w];l.push(v)}const m=new Float64Array(d).fill(NaN);for(let w=0;w<d;w++){const v=f[w];v>=0&&(m[w]=x(o[w],l[v]))}return{assignments:f,centres:l,sizes:y,distances:m}}function h(o,u,d){const s=o.length;if(s===0)return 0;const g=new Int32Array(d);for(let n=0;n<s;n++)g[u[n]]++;let i=0;for(let n=0;n<s;n++){const f=u[n],p=new Float64Array(d);for(let c=0;c<s;c++)n!==c&&(p[u[c]]+=x(o[n],o[c]));const l=g[f]>1?p[f]/(g[f]-1):0;let y=1/0;for(let c=0;c<d;c++){if(c===f||g[c]===0)continue;const m=p[c]/g[c];m<y&&(y=m)}y!==1/0&&(i+=(y-l)/Math.max(l,y))}return i/s}function r(o,u={}){const d=o.length;if(!d)return null;const s=u.criterion==="silhouette"?"silhouette":"elbow",g=Math.max(2,Math.floor(u.maxK||8)),i=u.seed===void 0?1:u.seed;if(s==="silhouette"){const w=[],v=[];for(let V=2;V<=Math.min(g,d);V++){const G=b(o,{k:V,seed:i});G&&(w.push(V),v.push(h(o,G.assignments,V)))}if(!w.length)return null;let E=0;for(let V=1;V<v.length;V++)v[V]>v[E]&&(E=V);return{k:w[E],criterion:s,scores:v,ks:w}}const n=[],f=[];for(let w=1;w<=Math.min(g,d);w++){const v=b(o,{k:w,seed:i});v&&(n.push(w),f.push(v.inertia))}if(f.length<2)return null;const p={k:n[0],y:f[0]},l={k:n[n.length-1],y:f[f.length-1]},y=Math.hypot(l.k-p.k,l.y-p.y)||1;let c=0,m=-1/0;for(let w=0;w<f.length;w++){const v=Math.abs((l.k-p.k)*(p.y-f[w])-(p.k-n[w])*(l.y-p.y))/y;v>m&&(m=v,c=w)}return{k:n[c],criterion:s,scores:f,ks:n}}function t(o){const u=o.length,d=u?o[0].length:0;if(!u||!d)return null;const s=new Array(d).fill(0);for(let i=0;i<u;i++)for(let n=0;n<d;n++)s[n]+=o[i][n];for(let i=0;i<d;i++)s[i]/=u;const g=new Array(d).fill(0);for(let i=0;i<u;i++)for(let n=0;n<d;n++){const f=o[i][n]-s[n];g[n]+=f*f}for(let i=0;i<d;i++)g[i]=u>1?Math.sqrt(g[i]/(u-1)):0;for(let i=0;i<u;i++)for(let n=0;n<d;n++)g[n]>0?o[i][n]=(o[i][n]-s[n])/g[n]:o[i][n]=o[i][n]-s[n];return{mean:s,sd:g}}}),We("packages/core/src/compute/compare.js",function(e,D){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return a}});const ne=D("packages/core/src/compute/statistics.js"),P=ne.numbers,Y=ne.moments,_=ne.frequencyMap,L=ne.categoricalDistance,Z=ne.normalTotalVariation,H=ne.isNumericColumn,x=ne.SUBSET_RELIABILITY_FLOOR,X=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function U(h,r){if(!h||!r||!(h.n>0)||!(r.n>0)||!Number.isFinite(h.mean)||!Number.isFinite(r.mean))return null;const t=(h.n*h.sd*h.sd+r.n*r.sd*r.sd)/(h.n+r.n);return t>0?(h.mean-r.mean)/Math.sqrt(t):null}function j(h,r){const t=P(h,r),{n:o,mean:u,m2:d}=Y(t),s=o>0?Math.sqrt(d/o):0;return{mean:u,sd:s,n:o}}function k(h,r,t,o){return H(h,r)&&H(t,o)}function b(h,r,t,o){if(k(h,r,t,o)){const g=j(h,r),i=j(t,o),n=U(g,i);return{measure:X.numeric,magnitude:n,distance:n===null?0:Z(n),direction:n===null?0:Math.sign(n),nA:g.n,nB:i.n,meanA:g.mean,meanB:i.mean,reliable:g.n>=x&&i.n>=x}}const u=_(h,r),d=_(t,o),s=L(u.map,u.total,d.map,d.total);return{measure:X.categorical,magnitude:s,distance:s===null?0:s,direction:0,nA:u.total,nB:d.total,meanA:null,meanB:null,reliable:u.total>=x&&d.total>=x}}function a(h,r,t={}){const o=new Set(h.columns),u=new Set(r.columns),d=h.columns.filter(f=>u.has(f)),s=Array.isArray(t.columns)&&t.columns.length?d.filter(f=>t.columns.includes(f)):d,g=h.indices(),i=r.indices(),n=[];for(const f of s){const p=h.handle(f),l=r.handle(f);if(!p||!l)continue;const y=b(p,g,l,i);n.push({column:f,name:h.name&&h.name(f)||r.name&&r.name(f)||f,measure:y.measure,magnitude:y.magnitude,distance:y.distance,direction:y.direction,nA:y.nA,nB:y.nB,meanA:y.meanA,meanB:y.meanB,reliable:y.reliable})}return n.sort((f,p)=>p.distance-f.distance||Math.abs(p.magnitude||0)-Math.abs(f.magnitude||0)),{ranked:n,nA:g.length,nB:i.length,unmatched:{onlyA:h.columns.filter(f=>!u.has(f)),onlyB:r.columns.filter(f=>!o.has(f))},measures:X}}}),We("packages/core/src/compute/anomaly.js",function(e,D){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return g}});const P=D("packages/core/src/compute/statistics.js").quantileSorted,_=D("packages/core/src/compute/special.js").logGamma,L=.6745,Z=3.5,H=1.5,x=.975,X=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function U(i){if(!i.length)return null;const f=Array.from(i,Number).sort((c,m)=>c-m),p=P(f,.5),l=f.map(c=>Math.abs(c-p)).sort((c,m)=>c-m),y=P(l,.5);return{median:p,mad:y}}function j(i,n={}){const f=Number.isFinite(n.threshold)?n.threshold:Z,p=i.length,l=new Array(p).fill(null),y=new Array(p).fill(!1),c=[];for(let v=0;v<p;v++){const E=Number(i[v]);Number.isFinite(E)&&c.push(E)}if(!c.length)return{median:null,mad:null,threshold:f,scores:l,flags:y,flagged:0};const m=U(c);if(m.mad===0)return{median:m.median,mad:0,threshold:f,scores:l,flags:y,flagged:0};let w=0;for(let v=0;v<p;v++){const E=Number(i[v]);if(!Number.isFinite(E))continue;const V=L*(E-m.median)/m.mad;l[v]=V,Math.abs(V)>f&&(y[v]=!0,w++)}return{median:m.median,mad:m.mad,threshold:f,scores:l,flags:y,flagged:w}}function k(i,n={}){const f=Number.isFinite(n.k)?n.k:H,p=[];for(let w=0;w<i.length;w++){const v=Number(i[w]);Number.isFinite(v)&&p.push(v)}if(!p.length)return null;const l=p.sort((w,v)=>w-v),y=P(l,.25),c=P(l,.75),m=c-y;return{q1:y,q3:c,iqr:m,lower:y-f*m,upper:c+f*m,k:f}}function b(i,n){if(n<=0)return 0;const f=_(i);if(n<i+1){let v=i,E=1/i,V=E;for(let G=0;G<1e3&&(v+=1,V*=n/v,E+=V,!(Math.abs(V)<Math.abs(E)*1e-15));G++);return E*Math.exp(-n+i*Math.log(n)-f)}const p=1e-300;let l=n+1-i,y=1/p,c=1/l,m=c;for(let v=1;v<1e3;v++){const E=-v*(v-i);l+=2,c=E*c+l,Math.abs(c)<p&&(c=p),y=l+E/y,Math.abs(y)<p&&(y=p),c=1/c;const V=c*y;if(m*=V,Math.abs(V-1)<1e-15)break}return 1-Math.exp(-n+i*Math.log(n)-f)*m}function a(i,n){return i<=0?0:b(n/2,i/2)}function h(i,n=x){if(!(n>0)||!(n<1))return NaN;let f=0,p=Math.max(1,i);for(;a(p,i)<n;)p*=2;for(let l=0;l<200;l++){const y=(f+p)/2;if(a(y,i)<n?f=y:p=y,p-f<1e-10)break}return(f+p)/2}function r(i){const n=i.length,f=i.map((p,l)=>{const y=p.slice();for(let c=0;c<n;c++)y.push(l===c?1:0);return y});for(let p=0;p<n;p++){let l=p;for(let c=p+1;c<n;c++)Math.abs(f[c][p])>Math.abs(f[l][p])&&(l=c);if(Math.abs(f[l][p])<1e-12)return null;if(l!==p){const c=f[l];f[l]=f[p],f[p]=c}const y=f[p][p];for(let c=0;c<2*n;c++)f[p][c]/=y;for(let c=0;c<n;c++){if(c===p)continue;const m=f[c][p];if(m!==0)for(let w=0;w<2*n;w++)f[c][w]-=m*f[p][w]}}return f.map(p=>p.slice(n))}function t(i,n){const f=i.length,p=new Array(n).fill(0);for(const c of i)for(let m=0;m<n;m++)p[m]+=c[m];for(let c=0;c<n;c++)p[c]/=f;const l=Array.from({length:n},()=>new Array(n).fill(0));for(const c of i)for(let m=0;m<n;m++){const w=c[m]-p[m];for(let v=m;v<n;v++)l[m][v]+=w*(c[v]-p[v])}const y=f>1?f-1:1;for(let c=0;c<n;c++)for(let m=c;m<n;m++)l[c][m]/=y,l[m][c]=l[c][m];return{mean:p,cov:l}}function o(i,n={}){const f=Number.isFinite(n.p)?n.p:x,p=Number.isFinite(n.ridge)?n.ridge:1e-6,l=i.length;if(!l)return null;const y=i[0].length;if(!y)return null;const c=new Array(l).fill(null),m=new Array(l).fill(null),w=new Array(l).fill(!1),v=[],E=[];for(let N=0;N<l;N++){const C=i[N];let S=C.length===y;const F=new Array(y);for(let $=0;S&&$<y;$++){const W=Number(C[$]);Number.isFinite(W)?F[$]=W:S=!1}S&&(v.push(N),E.push(F))}const V=y,G=h(V,f);if(E.length<=y)return{center:[],df:V,cutoff:G,singular:!0,used:E.length,distances:c,squared:m,flags:w,flagged:0};const{mean:q,cov:M}=t(E,y);let O=r(M),T=!1;if(!O){T=!0;let N=0;for(let F=0;F<y;F++)N+=M[F][F];const C=N/y*p||p,S=M.map((F,$)=>F.map((W,K)=>$===K?W+C:W));if(O=r(S),!O)return{center:q,df:V,cutoff:G,singular:!0,used:E.length,distances:c,squared:m,flags:w,flagged:0}}let A=0;for(let N=0;N<E.length;N++){const C=E[N],S=new Array(y);for(let W=0;W<y;W++)S[W]=C[W]-q[W];let F=0;for(let W=0;W<y;W++){let K=0;for(let I=0;I<y;I++)K+=O[W][I]*S[I];F+=S[W]*K}F<0&&(F=0);const $=v[N];m[$]=F,c[$]=Math.sqrt(F),F>G&&(w[$]=!0,A++)}return{center:q,df:V,cutoff:G,singular:T,used:E.length,distances:c,squared:m,flags:w,flagged:A}}const u=20,d=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function s(i,n={}){const f=n.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",p=Number.isFinite(n.windowLen)&&n.windowLen>=1?Math.floor(n.windowLen):u,l=Number.isFinite(n.threshold)?n.threshold:Z,y=Number.isFinite(n.k)?n.k:H,c=Number.isFinite(n.minPeriods)&&n.minPeriods>=1?Math.floor(n.minPeriods):p,m=i.length,w=new Array(m).fill(null),v=new Array(m).fill(!1);let E=0;for(let V=0;V<m;V++){const G=Number(i[V]);if(!Number.isFinite(G))continue;const q=Math.max(0,V-p+1),M=[];for(let O=q;O<=V;O++){const T=Number(i[O]);Number.isFinite(T)&&M.push(T)}if(!(M.length<c))if(f==="rollingIqr"){const O=k(M,{k:y});if(!O)continue;(G<O.lower||G>O.upper)&&(v[V]=!0,E++)}else{const O=U(M);if(!O||O.mad===0)continue;const T=L*(G-O.median)/O.mad;w[V]=T,Math.abs(T)>l&&(v[V]=!0,E++)}}return{method:f,windowLen:p,minPeriods:c,threshold:l,k:y,scores:w,flags:v,flagged:E}}function g(i={}){const n=i||{},f=n.field;if(typeof f!="string"||!f)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const p=n.method||"modifiedZScore";if(!(X.includes(p)||d.includes(p))||p==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${p}'`);const y=typeof n.orderBy=="string"?n.orderBy:null,c=n.latest===!0,m=d.includes(p),w=v=>Number(v==null?NaN:v[f]);return v=>{const E=Array.isArray(v)?v.slice():[...v];y&&E.sort((O,T)=>{const A=O?.[y],N=T?.[y];return A===N?0:A==null?-1:N==null?1:A<N?-1:1});const V=E.map(w);let G,q;if(m)({flags:G,scores:q}=s(V,{method:p,windowLen:n.windowLen,threshold:n.threshold,k:n.k,minPeriods:n.minPeriods}));else if(p==="iqr"){const O=k(V,{k:n.k});G=V.map(T=>O?Number.isFinite(T)&&(T<O.lower||T>O.upper):!1),q=V.map(()=>null)}else({flags:G,scores:q}=j(V,{threshold:n.threshold}));if(c){const O=G.length-1;return O<0||!G[O]?!1:{method:p,field:f,flagged:[{row:E[O],score:q[O]}]}}const M=[];for(let O=0;O<G.length;O++)G[O]&&M.push({row:E[O],score:q[O]});return M.length?{method:p,field:f,flagged:M}:!1}}}),We("packages/core/src/compute/forecast.js",function(e,D){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const ne=D("packages/core/src/compute/special.js"),P=ne.normalQuantile,Y=ne.studentTQuantile,L=D("packages/core/src/internal/warn.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),H=1e-4,x=1-1e-4;function X(n){const f=[];for(let p=0;p<n.length;p++){const l=n[p];if(l!==null&&typeof l=="object"){const y=Number.isFinite(l.at)?l.at:p,c=Number.isFinite(l.value)?l.value:null;f.push({at:y,value:c})}else f.push({at:p,value:Number.isFinite(l)?Number(l):null})}return f}function U(n){const f=n.filter(m=>m.value!==null),p=f[0],l=f[f.length-1],y=l.at-p.at,c=f.length>1&&y>0?y/(f.length-1):1;return{lastAt:l.at,step:c}}function j(n){return Math.min(x,Math.max(H,n))}function k(n,f=H,p=x,l=80){const y=(Math.sqrt(5)-1)/2;let c=f,m=p,w=m-y*(m-c),v=c+y*(m-c),E=n(w),V=n(v);for(let G=0;G<l;G++)E<V?(m=v,v=w,V=E,w=m-y*(m-c),E=n(w)):(c=w,w=v,E=V,v=c+y*(m-c),V=n(v));return(c+m)/2}function b(n,f){let p=null,l=0,y=0;for(let c=0;c<n.length;c++){const m=n[c];if(m!==null){if(p===null){p=m;continue}l+=(m-p)**2,y+=1,p=f*m+(1-f)*p}}return{level:p,sse:l,m:y}}function a(n,f,p){let l=null,y=null,c=0,m=0;for(let w=0;w<n.length;w++){const v=n[w];if(v===null){l!==null&&y!==null&&(l+=y);continue}if(l===null){l=v;continue}y===null&&(y=v-l);const E=l+y;c+=(v-E)**2,m+=1;const V=l;l=f*v+(1-f)*(V+y),y=p*(l-V)+(1-p)*y}return{level:l,trend:y,sse:c,m}}function h(n,f,p,l,y){const c=n.length;if(c<2*f)return null;const m=T=>{let A=0,N=0;for(let C=T;C<T+f&&C<c;C++)n[C]!==null&&(A+=n[C],N+=1);return N?A/N:null},w=m(0),v=m(f);if(w===null||v===null)return null;let E=w,V=(v-w)/f;const G=new Array(f).fill(0);for(let T=0;T<f;T++)G[T]=n[T]===null?0:n[T]-E;const q=G.reduce((T,A)=>T+A,0)/f;for(let T=0;T<f;T++)G[T]-=q;let M=0,O=0;for(let T=f;T<c;T++){const A=T%f,N=G[A],C=n[T];if(C===null){E+=V;continue}const S=E+V+N;M+=(C-S)**2,O+=1;const F=E;E=p*(C-N)+(1-p)*(E+V),V=l*(E-F)+(1-l)*V,G[A]=y*(C-E)+(1-y)*N}return{level:E,trend:V,season:G,phase:(c-1)%f,sse:M,count:O}}function r(n,f,p){let l=1;for(const c of f)l+=c*c;const y=Math.sqrt(n*l);return{se:y,margin:p*y}}function t(n,f={}){if(!n||typeof n.length!="number"||n.length===0)return null;const p=Z.includes(f.method)?f.method:"linear",l=Math.max(1,Math.floor(Number(f.horizon)||1)),y=Number.isFinite(f.confidence)&&f.confidence>0&&f.confidence<1?f.confidence:.95,c=1-(1-y)/2,m=X(n),w=m.map(M=>M.value),v=w.filter(M=>M!==null),E=v.length,{lastAt:V,step:G}=E?U(m):{lastAt:0,step:1},q=M=>V+M*G;return p==="linear"?o(m,E,l,y,c,q):p==="movingAverage"?u(v,E,l,y,c,f,q):p==="ses"?d(w,E,l,y,c,f,q):p==="holt"?s(w,E,l,y,c,f,q):g(w,E,l,y,c,f,q)}function o(n,f,p,l,y,c){if(f<2)return null;let m=0,w=0;for(const C of n)C.value!==null&&(m+=C.at,w+=C.value);m/=f,w/=f;let v=0,E=0,V=0;for(const C of n){if(C.value===null)continue;const S=C.at-m,F=C.value-w;v+=S*S,E+=S*F,V+=F*F}if(v===0)return null;const G=E/v,q=w-G*m,M=V===0?1:Math.max(0,Math.min(1,E*E/(v*V))),O=Math.max(0,V-G*E),T=f>2?Math.sqrt(O/(f-2)):null,A=f>2?Y(y,f-2):null,N=[];for(let C=1;C<=p;C++){const S=c(C),F=q+G*S;let $=null,W=null,K=null,I=null,B=null;if(T!==null){const J=1/f+(S-m)**2/v,te=T*Math.sqrt(1+J),Q=T*Math.sqrt(J);B=te,$=F-A*te,W=F+A*te,K=F-A*Q,I=F+A*Q}N.push({step:C,at:S,mean:F,lower:$,upper:W,lowerMean:K,upperMean:I,se:B})}return{method:"linear",horizon:p,confidence:l,n:f,sigma:T,r2:M,params:{slope:G,intercept:q},points:N}}function u(n,f,p,l,y,c,m){if(f<1)return null;const w=Math.max(1,Math.min(f,Math.floor(Number(c.windowLen)||f))),v=n.slice(f-w);let E=0;for(const T of v)E+=T;const V=E/w;let G=null,q=null;if(w>1){let T=0;for(const N of v)T+=(N-V)**2;G=Math.sqrt(T/(w-1))*Math.sqrt(1+1/w),q=Y(y,w-1)}const M=G===null?null:q*G,O=[];for(let T=1;T<=p;T++)O.push({step:T,at:m(T),mean:V,lower:M===null?null:V-M,upper:M===null?null:V+M,se:G});return{method:"movingAverage",horizon:p,confidence:l,n:f,sigma:G===null?null:G,params:{windowLen:w},points:O}}function d(n,f,p,l,y,c,m){if(f<1)return null;let w=Number.isFinite(c.alpha)?j(c.alpha):null;w===null&&(w=k(q=>b(n,q).sse));const v=b(n,w),E=P(y),V=v.m>0?v.sse/v.m:null,G=[];for(let q=1;q<=p;q++){const M=v.level;let O=null,T=null,A=null;if(V!==null){const N=[];for(let S=1;S<q;S++)N.push(w);const C=r(V,N,E);A=C.se,O=M-C.margin,T=M+C.margin}G.push({step:q,at:m(q),mean:M,lower:O,upper:T,se:A})}return{method:"ses",horizon:p,confidence:l,n:f,sigma:V===null?null:Math.sqrt(V),params:{alpha:w},points:G}}function s(n,f,p,l,y,c,m){if(f<2)return null;let w=Number.isFinite(c.alpha)?j(c.alpha):null,v=Number.isFinite(c.beta)?j(c.beta):null;if(w===null||v===null){let O=w===null?.5:w,T=v===null?.5:v;for(let A=0;A<6;A++)w===null&&(O=k(N=>a(n,N,T).sse)),v===null&&(T=k(N=>a(n,O,N).sse));w=w===null?O:w,v=v===null?T:v}const E=a(n,w,v),V=P(y),G=E.m>0?E.sse/E.m:null,q=w*v,M=[];for(let O=1;O<=p;O++){const T=E.level+O*E.trend;let A=null,N=null,C=null;if(G!==null){const S=[];for(let $=1;$<O;$++)S.push(w+$*q);const F=r(G,S,V);C=F.se,A=T-F.margin,N=T+F.margin}M.push({step:O,at:m(O),mean:T,lower:A,upper:N,se:C})}return{method:"holt",horizon:p,confidence:l,n:f,sigma:G===null?null:Math.sqrt(G),params:{alpha:w,beta:v},points:M}}function g(n,f,p,l,y,c,m){const w=Math.floor(Number(c.period));if(!(w>=2))return L("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(f<2*w)return null;let v=Number.isFinite(c.alpha)?j(c.alpha):null,E=Number.isFinite(c.beta)?j(c.beta):null,V=Number.isFinite(c.gamma)?j(c.gamma):null;const G=(C,S,F)=>{const $=h(n,w,C,S,F);return $?$.sse:1/0};if(v===null||E===null||V===null){let C=v===null?.5:v,S=E===null?.5:E,F=V===null?.5:V;for(let $=0;$<8;$++)v===null&&(C=k(W=>G(W,S,F))),E===null&&(S=k(W=>G(C,W,F))),V===null&&(F=k(W=>G(C,S,W)));v=v===null?C:v,E=E===null?S:E,V=V===null?F:V}const q=h(n,w,v,E,V);if(!q)return null;const M=P(y),O=q.count>0?q.sse/q.count:null,T=v*E,A=V*(1-v),N=[];for(let C=1;C<=p;C++){const S=q.season[(q.phase+C)%w],F=q.level+C*q.trend+S;let $=null,W=null,K=null;if(O!==null){const I=[];for(let J=1;J<C;J++)I.push(v+J*T+(J%w===0?A:0));const B=r(O,I,M);K=B.se,$=F-B.margin,W=F+B.margin}N.push({step:C,at:m(C),mean:F,lower:$,upper:W,se:K})}return{method:"holtWinters",horizon:p,confidence:l,n:f,sigma:O===null?null:Math.sqrt(O),params:{alpha:v,beta:E,gamma:V,period:w},points:N}}const i={FORECAST_METHODS:Z,forecast:t}}),We("packages/core/src/compute/hypothesis.js",function(e,D){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return M}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/compute/handle.js").valueReader,L=D("packages/core/src/compute/statistics.js"),Z=L.numbers,H=L.moments,x=L.frequencyMap,X=L.categoricalDistance,U=L.isNumericColumn,j=L.jarqueBera,k=L.proportionInterval,b=L.SUBSET_RELIABILITY_FLOOR,h=D("packages/core/src/compute/compare.js").pooledStandardMeanDifference,r=D("packages/core/src/compute/special.js"),t=r.studentT,o=r.studentTQuantile,u=r.normalCdf,d=r.normalQuantile,s=r.chiSquareUpperTail,g=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),i=.05,n=2e6;function f(O){const T=Number(O);return Number.isFinite(T)&&T>0&&T<1?T:.95}function p(O){const{n:T,mean:A,m2:N}=H(O);return{mean:A,sd:T>0?Math.sqrt(N/T):0,n:T}}function l(O,T){const A=O.length;if(A<2)return 0;let N=0;for(let C=0;C<A;C++){const S=O[C]-T;N+=S*S}return N/(A-1)}function y(O,T){return{name:"pooledStandardMeanDifference",value:h(p(O),p(T))}}function c(O,T,A){const N=O.length,C=T.length;if(N<2||C<2)return null;const S=f(A),{mean:F}=H(O),{mean:$}=H(T),W=l(O,F),K=l(T,$),I=W/N+K/C;if(!(I>0))return null;const B=Math.sqrt(I),J=(F-$)/B,te=W/N*(W/N)/(N-1),Q=K/C*(K/C)/(C-1),re=I*I/(te+Q),ie=Math.min(1,Math.max(0,2*(1-t(Math.abs(J),re)))),ue=F-$,ke=o(1-(1-S)/2,re)*B;return{test:g.WELCH,statistic:J,statisticName:"t",df:re,pValue:ie,interval:{estimate:ue,lower:ue-ke,upper:ue+ke,confidence:S,method:"welch-t (difference of means)"},effectSize:y(O,T),nA:N,nB:C,reliable:N>=b&&C>=b,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function m(O){const T=O.length;if(T===0)return Number.NaN;const A=T>>1;return T%2?O[A]:(O[A-1]+O[A])/2}function w(O,T,A){const N=O.length,C=T.length,S=N*C;if(S===0||S>n)return null;const F=new Float64Array(S);let $=0;for(let te=0;te<N;te++)for(let Q=0;Q<C;Q++)F[$++]=O[te]-T[Q];F.sort();const W=m(F),K=Math.sqrt(N*C*(N+C+1)/12),I=d(1-(1-A)/2);let B=Math.round(S/2-I*K);B>=0||(B=0);const J=Math.floor((S-1)/2);return B>J&&(B=J),{estimate:W,lower:F[B],upper:F[S-1-B],confidence:A,method:"hodges-lehmann (normal approximation)"}}function v(O,T,A){const N=O.length,C=T.length;if(N<1||C<1)return null;const S=f(A),F=N+C,$=new Array(F);for(let ie=0;ie<N;ie++)$[ie]={v:O[ie],g:0};for(let ie=0;ie<C;ie++)$[N+ie]={v:T[ie],g:1};$.sort((ie,ue)=>ie.v-ue.v);let W=0,K=0,I=0;for(;I<F;){let ie=I;for(;ie<F&&$[ie].v===$[I].v;)ie++;const ue=ie-I,ke=(I+1+ie)/2;for(let de=I;de<ie;de++)$[de].g===0&&(W+=ke);K+=ue*ue*ue-ue,I=ie}const B=W-N*(N+1)/2,J=N*C/2,te=N*C/12*(F+1-K/(F*(F-1)));let Q=1;if(te>0){const ie=Math.max(0,Math.abs(B-J)-.5);Q=Math.min(1,2*u(-ie/Math.sqrt(te)))}const re=w(O,T,S);return{test:g.MANN_WHITNEY,statistic:B,statisticName:"U",df:null,pValue:Q,interval:re,effectSize:y(O,T),nA:N,nB:C,reliable:N>=b&&C>=b,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function E(O,T,A,N,C){const S=k(O,T,C),F=k(A,N,C);if(!S||!F)return null;const $=S.proportion-F.proportion,W=$-Math.sqrt((S.proportion-S.lower)**2+(F.upper-F.proportion)**2),K=$+Math.sqrt((S.upper-S.proportion)**2+(F.proportion-F.lower)**2);return{lower:W,upper:K}}function V(O,T,A,N,C,S={}){if(!(T>0)||!(N>0))return null;const F=new Set([...O.keys(),...A.keys()]),$=F.size;if($<2)return null;const W=T+N;let K=0;for(const Q of F){const re=O.get(Q)||0,ie=A.get(Q)||0,ue=re+ie,ke=T*ue/W,de=N*ue/W;ke>0&&(K+=(re-ke)*(re-ke)/ke),de>0&&(K+=(ie-de)*(ie-de)/de)}const I=$-1,B=s(K,I);let J=null;S.category!==void 0&&F.has(S.category)?J=S.category:$===2&&([J]=[...F]);let te=null;if(J!==null){const Q=E(O.get(J)||0,T,A.get(J)||0,N,f(C));Q&&(te={estimate:(O.get(J)||0)/T-(A.get(J)||0)/N,lower:Q.lower,upper:Q.upper,confidence:f(C),method:"newcombe (difference in this category's share)",category:J})}return{test:g.CHI_SQUARE,statistic:K,statisticName:"chiSquare",df:I,pValue:B,interval:te,effectSize:{name:"categoricalTotalVariation",value:X(O,T,A,N)},nA:T,nB:N,reliable:T>=b&&N>=b,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function G(O){return O==null||O===""||typeof O=="number"&&Number.isNaN(O)?null:O instanceof Date?O.getTime():typeof O=="object"?String(O):O}function q(O,T,A){if(A===g.WELCH||A===g.MANN_WHITNEY)return{test:A,chosenBy:"override",reason:`caller override: ${A}`};const N=j(O),C=j(T),S=N===null?null:Math.exp(-N/2),F=C===null?null:Math.exp(-C/2);return S!==null&&S<i||F!==null&&F<i?{test:g.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${i})`}:{test:g.WELCH,chosenBy:"auto",reason:S!==null||F!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function M(O,T,A,N={}){if(!O||!T)return null;const C=f(N.confidence),S=_(T);let F;if(Array.isArray(N.groups)&&N.groups.length===2)F=[G(N.groups[0]),G(N.groups[1])];else{const{map:ie}=x(T,A),ue=[...ie.entries()].sort((ke,de)=>de[1]-ke[1]).slice(0,2).map(ke=>ke[0]);if(ue.length<2)return P("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;F=ue}const[$,W]=F;if($===null||W===null||$===W)return P("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const K=[],I=[];for(let ie=0;ie<A.length;ie++){const ue=G(S(A[ie]));ue===$?K.push(A[ie]):ue===W&&I.push(A[ie])}if(K.length===0||I.length===0)return P("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const B=N.test&&N.test!=="auto"?String(N.test):null,J=U(O,K.concat(I));let te,Q,re;if(B===g.CHI_SQUARE||!B&&!J){Q=B?"override":"auto",re=B?"caller override: chiSquare":"column family: categorical";const ie=x(O,K),ue=x(O,I);te=V(ie.map,ie.total,ue.map,ue.total,C,{category:N.category})}else{if((B===g.WELCH||B===g.MANN_WHITNEY)&&!J)return P("compareGroups:numeric-override",`[lattice] compareGroups: ${B} needs a numeric column, but the column is not numeric.`),null;const ie=Z(O,K),ue=Z(O,I),ke=q(ie,ue,B);Q=ke.chosenBy,re=ke.reason,te=ke.test===g.MANN_WHITNEY?v(ie,ue,C):c(ie,ue,C)}return te?{...te,chosenBy:Q,reason:re,groups:[$,W]}:(P("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),We("packages/core/src/compute/significance.js",function(e,D){"use strict";Object.defineProperty(e,"COMPARE_TESTS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compare",{enumerable:!0,get:function(){return we}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/compute/handle.js").valueReader,L=D("packages/core/src/compute/statistics.js"),Z=L.numbers,H=L.moments,x=L.frequencyMap,X=L.isNumericColumn,U=L.jarqueBera,j=L.proportionInterval,k=D("packages/core/src/compute/special.js"),b=k.studentT,a=k.studentTQuantile,h=k.normalCdf,r=k.normalQuantile,t=k.chiSquareUpperTail,o=k.incompleteBeta,u=Object.freeze({T:"t",WELCH:"welch",MANN_WHITNEY:"mannWhitney",ANOVA:"anova",KRUSKAL:"kruskal",CHI_SQUARE:"chiSquare",PROPORTIONS:"proportions"}),d=new Set([u.T,u.WELCH,u.MANN_WHITNEY]),s=new Set([u.ANOVA,u.KRUSKAL]),g=new Set([u.CHI_SQUARE,u.PROPORTIONS]),i=.05,n=[.2,.5,.8],f=[.147,.33,.474],p=[.01,.06,.14],l=[[.1,.3,.5],[.07,.21,.35],[.06,.17,.29],[.05,.15,.25]];function y(pe){const oe=Number(pe);return Number.isFinite(oe)&&oe>0&&oe<1?oe:.05}function c(pe){return pe==null||pe===""||typeof pe=="number"&&Number.isNaN(pe)?null:pe instanceof Date?pe.getTime():typeof pe=="object"?String(pe):pe}function m(pe,oe){const be=_(pe),fe=[],le=new Map;for(let ye=0;ye<oe.length;ye++){const Ne=c(be(oe[ye]));if(Ne===null)continue;let je=le.get(Ne);je||(je={value:Ne,rows:[]},le.set(Ne,je),fe.push(je)),je.rows.push(oe[ye])}return fe}function w(pe){const{n:oe,mean:be,m2:fe}=H(pe),le=oe>1?fe/(oe-1):0;return{n:oe,mean:be,sd:Math.sqrt(le),variance:le}}function v(pe,oe,be){if(!(oe>0)||!(be>0)||!(pe>=0)||!Number.isFinite(pe))return Number.NaN;if(pe===0)return 1;const fe=oe*pe/(oe*pe+be);return 1-o(oe/2,be/2,fe)}function E(pe,oe){const be=Math.abs(pe);return Number.isFinite(be)?be>=oe[2]?"large":be>=oe[1]?"medium":be>=oe[0]?"small":"negligible":"negligible"}function V(pe,oe,be){if(pe==="cohensD")return E(oe,n);if(pe==="cliffsDelta")return E(oe,f);if(pe==="etaSquared")return E(oe,p);const fe=Math.max(1,Math.min(l.length,Math.floor(be||1)));return E(oe,l[fe-1])}function G(pe,oe){if(!(pe.n>1)||!(oe.n>1))return null;const be=((pe.n-1)*pe.variance+(oe.n-1)*oe.variance)/(pe.n+oe.n-2);return be>0?(pe.mean-oe.mean)/Math.sqrt(be):null}function q(pe,oe){const be=pe.length,fe=oe.length;if(!be||!fe)return null;const le=Array.from(oe).sort((je,$e)=>je-$e);let ye=0,Ne=0;for(let je=0;je<be;je++){const $e=pe[je];let Re=0,Se=fe;for(;Re<Se;){const Ee=Re+Se>>1;le[Ee]<$e?Re=Ee+1:Se=Ee}const Ve=Re;let Fe=Re;for(;Fe<fe&&le[Fe]===$e;)Fe++;const Ce=Fe-Re;ye+=Ve,Ne+=fe-Fe}return(ye-Ne)/(be*fe)}function M(pe,oe,be,fe){const le=Math.min(be-1,fe-1);return!(oe>0)||!(le>0)?null:Math.sqrt(pe/(oe*le))}function O(pe){return Number.isFinite(pe)?pe<.001?"p < 0.001":pe>=.995?"p > 0.995":`p = ${pe.toFixed(3)}`:"p = —"}function T(pe){if(!Number.isFinite(pe))return"0";const oe=Math.abs(pe);return oe===0?"0":oe>=1e3?String(Math.round(pe)):oe>=100?String(Number(pe.toFixed(0))):oe>=10?String(Number(pe.toFixed(1))):oe>=1?String(Number(pe.toFixed(2))):String(Number(pe.toPrecision(2)))}const A=new Set(["cohensD","cliffsDelta"]);function N(pe){if(pe.difference!=null&&Math.abs(pe.difference)>=1e-12)return Math.sign(pe.difference);const oe=pe.effectSize;if(oe&&A.has(oe.name)&&Number.isFinite(oe.value)&&Math.abs(oe.value)>=1e-12)return Math.sign(oe.value);const[be,fe]=pe.groups;return Number.isFinite(be.mean)&&Number.isFinite(fe.mean)&&be.mean!==fe.mean?Math.sign(be.mean-fe.mean):0}function C(pe){const oe=pe.measureName||"values";return{subject:oe.charAt(0).toUpperCase()+oe.slice(1),be:oe==="values"?"are":"is",name:oe}}function S(pe,oe){const be=oe.unit?` ${oe.unit}`:"",{subject:fe,be:le}=C(oe),ye=pe.groups[0].label,Ne=pe.groups[1].label,je=pe.effectSize?pe.effectSize.label:"negligible",$e=pe.pValue<pe.alpha,Re=$e?"unlikely to be chance":"consistent with chance";if(!$e&&je==="negligible")return`${fe} ${le} essentially the same for ${ye} and ${Ne} (${O(pe.pValue)}); the effect is ${je}.`;const Se=N(pe),Ve=`the difference is ${Re} (${O(pe.pValue)}) and the effect is ${je}.`;if(Se===0)return`${fe} ${le} different between ${ye} and ${Ne}; ${Ve}`;const Fe=Se>0?ye:Ne,Ce=Se>0?Ne:ye,Ie=pe.difference!=null&&Math.abs(pe.difference)>=1e-12?` by about ${T(Math.abs(pe.difference))}${be}`:"";return`${fe} ${le} higher for ${Fe} than for ${Ce}${Ie}; ${Ve}`}function F(pe,oe){const{name:be}=C(oe),fe=pe.effectSize?pe.effectSize.label:"negligible",le=O(pe.pValue);return pe.pValue<pe.alpha?`The groups differ in ${be}; the difference is unlikely to be chance (${le}) and the effect is ${fe}.`:fe==="negligible"?`The groups are essentially the same in ${be} (${le}); the effect is ${fe}.`:`The groups show a ${fe} effect in ${be}, but the difference is consistent with chance (${le}).`}function $(pe,oe){const be=pe.length;if(be<2)return null;const{mean:fe,m2:le}=H(pe),ye=le/(be-1);if(!(ye>0))return null;const Ne=Math.sqrt(ye),je=Ne/Math.sqrt(be),$e=fe/je,Re=be-1,Se=Math.min(1,Math.max(0,2*(1-b(Math.abs($e),Re)))),Ve=a(1-oe/2,Re)*je,Fe=fe/Ne;return{test:u.T,statistic:$e,statisticName:"t",df:Re,pValue:Se,difference:fe,interval:{estimate:fe,lower:fe-Ve,upper:fe+Ve,confidence:1-oe,method:"paired-t (mean of the pair differences)"},effectSize:{name:"cohensD",label:E(Fe,n),value:Fe}}}function W(pe,oe){const be=Array.from(pe).filter(Ie=>Ie!==0),fe=be.length;if(!fe)return null;const le=Array.from({length:fe},(Ie,Be)=>Be).sort((Ie,Be)=>Math.abs(be[Ie])-Math.abs(be[Be])),ye=new Array(fe);let Ne=0;for(;Ne<fe;){let Ie=Ne;for(;Ie+1<fe&&Math.abs(be[le[Ie+1]])===Math.abs(be[le[Ne]]);)Ie++;const Be=(Ne+Ie)/2+1;for(let Ke=Ne;Ke<=Ie;Ke++)ye[le[Ke]]=Be;Ne=Ie+1}let je=0,$e=0;for(let Ie=0;Ie<fe;Ie++)$e+=ye[Ie],be[Ie]>0&&(je+=ye[Ie]);const Re=$e-je,Se=fe*(fe+1)/4,Ve=Math.sqrt(fe*(fe+1)*(2*fe+1)/24),Fe=Ve>0?(Math.abs(je-Se)-.5)/Ve:0,Ce=Math.min(1,Math.max(0,2*h(-Math.max(0,Fe)))),Ee=$e>0?(je-Re)/$e:0;return{test:u.MANN_WHITNEY,statistic:je,statisticName:"W",df:null,pValue:Ce,difference:null,interval:null,effectSize:{name:"cliffsDelta",label:E(Ee,f),value:Ee}}}function K(pe,oe,be){const fe=w(pe),le=w(oe);if(fe.n<2||le.n<2)return null;const ye=((fe.n-1)*fe.variance+(le.n-1)*le.variance)/(fe.n+le.n-2);if(!(ye>0))return null;const Ne=Math.sqrt(ye*(1/fe.n+1/le.n)),je=(fe.mean-le.mean)/Ne,$e=fe.n+le.n-2,Re=Math.min(1,Math.max(0,2*(1-b(Math.abs(je),$e)))),Se=fe.mean-le.mean,Ve=a(1-be/2,$e)*Ne,Fe=G(fe,le);return{test:u.T,statistic:je,statisticName:"t",df:$e,pValue:Re,difference:Se,interval:{estimate:Se,lower:Se-Ve,upper:Se+Ve,confidence:1-be,method:"student-t (pooled variance, difference of means)"},effectSize:{name:"cohensD",label:E(Fe,n),value:Fe},summaries:[fe,le]}}function I(pe,oe,be){const fe=w(pe),le=w(oe);if(fe.n<2||le.n<2)return null;const ye=fe.variance/fe.n+le.variance/le.n;if(!(ye>0))return null;const Ne=Math.sqrt(ye),je=(fe.mean-le.mean)/Ne,$e=fe.variance/fe.n*(fe.variance/fe.n)/(fe.n-1),Re=le.variance/le.n*(le.variance/le.n)/(le.n-1),Se=ye*ye/($e+Re),Ve=Math.min(1,Math.max(0,2*(1-b(Math.abs(je),Se)))),Fe=fe.mean-le.mean,Ce=a(1-be/2,Se)*Ne,Ee=G(fe,le);return{test:u.WELCH,statistic:je,statisticName:"t",df:Se,pValue:Ve,difference:Fe,interval:{estimate:Fe,lower:Fe-Ce,upper:Fe+Ce,confidence:1-be,method:"welch-t (unequal variances, difference of means)"},effectSize:{name:"cohensD",label:E(Ee,n),value:Ee},summaries:[fe,le]}}function B(pe,oe,be){const fe=pe.length,le=oe.length;if(fe<1||le<1)return null;const ye=w(pe),Ne=w(oe),je=fe+le,$e=new Array(je);for(let Ke=0;Ke<fe;Ke++)$e[Ke]={v:pe[Ke],g:0};for(let Ke=0;Ke<le;Ke++)$e[fe+Ke]={v:oe[Ke],g:1};$e.sort((Ke,qe)=>Ke.v-qe.v);let Re=0,Se=0,Ve=0;for(;Ve<je;){let Ke=Ve;for(;Ke<je&&$e[Ke].v===$e[Ve].v;)Ke++;const qe=(Ve+1+Ke)/2;for(let nt=Ve;nt<Ke;nt++)$e[nt].g===0&&(Re+=qe);const rt=Ke-Ve;Se+=rt*rt*rt-rt,Ve=Ke}const Fe=Re-fe*(fe+1)/2,Ce=fe*le/2,Ee=fe*le/12*(je+1-Se/(je*(je-1)));let Ie=1;if(Ee>0){const Ke=Math.max(0,Math.abs(Fe-Ce)-.5);Ie=Math.min(1,2*h(-Ke/Math.sqrt(Ee)))}const Be=q(pe,oe);return{test:u.MANN_WHITNEY,statistic:Fe,statisticName:"U",df:null,pValue:Ie,difference:null,interval:J(pe,oe,1-be),effectSize:{name:"cliffsDelta",label:E(Be,f),value:Be},summaries:[ye,Ne]}}function J(pe,oe,be){const fe=pe.length,le=oe.length,ye=fe*le;if(ye===0||ye>2e6)return null;const Ne=new Float64Array(ye);let je=0;for(let Ee=0;Ee<fe;Ee++)for(let Ie=0;Ie<le;Ie++)Ne[je++]=pe[Ee]-oe[Ie];Ne.sort();const $e=ye>>1,Re=ye%2?Ne[$e]:(Ne[$e-1]+Ne[$e])/2,Se=Math.sqrt(fe*le*(fe+le+1)/12),Ve=r(1-(1-be)/2);let Fe=Math.round(ye/2-Ve*Se);Fe>=0||(Fe=0);const Ce=Math.floor((ye-1)/2);return Fe>Ce&&(Fe=Ce),{estimate:Re,lower:Ne[Fe],upper:Ne[ye-1-Fe],confidence:be,method:"hodges-lehmann (location shift)"}}function te(pe,oe){const be=pe.length,fe=pe.map(w);if(fe.some(Ie=>Ie.n<2))return null;const le=fe.reduce((Ie,Be)=>Ie+Be.n,0),ye=fe.reduce((Ie,Be)=>Ie+Be.mean*Be.n,0)/le;let Ne=0,je=0;for(let Ie=0;Ie<be;Ie++)Ne+=fe[Ie].n*(fe[Ie].mean-ye)**2,je+=(fe[Ie].n-1)*fe[Ie].variance;const $e=be-1,Re=le-be;if(!(je>0)||Re<1)return null;const Se=Ne/$e,Ve=je/Re,Fe=Se/Ve,Ce=Math.min(1,Math.max(0,v(Fe,$e,Re))),Ee=Ne/(Ne+je);return{test:u.ANOVA,statistic:Fe,statisticName:"F",df:{between:$e,within:Re},pValue:Ce,difference:null,interval:null,effectSize:{name:"etaSquared",label:E(Ee,p),value:Ee},summaries:fe}}function Q(pe,oe){const be=pe.length,fe=pe.map(w);if(be<2)return null;const le=fe.reduce((Be,Ke)=>Be+Ke.n,0),ye=[];for(let Be=0;Be<be;Be++)for(let Ke=0;Ke<pe[Be].length;Ke++)ye.push({v:pe[Be][Ke],g:Be});ye.sort((Be,Ke)=>Be.v-Ke.v);const Ne=new Array(ye.length);let je=0,$e=0;for(;$e<ye.length;){let Be=$e;for(;Be<ye.length&&ye[Be].v===ye[$e].v;)Be++;const Ke=($e+1+Be)/2;for(let rt=$e;rt<Be;rt++)Ne[rt]=Ke;const qe=Be-$e;je+=qe*qe*qe-qe,$e=Be}const Re=new Array(be).fill(0);for(let Be=0;Be<ye.length;Be++)Re[ye[Be].g]+=Ne[Be];let Se=0;for(let Be=0;Be<be;Be++)Se+=Re[Be]*Re[Be]/fe[Be].n;Se=12/(le*(le+1))*Se-3*(le+1);const Ve=1-je/(le*le*le-le),Fe=Ve>0?Se/Ve:Se,Ce=be-1,Ee=Math.min(1,Math.max(0,t(Fe,Ce))),Ie=(Fe-be+1)/(le-be);return{test:u.KRUSKAL,statistic:Fe,statisticName:"H",df:Ce,pValue:Ee,difference:null,interval:null,effectSize:{name:"etaSquared",label:E(Ie,p),value:Math.max(0,Ie)},summaries:fe}}function re(pe,oe,be,fe,le){const ye=j(pe,oe,le),Ne=j(be,fe,le);if(!ye||!Ne)return null;const je=ye.proportion-Ne.proportion,$e=je-Math.sqrt((ye.proportion-ye.lower)**2+(Ne.upper-Ne.proportion)**2),Re=je+Math.sqrt((ye.upper-ye.proportion)**2+(Ne.proportion-Ne.lower)**2);return{estimate:je,lower:$e,upper:Re}}function ie(pe,oe,be,fe){const le=_(oe),ye=new Set,Ne=[];for(const Ke of pe){const qe=new Map;let rt=0;for(const nt of Ke.rows){const dt=c(le(nt));dt!==null&&(qe.set(dt,(qe.get(dt)||0)+1),rt++,ye.add(dt))}Ne.push(qe),Ke.total=rt}const je=[...ye];if(je.length<2)return null;const $e=pe.reduce((Ke,qe)=>Ke+qe.total,0);if(!($e>0))return null;let Re=0;for(const Ke of pe)for(const qe of je){const rt=Ne[pe.indexOf(Ke)].get(qe)||0,nt=pe.reduce((Pt,Nt)=>Pt+(Ne[pe.indexOf(Nt)].get(qe)||0),0),dt=Ke.total*nt/$e;dt>0&&(Re+=(rt-dt)*(rt-dt)/dt)}const Se=pe.length,Ve=je.length,Fe=(Se-1)*(Ve-1),Ce=Math.min(1,Math.max(0,t(Re,Fe))),Ee=M(Re,$e,Se,Ve);let Ie=null;if(Se===2&&Ve===2){const[Ke]=je,qe=Ne[0].get(Ke)||0,rt=Ne[1].get(Ke)||0,nt=re(qe,pe[0].total,rt,pe[1].total,fe);nt&&(Ie={...nt,confidence:fe,method:"newcombe (difference in this category's share)",category:Ke})}const Be=pe.map((Ke,qe)=>{const rt={};for(const nt of je)rt[String(nt)]=(Ne[qe].get(nt)||0)/Ke.total;return rt});return{test:u.CHI_SQUARE,statistic:Re,statisticName:"chiSquare",df:Fe,pValue:Ce,difference:null,interval:Ie,effectSize:{name:"cramersV",label:V("cramersV",Ee,Math.min(Se-1,Ve-1)),value:Ee},proportions:Be}}function ue(pe,oe,be,fe){const le=_(oe),ye=new Set;for(const nt of pe)for(const dt of nt.rows){const Pt=c(le(dt));Pt!==null&&ye.add(Pt)}if(ye.size!==2)return null;const[Ne]=[...ye],je=pe[0].rows.reduce((nt,dt)=>nt+(c(le(dt))===Ne?1:0),0),$e=pe[1].rows.reduce((nt,dt)=>nt+(c(le(dt))===Ne?1:0),0),Re=pe[0].rows.length,Se=pe[1].rows.length;if(!(Re>0)||!(Se>0))return null;const Ve=je/Re,Fe=$e/Se,Ce=(je+$e)/(Re+Se);if(!(Ce>0)||!(Ce<1))return null;const Ee=Math.sqrt(Ce*(1-Ce)*(1/Re+1/Se)),Ie=(Ve-Fe)/Ee,Be=Math.min(1,Math.max(0,2*h(-Math.abs(Ie)))),Ke=Ve-Fe,qe=re(je,Re,$e,Se,fe),rt=M(Ie*Ie,Re+Se,2,2);return{test:u.PROPORTIONS,statistic:Ie,statisticName:"z",df:null,pValue:Be,difference:Ke,interval:qe?{...qe,confidence:fe,method:"newcombe (difference in proportions)",category:Ne}:null,effectSize:{name:"cramersV",label:V("cramersV",rt,1),value:rt},proportions:[{[String(Ne)]:Ve},{[String(Ne)]:Fe}],focalCategory:Ne}}function ke(pe,oe,be,fe){if(be&&d.has(be))return{test:be,reason:`caller override: ${be}`};const le=U(pe),ye=U(oe),Ne=le===null?null:Math.exp(-le/2),je=ye===null?null:Math.exp(-ye/2);if(Ne!==null&&Ne<i||je!==null&&je<i)return{test:u.MANN_WHITNEY,reason:"two numeric groups, non-normal by Jarque-Bera"};const $e=w(pe),Re=w(oe);if($e.n>=3&&Re.n>=3&&$e.variance>0&&Re.variance>0){const Se=Math.max($e.variance,Re.variance)/Math.min($e.variance,Re.variance),Ve=$e.variance>=Re.variance?$e.n-1:Re.n-1,Fe=$e.variance>=Re.variance?Re.n-1:$e.n-1;if(2*Math.min(v(Se,Ve,Fe),1-v(Se,Ve,Fe))<fe)return{test:u.WELCH,reason:"two numeric groups, unequal variances (F-test)"}}return{test:u.T,reason:Ne!==null||je!==null?"two numeric groups, equal variances and no departure from normality":"two numeric groups (too few rows to screen normality)"}}function de(pe,oe){if(oe&&s.has(oe))return{test:oe,reason:`caller override: ${oe}`};for(const be of pe){const fe=U(be),le=fe===null?null:Math.exp(-fe/2);if(le!==null&&le<i)return{test:u.KRUSKAL,reason:"three or more numeric groups, non-normal by Jarque-Bera"}}return{test:u.ANOVA,reason:"three or more numeric groups, no departure from normality detected"}}function we(pe,oe,be,fe={},le=null){if(!pe||!oe)return null;const ye=y(fe.alpha),Ne=1-ye,je=fe.test&&fe.test!=="auto"?String(fe.test):null,$e=m(oe,be);if($e.length<2)return P("compare:groups",'[lattice] statistics.compare: the "by" column has fewer than two distinct values to group by.'),null;let Re;if(Array.isArray(fe.groups)&&fe.groups.length===2){const qe=[c(fe.groups[0]),c(fe.groups[1])];if(qe[0]===null||qe[1]===null||qe[0]===qe[1])return P("compare:distinct","[lattice] statistics.compare: the two groups must be two distinct, present values."),null;if(Re=$e.filter(rt=>rt.value===qe[0]||rt.value===qe[1]),Re.length!==2)return P("compare:empty","[lattice] statistics.compare: one of the two groups has no rows in the current set."),null;Re.sort((rt,nt)=>rt.value===qe[0]?-1:1)}else $e.length===2||je&&d.has(je)||je&&g.has(je)?Re=$e.slice(0,2):(je&&s.has(je),Re=$e);const Ve=X(pe,be),Fe=!!fe.paired&&le&&Re.length===2&&Ve;let Ce,Ee,Ie;if(Ve)if(Re.length===2&&!(je&&s.has(je))){const qe=Z(pe,Re[0].rows),rt=Z(pe,Re[1].rows);if(qe.length<3||rt.length<3)return P("compare:small","[lattice] statistics.compare: each group needs at least three readings to compare."),null;if(w(qe).variance===0||w(rt).variance===0)return P("compare:zero-variance","[lattice] statistics.compare: a group has zero variance, so the difference has no scale to test."),null;if(Fe){const dt=De(pe,le,Re[0].rows,Re[1].rows);return dt?(Ee=je?"override":"auto",Ie=je?`caller override: ${je} (paired)`:"two numeric groups, paired",Ce=je===u.MANN_WHITNEY?W(dt.diffs,ye):$(dt.diffs,ye),Ce?(Ce.paired=!0,Ce.chosenBy=Ee,Ce.reason=Ie,Ce.groups=[{value:Re[0].value,label:String(Re[0].value),n:dt.n},{value:Re[1].value,label:String(Re[1].value),n:dt.n}],Ce.alpha=ye,Ce.method=Ce.test===u.MANN_WHITNEY?"Wilcoxon signed-rank test (paired)":"Student's paired t-test (difference of pairs)",Ce.verdict=S(Ce,fe),Ce.categorical=!1,Ce):(P("compare:degenerate","[lattice] statistics.compare: the paired test had too little to work with."),null)):(P("compare:paired","[lattice] statistics.compare: not enough matched pairs to run a paired test."),null)}const nt=ke(qe,rt,je,ye);Ee=je?"override":"auto",Ie=nt.reason,nt.test===u.MANN_WHITNEY?Ce=B(qe,rt,ye):nt.test===u.WELCH?Ce=I(qe,rt,ye):Ce=K(qe,rt,ye),Ce&&Ce.interval&&Ce.difference===null&&(Ce.difference=Ce.interval.estimate)}else{const qe=Re.map(nt=>Z(pe,nt.rows));if(qe.some(nt=>nt.length<3))return P("compare:small","[lattice] statistics.compare: each group needs at least three readings to compare."),null;const rt=de(qe,je);Ee=je?"override":"auto",Ie=rt.reason,Ce=rt.test===u.KRUSKAL?Q(qe,ye):te(qe,ye)}else if(Re.length===2){const qe=ve(pe,Re).size===2;if(je===u.PROPORTIONS||qe&&!je)Ee=je?"override":"auto",Ie=je?"caller override: proportions":"categorical measure with two categories (binary)",Ce=ue(Re,pe,ye,Ne);else if(je===u.CHI_SQUARE||!qe&&!je)Ee=je?"override":"auto",Ie=je?"caller override: chiSquare":`categorical measure with ${ve(pe,Re).size} categories`,Ce=ie(Re,pe,ye,Ne);else return P("compare:numeric-needed",`[lattice] statistics.compare: ${je} needs a numeric measure, but the column is categorical.`),null}else Ee=je?"override":"auto",Ie=je?`caller override: ${je}`:`categorical measure with ${ve(pe,Re).size} categories`,Ce=ie(Re,pe,ye,Ne);if(!Ce)return P("compare:degenerate","[lattice] statistics.compare: the chosen test had too little to work with (too few values, or no variation)."),null;const Be=Ce.summaries,Ke=Ce.proportions;return{test:Ce.test,chosenBy:Ee,reason:Ie,statistic:Ce.statistic,statisticName:Ce.statisticName,df:Ce.df===void 0?null:Ce.df,pValue:Ce.pValue,alpha:ye,paired:!1,interval:Ce.interval||null,effectSize:Ce.effectSize,groups:Re.map((qe,rt)=>({value:qe.value,label:String(qe.value),n:Be?Be[rt].n:qe.total,...Be?{mean:Be[rt].mean,sd:Be[rt].sd}:{},...Ke?{proportions:Ke[rt]}:{}})),difference:Ce.difference===void 0?null:Ce.difference,method:Ce.test,categorical:!Ve,verdict:Re.length===2?S({...Ce,alpha:ye,groups:[{value:Re[0].value,label:String(Re[0].value),mean:Be?Be[0].mean:void 0},{value:Re[1].value,label:String(Re[1].value),mean:Be?Be[1].mean:void 0}],categorical:!Ve,difference:Ce.difference===void 0?null:Ce.difference},fe):F({...Ce,alpha:ye},fe)}}function ve(pe,oe){const be=_(pe),fe=new Set;for(const le of oe)for(const ye of le.rows){const Ne=c(be(ye));Ne!==null&&fe.add(Ne)}return fe}function De(pe,oe,be,fe){const le=_(oe),ye=_(pe),Ne=new Map;for(const $e of fe){const Re=c(le($e));Re!==null&&Ne.set(Re,ye($e))}const je=[];for(const $e of be){const Re=c(le($e));if(Re===null||!Ne.has(Re))continue;const Se=Number(ye($e)),Ve=Number(Ne.get(Re));!Number.isFinite(Se)||!Number.isFinite(Ve)||je.push(Se-Ve)}return je.length<2?null:{diffs:Float64Array.from(je),n:je.length}}}),We("packages/core/src/columns/detailcolumn.js",function(e,D){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const ne="__lattice_detail",P=36;function Y(L){const Z=L.config&&L.config.detailColumnWidth||P;return{id:ne,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:Z,min:Z,max:Z,pin:L.config&&L.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(H,x){return!!(x&&x.expanded)},formatValue(){return""}}}const _=Y}),We("packages/core/src/columns/treecolumn.js",function(e,D){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const P=D("packages/core/src/internal/predicates.js").isFunction,Y="__lattice_tree",_=260;function L(H){const x=H.tree||{},X=H.config&&H.config.treeColumnWidth||_,U=!!(H.config&&H.config.treeColumnFlex),j=()=>(H.columns&&P(H.columns.visible)?H.columns.visible():[]).find(h=>!h.generated)||null,k=(a,h)=>{if(h&&h.group)return h.groupValue;if(P(x.label))return x.label(a,h);if(typeof x.label=="string")return a==null?null:a[x.label];const r=j();return r&&P(r.getValue)?r.getValue(a,h):null},b=()=>{if(x.title)return x.title;const a=typeof x.label=="string"?H.columns&&P(H.columns.get)?H.columns.get(x.label):null:j();return a&&(a.title||a.id)||"Hierarchy"};return{id:Y,get title(){return b()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group",props:{icon:x.icon,iconClass:x.iconClass,content:x.content,checkbox:x.checkbox,onCheck:x.onCheck}},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:U?{flex:1,min:0,pin:H.config&&H.config.treeColumnPin||null,hidden:!1,resizable:!1,movable:!1,lockPosition:!0}:{width:X,min:140,pin:H.config&&H.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(a,h){return k(a,h)},formatValue(a,h){if(h&&h.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";if(a==null)return"";if(!x.label){const r=j();if(r&&P(r.formatValue))return r.formatValue(a,h)}return String(a)}}}const Z=L}),We("packages/core/src/columns/pivotcolumns.js",function(e,D){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return L}});const P=D("packages/core/src/internal/warn.js").warnOnce,Y="__lattice_pivot",_=500;function L(X){const{pivot:U,valueColumns:j,config:k}=X,b=U&&U.paths||[],a=X.separator||k&&k.pivot&&k.pivot.separator||" | ",h=k&&k.pivot&&k.pivot.maxColumns||_;if(!b.length||!j.length)return{tree:[],leaves:[],error:null};const r=Z(k),t=b.length*j.length+(r?j.length:0);if(t>h){const d=`pivot would generate ${t} columns, above the limit of ${h}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return P(`pivot.maxColumns:${t}`,d),{tree:[],leaves:[],error:d}}const o=[],u=[];for(const d of b){const s=[];for(const g of j){const i=x(d,g,a);s.push(i),u.push(i)}s.length===1?(s[0].title=String(d),o.push(s[0])):o.push({id:`${Y}:group:${d}`,title:String(d),columns:s,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(r){const d=j.map(g=>H(g,k));u.push(...d);const s=k&&k.pivot&&k.pivot.totalsLabel||"Total";if(d.length===1)d[0].title=s,r==="before"?o.unshift(d[0]):o.push(d[0]);else{const g={id:`${Y}:group:__totals`,title:s,columns:d,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};r==="before"?o.unshift(g):o.push(g)}}return{tree:o,leaves:u,error:null}}function Z(X){const U=X&&X.pivot&&X.pivot.groupTotals;return U==="before"||U==="after"?U:null}function H(X,U){return{id:`${Y}:__total${U&&U.pivot&&U.pivot.separator||" | "}${X.id}`,field:null,title:X.title||X.id,type:X.type,dataType:X.dataType,nullable:!0,align:X.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:X.id,total:!0},value:{pure:!0},cell:{align:X.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:X.total,lookup:null,layout:{width:X.layout&&X.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,k){const b=k&&k.totals;return b&&Object.hasOwn(b,X.id)?b[X.id]:null},formatValue(j,k){return j==null?"":X.formatValue?X.formatValue(j,k):String(j)}}}function x(X,U,j){return{id:`${Y}:${X}${j}${U.id}`,field:null,title:U.title||U.id,type:U.type,dataType:U.dataType,nullable:!0,align:U.align,generated:!0,pivot:{enabled:!1,index:0,path:X,sourceId:U.id},value:{pure:!0},cell:{align:U.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:U.total,lookup:null,layout:{width:U.layout&&U.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(){return null},formatValue(k,b){return k==null?"":U.formatValue?U.formatValue(k,b):String(k)}}}}),We("packages/core/src/compute/group.js",function(e,D){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return k}});const ne=D("packages/core/src/compute/handle.js"),P=ne.dictSize,Y=ne.identity,_=ne.presenceReader,L=ne.rowCount,Z=ne.valueReader,H="",x="\0",X=1<<20;function U(b,a,h,r){const t=b.length,o=b.map(n=>Z(n)),u=Array.isArray(r)&&r.some(Boolean),d=u?o.map((n,f)=>r[f]?p=>r[f](n(p)):n):o;if(!u&&t>0&&b.every(n=>n&&n.kind==="dictionary"&&n.dict)){const n=b.map(p=>P(p.dict)+1);let f=1;for(let p=0;p<t;p++)f*=n[p];if(f<=Number.MAX_SAFE_INTEGER){const p=b.map(m=>m.values),l=b.map(m=>_(m)),y=m=>{let w=0;for(let v=0;v<t;v++){const E=l[v],V=E&&E(m)===0?n[v]-1:p[v][m];w=w*n[v]+V}return w},c=new Float64Array(h);for(let m=0;m<h;m++)c[m]=y(a[m]);return{packed:c,strings:null,product:f,readers:d,keyOf:y}}}const g=n=>{let f="";for(let p=0;p<t;p++){const l=d[p](n);f+=(p===0?"":H)+(l==null?x:String(l))}return f},i=new Array(h);for(let n=0;n<h;n++)i[n]=g(a[n]);return{packed:null,strings:i,product:1/0,readers:d,keyOf:g}}function j(b,a,h,r){const t=new Uint32Array(r+1);for(let s=0;s<h;s++)t[a[s]+1]++;for(let s=0;s<r;s++)t[s+1]+=t[s];const o=new Uint32Array(h),u=t.slice(0,r);for(let s=0;s<h;s++)o[u[a[s]]++]=b[s];const d=new Array(r);for(let s=0;s<r;s++)d[s]=o.subarray(t[s],t[s+1]);return d}function k(b,a,h={}){const r=b||[],t=a||Y(L(r[0],h)),o=t.length;if(r.length===0||o===0)return{keys:[],buckets:[]};const{packed:u,strings:d,product:s,readers:g}=U(r,t,o,h.project),i=new Uint32Array(o);let n=0,f=null;if(u&&s<=Math.max(1024,Math.min(X,o*4))){const c=s,m=new Int32Array(c).fill(-1);for(let w=0;w<o;w++)m[u[w]]=0;for(let w=0;w<c;w++)m[w]===0&&(m[w]=n++);for(let w=0;w<o;w++)i[w]=m[u[w]];f=new Float64Array(n);for(let w=0;w<c;w++)m[w]>=0&&(f[m[w]]=w)}else if(u){const c=new Map;for(let m=0;m<o;m++){const w=u[m];let v=c.get(w);v===void 0&&(v=n++,c.set(w,v)),i[m]=v}f=new Float64Array(n);for(const[m,w]of c)f[w]=m}else{const c=new Map;for(let m=0;m<o;m++){const w=d[m];let v=c.get(w);v===void 0&&(v=n++,c.set(w,v)),i[m]=v}}const p=j(t,i,o,n),l=new Array(n);for(let c=0;c<n;c++){const m=p[c][0],w=new Array(g.length);for(let v=0;v<g.length;v++)w[v]=g[v](m);l[c]=w}const y={keys:l,buckets:p};return f&&(y.packed=f),y}}),We("packages/core/src/compute/pivot.js",function(e,D){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return o}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/compute/handle.js").valueComparator,Z=D("packages/core/src/compute/group.js").packKeys,x=D("packages/core/src/compute/total.js").total,X="|",U="/",j=2e3;function k(s,g,i){return`${s}${X}${g}${X}${i}`}function b(s,g){let i="";for(let n=0;n<s.length;n++){const f=s[n];i+=(n===0?"":g)+(f==null?"":String(f))}return i}function a(s,g,i={}){const n=i.separator||U,f=g.length,{keyOf:p,readers:l}=Z(s,g,0),y=new Map,c=[],m=[];for(let M=0;M<f;M++){const O=g[M],T=p(O);if(y.has(T))continue;y.set(T,c.length),m.push(T);const A=new Array(l.length);for(let N=0;N<l.length;N++)A[N]=l[N](O);c.push(A)}const w=_(i.locale),v=c.map((M,O)=>O);v.sort((M,O)=>{const T=c[M],A=c[O];for(let N=0;N<T.length;N++){const C=h(T[N],A[N],w);if(C!==0)return C}return M-O});const E=new Array(v.length),V=new Array(v.length),G=new Map;for(let M=0;M<v.length;M++){const O=v[M];E[M]=c[O],V[M]=b(c[O],n),G.set(m[O],M)}return{keys:E,paths:V,idOf:M=>{const O=G.get(p(M));return O===void 0?-1:O}}}function h(s,g,i){const n=s==null,f=g==null;return n||f?n&&f?0:n?1:-1:i(s,g)}function r(s){const g=s.values||s.totals||[];if(g.length&&typeof g[0]=="object"&&g[0]!==null)return g.filter(p=>p&&p.handle);const i=typeof s.handle=="function"?s.handle:null;if(!i)return g.length&&P("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 n=typeof s.totalOf=="function"?s.totalOf:null,f=[];for(const p of g){const l=i(p);l&&f.push({colId:p,handle:l,fn:n?n(p):"sum"})}return f}function t(s,g,i){if(Array.isArray(s)){const n=i||{};return{...n,pivotHandles:s,order:g||null,groups:n.groups||null}}return s||{}}function o(s,g,i){const n=t(s,g,i),f=n.separator||U,p=r(n),l=n.maxColumns===void 0?j:n.maxColumns,y=n.groups&&n.groups.buckets?n.groups:null,c=y?y.buckets:[n.order||new Uint32Array(0)],m=n.groupPaths||(y?y.keys.map(T=>b(T,f)):[""]),w=d(c),{keys:v,paths:E,idOf:V}=a(n.pivotHandles||[],w,n),G=E.length*Math.max(1,p.length),q=u(E,p,f);if(l&&G>l){const T=new Map;return{keys:v,paths:E,fields:q,groupPaths:m,columns:G,values:T,cells:T,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${G} columns, above pivot.maxColumns of ${l}. Narrow the pivot columns or raise the limit.`,columns:G,maxColumns:l}}}const M=new Map,O=E.length;for(let T=0;T<c.length;T++){const A=c[T],N=m[T]===void 0?"":m[T],C=A.length;if(C===0)continue;const S=new Int32Array(C),F=new Uint32Array(O+1);for(let K=0;K<C;K++){const I=V(A[K]);S[K]=I,I>=0&&F[I+1]++}for(let K=0;K<O;K++)F[K+1]+=F[K];const $=new Uint32Array(C),W=F.slice(0,O);for(let K=0;K<C;K++){const I=S[K];I>=0&&($[W[I]++]=A[K])}for(let K=0;K<O;K++){const I=F[K],B=F[K+1];if(B===I)continue;const J=$.subarray(I,B);for(let te=0;te<p.length;te++){const Q=p[te],re=x(Q.handle,J,Q.fn,n.totalContext||{locale:n.locale});M.set(k(N,E[K],Q.colId),re)}}}return{keys:v,paths:E,fields:q,groupPaths:m,columns:G,values:M,cells:M,error:null}}function u(s,g,i){if(g.length===0)return s.slice();const n=[];for(const f of s)for(const p of g)n.push(`${f}${i}${p.colId}`);return n}function d(s){if(s.length===1)return s[0]||new Uint32Array(0);let g=0;for(const f of s)g+=f?f.length:0;const i=new Uint32Array(g);let n=0;for(const f of s)!f||f.length===0||(i.set(f,n),n+=f.length);return i}}),We("packages/core/src/compute/explain.js",function(e,D){"use strict";Object.defineProperty(e,"explainContributors",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"explainChange",{enumerable:!0,get:function(){return k}});const P=D("packages/core/src/compute/total.js").total,_=D("packages/core/src/compute/group.js").groupByColumns,L=new Set(["sum","count","countValues"]),Z=new Set(["min","max"]),H=new Set(["avg"]);function x(b){return typeof b=="string"?b:typeof b=="function"&&b.totalName?b.totalName:null}function X(b,a,h,r){return P(b,a,h,r||{})}function U(b,a){if(a)try{return a(b)}catch{}return b==null?"":String(b)}function j(b){const{handle:a,fn:h,leaves:r,by:t,labelOf:o,rowLabel:u}=b,d={locale:b.locale},s=r&&r.length?r:[],g=x(h),i=X(a,s,h,d),n=Z.has(g);let f;if(n){let y=-1;for(let c=0;c<s.length;c++){const m=X(a,[s[c]],h,d);if(Object.is(m,i)){y=s[c];break}}f=y<0?[]:[{key:y,indices:[y],label:u?u(y):String(y)}]}else if(t){const y=_([t],s);f=y.keys.map((c,m)=>({key:c[0],indices:y.buckets[m],label:U(c[0],o)}))}else f=Array.from({length:s.length},(y,c)=>{const m=s[c];return{key:m,indices:[m],label:u?u(m):String(m)}});const p=s.length,l=[];for(const y of f){const c=X(a,y.indices,h,d),m=y.indices.length;let w,v;if(g==="avg")w=((typeof c=="number"?c:0)-(typeof i=="number"?i:0))*m,v=p?m/p:0;else if(n)w=typeof c=="number"?c:0,v=1;else{w=typeof c=="number"?c:0;const E=typeof i=="number"?i:0;v=E?w/E:0}l.push({key:y.key,label:y.label,count:m,value:c,contribution:w,share:v})}return l.sort((y,c)=>Math.abs(c.contribution)-Math.abs(y.contribution)||(y.label<c.label?-1:y.label>c.label?1:0)),{total:i,fn:g,weighted:H.has(g),single:n,contributors:l}}function k(b){const a=j({...b,leaves:b.after}),h=j({...b,leaves:b.before}),r=typeof a.total=="number"?a.total:0,t=typeof h.total=="number"?h.total:0,o=new Map;for(const s of a.contributors)o.set(s.key,s);const u=[],d=new Set;for(const s of h.contributors){d.add(s.key);const g=o.get(s.key);if(g===void 0)u.push({key:s.key,label:s.label,before:s.value,after:null,effect:-s.contribution,kind:"dropped",count:s.count});else{const i=g.contribution-s.contribution;i!==0&&u.push({key:s.key,label:s.label,before:s.value,after:g.value,effect:i,kind:"changed",count:g.count})}}for(const s of a.contributors)d.has(s.key)||u.push({key:s.key,label:s.label,before:null,after:s.value,effect:s.contribution,kind:"new",count:s.count});return u.sort((s,g)=>Math.abs(g.effect)-Math.abs(s.effect)||(s.label<g.label?-1:s.label>g.label?1:0)),{before:h.total,after:a.total,delta:r-t,weighted:a.weighted||h.weighted,single:a.single||h.single,drivers:u}}}),We("packages/core/src/store/bitset.js",function(e,D){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return P}});const ne=8;class P{static#e=new Uint8Array(256);static{for(let _=1;_<256;_++)P.#e[_]=P.#e[_>>1]+(_&1)}#t;#n;constructor(_=0){const L=Math.max(0,_|0);this.#n=L,this.#t=new Uint8Array(Math.ceil(L/ne))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(_){return _<0||_>=this.#n?0:this.#t[_>>3]>>(_&7)&1}set(_){return _>=0&&_<this.#n&&(this.#t[_>>3]|=1<<(_&7)),this}clear(_){return _>=0&&_<this.#n&&(this.#t[_>>3]&=~(1<<(_&7))),this}assign(_,L){return L?this.set(_):this.clear(_)}fill(_=!1){return this.#t.fill(_?255:0),_&&this.#r(),this}grow(_){const L=Math.max(0,_|0);if(L<=this.#n)return this;const Z=Math.ceil(L/ne);if(Z>this.#t.length){const H=new Uint8Array(Z);H.set(this.#t),this.#t=H}return this.#n=L,this}count(){const _=this.#t,L=P.#e;let Z=0;for(let H=0;H<_.length;H++)Z+=L[_[H]];return Z}and(_){const L=_ instanceof P?_.words:_,Z=this.#t,H=Math.min(Z.length,L.length);for(let x=0;x<H;x++)Z[x]&=L[x];for(let x=H;x<Z.length;x++)Z[x]=0;return this}or(_){const L=_ instanceof P?_.words:_,Z=this.#t,H=Math.min(Z.length,L.length);for(let x=0;x<H;x++)Z[x]|=L[x];return this}not(){const _=this.#t;for(let L=0;L<_.length;L++)_[L]=~_[L]&255;return this.#r(),this}clone(){const _=new P(this.#n);return _.words.set(this.#t.subarray(0,_.words.length)),_}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const _=this.#n&7;if(_===0)return;const L=this.#n>>3;L<this.#t.length&&(this.#t[L]&=(1<<_)-1)}static from(_){const L=Array.isArray(_)?_:Array.from(_),Z=new P(L.length);for(let H=0;H<L.length;H++)L[H]&&Z.set(H);return Z}}}),We("packages/core/src/store/dictionary.js",function(e,D){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return _}});const ne=D("packages/core/src/internal/compare.js"),P=ne.collator,Y=ne.defaultCompare;class _{#e;#t=new Map;#n=0;#r=null;#s=-1;#i="\0";constructor(Z=[]){this.#e=[];for(let H=0;H<Z.length;H++){const x=Z[H];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 Z=this.#e.length*8;for(let H=0;H<this.#e.length;H++){const x=this.#e[H];typeof x=="string"&&(Z+=x.length*2),Z+=16}return Z}codeOf(Z){const H=this.#t.get(Z);if(H!==void 0)return H;const x=this.#e.length;return this.#e.push(Z),this.#t.set(Z,x),this.#n++,x}lookup(Z){const H=this.#t.get(Z);return H===void 0?-1:H}has(Z){return this.#t.has(Z)}valueOf(Z){return this.#e[Z]}values(){return this.#e}ranks(Z){const H=Z||"";if(this.#r&&this.#s===this.#n&&this.#i===H)return this.#r;const x=this.#e.length,X=new Array(x);for(let b=0;b<x;b++)X[b]=b;const U=P(Z).compare,j=this.#e;X.sort((b,a)=>this.#o(j[b],j[a],U));const k=new Uint32Array(x);for(let b=0;b<x;b++)k[X[b]]=b;return this.#r=k,this.#s=this.#n,this.#i=H,k}#o(Z,H,x){return typeof Z=="string"&&typeof H=="string"?x(Z,H):Y(Z,H)}}}),We("packages/core/src/store/multivalue.js",function(e,D){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return ne}});class ne{#e;#t;#n=0;#r=0;constructor(Y={}){const _=Math.max(1,Y.rows??16),L=Math.max(1,Y.values??_);this.#e=new Int32Array(L),this.#t=new Uint32Array(_+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(Y){return Y<0||Y>=this.#n?0:this.#t[Y+1]-this.#t[Y]}at(Y){return Y<0||Y>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[Y],this.#t[Y+1])}has(Y,_){if(Y<0||Y>=this.#n)return!1;const L=this.#e,Z=this.#t[Y+1];for(let H=this.#t[Y];H<Z;H++)if(L[H]===_)return!0;return!1}hasAny(Y,_){for(let L=0;L<_.length;L++)if(this.has(Y,_[L]))return!0;return!1}hasAll(Y,_){for(let L=0;L<_.length;L++)if(!this.has(Y,_[L]))return!1;return!0}hasNone(Y,_){return!this.hasAny(Y,_)}push(Y){const _=this.#n,L=Y.length;this.#s(_+1),this.#i(this.#r+L);const Z=this.#r;for(let H=0;H<L;H++)this.#e[Z+H]=Y[H]|0;return this.#r+=L,this.#n=_+1,this.#t[_]=Z,this.#t[_+1]=this.#r,_}write(Y,_){if(Y===this.#n){this.push(_);return}if(Y<0||Y>this.#n)return;const L=this.#t[Y],Z=this.#t[Y+1],H=_.length;if(Z-L===H){for(let x=0;x<H;x++)this.#e[L+x]=_[x]|0;return}this.#o(Y,_)}compact(Y,_,L){const Z=this.#e,H=this.#t,x=this.#n,X=new Int32Array(Math.max(1,this.#r)),U=new Uint32Array(_+1);let j=0;for(let k=0;k<x;k++){if(Y[k]===L)continue;const b=H[k],a=H[k+1];U[Y[k]]=j;for(let h=b;h<a;h++)X[j++]=Z[h];U[Y[k]+1]=j}this.#e=X,this.#t=U,this.#n=_,this.#r=j}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#s(Y){if(Y+1<=this.#t.length)return;let _=this.#t.length-1;for(;_<Y;)_=_*2||16;const L=new Uint32Array(_+1);L.set(this.#t),this.#t=L}#i(Y){if(Y<=this.#e.length)return;let _=this.#e.length;for(;_<Y;)_=_*2||16;const L=new Int32Array(_);L.set(this.#e),this.#e=L}#o(Y,_){const L=this.#e,Z=this.#t,H=this.#n,x=_.length-(Z[Y+1]-Z[Y]),X=new Int32Array(Math.max(1,this.#r+x)),U=new Uint32Array(Z.length);let j=0;for(let k=0;k<H;k++){if(U[k]=j,k===Y)for(let b=0;b<_.length;b++)X[j++]=_[b]|0;else for(let b=Z[k];b<Z[k+1];b++)X[j++]=L[b];U[k+1]=j}this.#e=X,this.#t=U,this.#r=j}}}),We("packages/core/src/compute/sort.js",function(e,D){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return O}});const ne=D("packages/core/src/compute/handle.js"),P=ne.bitReader,Y=ne.dictRanks,_=ne.dictSize,L=ne.identity,Z=ne.isMissing,H=ne.presenceReader,x=ne.rowCount,X=ne.valueComparator,U=ne.valueReader,j=new Uint32Array(0),k=new ArrayBuffer(8),b=new Float64Array(k),a=new Uint32Array(k),h=(b[0]=-1,(a[1]&2147483648)!==0?1:0),r=h===1?0:1;function t(A,N){b[0]=A;let C=a[h],S=a[r];(C&2147483648)!==0?(C=~C>>>0,S=~S>>>0):C=(C^2147483648)>>>0,N[0]=S,N[1]=C}function o(A,N,C,S){if(S<2)return A;const F=new Uint32Array(256*8);for(let Q=0;Q<S;Q++){const re=N[Q],ie=C[Q];F[re&255]++,F[256+(re>>>8&255)]++,F[512+(re>>>16&255)]++,F[768+(re>>>24&255)]++,F[1024+(ie&255)]++,F[1280+(ie>>>8&255)]++,F[1536+(ie>>>16&255)]++,F[1792+(ie>>>24&255)]++}let $=A,W=N,K=C,I=new Uint32Array(S),B=new Uint32Array(S),J=new Uint32Array(S);const te=new Uint32Array(256);for(let Q=0;Q<8;Q++){const re=Q<<8,ie=(Q&3)<<3,ue=Q>=4;let ke=!1;for(let ve=0;ve<256;ve++)if(F[re+ve]===S){ke=!0;break}if(ke)continue;let de=0;for(let ve=0;ve<256;ve++)te[ve]=de,de+=F[re+ve];for(let ve=0;ve<S;ve++){const De=W[ve],pe=K[ve],oe=(ue?pe:De)>>>ie&255,be=te[oe]++;I[be]=$[ve],B[be]=De,J[be]=pe}let we=$;$=I,I=we,we=W,W=B,B=we,we=K,K=J,J=we}return $}function u(A,N,C){if(C<2)return A;const S=new Uint32Array(256*4);for(let B=0;B<C;B++){const J=N[B];S[J&255]++,S[256+(J>>>8&255)]++,S[512+(J>>>16&255)]++,S[768+(J>>>24&255)]++}let F=A,$=N,W=new Uint32Array(C),K=new Uint32Array(C);const I=new Uint32Array(256);for(let B=0;B<4;B++){const J=B<<8,te=B<<3;let Q=!1;for(let ue=0;ue<256;ue++)if(S[J+ue]===C){Q=!0;break}if(Q)continue;let re=0;for(let ue=0;ue<256;ue++)I[ue]=re,re+=S[J+ue];for(let ue=0;ue<C;ue++){const ke=$[ue],de=I[ke>>>te&255]++;W[de]=F[ue],K[de]=ke}let ie=F;F=W,W=ie,ie=$,$=K,K=ie}return F}function d(A,N,C,S){const F=new Uint32Array(S+1);for(let K=0;K<C;K++)F[N[K]]++;let $=0;for(let K=0;K<=S;K++){const I=F[K];F[K]=$,$+=I}const W=new Uint32Array(C);for(let K=0;K<C;K++)W[F[N[K]]++]=A[K];return W}function s(A,N,C,S){return C<2?A:S<=65536||S<=C*2?d(A,N,C,S):u(A,N,C)}function g(A,N){return A.length===N&&A.byteOffset===0?A:Uint32Array.prototype.slice.call(A,0,N)}function i(A,N,C=!1){const S=N||L(A.length),F=S.length;if(F<2)return Uint32Array.from(S);const $=new Uint32Array(F),W=new Uint32Array(F),K=new Uint32Array(F),I=new Uint32Array(F),B=new Uint32Array(2);let J=0,te=0;for(let ie=0;ie<F;ie++){const ue=S[ie],ke=A[ue];if(Number.isNaN(ke)){I[te++]=ue;continue}t(ke,B),C?(W[J]=~B[0]>>>0,K[J]=~B[1]>>>0):(W[J]=B[0],K[J]=B[1]),$[J++]=ue}const Q=o($.subarray(0,J),W.subarray(0,J),K.subarray(0,J),J);if(te===0)return g(Q,J);const re=new Uint32Array(F);return re.set(Q.subarray(0,J),0),re.set(I.subarray(0,te),J),re}function n(A,N,C=!1){const S=N||L(A.length),F=S.length;if(F<2)return Uint32Array.from(S);const $=Uint32Array.from(S),W=new Uint32Array(F);for(let K=0;K<F;K++){const I=(A[$[K]]^2147483648)>>>0;W[K]=C?~I>>>0:I}return g(u($,W,F),F)}function f(A,N,C={}){const S=N||L(x(A,C)),F=S.length;if(F<2)return Uint32Array.from(S);const $=Y(A.dict,C.locale),W=A.values,K=H(A),I=Math.max(_(A.dict),$.length),B=I,J=Uint32Array.from(S),te=new Uint32Array(F),Q=!!C.descending;for(let re=0;re<F;re++){const ie=J[re];let ue=K&&K(ie)===0?B:$[W[ie]];ue===void 0&&(ue=B),te[re]=Q?B-ue:ue}return g(s(J,te,F,I+1),F)}function p(A,N,C){const S=N.length;let F=Uint32Array.from(N);if(S<2)return F;let $=new Uint32Array(S);for(let W=1;W<S;W<<=1){for(let I=0;I<S;I+=W<<1){const B=Math.min(I+W,S),J=Math.min(I+(W<<1),S);let te=I,Q=B,re=I;for(;te<B&&Q<J;)$[re++]=C(A[F[te]],A[F[Q]])<=0?F[te++]:F[Q++];for(;te<B;)$[re++]=F[te++];for(;Q<J;)$[re++]=F[Q++]}const K=F;F=$,$=K}return F}function l(A,N,C){const S=P(A.values),F=N.length,$=new Uint32Array(F),W=C?1:0;let K=0;for(let I=0;I<F;I++)S(N[I])===W&&($[K++]=N[I]);for(let I=0;I<F;I++)S(N[I])!==W&&($[K++]=N[I]);return $}function y(A,N){const C=A.values,S=A.kind;if((S==="object"||S===void 0)&&(Array.isArray(C)||ArrayBuffer.isView(C))&&!A.presence)return C;const $=U(A),W=new Array(x(A)||0);for(let K=0;K<N.length;K++){const I=N[K];W[I]=$(I)}return W}function c(A,N){for(let C=0;C<N.length;C++)if(typeof A[N[C]]!="string")return!1;return!0}function m(A,N,C,S,F){const $=A.length,W=Uint32Array.from(A);if($<2||S<1)return W;const K=new Uint32Array($),I=S-1;for(let B=0;B<$;B++){const J=C[N[B]];K[B]=F?I-J:J}return g(s(W,K,$,S),$)}function w(A,N,C){const S=X(C),F=new Array(N);for(let W=0;W<N;W++)F[W]=W;F.sort((W,K)=>S(A[W],A[K])||W-K);const $=new Uint32Array(N);for(let W=0;W<N;W++)$[F[W]]=W;return $}function v(A,N,C){const S=N.length,F=new Map,$=[],W=new Uint32Array(S);for(let B=0;B<S;B++){const J=A[N[B]];let te=F.get(J);te===void 0&&(te=$.length,F.set(J,te),$.push(J)),W[B]=te}const K=$.length,I=w($,K,C.locale);return m(N,W,I,K,!!C.descending)}function E(A,N,C){const S=y(A,N);if(N.length>=2&&c(S,N)){const W=A.stringRank;return W&&W.version===A.version&&W.usable(N,S,C.locale)?W.sort(N,C):v(S,N,C)}const F=X(C.locale),$=C.descending?(W,K)=>F(K,W):F;return p(S,N,$)}function V(A,N,C){const S=y(A,N),F=C.compare,W=!!C.descending?(K,I)=>-F(K,I,void 0,void 0,!0):(K,I)=>F(K,I,void 0,void 0,!1);return p(S,N,W)}function G(A,N){const C=N.length,S=H(A),F=A.values,$=A.kind==="float64"&&!!F,W=A.kind==="object"||A.kind==="multi"||A.kind===void 0;if(!S&&!$&&!W)return{present:N,absent:j};const K=new Uint32Array(C),I=new Uint32Array(C);let B=0,J=0;if(S&&$)for(let te=0;te<C;te++){const Q=N[te];S(Q)===1&&!Number.isNaN(F[Q])?K[B++]=Q:I[J++]=Q}else if($&&!S)for(let te=0;te<C;te++){const Q=N[te];Number.isNaN(F[Q])?I[J++]=Q:K[B++]=Q}else if(S&&!W)for(let te=0;te<C;te++){const Q=N[te];S(Q)===1?K[B++]=Q:I[J++]=Q}else{const te=U(A);for(let Q=0;Q<C;Q++){const re=N[Q];Z(te(re))?I[J++]=re:K[B++]=re}}return J===0?{present:N,absent:j}:{present:K.subarray(0,B),absent:I.subarray(0,J)}}function q(A,N,C){if(N.length===0)return A;const S=new Uint32Array(A.length+N.length);return C?(S.set(N,0),S.set(A,N.length)):(S.set(A,0),S.set(N,A.length)),S}function M(A,N,C={}){const S=N||L(x(A,C));if(!A||S.length<2)return Uint32Array.from(S);const{present:F,absent:$}=G(A,S);if(F.length===0)return Uint32Array.from(S);const W=!!C.descending;let K;if(typeof C.compare=="function")K=V(A,F,C);else switch(A.kind){case"float64":K=i(A.values,F,W);break;case"int32":K=n(A.values,F,W);break;case"dictionary":K=f(A,F,C);break;case"bitset":K=l(A,F,W);break;default:K=E(A,F,C);break}return q(K,$,!!C.nullsFirst)}function O(A,N,C,S={}){const F=N||[],$=F.length&&(F[0].handle||T(A,F[0].col))||A&&A[0];let W=C||L(x($,S));for(let K=F.length-1;K>=0;K--){const I=F[K],B=I.handle||T(A,I.col)||A&&A[K];B&&(W=M(B,W,{descending:I.descending!==void 0?!!I.descending:I.dir==="desc",nullsFirst:!!I.nullsFirst,locale:I.locale!==void 0?I.locale:S.locale,compare:I.compare}))}return W instanceof Uint32Array?W:Uint32Array.from(W)}function T(A,N){if(!(!A||N===void 0)){for(let C=0;C<A.length;C++)if(A[C]&&A[C].id===N)return A[C]}}}),We("packages/core/src/store/stringrank.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return L}});const ne=D("packages/core/src/compute/sort.js"),P=ne.collateStringRanks,Y=ne.rankSortStrings,_=1e5;class L{#e=[];#t=new Map;#n;#r=0;#s=0;#i=-1;#o;#l=!1;#a=null;#c=-1;#u="\0";constructor(H=_){this.#o=H>0?H:_,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(H){this.#i=H}get generation(){return this.#s}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let H=this.#n.byteLength;const x=this.#e;for(let X=0;X<x.length;X++)H+=x[X].length*2+24;return H}#d(H,x){const X=this.#t.get(H);if(X!==void 0)return X;if(this.#l)return-1;if(x&&this.#e.length>=this.#o)return this.#l=!0,-1;const U=this.#e.length;return this.#e.push(H),this.#t.set(H,U),this.#s++,U}build(H,x){const X=x|0;this.#e=[],this.#t=new Map,this.#s=0,this.#l=!1,this.#a=null,this.#c=-1,this.#n=new Uint32Array(X);for(let U=0;U<X;U++){const j=H[U],k=typeof j=="string"?this.#d(j,!1):-1;this.#n[U]=k<0?0:k}this.#r=X}append(H,x,X){const U=(x|0)+(X|0);if(U>this.#n.length){const j=new Uint32Array(U);j.set(this.#n.subarray(0,this.#r)),this.#n=j}for(let j=x|0;j<U;j++){const k=H[j],b=typeof k=="string"?this.#d(k,!0):-1;this.#n[j]=b<0?0:b}this.#r=Math.max(this.#r,U)}ranks(H){const x=H||"";if(this.#a&&this.#c===this.#s&&this.#u===x)return this.#a;const X=P(this.#e,this.#e.length,H);return this.#a=X,this.#c=this.#s,this.#u=x,X}usable(H,x,X){if(this.#l||this.#e.length===0)return!1;const U=this.#n,j=this.#e,k=this.#r;for(let b=0;b<H.length;b++){const a=H[b];if(a>=k||j[U[a]]!==x[a])return!1}return!0}sort(H,x){const X=this.ranks(x.locale),U=this.#e.length,j=H.length,k=new Uint32Array(j),b=this.#n;for(let a=0;a<j;a++)k[a]=b[H[a]];return Y(H,k,X,U,!!x.descending)}}}),We("packages/core/src/store/columnstore.js",function(e,D){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return l}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/internal/predicates.js").isFunction,Z=D("packages/core/src/internal/paths.js").pathGetter,x=D("packages/core/src/store/bitset.js").Bitset,U=D("packages/core/src/store/dictionary.js").Dictionary,k=D("packages/core/src/store/multivalue.js").MultiValue,a=D("packages/core/src/store/stringrank.js").StringRankIndex,h=4294967295,r=1024,t=5e3,o=.2,u=new Set(["float64","int32","bitset","dictionary","object","multi"]);function d(y){return y==null}function s(y){if(typeof y=="number")return y;if(y instanceof Date)return y.getTime();if(typeof y=="boolean")return y?1:0;const c=Number(y);return Number.isNaN(c)&&typeof y=="string"?Date.parse(y):c}function g(y){const c=s(y);return Number.isFinite(c)?c|0:0}function i(y){return d(y)?[]:Array.isArray(y)?y:[y]}function n(y,c){switch(y.kind){case"float64":case"int32":return y.buf[c];case"bitset":return y.bits.get(c)===1;case"dictionary":return y.dict.valueOf(y.buf[c]);case"multi":{const m=y.mv.at(c),w=new Array(m.length);for(let v=0;v<m.length;v++)w[v]=y.dict.valueOf(m[v]);return w}default:return y.buf[c]}}function f(y,c){switch(y.kind){case"float64":case"int32":return y.values[c];case"bitset":return(y.values[c>>3]&1<<(c&7))!==0;case"dictionary":return(y.table||[])[y.values[c]];case"multi":{const m=y.offsets[c],w=y.offsets[c+1],v=y.table||[],E=new Array(w-m);for(let V=m;V<w;V++)E[V-m]=v[y.values[V]];return E}default:return y.values[c]}}class p{#e;#t;#n;#r;#s;#i;#o;#l=!1;#a=null;#c=null;#u=null;#d=null;#f=null;#h;#p;#m=-1;#g=null;#b=0;#y=0;#O=null;#w=null;#A=!1;constructor(c,m){this.#e=c.id;const w=u.has(c.kind)?c.kind:"object";c.kind&&!u.has(c.kind)&&P(`store.kind.${c.id}`,`column "${c.id}" declares unknown storage kind "${c.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=c.nullable!==!1,this.#o=c.dictionary??null,this.#i=m,this.#s=_(c.read)?c.read:Z(c.field||c.id),this.#h=c.stringRankIndex!=="off",this.#p=typeof c.stringRankMaxDistinct=="number"?c.stringRankMaxDistinct:0,this.#O=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.#A?null:this.#l?this.#t==="bitset"?this.#c.words:this.#t==="multi"?this.#u.values:this.#a:this.#T().values}get presence(){return this.#A||!this.#r?null:this.#l?this.#g:this.#T().presence}get dict(){return this.#A||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#A||!this.#h||this.kind!=="object")return null;const c=this.values,m=this.#i.physical();if(!c||m===0)return null;if(this.#f===null){if(typeof c[0]!="string")return null;const w=new a(this.#v());return w.build(c,m),w.version=this.#y,this.#f=w,this.#m=this.#y,w.capped?null:w}return this.#f.length<m&&this.#f.append(c,this.#f.length,m-this.#f.length),this.#f.version=this.#y,this.#m=this.#y,this.#f.capped?null:this.#f}#v(){return this.#p}#P(){this.#f=null,this.#m=-1}get offsets(){return this.#A||!this.#l||this.#t!=="multi"?null:this.#u.offsets}get version(){return this.#y}get bytes(){let c=0;return this.#a&&(c+=this.#a.byteLength??this.#a.length*8),this.#c&&(c+=this.#c.bytes),this.#u&&(c+=this.#u.bytes),this.#g&&(c+=this.#g.bytes),this.#d&&(c+=this.#d.bytes),this.#O&&(c+=this.#O.size*24),c}get(c){if(!this.#A&&!(c<0||c>=this.#i.physical())){if(!this.#l)return this.#E(c);if(this.#r&&this.#g.get(c)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[c];case"bitset":return this.#c.get(c)===1;case"dictionary":return this.#d.valueOf(this.#a[c]);case"multi":{const m=this.#u.at(c),w=new Array(m.length);for(let v=0;v<m.length;v++)w[v]=this.#d.valueOf(m[v]);return w}default:return this.#a[c]}}}set(c,m){this.#A||(this.#l?this.#C(c,m):this.#O.set(c,m===void 0?null:m),this.#f&&this.#P(),this.#y++)}read(c){return this.#s(c)}appendColumn(c,m,w){if(this.#A||w<=0)return;if(!this.#l){this.#y++;return}const v=this.#s,E=this.#r,V=this.#g;let G=!1;switch(this.#t){case"float64":{const q=this.#a;for(let M=0;M<w;M++){const O=v(c[M]);if(typeof O=="number"){E&&V.set(m+M),q[m+M]=O;continue}const T=O==null;E?V.assign(m+M,!T):T&&(G=!0),q[m+M]=T?NaN:s(O)}break}case"int32":{const q=this.#a;for(let M=0;M<w;M++){const O=v(c[M]),T=O==null;E?V.assign(m+M,!T):T&&(G=!0),q[m+M]=T?0:g(O)}break}case"bitset":{const q=this.#c;for(let M=0;M<w;M++){const O=v(c[M]),T=O==null;E?V.assign(m+M,!T):T&&(G=!0),q.assign(m+M,!T&&!!O)}break}case"dictionary":{const q=this.#a,M=this.#d;for(let O=0;O<w;O++){const T=v(c[O]),A=T==null;E?V.assign(m+O,!A):A&&(G=!0),q[m+O]=A?0:M.codeOf(T)}break}case"multi":{const q=this.#u,M=this.#d;for(let O=0;O<w;O++){const T=v(c[O]),A=T==null;E?V.assign(m+O,!A):A&&(G=!0);const N=i(T),C=new Array(N.length);for(let S=0;S<N.length;S++)C[S]=M.codeOf(N[S]);q.write(m+O,C)}break}default:{const q=this.#a;for(let M=0;M<w;M++){const O=v(c[M]),T=O==null;E?V.assign(m+M,!T):T&&(G=!0),q[m+M]=T?null:O}break}}G&&P(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#f&&this.#t==="object"&&(this.#f.append(this.#a,m,w),this.#f.version=this.#y+1,this.#m=this.#y+1),this.#y++}appendPacked(c,m,w){if(this.#A||w<=0||!c)return;if(!this.#l){this.#y++;return}const v=this.#g,E=c.presence;if(v)if(E)for(let G=0;G<w;G++)v.assign(m+G,(E[G>>3]&1<<(G&7))!==0);else for(let G=0;G<w;G++)v.set(m+G);const V=c.kind===this.#t;if(V&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(c.values,m),this.#y++;return}if(V&&this.#t==="bitset"){const G=c.values;for(let q=0;q<w;q++)this.#c.assign(m+q,(G[q>>3]&1<<(q&7))!==0);this.#y++;return}if(V&&this.#t==="dictionary"){const G=c.table||[],q=new Uint32Array(G.length);for(let A=0;A<G.length;A++)q[A]=this.#d.codeOf(G[A]);const M=c.values,O=this.#a,T=v;for(let A=0;A<w;A++){if(T&&(E&&(E[A>>3]&1<<(A&7))===0)){O[m+A]=0;continue}O[m+A]=q[M[A]]??0}this.#y++;return}if(V&&this.#t==="multi"){const G=c.table||[],q=new Uint32Array(G.length);for(let T=0;T<G.length;T++)q[T]=this.#d.codeOf(G[T]);const M=c.values,O=c.offsets;for(let T=0;T<w;T++){const A=O[T],N=O[T+1],C=new Array(N-A);for(let S=A;S<N;S++)C[S-A]=q[M[S]]??0;this.#u.write(m+T,C)}this.#y++;return}for(let G=0;G<w;G++){const q=E?(E[G>>3]&1<<(G&7))===0:c.kind==="object"?c.values[G]===null:!1;this.#C(m+G,q?null:f(c,G))}this.#y++}touch(){this.#y++}columnarise(c,m){if(this.#l||this.#A)return;const w=new Array(m);for(let v=0;v<m;v++)w[v]=this.#E(v);this.#t=this.#n,this.#l=!0,this.#S(c);for(let v=0;v<m;v++)this.#C(v,w[v]);this.#O.clear(),this.#w=null,this.#P(),this.#y++}grow(c){if(!(!this.#l||this.#A||c<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const m=new this.#a.constructor(c);m.set(this.#a),this.#a=m;break}case"bitset":this.#c.grow(c);break;case"multi":break;default:this.#a.length=c;break}this.#g&&this.#g.grow(c),this.#b=c,this.#y++}}convert(c){if(this.#A||!u.has(c)||(this.#n=c,!this.#l||c===this.#t))return!1;const m={kind:this.#t,buf:this.#a,bits:this.#c,mv:this.#u,dict:this.#d},w=this.#i.physical(),v=this.#g;this.#t=c,this.#S(this.#b);for(let E=0;E<w;E++){const V=v!==null&&v.get(E)===0;V&&c!=="multi"||this.#C(E,V?null:n(m,E))}return this.#P(),this.#y++,!0}compact(c,m,w){if(!this.#A){if(this.#P(),!this.#l){const v=this.#O;if(v.size){const E=new Map;for(const[V,G]of v)c[V]!==h&&E.set(c[V],G);this.#O=E}this.#w=null,this.#y++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const v=this.#a;for(let E=0;E<m;E++)c[E]!==h&&(v[c[E]]=v[E]);if(this.#t==="object")for(let E=w;E<m;E++)v[E]=void 0;break}case"bitset":{const v=this.#c;for(let E=0;E<m;E++)c[E]!==h&&v.assign(c[E],v.get(E)===1);for(let E=w;E<m;E++)v.clear(E);break}case"multi":this.#u.compact(c,w,h);break;default:break}if(this.#g){const v=this.#g;for(let E=0;E<m;E++)c[E]!==h&&v.assign(c[E],v.get(E)===1);for(let E=w;E<m;E++)v.clear(E)}this.#y++}}release(){this.#A||(this.#A=!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.#d=null,this.#f=null,this.#O=new Map,this.#w=null,this.#b=0,this.#y++)}#S(c){const m=Math.max(1,c);switch(this.#a=null,this.#c=null,this.#u=null,this.#t){case"float64":this.#a=new Float64Array(m);break;case"int32":this.#a=new Int32Array(m);break;case"bitset":this.#c=new x(m);break;case"dictionary":this.#a=new Uint32Array(m),this.#d=this.#d??new U(this.#o??[]);break;case"multi":this.#u=new k({rows:m,values:m}),this.#d=this.#d??new U(this.#o??[]);break;default:this.#a=new Array(m);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(m):this.#g=new x(m)),this.#b=m}#C(c,m){const w=d(m);switch(this.#r?this.#g.assign(c,!w):w&&P(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[c]=w?NaN:s(m);break;case"int32":this.#a[c]=w?0:g(m);break;case"bitset":this.#c.assign(c,!w&&!!m);break;case"dictionary":this.#a[c]=w?0:this.#d.codeOf(m);break;case"multi":{const v=i(m),E=new Array(v.length);for(let V=0;V<v.length;V++)E[V]=this.#d.codeOf(v[V]);this.#u.write(c,E);break}default:this.#a[c]=w?null:m;break}}#E(c){if(this.#O.has(c))return this.#O.get(c);const m=this.#s(this.#i.rowAt(c));return m===void 0?null:m}#T(){if(this.#w&&this.#w.version===this.#y)return this.#w;const c=this.#i.physical(),m=new Array(c),w=this.#r?new x(c):null;for(let v=0;v<c;v++){const E=this.#E(v);m[v]=E,w&&!d(E)&&w.set(v)}return this.#w={version:this.#y,values:m,presence:w},this.#w}}class l{#e;#t=new Map;#n=[];#r=[];#s=0;#i=0;#o=0;#l=0;#a=new x(0);#c=!1;#u=!0;#d;#f;#h;#p=!1;constructor(c,m={}){this.#e=Array.isArray(c)?c:[],this.#f=Math.max(1,m.initialCapacity??r),this.#u=m.retainSource!==!1,this.#d=this.#u?m.columnarBelow??t:0,this.#h=m.compactRatio??o;const w={rowAt:v=>this.#r[v],physical:()=>this.#s};for(const v of this.#e){if(!v||!v.id)continue;if(this.#t.has(v.id)){P(`store.dup.${v.id}`,`duplicate column id "${v.id}" in the store schema; ignoring the second`);continue}const E=new p(v,w);this.#t.set(v.id,E),this.#n.push(E)}this.#d<=0&&this.#b()}get count(){return this.#o}get physical(){return this.#s}get capacity(){return this.#c?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#c}get destroyed(){return this.#p}get bytes(){let c=this.#a.bytes+this.#r.length*8;for(const m of this.#n)c+=m.bytes;return c}append(c){const m=this.#s;if(this.#p||!c)return{from:m,to:m};const w=c.length|0;if(w===0)return{from:m,to:m};if(this.#u)for(let E=0;E<w;E++)this.#r[m+E]=c[E];if(this.#s=m+w,this.#o+=w,this.#a.grow(this.#s),!this.#c){if(this.#s>=this.#d)this.#b();else for(const E of this.#n)E.touch();return{from:m,to:this.#s}}this.#m(this.#s);const v=this.#n;for(let E=0;E<v.length;E++)v[E].appendColumn(c,m,w);return{from:m,to:this.#s}}appendPacked(c,m){const w=this.#s;if(this.#p||!c)return{from:w,to:w};const v=c.count|0;if(v===0)return{from:w,to:w};if(this.#u&&m)for(let V=0;V<v;V++)this.#r[w+V]=m[V];this.#s=w+v,this.#o+=v,this.#a.grow(this.#s),this.#c||this.#b(),this.#m(this.#s);const E=new Map;for(const V of c.columns)E.set(V.id,V);for(const V of this.#n){const G=E.get(V.id);G?V.appendPacked(G,w,v):V.grow(this.#i)}return{from:w,to:this.#s}}source(c){if(this.#u)return this.#r[c];if(!(c<0||c>=this.#s))return this.#g(c)}setSource(c,m){this.#p||c<0||c>=this.#s||this.#u&&(this.#r[c]=m)}get(c,m){const w=this.#t.get(c);return w?w.get(m):void 0}set(c,m,w){if(this.#p||m<0||m>=this.#s)return;const v=this.#t.get(c);if(!v){P(`store.set.${c}`,`set() on unknown column "${c}"`);return}v.set(m,w)}remove(c){return this.#p||c<0||c>=this.#s||this.#a.get(c)===1?!1:(this.#a.set(c),this.#l++,this.#o--,!0)}live(c){return c<0||c>=this.#s?!1:this.#a.get(c)===0}compact(c={}){if(this.#p||this.#l===0||!c.force&&this.#l/this.#s<this.#h)return null;const m=this.#s,w=new Uint32Array(m);let v=0;for(let E=0;E<m;E++)w[E]=this.#a.get(E)===1?h:v++;for(const E of this.#n)E.compact(w,m,v);if(this.#u){const E=this.#r;for(let V=0;V<m;V++)w[V]!==h&&(E[w[V]]=E[V]);E.length=v}return this.#s=v,this.#o=v,this.#l=0,this.#a=new x(Math.max(this.#i,v)),w}column(c){return this.#t.get(c)}columns(){return this.#n.slice()}liveIndices(){const c=new Uint32Array(this.#o);if(this.#l===0){for(let w=0;w<this.#s;w++)c[w]=w;return c}let m=0;for(let w=0;w<this.#s;w++)this.#a.get(w)===0&&(c[m++]=w);return c}convert(c,m){const w=this.#t.get(c);return w?w.convert(m):!1}destroy(){if(!this.#p){this.#p=!0;for(const c of this.#n)c.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#s=0,this.#o=0,this.#l=0,this.#i=0}}#m(c){if(c<=this.#i)return;let m=this.#i||this.#f;for(;m<c;)m*=2;for(const w of this.#n)w.grow(m);this.#a.grow(m),this.#i=m}#g(c){const m={};for(const w of this.#n)m[w.id]=w.get(c);return m}#b(){if(this.#c)return;let c=this.#f;for(;c<this.#s;)c*=2;this.#c=!0,this.#i=c,this.#a.grow(c);for(const m of this.#n)m.columnarise(c,this.#s)}}}),We("packages/core/src/store/pool.js",function(e,D){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return L}});const ne=64,P=8;function Y(H){let x=ne;for(;x<H;)x*=2;return x}class _{#e=new Map;#t=new WeakSet;#n;#r=0;#s={acquired:0,reused:0,released:0};constructor(x={}){this.#n=x.limit??P}get bytes(){return this.#r}mask(x){const X=new Uint8Array(this.#i(x),0,x);return X.fill(0),X}indices(x){return new Uint32Array(this.#i(x*4),0,x)}release(x){if(!x||!x.buffer)return!1;const X=x.buffer;if(!this.#t.has(X))return!1;this.#t.delete(X),this.#s.released++;const U=X.byteLength;let j=this.#e.get(U);return j||this.#e.set(U,j=[]),j.length>=this.#n||(j.push(X),this.#r+=U),!0}releaseAll(x){for(const X of x)this.release(X)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#s,retained:this.#r}}#i(x){const X=Y(x),U=this.#e.get(X);this.#s.acquired++;let j;return U&&U.length?(j=U.pop(),this.#r-=X,this.#s.reused++):j=new ArrayBuffer(X),this.#t.add(j),j}}function L(){return Z??=new _,Z}let Z=null}),We("packages/core/src/compute/sortspec.js",function(e,D){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return L}});function ne(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function P(Z){return!!Z&&typeof Z.compare!="function"}function Y(Z){if(!Z)return!0;for(let H=0;H<Z.length;H++)if(!P(Z[H]))return!1;return!0}function _(Z,H){const x=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,X=Z.locale!==void 0?Z.locale:H;return{col:x,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:ne(X)}}function L(Z,H){const x=Z||[],X=new Array(x.length);for(let U=0;U<x.length;U++)X[U]=_(x[U],H);return X}}),We("packages/core/src/compute/facet.js",function(e,D){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const ne=D("packages/core/src/compute/handle.js"),P=ne.presenceReader,Y=ne.valueReader,_=ne.dictSize,L=ne.dictValue,Z=Object.freeze(["equal","quantile","log"]),H=Object.freeze(["hour","day","week","month","quarter","year"]),x=20,X=50,U=1e4;function j(v,E){if(!v)return"none";const V=E;if(V&&(V.multi===!0||typeof V.items=="function"))return"category";const G=E&&E.base;if(G==="date"||G==="datetime"||G==="time"||G==="dateString")return"date";switch(v.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return G==="number"?"numeric":G==="boolean"?"boolean":G==="text"?"category":"none"}}function k(v){const E=v.values,V=v.kind;if((V==="float64"||V==="int32")&&E)return q=>E[q];const G=Y(v);return q=>b(G(q))}function b(v){if(typeof v=="number")return v;if(v instanceof Date)return v.getTime();if(v==null||v==="")return NaN;if(typeof v=="boolean")return v?1:0;if(typeof v=="string"){const E=Number(v);if(Number.isFinite(E))return E;const V=Date.parse(v);return Number.isFinite(V)?V:NaN}return NaN}function a(v,E,V,G=X){if(!v)return{cardinality:0,exact:!0};if(v.dict)return{cardinality:_(v.dict),exact:!0};if(v.kind==="bitset")return{cardinality:2,exact:!0};const q=Y(v),M=E?E.length:V,O=new Set;for(let T=0;T<M;T++){const A=q(E?E[T]:T);if(A!=null&&(O.add(A),O.size>G))return{cardinality:O.size,exact:!1}}return{cardinality:O.size,exact:!0}}const h=36e5,r=864e5;function t(v,E=x){const V=Number.isFinite(v)&&v>0?v:0,G=Math.max(1,E)*2;return V/h<=G?"hour":V/r<=G?"day":V/(7*r)<=G?"week":V/(30*r)<=G?"month":V/(91*r)<=G?"quarter":"year"}function o(v,E){if(!Number.isFinite(v))return NaN;const V=new Date(v);switch(E){case"hour":return V.setMinutes(0,0,0),V.getTime();case"day":return V.setHours(0,0,0,0),V.getTime();case"week":{V.setHours(0,0,0,0);const G=(V.getDay()+6)%7;return V.setDate(V.getDate()-G),V.getTime()}case"month":return V.setDate(1),V.setHours(0,0,0,0),V.getTime();case"quarter":return V.setMonth(Math.floor(V.getMonth()/3)*3,1),V.setHours(0,0,0,0),V.getTime();default:return V.setMonth(0,1),V.setHours(0,0,0,0),V.getTime()}}function u(v,E){const V=new Date(v);switch(E){case"hour":V.setHours(V.getHours()+1);break;case"day":V.setDate(V.getDate()+1);break;case"week":V.setDate(V.getDate()+7);break;case"month":V.setMonth(V.getMonth()+1);break;case"quarter":V.setMonth(V.getMonth()+3);break;default:V.setFullYear(V.getFullYear()+1);break}return V.getTime()}function d(v,E,V){const G=k(v),q=P(v),M=E?E.length:V;let O=1/0,T=-1/0,A=0,N=0;for(let C=0;C<M;C++){const S=E?E[C]:C;if(q&&!q(S)){A++;continue}const F=G(S);if(!Number.isFinite(F)){A++;continue}F<O&&(O=F),F>T&&(T=F),N++}return{min:O,max:T,nulls:A,finite:N}}function s(v,E,V,G){const q=k(v),M=P(v),O=E?E.length:V,T=O>G?O/G:1,A=[];for(let C=0;C<O;C+=T){const S=E?E[Math.floor(C)]:Math.floor(C);if(M&&!M(S))continue;const F=q(S);Number.isFinite(F)&&A.push(F)}const N=Float64Array.from(A);return N.sort(),N}function g(v,E,V,G={}){const q=G.kind||j(v,G.type);return q==="none"||!v?{kind:"none",buckets:[],suppressed:"type"}:q==="boolean"?i(v,E,V,G):q==="category"?n(v,E,V,G):p(v,E,V,q,G)}function i(v,E,V,G={}){const q=P(v);let M=0;if(q){const T=E?E.length:V;for(let A=0;A<T;A++)q(E?E[A]:A)||M++}const O=[{value:!1,label:"false"},{value:!0,label:"true"}];return M>0&&G.blanks!==!1&&O.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:O}}function n(v,E,V,G){const q=G.cardinalityLimit??X,{cardinality:M}=a(v,E,V,q);if(M>q&&(G.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:M};const O=Y(v),T=E?E.length:V,A=new Map;let N=0;for(let W=0;W<T;W++){const K=O(E?E[W]:W);if(K==null||K===""){N++;continue}if(Array.isArray(K)){if(!K.length){N++;continue}for(const I of K)A.set(I,(A.get(I)||0)+1);continue}A.set(K,(A.get(K)||0)+1)}let C=[...A.entries()];G.order==="alpha"?C.sort((W,K)=>String(W[0]).localeCompare(String(K[0]))):C.sort((W,K)=>K[1]-W[1]);let S=0,F=0;if(C.length>q){F=C.length-q;for(let W=q;W<C.length;W++)S+=C[W][1];C=C.slice(0,q)}const $=C.map(([W])=>({value:W,label:String(W)}));return S>0&&$.push({remainder:!0,label:`Other (${F} values)`}),N>0&&G.blanks!==!1&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:M}}function f(v,E,V,G,q){const M=s(v,E,V,U),O=M.length;if(O<100)return null;const T=M[Math.floor(.01*O)],A=M[Math.ceil(.99*O)-1];return!(A>T)||q-G<=2*(A-T)?null:{lo:T,hi:A}}function p(v,E,V,G,q){const{min:M,max:O,nulls:T,finite:A}=d(v,E,V);if(!A)return{kind:G,buckets:T&&q.blanks!==!1?[{null:!0,label:"Empty"}]:[],empty:!0};const N=Math.max(1,Math.floor(q.buckets||x));let C=[];if(G==="date"){const F=H.includes(q.granularity)?q.granularity:t(O-M,N);let $=o(M,F);for(;$<=O&&C.length<4096;){const W=u($,F);if(!(W>$))break;C.push({from:$,to:W}),$=W}return{kind:G,buckets:l(C,q.blanks===!1?0:T),granularity:F}}const S=Z.includes(q.strategy)?q.strategy:"equal";if(S==="quantile"){const F=s(v,E,V,U);if(F.length){const $=[F[0]];for(let W=1;W<N;W++){const K=F[Math.min(F.length-1,Math.floor(W/N*F.length))];K>$[$.length-1]&&$.push(K)}$.push(O);for(let W=0;W<$.length-1;W++)C.push({from:$[W],to:$[W+1]})}}else if(S==="log"&&M>0){const F=Math.log10(M),W=(Math.log10(O)-F)/N||1;for(let K=0;K<N;K++)C.push({from:10**(F+K*W),to:10**(F+(K+1)*W)})}if(!C.length&&S==="equal"){const F=f(v,E,V,M,O);if(F){const $=(F.hi-F.lo)/N;F.lo>M&&C.push({from:M,to:F.lo,overflow:"low"});for(let W=0;W<N;W++)C.push({from:F.lo+W*$,to:F.lo+(W+1)*$});C[C.length-1].to=F.hi,F.hi<O&&C.push({from:F.hi,to:O,overflow:"high"})}}if(!C.length){const F=(O-M)/N||1;for(let $=0;$<N;$++)C.push({from:M+$*F,to:M+($+1)*F})}return C[C.length-1].to=O,{kind:G,buckets:l(C,q.blanks===!1?0:T),strategy:S,min:M,max:O}}function l(v,E){return E>0?[...v,{null:!0,label:"Empty"}]:v}function y(v,E,V,G,q){const M=G&&G.buckets||[],O=q&&q.length>=M.length?q.subarray(0,M.length):new Uint32Array(M.length);if(O.fill(0),!v||!M.length)return O;const T=M.length-1,A=!!M[T]&&M[T].null===!0,N=E?E.length:V;if(G.kind==="boolean"){const W=Y(v);for(let K=0;K<N;K++){const I=W(E?E[K]:K);if(I==null){A&&O[T]++;continue}O[I?1:0]++}return O}if(G.kind==="category"){const W=new Map;for(let B=0;B<M.length;B++)!M[B].null&&!M[B].remainder&&W.set(M[B].value,B);const K=M.findIndex(B=>B.remainder),I=Y(v);for(let B=0;B<N;B++){const J=I(E?E[B]:B);if(J==null||J===""){A&&O[T]++;continue}if(Array.isArray(J)){if(!J.length){A&&O[T]++;continue}for(const Q of J){const re=W.get(Q);re!==void 0?O[re]++:K>=0&&O[K]++}continue}const te=W.get(J);te!==void 0?O[te]++:K>=0&&O[K]++}return O}const C=A?M.length-1:M.length,S=new Float64Array(C+1);for(let W=0;W<C;W++)S[W]=M[W].from;S[C]=C?M[C-1].to:0;const F=k(v),$=P(v);for(let W=0;W<N;W++){const K=E?E[W]:W;if($&&!$(K)){A&&O[T]++;continue}const I=F(K);if(!Number.isFinite(I)){A&&O[T]++;continue}const B=c(S,C,I);B>=0&&O[B]++}return O}function c(v,E,V){if(!E||V<v[0])return-1;if(V>=v[E])return V===v[E]?E-1:-1;let G=0,q=E-1;for(;G<q;){const M=G+q+1>>>1;V>=v[M]?G=M:q=M-1}return G}function m(v,E,V,G={}){const q=G.bounds||g(v,G.boundsIndices??E,V,G);return{bounds:q,counts:y(v,E,V,q)}}const w=m}),We("packages/core/src/compute/pivotmatrix.js",function(e,D){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return o}});const P=D("packages/core/src/compute/handle.js").valueComparator,_=D("packages/core/src/compute/total.js").total,Z=D("packages/core/src/compute/group.js").packKeys,H=D("packages/core/src/compute/pivot.js"),x=H.joinPath,X=H.DEFAULT_PATH_SEPARATOR,U=H.DEFAULT_MAX_COLUMNS,j="";function k(u,d,s={}){const g=s.separator||X,i=u||[],n=d instanceof Uint32Array?d:Uint32Array.from(d||[]),f=n.length;if(i.length===0)return{tuples:[[]],paths:[j],buckets:[n]};const{keyOf:p,readers:l}=Z(i,n,0),y=new Map,c=[],m=[],w=[];for(let M=0;M<f;M++){const O=n[M],T=p(O);let A=y.get(T);if(A===void 0){A=c.length,y.set(T,A),m.push(T);const N=new Array(l.length);for(let C=0;C<l.length;C++)N[C]=l[C](O);c.push(N),w.push([])}w[A].push(O)}const v=P(s.locale),E=c.map((M,O)=>O);E.sort((M,O)=>{const T=c[M],A=c[O];for(let N=0;N<T.length;N++){const C=b(T[N],A[N],v);if(C!==0)return C}return M-O});const V=new Array(E.length),G=new Array(E.length),q=new Array(E.length);for(let M=0;M<E.length;M++){const O=E[M];V[M]=c[O],G[M]=x(c[O],g),q[M]=Uint32Array.from(w[O])}return{tuples:V,paths:G,buckets:q}}function b(u,d,s){const g=u==null,i=d==null;return g||i?g&&i?0:g?1:-1:s(u,d)}function a(u,d,s){const g=[];for(let i=0;i<u.length;i++)s.has(u[i])&&g.push(u[i]);return Uint32Array.from(g)}function h(u,d,s,g){return{value:d.length?_(u,d,s,g):null,leaves:d,count:d.length}}function r(u){const d=u&&u.opts||{},s=d.separator||X,g=d.totalContext||{locale:d.locale},i=(u.measures||[]).filter(G=>G&&G.handle),n=u.leaves instanceof Uint32Array?u.leaves:Uint32Array.from(u.leaves||[]),f=k(u.rowHandles||[],n,{...d,separator:s}),p=k(u.columnHandles||[],n,{...d,separator:s}),l=d.maxColumns===void 0?U:d.maxColumns,y=p.paths.length*Math.max(1,i.length),c=new Map;if(l&&y>l)return{rowAxis:f,columnAxis:p,measures:i.map(G=>({colId:G.colId,fn:G.fn})),body:c,rowMargin:c,columnMargin:c,grand:c,columns:y,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${y} columns, above pivot.maxColumns of ${l}. Narrow the pivot columns or raise the limit.`,columns:y,maxColumns:l}};const m=new Map,w=new Map,v=new Map,E=new Map,V=p.buckets.map(G=>new Set(G));for(let G=0;G<p.paths.length;G++){const q=p.buckets[G],M=p.paths[G];for(const O of i)v.set(o(M,O.colId),h(O.handle,q,O.fn,g))}for(let G=0;G<f.paths.length;G++){const q=f.buckets[G],M=f.paths[G];for(const O of i)w.set(o(M,O.colId),h(O.handle,q,O.fn,g));for(let O=0;O<p.paths.length;O++){const T=a(q,p.buckets[O],V[O]);if(T.length===0)continue;const A=p.paths[O];for(const N of i)m.set(t(M,A,N.colId),h(N.handle,T,N.fn,g))}}for(const G of i)E.set(G.colId,h(G.handle,n,G.fn,g));return{rowAxis:f,columnAxis:p,measures:i.map(G=>({colId:G.colId,fn:G.fn})),body:m,rowMargin:w,columnMargin:v,grand:E,columns:y,error:null}}function t(u,d,s){return`${u}\0${d}\0${s}`}function o(u,d){return`${u}\0${d}`}}),We("packages/core/src/compute/reference.js",function(e,D){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return U}}),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 a}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return r}});const P=D("packages/core/src/internal/paths.js").getPath,Y=D("packages/core/src/compute/handle.js"),_=Y.isMissing,L=Y.valueComparator,H=D("packages/core/src/compute/filter.js").testValue,x="",X="\0";function U(u,d){const s=d.includes(".")?P(u,d):u?.[d];return s===void 0?null:s}function j(u,d,s={}){const g=d||[];let i=u.map((n,f)=>f);if(g.length===0)return i;for(let n=g.length-1;n>=0;n--)i=k(u,i,g[n],s);return i}function k(u,d,s,g){const i=s.locale!==void 0?s.locale:g.locale,n=L(i),f=s.descending!==void 0?!!s.descending:s.dir==="desc",p=[],l=[];for(const m of d){const w=U(u[m],s.col);_(w)?l.push(m):p.push(m)}const y=new Map;for(let m=0;m<p.length;m++)y.set(p[m],m);const c=(m,w)=>{const v=U(u[m],s.col),E=U(u[w],s.col);let V;return typeof s.compare=="function"?(V=s.compare(v,E,u[m],u[w],f),f&&(V=-V)):V=f?n(E,v):n(v,E),V!==0?V:y.get(m)-y.get(w)};return p.sort(c),s.nullsFirst?l.concat(p):p.concat(l)}function b(u,d,s={}){const g=[];for(let i=0;i<u.length;i++)a(u[i],d,s,i)&&g.push(i);return g}function a(u,d,s,g){if(!d)return!0;if(Array.isArray(d.conditions)){const i=d.conditions.filter(f=>f!=null);if(i.length===0)return!0;if(d.op==="or")return i.some(f=>a(u,f,s,g));const n=i.every(f=>a(u,f,s,g));return d.op==="not"?!n:n}return d.col===void 0&&typeof s.custom=="function"?!!s.custom(d,u,g):H(U(u,d.col),d,s.locale)}function h(u,d,s,g){const i=s||u.map((l,y)=>y),n=new Map,f=[],p=[];for(const l of i){const y=d.map((w,v)=>{const E=U(u[l],w);return g&&g[v]?g[v](E):E}),c=y.map(w=>w==null?X:String(w)).join(x);let m=n.get(c);m===void 0&&(m=f.length,n.set(c,m),f.push(y),p.push([])),p[m].push(l)}return{keys:f,buckets:p}}function r(u,d,s={}){const g=L(s.locale),i=u.filter(f=>!_(f)),n=i.map(t).filter(f=>f!==null);switch(d){case"count":return u.length;case"countValues":return i.length;case"sum":return n.reduce((f,p)=>f+p,0);case"avg":return i.length===0?null:n.reduce((f,p)=>f+p,0)/i.length;case"min":return i.length===0?null:i.reduce((f,p)=>g(p,f)<0?p:f);case"max":return i.length===0?null:i.reduce((f,p)=>g(p,f)>0?p:f);case"first":return u.length===0?null:o(u[0]);case"last":return u.length===0?null:o(u[u.length-1]);default:return null}}function t(u){if(typeof u=="number")return Number.isNaN(u)?null:u;if(u==null||u===""||typeof u=="boolean")return null;if(u instanceof Date)return u.getTime();const d=Number(u);return Number.isNaN(d)?null:d}function o(u){return u===void 0?null:u}}),We("packages/core/src/compute/index.js",function(e,D){"use strict";const ne=D("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return ne.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return ne.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return ne.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return ne.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return ne.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return ne.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return ne.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return ne.rankSortStrings}});const P=D("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return P.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return P.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return P.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return P.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return P.describeSort}});const Y=D("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return Y.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return Y.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return Y.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return Y.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return Y.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return Y.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return Y.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return Y.mentionsColumn}});const _=D("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return _.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return _.packKeys}});const L=D("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return L.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return L.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return L.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return L.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return L.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return L.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return L.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return L.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return L.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return L.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return L.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return L.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return L.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return L.QUANTILE_SAMPLE}});const Z=D("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const H=D("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return H.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return H.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return H.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return H.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return H.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return H.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return H.DEFAULT_MAX_COLUMNS}});const x=D("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 X=D("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return X.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return X.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return X.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return X.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return X.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return X.referenceValue}});const U=D("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return U.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return U.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return U.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return U.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return U.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return U.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return U.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return U.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return U.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return U.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return U.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return U.isMissing}});const j=D("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 k=D("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return k.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return k.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return k.openWindow}});const b=D("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 a=D("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return a.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return a.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return a.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return a.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return a.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return a.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return a.anomalyCondition}});const h=D("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return h.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return h.forecast}})}),We("packages/core/src/source/rows.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return h}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/internal/predicates.js").isFunction,L=32,Z="\0";function H(r){return new x(r)}class x{#e;#t;constructor(t){this.#e=_(t&&t.rowKey)?t.rowKey:null;const o=t&&t.config?t.config.rowHeight:void 0;this.#t=typeof o=="number"||_(o)?o:L}get keyed(){return this.#e!==null}keyOf(t,o){if(this.#e){const u=this.#e(t);if(u!=null)return String(u)}else P("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${o}`}heightOf(t){return _(this.#t)?Number(this.#t(t))||L:this.#t}leaf(t,o,u=0,d=null){const s={key:this.keyOf(t,o),data:t,level:u,parent:d,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:o};return s.height=this.heightOf(s),s}group(t){const o={key:a(t.keyPath||t.path),data:null,level:t.level,parent:t.parent||null,children:[],group:!0,expanded:t.expanded!==!1,leafCount:t.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:t.column,groupValue:t.value,groupPath:t.path,hasChildren:t.hasChildren!==!1};return t.totals&&(o.totals=t.totals),o.height=this.heightOf(o),o}footer(t){const o={key:`${t.key}${Z}footer`,data:null,level:t.level,parent:t,group:!0,footer:!0,expanded:!1,leafCount:t.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:t.groupColumn,groupValue:t.groupValue,groupPath:t.groupPath,hasChildren:!1,totals:t.totals};return o.height=this.heightOf(o),o}detail(t,o){return{key:`${t.key}${Z}detail`,data:t.data,level:t.level+1,parent:t,group:!1,detail:!0,expanded:!1,leafCount:0,height:o,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:t.key}}grandTotal(t,o){const u={key:`${Z}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:o,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:t};return u.height=this.heightOf(u),u}skeleton(t,o=0,u=!1){const d={key:`${Z}pending${Z}${t}`,data:null,level:o,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:t,selected:!1,physical:null,pending:!0};return u&&(d.loadError=!0),d.height=this.heightOf(d),d}}function X(r,t,o,u){return{key:`${Z}pinned${Z}${o}${Z}${t}`,data:r,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:u,index:null,selected:!1,physical:null,hasChildren:!1,pinned:o}}function U(r,t){return new Proxy([],{get(o,u,d){if(u==="length")return r();if(typeof u=="string"){const s=Number(u);if(Number.isInteger(s)&&s>=0)return t(s)}return Reflect.get(o,u,d)},has(o,u){if(typeof u=="string"){const d=Number(u);if(Number.isInteger(d)&&d>=0)return d<r()}return Reflect.has(o,u)}})}function j(r){return r==null?"":String(r)}const k="";function b(r){if(r==null)return k;const t=String(r);return t.startsWith(k)?k+t:t}function a(r){const t=r||[];let o="g";for(let u=0;u<t.length;u++)o+=Z+b(t[u]);return o}function h(r){const t=new Array(r.length),o=[];for(let u=0;u<r.length;u++)o.push(r[u]),t[u]=a(o);return t}}),We("packages/core/src/source/handles.js",function(e,D){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return Z}});const P=D("packages/core/src/internal/predicates.js").isFunction,_=D("packages/core/src/internal/warn.js").warnOnce;class L{#e;#t;#n;#r=new Map;#s=0;constructor(x,X,U){this.#e=x,this.#t=X,this.#n=P(U)?U:()=>!1}get store(){const x=this.#e.store;return x&&P(x.column)?x:null}invalidate(){this.#s++}handle(x){const X=this.store;if(X){const b=X.column(x);if(b)return b}const U=this.#r.get(x);if(U&&U.builtAt===this.#s)return U.handle;const j=this.#i(x);if(!j)return;if(X&&this.#n()){_(`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 k=this.#o(j);return this.#r.set(x,{handle:k,builtAt:this.#s}),k}#i(x){const X=this.#e.columns;return X&&P(X.get)?X.get(x):void 0}#o(x){const X=this.#t()||[],U=X.length,j=new Array(U),k=P(x.getValue)?a=>x.getValue(a):a=>a?.[x.field||x.id];for(let a=0;a<U;a++)j[a]=X[a]===void 0?void 0:k(X[a]);const b=this.#s;return{id:x.id,kind:"object",nullable:!1,values:j,presence:null,dict:null,offsets:null,get(a){return j[a]},version:b}}}function Z(H,x,X){return new L(H,x,X)}}),We("packages/core/src/compute/incremental.js",function(e,D){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const P=D("packages/core/src/store/columnstore.js").toFloat,Y=Object.freeze(["sum","avg","countValues","min","max"]),_=Object.freeze(["float64"]),L=1e15;function Z(U,j){return typeof U!="string"||!Y.includes(U)?!1:!!j&&_.includes(j.kind)}function H(U){if(U==null)return null;const j=P(U);return Number.isNaN(j)?null:j}class x{#e;#t=0;#n=0;#r=0;#s=1/0;#i=-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 k=0;k<j.length;k++){const b=H(j[k]);b!==null&&this.#c(b)}this.#o=!0}seedColumn(j,k,b){this.#a();for(let a=0;a<b.length;a++){const h=b[a];if(k&&k(h)===0)continue;const r=j[h];Number.isNaN(r)||this.#c(r)}this.#o=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#s=1/0,this.#i=-1/0,this.#l=!1}#c(j){if(!Number.isFinite(j)){this.#l=!0;return}const k=this.#t+j;this.#n+=Math.abs(this.#t)>=Math.abs(j)?this.#t-k+j:j-k+this.#t,this.#t=k,this.#r++,j<this.#s&&(this.#s=j),j>this.#i&&(this.#i=j)}#u(j){const k=this.#t-j;this.#n+=Math.abs(this.#t)>=Math.abs(j)?this.#t-k-j:-j-k+this.#t,this.#t=k,this.#r--}update(j,k){if(!this.#o)return!1;const b=H(j),a=H(k);return b===null&&a===null?!0:b!==null&&!Number.isFinite(b)||a!==null&&!Number.isFinite(a)?!1:this.#e==="min"||this.#e==="max"?b===null||a===null?!1:this.#e==="min"?a<this.#s?(this.#s=a,!0):b>this.#s:a>this.#i?(this.#i=a,!0):b<this.#i:Math.abs(this.#t)>L?!1:(b!==null&&this.#u(b),a!==null&&this.#c(a),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#s:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#o=!1}}const X=x}),We("packages/core/src/source/filterwire.js",function(e,D){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return v}});const P=D("packages/core/src/internal/warn.js").warnOnce,Y="source.remote.hostFilter",_="source.where.pageRelative";function L(G,q){!Array.isArray(G)||!G.length||P(_,`filters.where (${G.join(", ")}) runs over the rows the ${q} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function Z(G){const q=(G||{}).config;!q||!q.hostFilter||P(Y,"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 H="source.where.notApplied";function x(G,q){P(`${H}:${G}`,`filters.where("${G}") is registered but the ${q} 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 X="source.where.overThreshold";function U(G,q,M,O){!Array.isArray(G)||!G.length||P(`${X}:${q}`,`filters.where (${G.join(", ")}) is not applied to the ${q} pushdown source:`,M===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${M.toLocaleString()} rows, at or past the whereRowLimit of ${O.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 k(G){let q=j.get(G);return q||(q=new Intl.DateTimeFormat("en-US",{timeZone:G,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),j.set(G,q)),q}function b(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function a(G,q){const M=k(q).formatToParts(new Date(G)),O={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const T of M)T.type==="year"?O.y=+T.value:T.type==="month"?O.m=+T.value:T.type==="day"?O.d=+T.value:T.type==="hour"?O.h=+T.value%24:T.type==="minute"?O.mi=+T.value:T.type==="second"&&(O.s=+T.value);return O}function h(G,q){const M=a(G,q);return Date.UTC(M.y,M.m-1,M.d,M.h,M.mi,M.s)-Math.floor(G/1e3)*1e3}function r(G,q,M,O){const T=Date.UTC(G,q-1,M),A=T-h(T,O);return T-h(A,O)}function t(G,q,M){const O=new Date(Date.UTC(G.y,G.m-1,G.d+q));return r(O.getUTCFullYear(),O.getUTCMonth()+1,O.getUTCDate(),M)}const o=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function u(G,q){if(typeof G!="string")return null;const M=G.trim().toLowerCase().replace(/[\s_-]+/g,""),O=/^last(\d*|n)days?$/.exec(M);if(O){const T=O[1]==="n"?"":O[1],A=Number(T||q);return!Number.isFinite(A)||A<=0?null:{kind:"lastNDays",n:Math.floor(A)}}switch(M){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 d(G,q={}){const M=u(G,q.n);if(!M)return null;const O=q.tz||b(),T=q.now instanceof Date?q.now.getTime():typeof q.now=="number"?q.now:Date.now(),A=a(T,O),N=r(A.y,A.m,A.d,O),C=t(A,1,O);let S=N,F=C;switch(M.kind){case"today":break;case"yesterday":S=t(A,-1,O),F=N;break;case"lastNDays":F=q.includeToday?C:N,S=t(A,q.includeToday?-(M.n-1):-M.n,O);break;case"thisWeek":{const $=Number.isFinite(q.weekStartsOn)?Number(q.weekStartsOn):1,K=(new Date(Date.UTC(A.y,A.m-1,A.d)).getUTCDay()-$+7)%7;S=t(A,-K,O),F=t(A,-K+7,O);break}case"thisMonth":S=r(A.y,A.m,1,O),F=r(A.m===12?A.y+1:A.y,A.m===12?1:A.m+1,1,O);break;case"thisQuarter":case"quarterToDate":{const $=Math.floor((A.m-1)/3)*3+1;S=r(A.y,$,1,O),F=M.kind==="quarterToDate"?C:$===10?r(A.y+1,1,1,O):r(A.y,$+3,1,O);break}case"thisYear":case"yearToDate":S=r(A.y,1,1,O),F=M.kind==="yearToDate"?C:r(A.y+1,1,1,O);break;default:return null}return{from:new Date(S).toISOString(),to:new Date(F).toISOString(),bounds:"[)",tz:O,relative:M.kind==="lastNDays"?`last${M.n}Days`:M.kind,n:M.n}}function s(G){if(!G||typeof G!="object")return null;const q=G.value;if(q&&typeof q=="object"&&!Array.isArray(q)&&"relative"in q)return{token:String(q.relative),n:typeof q.n=="number"?q.n:void 0};if(G.op==="relative"&&typeof G.value=="string")return{token:G.value,n:void 0};const M=G.meta;return M&&typeof M.relative=="string"&&G.value===void 0?{token:M.relative,n:typeof M.n=="number"?M.n:void 0}:null}function g(){return`Known tokens: ${o.filter(q=>q!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function i(G){const q=s(G);return q?u(q.token,q.n)!==null:!1}function n(G,q={}){const M=s(G);if(!M)return G;const O=d(M.token,{...q,n:M.n});return O?{...G,type:G.type||"date",op:"between",value:[O.from,O.to],bounds:G.bounds||O.bounds,meta:{...G.meta||{},relative:O.relative,tz:O.tz}}:(P(`source.relative.${M.token}`,`unknown relative date token "${M.token}"; sending the condition unresolved.`,g()),G)}function f(G){return!!G&&typeof G=="object"&&Array.isArray(G.conditions)}function p(G,q){if(G){if(f(G)){for(const M of G.conditions)p(M,q);return}q(G)}}function l(G,q){if(!G)return null;if(!f(G))return q(G);const M=G;let O=!1;const T=[];for(const A of M.conditions){const N=l(A,q);N!==A&&(O=!0),N&&T.push(N)}return!O&&T.length===M.conditions.length?G:T.length?{...M,conditions:T}:null}function y(G){if(!G)return null;if(!f(G))return G;const q=G,M=[];for(const O of q.conditions){const T=y(O);T&&M.push(T)}return M.length?{op:q.op,conditions:M}:null}function c(G){const q=y(G);return q?f(q)&&q.op==="and"?q:{op:"and",conditions:[q]}:null}function m(G){const q=(G||[]).filter(Boolean);return q.length?{op:"and",conditions:q}:null}function w(G,q={}){const M=l(G,O=>n(O,q));return c(M)}function v(G){const q=E(G.filters??null);return JSON.stringify([q,G.sort??null,G.quick??"",G.groupBy??null,G.pivotBy??null,V(G.context)])}function E(G){if(!G)return null;if(f(G)){const O=G;return{op:O.op,conditions:O.conditions.map(E)}}const q=G,M=q.meta&&typeof q.meta.relative=="string"?q.meta.relative:s(q)?.token;return{col:q.col,op:q.op,bounds:q.bounds??null,caseSensitive:q.caseSensitive??!1,value:M?`rel:${M}`:q.value??null}}function V(G){if(G==null)return null;try{return JSON.parse(JSON.stringify(G))}catch{return P("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),We("packages/core/src/source/tree.js",function(e,D){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return a}});const P=D("packages/core/src/internal/predicates.js").isFunction,_=D("packages/core/src/internal/warn.js").warnOnce,L="",Z="\0tree:";function H(h,r){return{physical:h,key:r,level:0,children:[],value:void 0}}function x(h,r){const t=[],o=new Map;for(let u=0;u<h.length;u++){const d=h[u],s=r.pathOf(d),g=Array.isArray(s)?s.map(n=>String(n)):[];if(!g.length){const n=H(d,r.keyOf(d));t.push(n);continue}let i=null;for(let n=0;n<g.length;n++){const f=g.slice(0,n+1).join(L),p=n===g.length-1;let l=o.get(f);l&&p&&l.physical===-1&&(l.physical=d,l.key=r.keyOf(d)),l||(l=H(p?d:-1,p?r.keyOf(d):Z+f),l.level=n,l.value=g[n],o.set(f,l),i?i.children.push(l):t.push(l)),i=l}}return{roots:t,nodes:o}}function X(h,r){const t=new Map,o=[];for(let g=0;g<h.length;g++){const i=h[g],n=r.keyOf(i),f=H(i,n);t.set(n,f);const p=r.parentOf(i);p!=null&&p!==""&&o.push({node:f,parent:String(p)})}let u=null;const d=new Map;for(const{node:g,parent:i}of o){const n=t.get(i);if(n){d.set(g.key,n);continue}r.orphans&&r.orphans!=="root"&&(u||(u=H(-1,`${Z}orphans`),u.value=r.orphans),d.set(g.key,u))}const s=[];for(const g of t.values()){const i=d.get(g.key);i?i.children.push(g):s.push(g)}return u&&u.children.length&&s.push(u),{roots:U(s,t,r.orphans,u),nodes:t}}function U(h,r,t,o){const u=new Set,d=[...h];for(;d.length;){const f=d.pop();if(!u.has(f.key)){u.add(f.key);for(const p of f.children)d.push(p)}}const s=[];for(const f of r.values())u.has(f.key)||s.push(f);if(!s.length)return h;const g=!!t&&t!=="root";_("tree.cycle",`tree.parentKey produced ${s.length} row(s) inside a parent cycle; `+(g?`they are shown under "${t}".`:"they are shown at the root."));for(const f of s)f.children=f.children.filter(p=>u.has(p.key));if(!g)return[...h,...s];let i=o;const n=[...h];return i||(i=H(-1,`${Z}orphans`),i.value=t,n.push(i)),i.children.push(...s),n}function j(h){let r=0;const t=(o,u)=>{for(const d of o)d.level=u,u>r&&(r=u),d.children.length&&t(d.children,u+1)};return t(h,0),r}function k(h,r){if(!h||typeof h!="object")return null;const t=h.path,o=h.parentKey,u=P(h.hasChildren)?d=>!!h.hasChildren(r.dataAt(d)):null;if(P(t))return{mode:"path",pathOf:d=>t(r.dataAt(d)),keyOf:r.keyOf,declaresChildren:u};if(o!=null){const d=P(o)?o:s=>s?.[o];return{mode:"parentKey",parentOf:s=>d(r.dataAt(s)),keyOf:r.keyOf,orphans:h.orphans||"root",declaresChildren:u}}return _("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function b(h,r){const t=r.mode==="path"?x(h,r):X(h,r),o=j(t.roots);return{...t,depth:o}}function a(h,r){const t=new Map,o=u=>{for(let d=0;d<u.length;d++){const s=u[d];if(s.physical>=0){const g=r?r(s.physical):!1,i=g&&s.children.length===0;t.set(s.physical,{level:s.level,posinset:d+1,setsize:u.length,hasChildren:s.children.length>0||g,lazy:i})}s.children.length&&o(s.children)}};return o(h),t}}),We("packages/core/src/source/settle.js",function(e,D){"use strict";Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return P}});const ne=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function P(Y){const _=Y&&typeof Y=="object"?Y.reason:null;return typeof _=="string"&&ne.includes(_)}}),We("packages/core/src/source/memory.js",function(e,D){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return K}});const P=D("packages/core/src/internal/lru.js").Lru,Y=D("packages/core/src/internal/warn.js"),_=Y.warnOnce,L=Y.fail,H=D("packages/core/src/internal/predicates.js").isFunction,X=D("packages/core/src/internal/compare.js").defaultCompare,j=D("packages/core/src/internal/merge.js").mergeRow,k=D("packages/core/src/source/rows.js"),b=k.createRowFactory,a=k.groupKey,h=k.groupPathElement,r=k.groupPrefixKeys,t=k.lazyRowView,u=D("packages/core/src/source/handles.js").createHandleProvider,d=D("packages/core/src/compute/incremental.js"),s=d.RunningTotal,g=d.isIncremental,n=D("packages/core/src/compute/handle.js").presenceReader,f=D("packages/core/src/source/filterwire.js"),p=f.querySignature,l=f.mapConditions,y=f.resolveRelativeCondition,c=D("packages/core/src/source/tree.js"),m=c.buildTree,w=c.resolveTree,v=c.indexTree,E=D("packages/core/src/source/settle.js"),V=E.PIPELINE_SETTLE_REASONS,G=E.isPipelineSettle,q=Object.freeze(["filter","sort","group","total","pivot","flatten"]),M=Object.freeze([]);function O(I,B){if(!I)return null;const J=B==="grand"?I.grandTotal:I.groupTotal;return J??I.total}function T(I){return!!I&&!I.running}function A(I){if(I)return I.value&&H(I.value.compare)?I.value.compare:H(I.compare)?I.compare:void 0}function N(I){const B=I&&I.dataType;return!B||!H(B.items)?null:{items:B.items,type:I.itemType&&I.itemType.name||"text"}}function C(I){return!!I&&(typeof I=="object"||typeof I=="function")&&H(I.then)}const S=new Uint32Array(0),F=4096;function $(I,B){return new K(I,B)}function W(I,B){if(B==="regex")try{const J=new RegExp(I,"iu");return te=>J.test(te)}catch{return J=>J.includes(I)}if(B==="fuzzy"){const J=[...I].filter(te=>te!==" ");return J.length?te=>{let Q=0;for(let re=0;re<te.length&&Q<J.length;re++)te[re]===J[Q]&&Q++;return Q===J.length}:()=>!0}if(B==="words"){const J=I.split(/\s+/).filter(Boolean);return J.length?te=>J.every(Q=>te.includes(Q)):()=>!0}return J=>J.includes(I)}class K{mode="memory";#e;#t;#n;#r=!1;#s=null;#i;#o;#l=new Map;#a=!1;#c=0;#u=0;#d=new Map;#f=new Map;#h;#p=null;#m=K.#g();static#g(){return{slots:[],groupHeadings:M,unnumbered:M,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#b=new Map;#y=null;#O=new Map;#w=-1;#A=[];#v=new Map;#P=-1;#S=[];#C=null;#E=null;#T=null;#M=null;#N=null;#R=null;#D=null;#W=null;#V=Symbol("unset");#x=new Map;#q=null;get#B(){return this.#m.slots}set#B(B){this.#m.slots=B}get#Y(){return this.#m.inlineLeaves}set#Y(B){this.#m.inlineLeaves=B}get#G(){return this.#m.groupHeadings}set#G(B){this.#m.groupHeadings=B}get#I(){return this.#m.unnumbered}set#I(B){this.#m.unnumbered=B}get#H(){return this.#m.pivot}set#H(B){this.#m.pivot=B}constructor(B,J){this.#t=B||{mode:"memory"},this.#e=J||{};const te=this.#e.config||{};this.#n=this.#t.rows||te.rows||[],this.#i=b(this.#e),this.#o=u(this.#e,()=>this.#n,()=>this.#r),this.#h=new P(Number(te.rowCacheSize)||F);for(const Q of q)this.#l.set(Q,{key:null,result:null,id:0,computed:!1})}count(){this.#U();const B=this.#be();return B?B.length:this.#B.length}#be(){const B=Number(this.#K("pageSize",0))||0;if(B<=0)return null;const J=this.#B.length,te=Math.max(1,Math.ceil(J/B)),re=Math.min(Math.max(0,Number(this.#K("page",0))||0),te-1)*B;return{offset:re,length:Math.max(0,Math.min(B,J-re))}}pageInfo(){this.#U();const B=Number(this.#K("pageSize",0))||0,J=this.#B.length;if(B<=0)return{page:0,pageSize:0,total:J,pageCount:1};const te=Math.max(1,Math.ceil(J/B));return{page:Math.min(Math.max(0,Number(this.#K("page",0))||0),te-1),pageSize:B,total:J,pageCount:te}}totalCount(){return this.#Ke().length}matchCount(){return this.#U(),this.#m.matchCount}at(B){this.#U();const J=this.#be();if(J)return B<0||B>=J.length?void 0:this.#ft(J.offset+B,B);if(!(B<0||B>=this.#B.length))return this.#ft(B,B)}byKey(B){this.#U(),this.#p||this.#se();const J=this.#p.get(B);if(J!==void 0)return this.#le(J);for(let te=0;te<this.#B.length;te++){const Q=this.#B[te];if(typeof Q!="number"&&Q&&Q.key===B)return this.#ft(te)}}loaded(B){return B>=0&&B<this.count()}hint(B,J){}display(){return this.#U(),this.#q||(this.#q=this.#$e()),this.#q}invalidateQuickText(){this.#x.clear(),this.invalidate("filter")}invalidate(B){const J=q.indexOf(B);J<0&&L(`unknown pipeline stage "${B}"; expected one of ${q.join(", ")}`);for(let te=J;te<q.length;te++){const Q=this.#l.get(q[te]);Q.key=null,Q.computed=!1}this.#q=null}apply(B){const J=[],te={added:[],updated:[],removed:[],rejected:J};if(!B)return te;let Q=!1;const re=new Set;if(B.remove&&B.remove.length)for(const ie of B.remove){const ue=this.#_e(ie);if(ue===void 0){J.push({operation:"remove",id:this.#he(ie),reason:"unknown-id"});continue}te.removed.push(this.#i.keyOf(this.#r?this.#j(ue):this.#n[ue],ue)),this.#r||(this.#n[ue]=void 0),this.#h.delete(ue),this.#x.delete(ue),Q=!0}if(B.update&&B.update.length){const ie=this.#O.size||this.#kt()?this.#De():null,ue=this.#v.size?this.#et():null,ke=ue&&ue.length?this.#De():null;for(const de of B.update){const we=this.#_e(de);if(we===void 0){J.push({operation:"update",id:this.#Re(de),reason:"unknown-id"});continue}const ve=this.#r?this.#s&&this.#s.has(we)?this.#s.get(we):this.#j(we):this.#n[we],De=j(ve,de);for(const pe of this.#xe(ve,De))re.add(pe);if(this.#r||(this.#n[we]=De),ie&&this.#Qe(ie,we,ve,De),ke&&this.#wt(ue,ke,we,ve,De),this.#p){const pe=this.#i.keyOf(ve,we),oe=this.#i.keyOf(De,we);pe!==oe&&(this.#p.delete(pe),this.#p.set(oe,we))}this.#h.delete(we),this.#x.delete(we),te.updated.push(this.#le(we))}}if(B.add&&B.add.length&&this.#r){typeof B.at=="number"&&B.at<this.#dt()&&(this.#h.clear(),this.#x.clear()),this.#p=null;for(const ie of B.add){const ue=this.#Pe(this.#Re(ie));ue!==void 0&&te.added.push(this.#le(ue))}Q=!0}else if(B.add&&B.add.length){let ie=typeof B.at=="number"?B.at:this.#n.length;if(ie<this.#n.length){let de=0;for(let we=0;we<this.#n.length;we++)this.#n[we]!==void 0&&de++;if(de!==this.#n.length){let we=0;for(let ve=0;ve<this.#n.length;ve++)this.#n[ve]!==void 0&&(this.#n[we++]=this.#n[ve]);this.#n.length=we,this.#p=null,this.#h.clear(),this.#x.clear()}}const ue=this.#n.length;ie=Math.max(0,ie);let ke=B.add===this.#n?B.add.slice():B.add;if(this.#i.keyed){const de=[];for(const we of ke){const ve=this.#Re(we);if(this.#_e(ve)!==void 0){J.push({operation:"add",id:ve,reason:"duplicate-id"});continue}de.push(we)}de.length!==ke.length&&(ke=de)}if(!ke.length)return te;if(ie>=ue)for(let de=0;de<ke.length;de++)this.#n.push(ke[de]);else this.#n.splice(ie,0,...ke),this.#h.clear(),this.#x.clear();for(let de=0;de<ke.length;de++)te.added.push(this.#le(ie>=ue?ue+de:ie+de));Q=!0}return this.#c++,Q&&(this.#p=null,this.#rt()),this.#o.invalidate(),this.#q=null,Q||this.#z(re)?(this.#u++,this.invalidate("filter")):this.invalidate("total"),this.#gt("rows:changed",{companion:!0,added:te.added.length,updated:te.updated.length,removed:te.removed.length}),this.#s=null,te}groupHeadingsAt(B){this.#U();const J=this.#G;if(!J.length||!Number.isInteger(B)||B<0)return M;let te=0,Q=J.length-1,re=-1;for(;te<=Q;){const ue=te+Q>>1;J[ue].at<=B?(re=ue,te=ue+1):Q=ue-1}if(re<0)return M;const ie=[];for(let ue=J[re].row;ue;ue=ue.parent)ie.push(ue);return ie.reverse(),ie}unnumberedRowCount(B){this.#U();const J=this.#I;if(!J.length||!Number.isInteger(B)||B<0)return 0;let te=0,Q=J.length-1,re=-1;for(;te<=Q;){const ie=te+Q>>1;J[ie].at<=B?(re=ie,te=ie+1):Q=ie-1}return re+1}moveRow(B,J){if(this.#r)return _("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 te=this.#n;if(!Number.isInteger(B)||!Number.isInteger(J))return!1;let Q=0;for(let ue=0;ue<te.length;ue++)te[ue]!==void 0&&Q++;if(B<0||B>=Q)return!1;const re=Math.max(0,Math.min(Q-1,J));if(re===B)return!1;if(Q!==te.length){let ue=0;for(let ke=0;ke<te.length;ke++)te[ke]!==void 0&&(te[ue++]=te[ke]);te.length=ue}const[ie]=te.splice(B,1);return te.splice(re,0,ie),this.#c++,this.#u++,this.#p=null,this.#h.clear(),this.#x.clear(),this.#rt(),this.#o.invalidate(),this.#q=null,this.invalidate("filter"),this.#gt("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(B){this.#ce(),this.#c++,this.#u++,this.#p=null,this.#x.clear(),this.#h.clear(),this.#rt(),this.#o.invalidate(),this.invalidate("filter"),this.#gt("model:changed",{reason:"reload"})}destroy(){this.#ce(),this.#h.clear(),this.#x.clear(),this.#p=null,this.#B=[],this.#Y=null,this.#q=null,this.#rt();for(const B of q)this.#l.set(B,{key:null,result:null,id:0,computed:!1})}#ce(){for(const{controller:B}of this.#b.values())try{B.abort()}catch{}this.#b.clear()}setRows(B){this.#n=B||[],this.#r=!1,this.#c++,this.#u++,this.#p=null,this.#x.clear(),this.#h.clear(),this.#rt(),this.#o.invalidate(),this.invalidate("filter")}notePriorRows(B){this.#s=B||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 B=this.#e.store;if(!B||!H(B.source))return this.#n;const J=B.physical||0,te=new Array(J);for(let Q=0;Q<J;Q++)te[Q]=B.live&&!B.live(Q)?void 0:B.source(Q);return te}#de(){const B=this.#K("detail",null);return!B||!H(B.isOpen)||B.inline===!1?null:B}#Me(){const B=(this.#e.config||{}).tree;return this.#V!==B&&(this.#V=B,this.#W=w(B,{dataAt:J=>this.#j(J),keyOf:J=>this.#i.keyOf(this.#j(J),J)})),this.#W}#re(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#re())return null;this.#U();const B=this.#m.grand;return B?this.#i.grandTotal(B,this.#nt(this.#m.grandLeaves)):null}pivot(){return this.#U(),this.#H}pivotMatrix(){this.#U();const B=this.#m.groupLeaves,J=(this.#e.compute||{}).pivotMatrix;if(!H(J))return null;const te=this.#K("groupBy",[]),Q=this.#K("pivotBy",[]);if(!te.length&&!Q.length)return _("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 re=this.#De().map(ue=>({colId:ue.id,handle:this.#o.handle(ue.id),fn:O(ue,"group")})).filter(ue=>ue.handle&&ue.fn),ie=this.#e.config||{};return J({rowHandles:te.map(ue=>this.#o.handle(ue)).filter(Boolean),columnHandles:Q.map(ue=>this.#o.handle(ue)).filter(Boolean),measures:re,leaves:B||new Uint32Array(0),opts:{locale:ie.locale,separator:(ie.pivot||{}).separator,maxColumns:(ie.pivot||{}).maxColumns}})}keysForLeaves(B){const J=[];if(!B)return J;for(let te=0;te<B.length;te++){const Q=this.#le(B[te]);Q&&Q.key!=null&&J.push(String(Q.key))}return J}leavesOf(B){this.#U();const J=this.#l.get("group"),te=J&&J.result;if(!te||!te.nodes)return[];const Q=te.nodes.get(B);if(!Q)return[];const re=[],ie=ue=>{const ke=ue.row&&ue.row.children;if(ke&&ke.length){for(const de of ke){const we=te.nodes.get(de.key);we&&ie(we)}return}if(ue.leaves)for(let de=0;de<ue.leaves.length;de++)re.push(this.#le(ue.leaves[de]))};return ie(Q),re}#he(B){return typeof B=="string"?B:this.#Re(B)}#Re(B){try{return this.#i.keyOf(B,-1)}catch{return"(unkeyed)"}}#_e(B){if(typeof B=="string")return this.#Pe(B);if(this.#i.keyed){const te=this.#i.keyOf(B,-1),Q=this.#Pe(te);if(Q!==void 0)return Q}if(this.#r)return;const J=this.#n.indexOf(B);return J>=0?J:void 0}#Pe(B){return this.#p||this.#se(),this.#p.get(B)}#se(){this.#p=new Map;const B=this.#dt(),J=this.#e.store,te=J&&H(J.live)?Q=>J.live(Q):null;for(let Q=0;Q<B;Q++){if(te&&!te(Q))continue;const re=this.#j(Q);re!==void 0&&this.#p.set(this.#i.keyOf(re,Q),Q)}}#xe(B,J){const te=[];for(const Q of this.#Z())this.#He(Q)&&this.#oe(Q,B,J,new Set)&&te.push(Q);return te}#oe(B,J,te,Q){if(Q.has(B))return!1;Q.add(B);const re=this.#He(B);if(!re)return!1;const ie=re.value&&re.value.deps;return Array.isArray(ie)&&ie.length?ie.some(ue=>this.#oe(String(ue),J,te,Q)):H(re.getValue)?!Object.is(re.getValue(J),re.getValue(te)):!1}#Z(){const B=new Set;for(const te of this.#K("sort",[]))B.add(te.col);for(const te of this.#K("groupBy",[]))B.add(te);const J=te=>{if(te){if(Array.isArray(te.conditions)){te.conditions.forEach(J);return}te.col&&B.add(te.col)}};return J(this.#K("filters",null)),[...B]}#z(B){if(!B.size)return!1;if(this.#K("quick",""))return!0;for(const J of this.#Z())if(B.has(J))return!0;return!1}#U(){if(!this.#a){this.#a=!0;try{this.#J()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#J(){const B=this.#te("filter",()=>this.#fe(),()=>this.#je()),J=this.#Ee(B),te=this.#te("group",()=>this.#ae(),()=>this.#k(J)),Q=this.#te("total",()=>this.#F(),()=>this.#Ve(te));this.#te("pivot",()=>this.#we(),()=>this.#Ot(te)),this.#te("flatten",()=>this.#ie(),()=>this.#qe(te)),this.#Ae(te,Q)}#Ee(B){const J=this.#l.get("sort"),te=this.#$();if(J.computed&&J.key===te&&!this.#b.has("sort"))return J.result;const Q=this.#b.get("sort");return Q&&Q.key===te?J.result:J.result&&this.#ve(B)?(this.#ke(B,te),J.result):this.#te("sort",()=>te,()=>this.#Ue(B))}#ee(){if(this.#y===null){const B=this.#e.pipelineWorker,J=H(B)?B():null;this.#y=J||!1}return this.#y||null}#pe(){const B=this.#K("sort",[]);if(!Array.isArray(B)||!B.length)return null;const J=(this.#e.config||{}).locale,te=[],Q=[];for(const re of B){const ie=this.#He(re.col);if(ie&&ie.running)continue;if(ie&&ie.value&&H(ie.value.compare))return null;const ue=this.#o.handle(re.col);if(!ue)return null;te.push({col:re.col,descending:re.dir==="desc",nullsFirst:!!re.nullsFirst,locale:J}),Q.push(ue)}return te.length?{entries:te,handles:Q,locale:J}:null}#ve(B){if(this.#_())return!1;const J=this.#ee();if(!J)return!1;const te=Number(J.threshold);return Number.isFinite(te)&&B.length<te?!1:!!this.#pe()}#ke(B,J){const te=this.#ee(),Q=te&&this.#pe();if(!Q){this.#te("sort",()=>J,()=>this.#Ue(B));return}const re=new AbortController;this.#b.set("sort",{key:J,controller:re});const ie=Q.entries.length===1?te.sortColumn(Q.handles[0],B,{descending:Q.entries[0].descending,nullsFirst:Q.entries[0].nullsFirst,locale:Q.locale,signal:re.signal,key:"sort"}):te.sortMulti(Q.handles,Q.entries.map((ue,ke)=>({...ue,handle:Q.handles[ke]})),B,{signal:re.signal,key:"sort"});if(!C(ie)){this.#b.delete("sort"),this.#te("sort",()=>J,()=>ie);return}ie.then(ue=>this.#Te(J,ue),ue=>this.#ye("sort",J,ue))}#Te(B,J){const te=this.#b.get("sort");if(!(!te||te.key!==B)){if(this.#$()!==B){this.#b.delete("sort");return}this.#b.delete("sort"),this.#te("sort",()=>B,()=>J),this.#q=null,this.#U(),this.#gt("model:changed",{reason:V[0]})}}#ye(B,J,te){const Q=this.#b.get(B);if(!(!Q||Q.key!==J)&&(this.#b.delete(B),!(te&&te.name==="AbortError")&&B==="sort"&&this.#$()===J)){const re=this.#te("filter",()=>this.#fe(),()=>this.#je());this.#te("sort",()=>J,()=>this.#Ue(re)),this.#q=null,this.#U(),_("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",te),this.#gt("model:changed",{reason:V[1]})}}#Ae(B,J){const te=B&&B.leaves?B.leaves.length:this.#m.slots.length;this.#m.matchCount=te,this.#m.grand=J&&J.grand||null,this.#m.grandLeaves=B&&B.leaves?B.leaves.length:0,this.#m.groupLeaves=B&&B.leaves?B.leaves:null}#te(B,J,te){const Q=this.#l.get(B),re=J();return Q.computed&&Q.key===re||(Q.result=te(),Q.key=re,Q.computed=!0,Q.id++,B==="flatten"&&(this.#q=null)),Q.result}#me(B){return this.#l.get(B).id}#fe(){const B=(this.#e.config||{}).hostFilter,J=B&&H(B.active)&&B.active()?1:0,te=this.#K("where",null),Q=te?te.version:0,re=this.#Et("filter.sig",`${this.#pt()}`,()=>p({filters:this.#K("filters",null),quick:this.#K("quick",""),quickMode:this.#K("quickMode","contains")}));return`${this.#u}|${re}|${J}|${Q}`}#$(){const B=this.#_();return`${this.#me("filter")}|${JSON.stringify(this.#K("sort",[]))}`+(B?`|manual:${B.version}`:"")}#_(){const B=this.#K("rowOrder",null);return B&&Array.isArray(B.keys)?B:null}#ue(B,J){this.#p||this.#se();const te=this.#p,Q=this.#dt(),re=J.keys.length,ie=new Float64Array(Q);for(let ue=0;ue<Q;ue++)ie[ue]=re+ue;for(let ue=0;ue<re;ue++){const ke=te.get(J.keys[ue]);ke!==void 0&&(ie[ke]=ue)}return Uint32Array.from(B).sort((ue,ke)=>ie[ue]-ie[ke])}orderedKeys(){this.#p||this.#se();const B=this.#p,J=new Map;for(const[ue,ke]of B)J.set(ke,ue);const te=Uint32Array.from([...J.keys()]).sort(),Q=this.#_(),re=Q?this.#ue(te,Q):this.#Ue(te),ie=new Array(re.length);for(let ue=0;ue<re.length;ue++)ie[ue]=J.get(re[ue]);return ie}#ae(){const B=this.#K("pivotBy",[]).length>0?"p":"u";return`${this.#me("sort")}|${JSON.stringify(this.#K("groupBy",[]))}|${B}`}#F(){const B=this.#at()?"f":"a",J=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#me("group")}|${JSON.stringify(this.#K("totals",[]))}|${B}${J}|${this.#c}`}#we(){return`${this.#me("group")}|${JSON.stringify(this.#K("pivotBy",[]))}`}#ie(){const J=this.#We()||!this.#re()?this.#me("total"):"x",te=`${this.#pt()}`,Q=this.#Et("flatten.keys",te,()=>{const ie=this.#K("expanded",null);return ie?[...ie].sort().join(""):"*"}),re=this.#Et("flatten.detail",te,()=>{const ie=this.#K("detail",null);return ie&&H(ie.signature)?ie.signature():""});return`${J}|${this.#me("pivot")}|${Q}|${re}`}#We(){const B=this.#K("groupBy",[]);return Array.isArray(B)&&B.length>0}stageState(){const B=[];for(const[J,te]of this.#l){const Q=te.result;B.push({stage:J,materialised:!!te.computed,bytes:Q&&typeof Q.byteLength=="number"?Q.byteLength:null,rows:Q&&typeof Q.length=="number"?Q.length:null,rebuilds:te.id})}return B}facetIndices(B){return this.#je(B||null)}facetRows(B){const J=this.facetIndices(B),te=[];for(let Q=0;Q<J.length;Q++){const re=this.#le(J[Q]);re&&te.push(re)}return te}invalidateRows(){this.#h.clear(),this.#x.clear(),this.#q=null}invalidateHandles(){this.#o.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Ke()}filteredIndices(){const B=this.#l.get("filter");if(B&&B.computed&&B.key===this.#fe())return B.result||this.#Ke();this.#U();const J=this.#l.get("filter");return(J&&J.computed?J.result:null)||this.#Ke()}unfilteredRows(){const B=this.#Ke(),J=[];for(let te=0;te<B.length;te++){const Q=this.#le(B[te]);Q&&J.push(Q)}return J}#je(B=null){const J=this.#Ke(),te=this.#K("filters",null),Q=B?this.#Ye("pruneColumn")(te,B):te,re=this.#lt(Q),ie=String(this.#K("quick","")||"").trim().toLowerCase(),ue=ie?W(ie,String(this.#K("quickMode","contains")||"contains")):null,ke=(this.#e.config||{}).hostFilter,de=!!(ke&&H(ke.active)&&ke.active()),we=this.#K("where",null),ve=!!(we&&we.active);if(!re&&!ie&&!de&&!ve)return J;let De=null;re&&(De=this.#Ye("evaluateFilters")(re,{handle:fe=>this.#o.handle(fe),count:this.#dt(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:fe=>N(this.#He(fe))}));const pe=new Uint32Array(J.length);let oe=0;for(let be=0;be<J.length;be++){const fe=J[be];if(!(De&&!De[fe])&&!(ue&&!this.#Ce(fe,ue))){if(de||ve){const le=this.#le(fe);if(de&&!ke.passes(le)||ve&&!we.passes(le.data,le.key))continue}pe[oe++]=fe}}if(De){const be=(this.#e.compute||{}).releaseMask;H(be)&&be({pool:this.#e.pool},De)}return pe.subarray(0,oe)}handleFor(B){return this.#o.handle(B)}#Ue(B){const J=this.#_();if(J)return this.#ue(B,J);const te=this.#K("sort",[]).filter(ie=>{const ue=this.#He(ie.col);return!ue||!ue.running?!0:(_(`source.sort.running.${ie.col}`,`sort ignores "${ie.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!te.length)return B;const Q=(this.#e.config||{}).locale;if(te.length===1){const ie=te[0],ue=this.#o.handle(ie.col);if(!ue)return _(`source.sort.${ie.col}`,`sort ignores unknown column "${ie.col}".`),B;const ke=this.#He(ie.col);return this.#Ye("sortColumn")(ue,B,{descending:ie.dir==="desc",nullsFirst:ie.nullsFirst,locale:Q,compare:A(ke)})}const re=[];for(const ie of te){const ue=this.#o.handle(ie.col);if(!ue){_(`source.sort.${ie.col}`,`sort ignores unknown column "${ie.col}".`);continue}re.push({handle:ue,descending:ie.dir==="desc",nullsFirst:ie.nullsFirst,locale:Q,compare:A(this.#He(ie.col))})}return re.length?this.#Ye("sortMulti")(re.map(ie=>ie.handle),re,B):B}#k(B){const J=this.#K("groupBy",[]),te=this.#Me();if(te&&!J.length){const be=m(B,te);return this.#R=v(be.roots,te.declaresChildren),{roots:null,leaves:B,nodes:new Map,tree:be}}if(this.#R=null,te&&J.length&&_("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:B,nodes:new Map};const Q=(this.#e.config||{}).timeZone,re=[],ie=[];let ue=!1;for(const be of J){const fe=this.#o.handle(be);if(!fe){_(`source.group.${be}`,`grouping ignores unknown column "${be}".`);continue}re.push(fe);const le=this.#He(be),ye=le&&le.dataType;if(ye&&H(ye.groupProjector)){const Ne=le.typeOptions&&le.typeOptions.timeZone||Q||void 0,je=ye.groupProjector(le,Ne);ie.push(je||null),je&&(ue=!0)}else ie.push(null)}if(!re.length)return{roots:null,leaves:B,nodes:new Map};const{keys:ke,buckets:de}=this.#Ye("groupByColumns")(re,B,{locale:(this.#e.config||{}).locale,project:ue?ie:void 0}),we=this.#K("pivotBy",[]).length>0,ve=[],De=new Map;for(let be=0;be<de.length;be++){const fe=ke[be];let le=null;const ye=[];for(let Ne=0;Ne<fe.length;Ne++){ye.push(h(fe[Ne]));const je=a(ye),$e=Ne===fe.length-1;let Re=De.get(je);if(!Re){const Se=this.#i.group({path:[...ye],column:J[Ne],value:fe[Ne],level:Ne,parent:le,expanded:we&&$e?!1:this.#Je(je,{key:je,column:J[Ne],value:fe[Ne],level:Ne,path:[...ye]}),hasChildren:!(we&&$e)});Re={row:Se,leaves:null},De.set(je,Re),le?le.children.push(Se):ve.push(Se)}Re.row.leafCount+=de[be].length,Ne===fe.length-1&&(Re.leaves=de[be]),le=Re.row}}const pe=this.#K("sort",[])||[],oe=(be,fe)=>{if(!be||be.length<2){if(be)for(const je of be)oe(je.children,fe+1);return}const le=J[fe],ye=pe.find(je=>je.col===le),Ne=ye&&ye.dir==="desc"?-1:1;be.sort((je,$e)=>Ne*X(je.groupValue,$e.groupValue));for(const je of be)oe(je.children,fe+1)};return oe(ve,0),{roots:ve,leaves:B,nodes:De,keys:ke,buckets:de}}#Le(B,J){const te=new Map,Q=new Map,re=ie=>{const ue=ie.physical>=0?[ie.physical]:[];for(const ke of ie.children)ue.push(...re(ke));if(ie.children.length){const ke=this.#Ze(J,Uint32Array.from(ue),null);ie.physical>=0?te.set(ie.physical,ke):Q.set(ie.key,ke)}return ue};for(const ie of B.roots)re(ie);return{byPhysical:te,byKey:Q}}#Ve(B){const J=this.#De();if(!J.length)return this.#E=null,this.#T=null,{grand:null};const te={id:this.#me("group"),columns:J.map(pe=>pe.id).join("")},Q=this.#E&&this.#E.id===te.id&&this.#E.columns===te.columns,re=this.#kt()&&Q?this.#C:null,ie=re?J.filter(pe=>re.has(pe.id)):J,ue=Q?this.#T:null,ke=this.#at()?null:this.#vt(),de=this.#Oe(J),we=pe=>{const oe=B.nodes.get(pe.key);let be=oe&&oe.leaves?oe.leaves:null;if(pe.children&&pe.children.length){const ye=pe.children.map(we);let Ne=0;for(const Re of ye)Ne+=Re.length;const je=new Uint32Array(Ne);let $e=0;for(const Re of ye)je.set(Re,$e),$e+=Re.length;be=je}be=be||new Uint32Array(0);const fe=ke?ke.get(pe.key)||S:be,le=this.#Ct(pe,re?ie:J,fe,de);return pe.totals=re?{...pe.totals,...le}:le,be};if(B.roots&&ie.length)for(const pe of B.roots)we(pe);if(this.#D=B.tree?this.#Le(B.tree,J):null,this.#E=te,this.#C=this.#kt()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#A.length=0,this.#T=null,{grand:null};const De=ke?this.#ne():B.leaves;return this.#T=this.#Xe(J,De,re,ue),{grand:this.#T}}#Xe(B,J,te,Q){const re={},ie=this.#me("group");ie!==this.#w&&(this.#Pt(),this.#w=ie);const ue=this.#A;this.#A=[];for(const ke of B){if(!T(ke))continue;const de=this.#o.handle(ke.id);if(!de)continue;const we=O(ke,"grand");if(!g(we,de)){if(te&&!te.has(ke.id)&&Q&&ke.id in Q){re[ke.id]=Q[ke.id];continue}re[ke.id]=this.#Ze([ke],J,null,"grand")[ke.id];continue}let ve=this.#O.get(ke.id);if((!ve||ve.fn!==we)&&(ve=new s(we),this.#O.set(ke.id,ve)),ve.valid){let De=!0;for(const pe of ue)if(pe.colId===ke.id&&!ve.update(pe.before,pe.after)){De=!1;break}if(De){re[ke.id]=ve.value();continue}ve.invalidate()}ve.seedColumn(de.values,n(de),J),re[ke.id]=ve.valid?ve.value():this.#Ze([ke],J,null,"grand")[ke.id]}return re}#Oe(B){const J=this.#me("group");J!==this.#P&&(this.#v.clear(),this.#P=J);const te=new Map;for(const re of B){if(!T(re))continue;const ie=this.#o.handle(re.id),ue=O(re,"group");g(ue,ie)&&te.set(re.id,{fn:ue})}if(!te.size)return this.#S.length=0,te;const Q=this.#S;this.#S=[];for(const re of Q){const{beforeKeys:ie,afterKeys:ue,colDeltas:ke}=re,de=ie.length?new Set(ie):null,we=ue.length?new Set(ue):null;for(const{colId:ve,before:De,after:pe}of ke)if(te.has(ve)){for(const oe of ie)we&&we.has(oe)||this.#Se(oe,ve,De,null);for(const oe of ue)de&&de.has(oe)||this.#Se(oe,ve,null,pe);for(const oe of ie)we&&!we.has(oe)||this.#Se(oe,ve,De,pe)}}return te}#Se(B,J,te,Q){const re=this.#v.get(B),ie=re&&re.get(J);!ie||!ie.valid||ie.update(te,Q)||ie.invalidate()}#Ct(B,J,te,Q){if(!Q||!Q.size)return this.#Ze(J,te,B);const re={};let ie=null,ue=this.#v.get(B.key);for(const ke of J){const de=Q.get(ke.id);if(!de){(ie||(ie=[])).push(ke);continue}const we=this.#o.handle(ke.id);if(!we)continue;ue||(ue=new Map,this.#v.set(B.key,ue));let ve=ue.get(ke.id);if((!ve||ve.fn!==de.fn)&&(ve=new s(de.fn),ue.set(ke.id,ve)),ve.valid||ve.seedColumn(we.values,n(we),te),ve.valid){re[ke.id]=ve.value();continue}(ie||(ie=[])).push(ke)}return ie&&Object.assign(re,this.#Ze(ie,te,B)),re}#Qe(B,J,te,Q){const re=!this.#at()||this.#Ge(J);for(const ie of B){const ue=ie.getValue;if(!H(ue))continue;const ke=ue(te),de=ue(Q);Object.is(ke,de)||(this.#C&&this.#C.add(ie.id),re&&this.#O.has(ie.id)&&this.#A.push({colId:ie.id,before:ke,after:de}))}}#et(){const B=this.#K("groupBy",[]),J=[];for(const te of B){const Q=this.#He(te);Q&&J.push(Q)}return J}#tt(B,J){const te=new Array(B.length);for(let Q=0;Q<B.length;Q++){const re=B[Q].getValue;te[Q]=h(H(re)?re(J):void 0)}return te}#wt(B,J,te,Q,re){if(this.#at()&&!this.#Ge(te))return;const ie=r(this.#tt(B,Q)),ue=r(this.#tt(B,re)),ke=ie.length!==ue.length||ie.some((we,ve)=>we!==ue[ve]),de=[];for(const we of J){const ve=we.getValue;if(!H(ve))continue;const De=ve(Q),pe=ve(re);!ke&&Object.is(De,pe)||de.push({colId:we.id,before:De,after:pe})}!de.length&&!ke||this.#S.push({beforeKeys:ie,afterKeys:ue,colDeltas:de})}#Ge(B){const J=this.#l.get("filter"),te=J&&J.computed?J.result:null;if(!te)return!0;let Q=0,re=te.length-1;for(;Q<=re;){const ie=Q+re>>1,ue=te[ie];if(ue===B)return!0;ue<B?Q=ie+1:re=ie-1}return!1}#at(){return(this.#e.config||{}).totalFilteredOnly!==!1}#nt(B){return this.#at()?B:this.#ne().length}#ne(){return(!this.#M||this.#M.version!==this.#u)&&(this.#M={version:this.#u,indices:this.#Ke()}),this.#M.indices}#vt(){const B=this.#K("groupBy",[]),J=`${this.#u}|${JSON.stringify(B)}`;if(this.#N&&this.#N.key===J)return this.#N.map;const te=new Map,Q=[];for(const re of B){const ie=this.#o.handle(re);ie&&Q.push(ie)}if(Q.length){const re=this.#ne(),{keys:ie,buckets:ue}=this.#Ye("groupByColumns")(Q,re,{locale:(this.#e.config||{}).locale}),ke=new Map;for(let de=0;de<ue.length;de++){const we=ie[de],ve=[];for(let De=0;De<we.length;De++){ve.push(h(we[De]));const pe=a(ve);let oe=ke.get(pe);oe||(oe=[],ke.set(pe,oe));for(let be=0;be<ue[de].length;be++)oe.push(ue[de][be])}}for(const[de,we]of ke)te.set(de,Uint32Array.from(we))}return this.#N={key:J,map:te},te}#kt(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#rt(){this.#Pt(),this.#st(),this.#C=null,this.#E=null,this.#T=null}#Pt(){this.#O.clear(),this.#A.length=0,this.#w=-1}#st(){this.#v.clear(),this.#S.length=0,this.#P=-1}#Ot(B){const J=this.#K("pivotBy",[]);if(!J.length)return this.#H=null,null;const te=(this.#e.compute||{}).pivot;if(!H(te))return _("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#H=null,null;const Q=J.map(ie=>this.#o.handle(ie)).filter(Boolean),re=this.#De();return this.#H=te(Q,B.leaves,{groups:B.keys&&B.buckets?{keys:B.keys,buckets:B.buckets}:null,totals:re.map(ie=>ie.id),handle:ie=>this.#o.handle(ie),totalOf:ie=>O(re.find(ue=>ue.id===ie),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#H}#qe(B){const J=this.#l.get("total").result,te=!!(this.#e.config||{}).groupFooter,Q=this.#de();if(B.tree)return this.#Fe(B,J,Q);if(!B.roots&&!Q){if(J&&J.grand&&!this.#re()){const we=this.#i.grandTotal(J.grand,this.#nt(B.leaves.length));if(this.#Y===B.leaves&&Array.isArray(this.#B))this.#B[this.#B.length-1]=we;else{const ve=Array.from(B.leaves);ve.push(we),this.#B=ve,this.#Y=B.leaves}this.#I=[{at:this.#B.length-1}]}else this.#Y=null,this.#B=B.leaves,this.#I=M;return this.#G=M,this.#B}const re=[],ie=[],ue=[],ke=we=>{if(re.push(we),!Q)return;const ve=this.#le(we);!ve||!Q.isOpen(ve.key)||(ve.master=!0,ve.expanded=!0,ue.push({at:re.length}),re.push(this.#i.detail(ve,Q.heightOf(ve))))};if(!B.roots){for(let we=0;we<B.leaves.length;we++)ke(B.leaves[we]);return J&&J.grand&&!this.#re()&&(ue.push({at:re.length}),re.push(this.#i.grandTotal(J.grand,this.#nt(B.leaves.length)))),this.#Y=null,this.#G=M,this.#I=ue.length?ue:M,this.#B=re,re}const de=(we,ve,De)=>{if(we.expanded=we.hasChildren===!1?!1:this.#Je(we.key,{key:we.key,column:we.groupColumn,value:we.groupValue,level:we.level,path:we.groupPath}),we.posinset=ve+1,we.setsize=De,ie.push({at:re.length,row:we}),ue.push({at:re.length}),re.push(we),!!we.expanded){if(we.children&&we.children.length)for(let pe=0;pe<we.children.length;pe++)de(we.children[pe],pe,we.children.length);else{const pe=B.nodes.get(we.key),oe=pe&&pe.leaves?pe.leaves:null;if(oe)for(let be=0;be<oe.length;be++)ke(oe[be])}te&&we.totals&&(ue.push({at:re.length}),re.push(this.#i.footer(we)))}};for(let we=0;we<B.roots.length;we++)de(B.roots[we],we,B.roots.length);return J&&J.grand&&!this.#re()&&(ue.push({at:re.length}),re.push(this.#i.grandTotal(J.grand,this.#nt(B.leaves.length)))),this.#G=ie,this.#I=ue,this.#B=re,re}#Ke(){const B=this.#e.store;if(B&&H(B.liveIndices))return B.liveIndices();const J=new Uint32Array(this.#n.length);let te=0;for(let Q=0;Q<this.#n.length;Q++)this.#n[Q]!==void 0&&(J[te++]=Q);return J.subarray(0,te)}#dt(){const B=this.#e.store;return B&&typeof B.physical=="number"?B.physical:this.#n.length}#j(B){const J=this.#e.store;return J&&H(J.source)?J.source(B):this.#n[B]}#ft(B,J=B){const te=this.#B[B];if(typeof te!="number")return te.index=J,te;const Q=this.#le(te);return Q.index=J,Q}#le(B){let J=this.#h.get(B);J||(J=this.#i.leaf(this.#j(B),B),this.#h.set(B,J));const te=this.#R?this.#R.get(B):null;if(te){J.level=te.level,J.posinset=te.posinset,J.setsize=te.setsize,J.hasChildren=te.hasChildren,J.expanded=te.hasChildren&&!te.lazy&&this.#Je(J.key);const Q=this.#D?this.#D.byPhysical.get(B):void 0;Q?J.totals=Q: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}#Fe(B,J,te){const Q=[],re=[],ie=ke=>{if(ke.leafCount!==void 0)return ke.leafCount;let de=ke.physical>=0?1:0;for(const we of ke.children)de+=ie(we);return ke.leafCount=de,de},ue=ke=>{const de=this.#Je(ke.key);if(ke.physical>=0){if(Q.push(ke.physical),te&&te.isOpen(this.#le(ke.physical).key)){const we=this.#le(ke.physical);re.push({at:Q.length}),Q.push(this.#i.detail(we,te.heightOf(we)))}}else Q.push(this.#i.group({path:[ke.key],column:null,value:ke.value,level:ke.level,parent:null,expanded:de,hasChildren:ke.children.length>0,leafCount:ie(ke),totals:this.#D?this.#D.byKey.get(ke.key):void 0}));if(de)for(const we of ke.children)ue(we)};for(const ke of B.tree.roots)ue(ke);return J&&J.grand&&!this.#re()&&(re.push({at:Q.length}),Q.push(this.#i.grandTotal(J.grand,this.#nt(B.leaves.length)))),this.#Y=null,this.#G=M,this.#I=re.length?re:M,this.#B=Q,Q}#$e(){return t(()=>this.count(),B=>this.at(B))}#Ce(B,J){let te=this.#x.get(B);if(te===void 0){const Q=this.#j(B),re=this.#mt(),ie=[],ue=this.#e.columnHidden;for(const ke of re){if(ke.quickFilter===!1||H(ue)&&ue(ke.id))continue;const de=ke.value&&H(ke.value.quickFilterText)?ke.value.quickFilterText({value:void 0,data:Q,row:null,column:ke,colId:ke.id,grid:null,context:this.#K("context",null)}):null,we=de??(H(ke.formatValue)?ke.formatValue(H(ke.getValue)?ke.getValue(Q):void 0):"");we!=null&&we!==""&&ie.push(String(we))}te=ie.join(" ").toLowerCase(),this.#x.set(B,te)}return J(te)}#De(){const B=this.#K("totals",[]),J=B&&B.length?new Set(B):null;return this.#mt().filter(te=>J?J.has(te.id):!!(te.total||te.groupTotal||te.grandTotal))}#Ze(B,J,te,Q="group"){const re={},ie=(this.#e.compute||{}).total;for(const ue of B){if(!T(ue))continue;const ke=this.#o.handle(ue.id);if(!ke)continue;const de=O(ue,Q);if(de)if(H(de)){const we=new Array(J.length);for(let ve=0;ve<J.length;ve++)we[ve]=ke.get(J[ve]);re[ue.id]=de(we,{row:te,column:ue,grid:this.#e.grid||null,context:this.#K("context",null),valueAt:(ve,De)=>{const pe=this.#o.handle(ve);return pe&&De>=0&&De<J.length?pe.get(J[De]):null}})}else H(ie)&&(re[ue.id]=ie(ke,J,de))}return re}#lt(B){if(!B)return B;const J=this.#e.config||{},te={tz:J.timeZone,weekStartsOn:J.weekStartsOn};return l(B,Q=>{const re=y(Q,te),ie=this.#He(re&&re.col),ue=ie&&ie.type==="datetime";if(re&&re.type)return re.type==="datetime"&&!re.timeZone&&ie?{...re,timeZone:J.timeZone||void 0}:re;if(ue)return{...re,type:"datetime",timeZone:J.timeZone||void 0};const ke=ie&&(ie.dataType?.base||ie.type);return ke?{...re,type:ke}:re})}#Je(B,J){const te=this.#K("expanded",null);return te?H(te.has)?te.has(B,J):Array.prototype.includes.call(te,B):!0}#K(B,J){if(B==="context"||!H(this.#e.stateVersion))return this.#ht(B,J);const te=this.#ct(B),Q=this.#d.get(B);if(Q&&Q.version===te)return Q.value;const re=this.#ht(B,J);return this.#d.set(B,{version:te,value:re}),re}#ht(B,J){const te=this.#e.state;if(te&&H(te[B])){const Q=te[B]();return Q??J}return J}#pt(){const B=this.#e.stateVersion;return H(B)?B():0}#Rt(){const B=this.#e.columnsVersion,J=this.#e.permissionsVersion;return`${H(B)?B():0}|${H(J)?J():0}`}#ct(B){return B==="totals"?this.#Rt():`${this.#pt()}`}#Et(B,J,te){if(!H(this.#e.stateVersion))return te();const Q=this.#f.get(B);if(Q&&Q.version===J)return Q.key;const re=te();return this.#f.set(B,{version:J,key:re}),re}#Ye(B){const J=(this.#e.compute||{})[B];return H(J)||L(`ctx.compute.${B} is required by the memory source pipeline`),J}#mt(){const B=this.#e.columns;return B&&H(B.all)?B.all():[]}#He(B){const J=this.#e.columns;return J&&H(J.get)?J.get(B):void 0}#gt(B,J){const te=this.#e.emit;H(te)&&te(B,J)}}}),We("packages/core/src/source/abort.js",function(e,D){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return L}});class ne extends Error{constructor(H,x="superseded"){super(`[lattice] request ${H?`"${H}" `:""}${x}`),this.name="SupersededError",this.superseded=!0,this.key=H}}class P{#e;constructor(H,x,X,U){this.#e=H,this.key=x,this.controller=X,this.signal=X.signal,this.seq=U}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(H){this.signal.aborted||this.controller.abort(new ne(this.key,H)),this.#e.settle(this)}}class Y{#e=new Map;#t=0;begin(H="",x="superseded"){const X=this.#e.get(H);X&&!X.signal.aborted&&X.controller.abort(new ne(H,x));const U=new P(this,H,new AbortController,++this.#t);return this.#e.set(H,U),U}tokenFor(H){return this.#e.get(H)}pending(H=""){const x=this.#e.get(H);return!!x&&!x.signal.aborted}get size(){return this.#e.size}settle(H){this.#e.get(H.key)===H&&this.#e.delete(H.key)}abort(H="",x="superseded"){const X=this.#e.get(H);X&&X.abort(x)}abortAll(H="superseded"){for(const x of[...this.#e.values()])x.abort(H);this.#e.clear()}}function _(){return new Y}function L(Z){if(!Z||typeof Z!="object")return!1;const H=Z;return H.superseded===!0||H.name==="AbortError"||H.name==="SupersededError"}}),We("packages/core/src/source/blockcache.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return _}});const ne=100,P=32;class Y{constructor(Z){this.id=Z,this.rows=null,this.state="pending",this.token=null,this.error=null}}class _{#e=new Map;#t;#n;#r=0;#s=-1;constructor(Z={}){this.#t=Math.max(1,Math.floor(Number(Z.pageSize)||ne)),this.#n=Math.max(1,Math.floor(Number(Z.maxCachedPages)||P))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(Z){return Math.floor(Z/this.#t)}rangeOf(Z){return{start:Z*this.#t,end:(Z+1)*this.#t}}has(Z){return this.#e.has(Z)}pending(Z){const H=this.#e.get(Z);return!!H&&H.state==="pending"}loaded(Z){const H=this.#e.get(Z);return!!H&&H.state==="loaded"}begin(Z,H){let x=this.#e.get(Z);return x||(x=new Y(Z)),x.state="pending",x.token=H,x.error=null,this.#i(Z,x),x}fill(Z,H){const x=this.#e.get(Z)||new Y(Z);x.rows=H,x.state="loaded",x.token=null,this.#i(Z,x)}failed(Z,H){const x=this.#e.get(Z)||new Y(Z);x.state="error",x.error=H,x.token=null,this.#i(Z,x)}delete(Z){return this.#e.delete(Z)}rowAt(Z){const H=this.blockOf(Z),x=this.#e.get(H);if(!(!x||x.state!=="loaded"||!x.rows))return this.#i(H,x),x.rows[Z-H*this.#t]}rowLoaded(Z){const H=this.blockOf(Z),x=this.#e.get(H);return!!x&&x.state==="loaded"&&!!x.rows&&Z-H*this.#t<x.rows.length}erroredAt(Z){const H=this.#e.get(this.blockOf(Z));return!!H&&H.state==="error"}loadedExtent(){let Z=0;for(const H of this.#e.values()){if(H.state!=="loaded"||!H.rows)continue;const x=H.id*this.#t+H.rows.length;x>Z&&(Z=x)}return Z}fillOf(Z){const H=this.#e.get(Z);return H&&H.state==="loaded"&&H.rows?H.rows.length:null}protect(Z,H){this.#r=this.blockOf(Math.max(0,Z)),this.#s=this.blockOf(Math.max(0,H))}evict(){const Z=[];if(this.#e.size<=this.#n)return Z;for(const[H,x]of this.#e){if(this.#e.size-Z.length<=this.#n)break;H>=this.#r&&H<=this.#s||x.state!=="pending"&&Z.push(H)}for(const H of Z)this.#e.delete(H);return Z}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(Z,H){this.#e.delete(Z),this.#e.set(Z,H)}}}),We("packages/core/src/source/pagewindow.js",function(e,D){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return ne}});function ne(P,Y,_,L){const Z=Math.floor(Number(P)||0);if(Z<=0)return null;const H=Math.max(0,Math.floor(Number(Y)||0)),x=Math.max(0,Math.floor(Number(_)||0));if(L){const X=Math.max(1,Math.ceil(x/Z)),U=Math.min(H,X-1),j=U*Z;return{page:U,pageSize:Z,offset:j,length:Math.max(0,Math.min(Z,x-j)),pageCount:X,total:x}}return{page:H,pageSize:Z,offset:H*Z,length:Z,pageCount:Math.max(H+2,Math.ceil(x/Z)),total:null}}}),We("packages/core/src/source/paged.js",function(e,D){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return p}});const P=D("packages/core/src/internal/lru.js").Lru,_=D("packages/core/src/internal/predicates.js").isFunction,Z=D("packages/core/src/internal/warn.js").warnOnce,x=D("packages/core/src/internal/schedule.js").settleDebounce,X=D("packages/core/src/source/abort.js"),U=X.createAbortScope,j=X.isAbortError,k=D("packages/core/src/source/blockcache.js"),b=k.BlockCache,a=k.DEFAULT_PAGE_SIZE,h=k.DEFAULT_MAX_CACHED_PAGES,t=D("packages/core/src/source/rows.js").createRowFactory,o=D("packages/core/src/source/filterwire.js"),u=o.wireFilters,d=o.querySignature,s=o.warnHostFilterNotApplied,i=D("packages/core/src/source/pagewindow.js").pageWindow,n=120;function f(l,y){return new p(l,y)}class p{mode="paged";#e;#t;#n;#r=U();#s;#i;#o=new Map;#l=null;#a=null;#c=!1;#u=0;#d="";#f={start:0,end:0};#h;#p=!1;#m=0;#g="";constructor(y,c){this.#e=y||{mode:"paged"},this.#t=c||{},this.#n=new b({pageSize:this.#e.pageSize||a,maxCachedPages:this.#e.maxCachedPages||h}),this.#s=t(this.#t),this.#i=new P(this.#n.pageSize*4),this.#h=x((m,w)=>this.#w(m,w),n),this.#d=this.#C(),_(this.#e.fetch)||Z("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),s(this.#t)}count(){const y=this.#y();return y?y.length:this.#b()}#b(){if(this.#P(),this.#l!==null)return this.#l;const y=Math.max(this.#u,this.#n.loadedExtent());return this.#c?y:y+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const y=this.#y();if(!y){const c=this.#b();return{page:0,pageSize:0,total:this.exact()?c:null,pageCount:1,counting:!1}}return{page:y.page,pageSize:y.pageSize,total:y.total,pageCount:y.pageCount,counting:y.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const y=this.#b(),c=i(this.#T("pageSize",0),this.#T("page",0),y,this.exact());if(!c)return this.#g="",null;const m=`${this.#m}:${c.offset}:${c.length}`;if(m!==this.#g&&!this.#p&&(this.#g=m,c.length>0)){const w=c.offset+c.length-1;this.#f={start:c.offset,end:w},this.#w(c.offset,w)}return c}at(y){const c=this.#y();if(c){if(y<0||y>=c.length)return;const m=this.#O(c.offset+y);return m&&(m.index=y),m}return this.#O(y)}#O(y){if(y<0||y>=this.#b())return;const c=this.#i.get(y);if(c&&(c.data!==null||!this.#n.rowLoaded(y)))return c;const m=this.#n.rowAt(y);if(m===void 0){const v=this.#s.skeleton(y,0,this.#n.erroredAt(y));return this.#i.set(y,v),v}const w=this.#s.leaf(m,y);return w.index=y,this.#i.set(y,w),this.#o.set(w.key,y),w}byKey(y){const c=this.#o.get(y);return c===void 0?void 0:this.#O(c)}loaded(y){const c=this.#y();return c?y>=0&&y<c.length&&this.#n.rowLoaded(c.offset+y):this.#n.rowLoaded(y)}loadedCount(){this.#P();let y=0;for(const c of this.#n.ids()){if(!this.#n.loaded(c))continue;const m=this.#n.fillOf(c);typeof m=="number"&&(y+=m)}return y}residentRows(){this.#P();const y=this.#y(),c=y?y.offset:0,m=y?y.offset+y.length:1/0,w=[],v=this.#n.ids().sort((E,V)=>E-V);for(const E of v){if(!this.#n.loaded(E))continue;const{start:V}=this.#n.rangeOf(E),G=this.#n.fillOf(E)||0;for(let q=V;q<V+G;q++){if(q<c||q>=m)continue;const M=this.#i.peek(q);if(M&&M.data!==null&&M.data!==void 0){w.push(M);continue}const O=this.#n.rowAt(q);if(O===void 0)continue;const T=this.#s.leaf(O,q);T.index=q,this.#i.set(q,T),this.#o.set(T.key,q),w.push(T)}}return w}hint(y,c){if(this.#p)return;const m=this.#P();let w=Math.max(0,Math.floor(y)),v=Math.max(w,Math.floor(c));const E=this.#y();if(E){if(E.length===0)return;w=E.offset,v=E.offset+E.length-1}this.#f={start:w,end:v},this.#n.protect(w,v);for(const V of this.#n.evict())this.#v(V);this.#h(w,v),m&&this.#h.flush()}#w(y,c){if(this.#p)return;this.#n.protect(y,c);const m=this.#n.blockOf(y),w=this.#n.blockOf(c);for(let v=m;v<=w&&!(this.#l!==null&&v*this.#n.pageSize>=this.#l);v++)this.#n.has(v)||this.#A(v)}apply(y){const c={added:[],updated:[],removed:[]};if(!y)return c;if(y.update)for(const m of y.update){const w=this.#s.keyOf(m,-1),v=this.#o.get(w);if(v===void 0)continue;const E=this.#s.leaf(m,v);E.index=v,this.#i.set(v,E),c.updated.push(E)}return(y.add&&y.add.length||y.remove&&y.remove.length)&&this.reload(),c}reload(y){this.#S("reload"),this.#h.cancel(),this.hint(this.#f.start,this.#f.end)}destroy(){this.#p=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#o.clear()}exact(){return this.#l!==null||this.#c}pending(){return this.#r.size}async#A(y){if(!_(this.#e.fetch))return;const c=this.#r.begin(`block:${y}`);this.#n.begin(y,c);const{start:m,end:w}=this.#n.rangeOf(y),v=this.#d;try{const E=await this.#e.fetch({range:{start:m,end:w},sort:this.#T("sort",[]),filters:u(this.#T("filters",null),this.#E()),quick:this.#T("quick","")||void 0,context:this.#T("context",null),signal:c.signal});if(!c.current||v!==this.#d||this.#p)return;c.settle();const V=E&&E.rows||[];this.#n.fill(y,V);for(let q=0;q<V.length;q++)this.#i.delete(m+q);const G=E&&typeof E.total=="number"?E.total:E&&typeof E.count=="number"?E.count:null;G!==null?(this.#l=G,this.#c=!0):V.length<this.#n.pageSize?(this.#c=!0,this.#l=m+V.length):this.#u=Math.max(this.#u,m+V.length),this.#M("model:changed",{reason:"page",block:y,from:m,to:m+V.length}),this.#M("rows:changed",{companion:!0,reason:"page",block:y,from:m,to:m+V.length}),this.#l!==null&&this.#l!==this.#a&&(this.#a=this.#l,this.#M("source:total",{total:this.#l,groupPath:[]}))}catch(E){if(c.settle(),j(E))return;this.#n.failed(y,E);for(let V=m;V<w;V++)this.#i.delete(V);this.#M("model:changed",{reason:"page-error",block:y,range:{start:m,end:w}}),this.#M("source:error",{error:E,block:y,range:{start:m,end:w}})}}#v(y){const{start:c,end:m}=this.#n.rangeOf(y);for(let w=c;w<m;w++){const v=this.#i.peek(w);v&&this.#o.delete(v.key),this.#i.delete(w)}}#P(){const y=this.#C();return y===this.#d?!1:(this.#d=y,this.#S("query"),!0)}#S(y){this.#r.abortAll(y),this.#n.clear(),this.#i.clear(),this.#o.clear(),this.#l=null,this.#a=null,this.#c=!1,this.#u=0,this.#m++,this.#M("model:changed",{reason:y})}#C(){return d({filters:this.#T("filters",null),sort:this.#T("sort",[]),quick:this.#T("quick",""),context:this.#T("context",null)})}#E(){const y=this.#t.config||{};return{tz:y.timeZone,weekStartsOn:y.weekStartsOn}}#T(y,c){const m=this.#t.state;if(m&&_(m[y])){const w=m[y]();return w??c}return c}#M(y,c){const m=this.#t.emit;_(m)&&m(y,c)}}}),We("packages/core/src/source/aggregates.js",function(e,D){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"aggregateP",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return U}});const ne=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)"},percentile:{pushable:!0,class:"identical",sql:"quantile_cont(%c, %p)",parametric:!0},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 P(){const j=new Set;for(const[k,b]of Object.entries(ne))b.pushable&&j.add(k);return j}function Y(j,k,b,a="?"){let h=j.split("%c").join(k);return b!==void 0&&(h=h.split("%w").join(b)),h.split("%p").join(a)}function _(j){const k=j&&(j.p!==void 0?j.p:j.params&&j.params.p);return typeof k=="number"&&k>=0&&k<=1?k:void 0}function L(j){const k=j||{},b=k.default==="engine"||k.default==="engine-if-identical"?k.default:"client",a={};if(k.overrides&&typeof k.overrides=="object")for(const[h,r]of Object.entries(k.overrides))(r==="engine"||r==="client")&&(a[h]=r);return{default:b,overrides:a}}function Z(j,k){const b=ne[j];if(!b||!b.pushable)return"client";const a=k.overrides[j];return a==="engine"||a==="client"?a:k.default==="client"?"client":k.default==="engine-if-identical"?b.class==="identical"?"engine":"client":"engine"}function H(j,k){const b=L(k),a=[],h=[];for(const r of j||[]){const t=ne[r.fn],o=Z(r.fn,b),u={id:r.id,col:r.col,fn:r.fn,class:t?t.class:"fallback"};if(r.weight!==void 0&&(u.weight=r.weight),r.params!==void 0&&(u.params=r.params),t&&t.parametric){const d=_(r);d!==void 0&&(u.p=d)}if(o==="engine"&&t&&t.parametric&&u.p===void 0){h.push({...u,reason:`"${r.fn}" needs \`p\`, a number from 0 to 1`});continue}o==="engine"?a.push(u):(u.reason=t&&!t.pushable?t.note||"the engine cannot express this stat":"client by config",h.push(u))}return{engine:a,client:h,config:b}}const x=/^[A-Za-z_][A-Za-z0-9_$]*$/;function X(j,k=[]){return(j||[]).every(a=>{if(typeof a=="string")return x.test(a);if(!a||typeof a!="object")return!1;const h=a;return Array.isArray(k)&&k.includes(h.bucket)&&typeof h.col=="string"&&x.test(h.col)&&typeof h.size=="number"&&Number.isFinite(h.size)&&h.size>0})}function U(){return Object.entries(ne).map(([j,k])=>({stat:j,class:k.class,sql:k.sql?Y(k.sql,"col",k.twoColumn?"weight":void 0):"",note:k.note||(k.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),We("packages/core/src/source/pushdown.js",function(e,D){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return te}});const P=D("packages/core/src/internal/compare.js").defaultCompare,_=D("packages/core/src/internal/predicates.js").isFunction,Z=D("packages/core/src/internal/merge.js").toArray,x=D("packages/core/src/internal/warn.js").warnOnce,X=D("packages/core/src/source/filterwire.js"),U=X.isGroup,j=X.warnWherePageRelative,k=X.warnWhereOverThreshold,b=X.wireFilters,a=D("packages/core/src/source/aggregates.js"),h=a.resolveAggregatePlan,r=a.groupKeysPushable,t=a.STAT_PUSHDOWN,o=a.aggregateP,u=a.fillAggregateSql,s=D("packages/core/src/source/abort.js").SupersededError,g=1e3;function i(Q){const re=Q&&Q.signal;if(!re||!re.aborted)return;const ie=re.reason;throw ie instanceof Error?ie:new s("","superseded before it was sent")}const n=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function f(Q){if(!Q||typeof Q!="object")return!1;const re=Q.returning==="row"||Q.returning==="key"?Q.returning:"none";return{append:Q.append===!0,update:Q.update===!0,delete:Q.delete===!0,returning:re}}function p(Q,re){if(!Q||typeof re!="string")return;if(!re.includes("."))return Q[re];let ie=Q;for(const ue of re.split(".")){if(ie===null||typeof ie!="object")return;ie=ie[ue]}return ie}function l(Q){if(Q===!0)return!0;if(!Q||typeof Q!="object")return!1;const re=Q;return re.enabled===!1?!1:re.enabled===!0||_(re.commit)}function y(Q){const re={...n,...Q||{}};return re.operators=new Set(re.operators||[]),re.mutate=f(re.mutate),re}function c(Q,re){return!Q||!Q.op||!re.operators.size?!1:re.operators.has(Q.op)}function m(Q,re){if(!Q)return{pushed:null,residual:null};if(!re.filter)return{pushed:null,residual:Q};if(re.filter==="term"){if(U(Q)){const de=Q.conditions||[];if(String(Q.op)!=="and")return{pushed:null,residual:Q};const we=de.findIndex(De=>!U(De)&&c(De,re));if(we<0)return{pushed:null,residual:Q};const ve=de.filter((De,pe)=>pe!==we);return{pushed:de[we],residual:ve.length?{op:"and",conditions:ve}:null}}return c(Q,re)?{pushed:Q,residual:null}:{pushed:null,residual:Q}}if(!U(Q))return c(Q,re)?{pushed:Q,residual:null}:{pushed:null,residual:Q};if(String(Q.op)!=="and")return(Q.conditions||[]).every(we=>U(we)?m(we,re).residual===null:c(we,re))?{pushed:Q,residual:null}:{pushed:null,residual:Q};const ie=[],ue=[];for(const de of Q.conditions||[]){if(U(de)){if(re.filter==="flat"){ue.push(de);continue}const we=m(de,re);we.pushed&&ie.push(we.pushed),we.residual&&ue.push(we.residual);continue}(c(de,re)?ie:ue).push(de)}const ke=de=>de.length===0?null:de.length===1?de[0]:{op:"and",conditions:de};return{pushed:ke(ie),residual:ke(ue)}}const w="__lattice_leaves";function v(Q){return Q.aggregates?Q.aggregates instanceof Set?Q.aggregates:new Set(Z(Q.aggregates)):new Set}function E(Q){const re=v(Q);return re.size?re.has("count")?Q.filter!=="tree"||!Q.operators||!Q.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(Q,re,ie,ue,ke,de,we){const ve=Array.isArray(Q.groupBy)?Q.groupBy:[],De=Array.isArray(Q.groupPath)?Q.groupPath:[],pe=Array.isArray(Q.groupValues)?Q.groupValues:null;if(!re.group){const oe=E(re);if(oe)return oe}return r(ve)?ie.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":ue?ke?de&&!de.conditioned?"a host `where` predicate can only run in the browser, over rows the engine grouped":we?"fullDataset holds the whole matching set, so the grid groups it itself":!pe||pe.length!==De.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const G="pushdown:pivot-unsupported",q="pushdown:group-unsupported",M=Symbol("lattice.remote.ungroupedLevel");function O(Q,re,ie,ue,ke,de){const we=Array.isArray(Q.pivotBy)?Q.pivotBy:[],ve=Array.isArray(Q.groupBy)?Q.groupBy:[],De=Array.isArray(Q.groupPath)?Q.groupPath:[],pe=Array.isArray(Q.groupValues)?Q.groupValues:null;return re.pivot?r(we)?ve.length&&!r(ve)?"a grouping key is not a plain column the engine can name in a GROUP BY":ie.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":ue?ke?de&&!de.conditioned?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!pe||pe.length!==De.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function T(Q,re,ie=!1){const ue=m(Q.filters||null,re),ke=[];ue.residual&&ke.push("filter");const de=Q.sort||[],we=de.length===0||re.sort==="multi"&&de.length>=1||re.sort==="single"&&de.length===1;!we&&de.length&&ke.push("sort");const ve=Q.quick?String(Q.quick):"",De=!ve||!!re.quick;De||ke.push("quick");const pe=Q.where&&Q.where.active?Q.where:null;pe&&ke.push("where");const oe={filters:ue.residual,sort:we?null:de,quick:De?"":ve,where:pe},be=!!ie,fe=Array.isArray(Q.groupBy)&&Q.groupBy.length>0,le=fe?V(Q,re,ue,we,De,pe,be):"",ye=Q.pivotMode!==!1&&Array.isArray(Q.pivotBy)&&Q.pivotBy.length>0,Ne=ye?O(Q,re,ue,we,De,pe):"",je=ye&&Ne==="";ye&&!je&&ke.push("pivot");const $e=ye?je&&fe:fe&&le==="";fe&&!ye&&!$e&&ke.push("group");const Re=($e||je)&&Array.isArray(Q.groupValues)?Q.groupValues.length:0;pe&&pe.conditioned&&($e||je)&&(oe.where=null,ke.splice(ke.indexOf("where"),1));const Se=$e||ye?!1:be||!!(oe.filters||oe.sort||oe.quick||oe.where)||!re.range;return{pushed:{...Q,filters:ue.pushed,sort:we?de:[],quick:De?ve:"",range:Se?null:Q.range},residual:oe,needsAll:Se,unpushed:ke,full:be,grouped:$e,groupLevel:Re,groupReason:ye?"":le,pivoted:je,pivotReason:Ne}}function A(Q){const re=Array.isArray(Q.totals)?Q.totals:[],ie=Q.totalFns&&typeof Q.totalFns=="object"?Q.totalFns:{},ue=[],ke=[];for(const de of re){const we=String(de),ve=ie[we],De=typeof ve=="string"?ve:ve&&typeof ve.fn=="string"?ve.fn:null,pe=ve&&typeof ve=="object"?o(ve):void 0,oe=De?t[De]:null;oe&&oe.parametric&&pe===void 0?ke.push({id:we,fn:De,class:oe.class,reason:`"${De}" needs \`p\`, a number from 0 to 1`}):De?!oe||!oe.pushable||!oe.sql?ke.push({id:we,fn:De,class:oe?oe.class:"fallback",reason:oe&&oe.note?oe.note:`the pushdown map cannot express "${De}"`}):oe.twoColumn?ke.push({id:we,fn:De,class:oe.class,reason:`"${De}" reduces two columns, and a grouped request carries no weight column`}):ue.push({id:we,col:we,fn:De,class:oe.class,...pe!==void 0?{p:pe}:{}}):ke.push({id:we,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:ue,client:ke}}function N(Q){return{...Q,engine:Q.engine.map(re=>{const ie=t[re.fn];if(!ie||!ie.sql)return re;const ue=ke=>`"${ke}"`;return{...re,sql:u(ie.sql,ue(re.col),re.weight!==void 0?ue(re.weight):void 0)}})}}const C=Object.freeze({items:Q=>Q==null?[]:Array.isArray(Q)?Q:[Q]});function S(Q,re,ie){if(!re)return Q;let ue=Q;if(re.filters&&_(ie.evaluateFilters)){const ke=ue,de={count:ue.length,handle:De=>({id:De,get:pe=>p(ke[pe],De)}),itemwise:De=>ke.some(pe=>Array.isArray(p(pe,De)))?C:null},we=ie.evaluateFilters(re.filters,de),ve=[];for(let De=0;De<ue.length;De++)we[De]&&ve.push(ue[De]);ue=ve}if(re.where&&re.where.active&&(re.whole||j(re.where.names,"pushdown"),ue=ue.filter(ke=>re.where.passes(ke))),re.quick){const ke=re.quick.toLowerCase();ue=ue.filter(de=>{if(!de||typeof de!="object")return!1;for(const we of Object.values(de))if(we!=null&&String(we).toLowerCase().includes(ke))return!0;return!1})}if(re.sort&&re.sort.length&&_(ie.sortMulti)){const ke=[...new Set(re.sort.map(De=>De.col))],de=ue,we=ke.map(De=>({id:De,get:pe=>p(de[pe],De)})),ve=ie.sortMulti(we,re.sort.map(De=>({col:De.col,dir:De.dir})),Uint32Array.from({length:ue.length},(De,pe)=>pe),{});ue=Array.from(ve,De=>de[De])}return ue}function F(Q){return JSON.stringify({filters:Q.filters||null,sort:Q.sort||[],quick:Q.quick||"",groupBy:Q.groupBy||[],groupPath:Q.groupPath||[],context:Q.context??null})}function $(Q){if(!Q||typeof Q!="object")return 16;let re="";try{re=JSON.stringify(Q)}catch{return 200}return re.length*2+64}function W(Q){const re=Q||{};return{enabled:!!re.enabled,maxRows:Number.isFinite(re.maxRows)?re.maxRows:1e6,maxBytesEstimate:Number.isFinite(re.maxBytesEstimate)?re.maxBytesEstimate:512*1024*1024}}const K=5e4;function I(Q){return Number.isFinite(Q)&&Q>=0?Q:K}function B(Q){return!!Q&&_(Q.then)}async function J(Q){if(!Q||Q.total!==void 0||!B(Q.pendingTotal))return Q;const re=await Q.pendingTotal,{pendingTotal:ie,...ue}=Q;return typeof re=="number"?{...ue,total:re}:ue}function te(Q={}){const re=Q.adapter;if(!re||!_(re.execute))return x("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...Q,mode:"remote",fetch:async()=>({rows:[],total:0})};const ie=y(re.capabilities),ue=re.capabilities&&Object.getOwnPropertyDescriptor(re.capabilities,"operators");ue&&_(ue.get)&&Object.defineProperty(ie,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(re.capabilities.operators||[]),set:()=>{}});const ke=re.name||"adapter";let de=null;const we=()=>_(re.ready)?(de||(de=Promise.resolve(re.ready()).then(()=>{Object.assign(ie,y(re.capabilities))},ae=>{throw de=null,ae})),de):null,ve=W(Q.fullDataset),De=!!Q.allowPartialResults,pe=I(Q.whereRowLimit);let oe=null;const be=Q.aggregates;let fe=null,le=null,ye=null,Ne=null,je=null,$e=null,Re=0,Se=null;const Ve=()=>!ve.enabled||!fe?null:(Se!==fe.key&&(Re++,Se=fe.key),{rows:fe.rows,version:Re}),Fe=async ae=>{const Pe=ae.where&&ae.where.active?ae.where:null;if(!Pe)return{request:ae,probe:null};if(Pe.conditioned){const ut=T(ae,ie,ve.enabled);if(ut.grouped||ut.pivoted)return{request:ae,probe:null}}const{where:Te,...xe}=ae,_e=T(xe,ie,ve.enabled);if(_e.needsAll)return{request:ae,probe:null};const Ye=F(_e.pushed);let Qe=null;return(!oe||oe.key!==Ye)&&(ie.total?(i(ae),Qe=await J(await re.execute(_e.pushed,ae)),oe={key:Ye,size:Qe&&typeof Qe.total=="number"?Qe.total:null}):oe={key:Ye,size:null}),oe.size!==null&&oe.size<pe?{request:ae,probe:null}:(k(Pe.names,ke,oe.size,pe),{request:xe,probe:Qe})},Ce=async(ae,Pe)=>{$e=null;const Te=A(ae.pushed);ye={engine:Te.engine,client:Te.client,groupBy:ae.pushed.groupBy},Te.client.length&&x(`source.pushdown.group.totals.${ke}.${Te.client.map(Ye=>Ye.id).join(".")}`,`the ${ke} adapter cannot compute the group subtotal for ${Te.client.map(Ye=>`"${Ye.id}" (${Ye.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 xe=await re.executeGroupLevel(ae.pushed,Te.engine,Pe)||{};let _e=xe.rows||[];return!ie.range&&Pe.range&&(_e=_e.slice(Pe.range.start,Pe.range.end)),Ke(xe),xe.total===void 0?{rows:_e}:{rows:_e,total:xe.total}},Ee=new Map,Ie=64,Be=async(ae,Pe)=>{$e=null;const Te=ae.pushed,xe=Te.groupBy,_e=Array.isArray(Te.groupValues)?Te.groupValues:[],Ye=_e.length,Qe=[...Te.filters?[Te.filters]:[],...xe.slice(0,Ye).map((ot,gt)=>({col:ot,op:"eq",value:_e[gt]===void 0?null:_e[gt],caseSensitive:!0}))],ut=Qe.length===0?null:Qe.length===1?Qe[0]:{op:"and",conditions:Qe},mt=Pe.range?Pe.range.start:0;if(Ye>=xe.length){const ot={...Te,filters:ut,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},gt=await J(await re.execute(ot,Pe))||{};let xt=gt.rows||[];return!ie.range&&Pe.range&&(xt=xt.slice(Pe.range.start,Pe.range.end)),typeof gt.total=="number"?{rows:xt,total:gt.total}:{rows:xt}}const bt=xe[Ye],Rt=A(Te),Dt=v(ie),Ct=Rt.engine.filter(ot=>Dt.has(ot.fn)),_t=[...Rt.engine.filter(ot=>!Dt.has(ot.fn)).map(ot=>({id:ot.id,fn:ot.fn,class:ot.class,reason:`the ${ke} adapter does not compute "${ot.fn}"`})),...Rt.client];ye={engine:Ct,client:_t,groupBy:xe},_t.length&&x(`source.pushdown.group.totals.${ke}.${_t.map(ot=>ot.id).join(".")}`,`the ${ke} adapter cannot compute the group subtotal for ${_t.map(ot=>`"${ot.id}" (${ot.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const tn=[...Ct.map(ot=>({id:ot.id,col:ot.col,fn:ot.fn,...ot.p!==void 0?{p:ot.p}:{}})),{id:w,col:bt,fn:"count"}],Ht={...Te,filters:ut,range:null},Xt=JSON.stringify([F(Ht),_e,bt,tn]);let Je=mt>0?Ee.get(Xt):void 0;if(!Je){for(Je=Promise.resolve(re.executeGroupedAggregates(Ht,[bt],tn)),Ee.delete(Xt),Ee.set(Xt,Je);Ee.size>Ie;)Ee.delete(Ee.keys().next().value);Je.catch(()=>{Ee.get(Xt)===Je&&Ee.delete(Xt)})}const at=await Je||[];i(Pe);const St=ot=>{const gt={};for(const xt of Ct)gt[xt.id]=ot?ot[xt.id]:void 0;return gt},wt=(Te.sort||[]).find(ot=>ot&&ot.col===bt),vt=wt&&wt.dir==="desc"?-1:1,Xe=at.filter(ot=>ot&&ot.level===1).map(ot=>({[bt]:ot.keys[0]===void 0?null:ot.keys[0],leafCount:Number(ot.values&&ot.values[w])||0,totals:St(ot.values)})).sort((ot,gt)=>vt*P(ot[bt],gt[bt]));if(Ye===0){const ot=at.find(xt=>xt&&xt.level===0),gt=ot?Number(ot.values&&ot.values[w]):NaN;Ke({matchCount:Number.isFinite(gt)?gt:Xe.reduce((xt,Lt)=>xt+Lt.leafCount,0),...ot?{grand:St(ot.values)}:{}})}const ht=Pe.range?Pe.range.end:Xe.length;return{rows:Xe.slice(mt,ht),total:Xe.length}},Ke=ae=>{typeof ae.matchCount=="number"&&(Ne=ae.matchCount,je=ae.grand?{totals:ae.grand,leafCount:ae.matchCount}:null)},qe=async(ae,Pe)=>{$e=null;const Te=A(ae.pushed);ye={engine:Te.engine,client:Te.client,groupBy:ae.pushed.groupBy,pivotBy:ae.pushed.pivotBy},Te.client.length&&x(`source.pushdown.pivot.totals.${ke}.${Te.client.map(ut=>ut.id).join(".")}`,`the ${ke} adapter cannot compute the pivot cells for ${Te.client.map(ut=>`"${ut.id}" (${ut.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 xe=await re.executePivotLevel(ae.pushed,Te.engine,Pe)||{};let _e=xe.rows||[];!ie.range&&Pe.range&&(_e=_e.slice(Pe.range.start,Pe.range.end)),Ke(xe);const Ye=xe.pivot&&typeof xe.pivot=="object"?xe.pivot:{},Qe={cells:Array.isArray(Ye.cells)?Ye.cells:[],...Array.isArray(Ye.axis)?{axis:Ye.axis}:{}};return xe.total===void 0?{rows:_e,pivot:Qe}:{rows:_e,total:xe.total,pivot:Qe}},rt=ae=>{x(`source.pushdown.pivot.${ke}.${ae}`,`pushdown:pivot-unsupported: the ${ke} adapter cannot pivot this query because ${ae}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const Pe=new Error(`[lattice] ${G}: the ${ke} adapter cannot pivot this query because ${ae}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw Pe.code=G,Pe.reason=ae,Pe},nt=(ae,Pe)=>{const Te={key:Pe,state:"pending",value:null};return $e=Te,ae.then(xe=>($e===Te&&($e={key:Pe,state:"settled",value:typeof xe=="number"?xe:null}),xe),xe=>{throw $e===Te&&($e={key:Pe,state:"failed",value:null}),xe})};let dt=0,Pt=[];const Nt=()=>dt===0?null:new Promise(ae=>{const Pe=setTimeout(ae,g);Pt.push(()=>{clearTimeout(Pe),ae()})});let it;const ct=async ae=>{const Pe=we();Pe&&await Pe;const xe=ae&&ae.pivotMode!==!1&&Array.isArray(ae.pivotBy)&&ae.pivotBy.length>0?{request:ae,probe:null}:await Fe(ae);i(ae);let _e=T(xe.request,ie,ve.enabled);if(ie.group&&_e.grouped&&!_e.pivoted&&!_(re.executeGroupLevel)&&(x(`source.pushdown.group.method.${ke}`,`the ${ke} 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.`),_e=T(xe.request,{...ie,group:!1,aggregates:null},ve.enabled)),_e.pivoted&&!_(re.executePivotLevel)&&(_e=T(xe.request,{...ie,pivot:!1},ve.enabled),_e.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),_e.grouped&&!_e.pivoted&&!ie.group&&!_(re.executeGroupedAggregates)&&(x(`source.pushdown.group.aggregates.method.${ke}`,`the ${ke} 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\`.`),_e=T(xe.request,{...ie,aggregates:null},ve.enabled)),le=_e,_e.pivoted)return qe(_e,ae);if(_e.pivotReason&&rt(_e.pivotReason),_e.grouped)return ie.group?Ce(_e,ae):Be(_e,ae);const Qe=!!_e.groupReason&&!_e.full;Qe?x(`source.pushdown.group-unsupported.${ke}.${_e.groupReason}`,`pushdown:group-unsupported: the ${ke} adapter was not asked to group this query because ${_e.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.`):_e.groupReason&&x(`source.pushdown.group.${ke}.${_e.groupReason}`,`the ${ke} adapter was not asked to group this query because ${_e.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 ut=Ht=>Qe?{...Ht,[M]:!0}:Ht;if(!_e.needsAll){const Ht=xe.probe||await re.execute(_e.pushed,ae),Xt=Ht.rows||[];return B(Ht.pendingTotal)&&Ht.total===void 0?ut({rows:Xt,pendingTotal:nt(Ht.pendingTotal,F(_e.pushed))}):($e=null,!ie.total&&Ht.total===void 0?ut({rows:Xt}):ut({rows:Xt,total:Ht.total??Xt.length}))}const mt=_e.unpushed.filter(Ht=>!(Ht==="where"&&_e.residual.where&&_e.residual.where.anyConditioned));mt.length&&x(`source.pushdown.residual.${ke}.${mt.join(".")}`,`the ${ke} adapter cannot push ${mt.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 bt=F(_e.pushed);if(!fe||fe.key!==bt){const Ht=await J(await re.execute(_e.pushed,ae));$e=null;const Xt=Ht.rows||[];if(_e.full){const Je=typeof Ht.total=="number"?Math.max(Ht.total,Xt.length):Xt.length;if(Je>ve.maxRows)throw new Error(`[lattice] fullDataset refused: the ${ke} adapter's matching set is ${Je.toLocaleString()} rows, past the configured maxRows of ${ve.maxRows.toLocaleString()}. The whole set cannot be held client-side, so it is refused rather than truncated — a fraction shown as the whole would make every total and statistic silently wrong. Narrow the filter or raise maxRows.`);const at=Xt.length*$(Xt[0]);if(at>ve.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${ke} adapter's matching set is an estimated ${Math.round(at/(1024*1024)).toLocaleString()} MB across ${Xt.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(ve.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 Ht.total=="number"&&Xt.length<Ht.total){const Je=!!(_e.residual.filters||_e.residual.quick||_e.residual.sort&&_e.residual.sort.length);if(Je&&!De)throw new Error(`[lattice] the ${ke} adapter returned ${Xt.length} of ${Ht.total} matching rows when asked for the whole result, and the query has residual ${_e.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.`);Je?x(`source.pushdown.partial.residual.${ke}`,`the ${ke} adapter returned ${Xt.length} of ${Ht.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.${ke}`,`the ${ke} adapter returned ${Xt.length} of ${Ht.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}fe={key:bt,rows:Xt,total:typeof Ht.total=="number"?Ht.total:null}}let Rt=_e;if(_e.residual.where){const Ht=fe.total??fe.rows.length;if(Ht>=pe){k(_e.residual.where.names,ke,Ht,pe);const{where:Xt,...Je}=xe.request;Rt=T(Je,ie,ve.enabled),le=Rt}}const Dt=fe.total!==null&&fe.rows.length>=fe.total,Ct=S(fe.rows,{...Rt.residual,whole:Dt},Q.compute||{}),_t=ae.range?ae.range.start:0,tn=ae.range?ae.range.end:Ct.length;return ut({rows:Ct.slice(_t,tn),total:Ct.length})},ft=async(ae,Pe,Te)=>{const _e=Te&&Te.waitForPage&&it&&_(it.pageForegroundIdle)?it.pageForegroundIdle():Nt();_e&&await _e;const Ye=we();Ye&&await Ye;const Qe=T(ae,ie,ve.enabled);le=Qe;const ut=h(Pe,be),mt=Array.isArray(ae.groupBy)?ae.groupBy:[],bt=mt.length>0,Rt=!Qe.residual.filters&&!Qe.residual.quick,Dt=!bt||r(mt,ie.buckets);let Ct=ut.engine,_t=ut.client;if(ie.aggregates&&Ct.length){const at=ie.aggregates instanceof Set?ie.aggregates:new Set(Z(ie.aggregates)),St=Ct.filter(wt=>!at.has(wt.fn));St.length&&(Ct=Ct.filter(wt=>at.has(wt.fn)),_t=[...St.map(wt=>({...wt,reason:`the ${ke} adapter does not compute "${wt.fn}"`})),..._t])}const tn=at=>{_t=[...Ct.map(St=>({...St,reason:at})),..._t],Ct=[]};let Ht="";if(Ct.length&&!Rt){const at=Qe.residual.quick&&!Qe.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)";tn(at),bt&&(Ht=at)}else if(Ct.length&&!Dt){const at="a grouping key the engine cannot form forces all-client (no mixed provenance)";tn(at),Ht=at}let Xt={},Je;if(Ct.length&&(_(bt?re.executeGroupedAggregates:re.executeAggregates)?bt?Je=await re.executeGroupedAggregates(Qe.pushed,mt,Ct)||[]:Xt=await re.executeAggregates(Qe.pushed,Ct)||{}:(x(`source.pushdown.aggregates.${ke}${bt?".grouped":""}`,`the ${ke} adapter cannot compute ${bt?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),tn(`adapter cannot compute ${bt?"grouped ":""}aggregates`),bt&&(Ht=`the ${ke} adapter cannot compute grouped aggregates`))),bt){const at=Je!==void 0;at!==Qe.grouped&&(le={...Qe,grouped:at,groupReason:at?"":Ht||Qe.groupReason,unpushed:at?Qe.unpushed.filter(St=>St!=="group"):Qe.unpushed.includes("group")?Qe.unpushed:[...Qe.unpushed,"group"]})}return ye={engine:Ct,client:_t,...bt?{groupBy:mt}:{}},{values:Xt,engine:Ct,client:_t,...Je!==void 0?{groups:Je}:{}}},Tt=async ae=>{dt++;try{return await ct(ae)}finally{if(dt--,dt===0&&Pt.length){const Pe=Pt;Pt=[];for(const Te of Pe)Te()}}},pt=l(Q.edit),Oe=Q.edit&&typeof Q.edit=="object"&&_(Q.edit.commit);let Ae=Q.edit;if(pt&&!Oe)if(ie.mutate&&ie.mutate.update){const ae=Pe=>{if(!ie.mutate||!ie.mutate.update)throw new Error(`[lattice] the ${ke} 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 Te={kind:"update",key:String(Pe.key),patch:{[Pe.colId]:Pe.value}};return re.mutate(Te,Pe.request||{})};Ae={...Q.edit===!0?{}:Q.edit,commit:ae}}else x(`source.pushdown.readonly.${ke}`,`edit is enabled but the ${ke} adapter declares mutate: ${ie.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 ge=pt&&ie.mutate&&(ie.mutate.append||ie.mutate.delete)?{append:ie.mutate.append===!0,remove:ie.mutate.delete===!0,returning:ie.mutate.returning,mutate:(ae,Pe)=>re.mutate(ae,Pe||{})}:null,Le=async ae=>{const Pe=we();Pe&&await Pe;const{range:Te,signal:xe,export:_e,...Ye}=ae||{},Qe={...Ye,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:T(Qe,ie,ve.enabled),signal:xe}};async function*Me(ae,Pe={}){const{plan:Te,signal:xe}=await Le(ae),_e=Math.max(1,Math.floor(Number(Pe.pageSize))||5e3),Ye={signal:xe,stream:!0},Qe=ae&&ae.range&&Number.isFinite(Number(ae.range.start))&&Number.isFinite(Number(ae.range.end))?{start:Math.max(0,Number(ae.range.start)),end:Math.max(0,Number(ae.range.end))}:null;if(!Te.needsAll){const bt=Qe?Qe.start:0,Rt=Qe?Qe.end:1/0;for(let Dt=bt;Dt<Rt;Dt+=_e){i(Ye);const Ct=Math.min(Dt+_e,Rt),_t=await re.execute({...Te.pushed,range:{start:Dt,end:Ct}},Ye);_t&&B(_t.pendingTotal)&&_t.pendingTotal.then(null,()=>{});const tn=_t&&_t.rows||[];if(tn.length&&(yield tn),tn.length<Ct-Dt)return}return}i(Ye);const ut=await J(await re.execute({...Te.pushed,range:void 0},Ye));let mt=S(ut&&ut.rows||[],{...Te.residual,whole:!0},Q.compute||{});Qe&&(mt=mt.slice(Qe.start,Qe.end));for(let bt=0;bt<mt.length;bt+=_e)yield mt.slice(bt,bt+_e)}const He=async ae=>{const{plan:Pe,signal:Te}=await Le(ae);if(!Pe.needsAll&&ie.total){i({signal:Te});const _e=await J(await re.execute({...Pe.pushed,range:{start:0,end:0}},{signal:Te}));if(_e&&typeof _e.total=="number")return _e.total}let xe=0;for await(const _e of Me({...ae,range:void 0}))xe+=_e.length;return xe},ce=async ae=>{await we();const Pe=b(ae.filters||null,{tz:Q.timeZone,weekStartsOn:Q.weekStartsOn}),Te=ae.quick?String(ae.quick):"";return m(Pe,ie).residual||Te&&!ie.quick?null:re.facets({...ae,filters:Pe,quick:Te})};return it={...Q,edit:Ae,rowMutate:ge,mode:"remote",fetch:Tt,foregroundIdle:Nt,facetProvider:_(re.facets)?ce:void 0,aggregate:ft,countMatching:He,streamMatching:Me,capabilitiesOf:y,planQuery:T,wireFilters:b,resolveAggregatePlan:ae=>h(ae,be),STAT_PUSHDOWN:t,lastPlan:()=>le?{...le,...ye?{aggregates:N(ye)}:{},...$e?{total:{deferred:!0,state:$e.state,value:$e.value}}:{}}:null,fullFrame:Ve,counts:()=>({match:Ne,total:Ne,pending:!!$e&&$e.state==="pending"}),grandTotals:()=>je},it}}),We("packages/core/src/source/remote.js",function(e,D){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return N}});const P=D("packages/core/src/internal/lru.js").Lru,_=D("packages/core/src/internal/predicates.js").isFunction,Z=D("packages/core/src/internal/warn.js").warnOnce,x=D("packages/core/src/internal/schedule.js").settleDebounce,X=D("packages/core/src/source/abort.js"),U=X.createAbortScope,j=X.isAbortError,k=D("packages/core/src/source/blockcache.js"),b=k.BlockCache,a=k.DEFAULT_PAGE_SIZE,h=k.DEFAULT_MAX_CACHED_PAGES,r=D("packages/core/src/source/rows.js"),t=r.createRowFactory,o=r.groupKey,u=D("packages/core/src/source/filterwire.js"),d=u.wireFilters,s=u.querySignature,g=u.warnHostFilterNotApplied,n=D("packages/core/src/source/pagewindow.js").pageWindow,p=D("packages/core/src/source/memory.js").MemorySource,y=D("packages/core/src/compute/handle.js").valueComparator,c=D("packages/core/src/compute/pivot.js"),m=c.pivotKey,w=c.joinPath,v=c.DEFAULT_PATH_SEPARATOR,V=D("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,G=1,q=120,M=1e3;function O(C,S,F){for(let $=0;$<Math.max(C.length,S.length);$++){const W=C[$],K=S[$],I=W==null,B=K==null;if(I||B){if(I&&B)continue;return I?1:-1}const J=F(W,K);if(J!==0)return J}return 0}function T(C,S){return new N(C,S)}class A{constructor(S,F,$,W){this.path=S,this.keyPath=W||S,this.values=[],this.level=F,this.key=o(this.keyPath),this.cache=new b($),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 N{mode="remote";#e;#t;#n;#r;#s=new Map;#i=new Set;#o=U();#l;#a;#c=new Map;#u=[];#d=null;#f="";#h;#p=!1;#m=!1;#g=[];#b=!1;#y=0;#O="";#w=null;#A=-1;constructor(S,F){this.#e=S||{mode:"remote"},this.#t=F||{},_(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#D(),this.unfilteredIndices=()=>this.#W(),this.handleFor=J=>this.#V(J),this.display=()=>this.#x(),this.grandTotalRow=()=>this.#B(),this.unfilteredRows=()=>this.#I(),this.facetIndices=J=>this.#q(J));const $=this.#e.counts;_($)&&(this.matchCount=()=>this.#Y("match"),this.totalCount=()=>this.#Y("total"));const W=this.#e.grandTotals;_(W)&&(this.grandTotalRow=()=>this.#G());const K=this.#e.foregroundIdle;_(K)&&(this.foregroundIdle=()=>this.#he(K),this.#e.pageForegroundIdle=()=>this.#b?this.#he(K):null);const I=this.#e.facetProvider;_(I)&&(this.facetProvider=I);const B=this.#e;_(B.countMatching)&&_(B.streamMatching)&&(this.selectionQuery=()=>this.#H(),this.countMatching=J=>B.countMatching(J),this.streamMatching=(J,te)=>B.streamMatching(J,te),this.loadedRows=()=>this.#be(),this.resident=()=>this.#N()!==null),this.#n={pageSize:this.#e.pageSize||a,maxCachedPages:this.#e.maxCachedPages||h},this.#l=t(this.#t),this.#a=new P(this.#n.pageSize*4),this.#h=x((J,te)=>this.#T(J,te),q),this.#r=new A([],0,this.#n),this.#s.set(this.#r.key,this.#r),this.#f=this.#ve(),_(this.#e.fetch)||Z("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#me()}count(){const S=this.#S();return S?S.length:this.#v()}#v(){const S=this.#N();return S?S.count():(this.#ee(),this.#xe(this.#r))}#P(){if(this.#N())return!0;const S=F=>{if(F.count===null&&!F.complete)return!1;for(const $ of F.children.values())if(this.#ke($.key,this.#Te($))&&!S($))return!1;return!0};return S(this.#r)}pageInfo(){const S=this.#S(),F=this.totalPending();if(!S){const $=this.#v();return{page:0,pageSize:0,total:this.#P()?$:null,pageCount:1,counting:F}}return{page:S.page,pageSize:S.pageSize,total:S.total,pageCount:S.pageCount,counting:F||S.total===null&&this.#o.size>0&&this.#r.cache.loadedExtent()===0}}#S(){const S=this.#v(),F=n(this.#$("pageSize",0),this.#$("page",0),S,this.#P());if(!F)return this.#O="",null;const $=`${this.#y}:${F.offset}:${F.length}`;return $!==this.#O&&!this.#p&&(this.#O=$,F.length>0&&!this.#N()&&this.#T(F.offset,F.offset+F.length-1)),F}at(S){const F=this.#S();if(F){if(S<0||S>=F.length)return;const $=this.#C(F.offset+S);return $&&($.index=S),$}return this.#C(S)}#C(S){const F=this.#N();if(F)return F.at(S);if(this.#ee(),S<0||S>=this.#v())return;const $=this.#Z(this.#r,S);if(!$)return;const W=this.#z($.node,$.local);return W&&(W.index=S),W||this.#l.skeleton(S,$.node.level,$.node.cache.erroredAt($.local))}byKey(S){const F=this.#N();if(F)return F.byKey(S);const $=this.#c.get(S);if(!$)return;const W=$.lastIndexOf(":"),K=this.#s.get($.slice(0,W));return K&&this.#z(K,Number($.slice(W+1)))||void 0}loaded(S){const F=this.#S();if(F){if(S<0||S>=F.length)return!1;S+=F.offset}const $=this.#N();if($)return $.loaded(S);if(S<0||S>=this.#v())return!1;const W=this.#Z(this.#r,S);return!!W&&W.node.cache.rowLoaded(W.local)}hint(S,F){if(this.#p)return;this.#b=!0;const $=this.#ee();let W=Math.max(0,Math.floor(S)),K=Math.max(W,Math.floor(F));const I=this.#S();if(I){if(I.length===0)return;W=I.offset,K=I.offset+I.length-1}for(const[B,J]of this.#E(W,K)){B.cache.protect(J.min,J.max);for(const te of B.cache.evict())this.#Ee(B,te)}this.#h(W,K),$&&this.#h.flush()}#E(S,F){const $=this.#v(),W=new Map;for(let K=S;K<=F&&K<$;K++){const I=this.#Z(this.#r,K);if(!I)continue;const B=W.get(I.node);B?(B.min=Math.min(B.min,I.local),B.max=Math.max(B.max,I.local)):W.set(I.node,{min:I.local,max:I.local})}return W.size||W.set(this.#r,{min:S,max:S}),W}#T(S,F){if(!this.#p)for(const[$,W]of this.#E(S,F)){$.cache.protect(W.min,W.max);const K=$.cache.blockOf(W.min),I=$.cache.blockOf(W.max);for(let B=K;B<=I&&!($.count!==null&&B*$.cache.pageSize>=$.count);B++)$.cache.has(B)||this.#de($,B)}}apply(S){const F={added:[],updated:[],removed:[]};if(!S)return F;if(S.update)for(const $ of S.update){const W=this.#c.get(this.#l.keyOf($,-1));if(!W)continue;this.#a.delete(W);const K=W.lastIndexOf(":"),I=this.#s.get(W.slice(0,K));if(!I)continue;const B=Number(W.slice(K+1)),J=I.cache.blockOf(B);if(!I.cache.loaded(J))continue;const{start:te}=I.cache.rangeOf(J),Q=[];for(let ie=te;ie<te+I.cache.pageSize;ie++){const ue=I.cache.rowAt(ie);if(ue===void 0)break;Q.push(ie===B?$:ue)}I.cache.fill(J,Q);const re=this.#z(I,B);re&&F.updated.push(re)}return(S.add&&S.add.length||S.remove&&S.remove.length)&&this.reload({keepExpanded:!0}),F}reload(S){this.#o.abortAll("reload"),this.#h.cancel(),S&&S.keepExpanded===!1&&this.#i.clear(),this.#pe(),this.#_("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#o.abortAll("destroyed"),this.#pe(),this.#s.clear(),this.#i.clear(),this.#w&&_(this.#w.destroy)&&this.#w.destroy(),this.#w=null}expand(S){this.#i.has(S)||(this.#i.add(S),this.#_("group:toggled",{key:S,expanded:!0}),this.#_("model:changed",{reason:"expand",key:S}))}collapse(S){this.#i.delete(S)&&(this.#_("group:toggled",{key:S,expanded:!1}),this.#_("model:changed",{reason:"collapse",key:S}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#u}pivot(){this.#ee();const S=this.#d;if(!S||!S.keys.size||!this.#$("pivotBy",[]).length)return null;if(!S.result){const F=y((this.#t.config||{}).locale),$=[...S.keys.entries()].sort((K,I)=>O(K[1],I[1],F)),W=$.map(([K])=>K);S.result={keys:$.map(([,K])=>K),paths:W,fields:this.#Pe(W),groupPaths:[],columns:W.length*Math.max(1,this.#ye().length),values:S.cells,cells:S.cells,error:null}}return S.result}invalidateHandles(){this.#w&&(_(this.#w.invalidateHandles)&&this.#w.invalidateHandles(),_(this.#w.invalidate)&&this.#w.invalidate("filter"))}#M(){const S=this.#e.fullFrame;return _(S)?S():null}#N(){const S=this.#M();return S?(this.#w||(this.#w=new p({mode:"memory"},this.#R())),S.version!==this.#A&&(this.#w.setRows(S.rows),this.#A=S.version),this.#w):null}#R(){const S=this.#t,F=S.state||{};return{...S,state:{...F,page:()=>0,pageSize:()=>0}}}#D(){const S=this.#N();return S?S.filteredIndices():new Uint32Array(0)}#W(){const S=this.#N();return S?S.unfilteredIndices():new Uint32Array(0)}#V(S){const F=this.#N();return F?F.handleFor(S):void 0}#x(){const S=this.#N();return S?S.display():[]}#q(S){const F=this.#N();return F&&_(F.facetIndices)?F.facetIndices(S):new Uint32Array(0)}#B(){const S=this.#N();return S&&_(S.grandTotalRow)?S.grandTotalRow():null}#Y(S){const F=this.#N();if(F){const I=S==="match"?F.matchCount:F.totalCount;if(_(I))return I.call(F)}const $=this.#e.counts,W=_($)?$():null,K=W?W[S]:null;return typeof K=="number"?K:this.#v()}#G(){const S=this.#N();if(S&&_(S.grandTotalRow))return S.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const $=this.#e.grandTotals,W=_($)?$():null;return!W||!W.totals?null:this.#l.grandTotal(W.totals,W.leafCount||0)}#I(){const S=this.#N();if(S&&_(S.unfilteredRows))return S.unfilteredRows();const F=[],$=this.count();for(let W=0;W<$;W++){const K=this.at(W);K&&F.push(K)}return F}#H(){const S=this.#$("quick",""),F={protocol:G,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:d(this.#$("filters",null),this.#fe()),sort:this.#$("sort",[]),context:this.#$("context",null)};S&&(F.quick=S);const $=this.#$("where",null);return $&&$.active&&(F.where=$),F}#be(){const S=this.#$("groupBy",[]).length,F=[];for(const $ of this.#s.values())if(!($.level!==S&&!$.flat))for(const W of $.cache.ids()){if(!$.cache.loaded(W))continue;const{start:K,end:I}=$.cache.rangeOf(W);for(let B=K;B<I&&$.cache.rowLoaded(B);B++){const J=this.#z($,B);J&&!J.group&&F.push(J)}}return F}loadedCount(){const S=this.#N();if(S){const W=S.matchCount();return typeof W=="number"?W:S.count()}this.#ee();const F=this.#$("groupBy",[]).length;let $=0;for(const W of this.#s.values())if(!(W.level!==F&&!W.flat))for(const K of W.cache.ids()){if(!W.cache.loaded(K))continue;const I=W.cache.fillOf(K);typeof I=="number"&&($+=I)}return $}residentRows(){const S=this.#N();return S?S.display():this.#$("groupBy",[]).length>0?null:(this.#ee(),this.#be())}#ce(S,F,$){const{start:W,end:K}=S.cache.rangeOf(F),I=this.#$("groupBy",[]),B=this.#$("pivotBy",[]),J=this.#$("quick",""),te=this.#ye(),Q={protocol:G,range:{start:W,end:K},groupPath:S.path,groupValues:S.values,groupBy:I,totals:te,totalFns:this.#Ae(te),pivotBy:B,pivotMode:B.length>0,filters:d(this.#$("filters",null),this.#fe()),sort:this.#$("sort",[]),context:this.#$("context",null),signal:$};J&&(Q.quick=J);const re=this.#$("where",null);return re&&re.active&&(Q.where=re),Q}async#de(S,F){if(!_(this.#e.fetch))return;if(!this.#m){this.#m=!0;const I=this.#g;this.#g=[],queueMicrotask(()=>{for(const B of I)B()})}const $=this.#o.begin(`${S.key}:${F}`);S.cache.begin(F,$);const W=this.#f,{start:K}=S.cache.rangeOf(F);try{const I=await this.#e.fetch(this.#ce(S,F,$.signal));if(!$.current||W!==this.#f||this.#p)return;$.settle();const B=I&&I.rows||[];if(!!(I&&I[V])&&!S.flat){S.flat=!0,S.children.clear();for(const[re,ie]of[...this.#c])ie.startsWith(`${S.key}:`)&&(this.#a.delete(ie),this.#c.delete(re))}S.cache.fill(F,B),S.failed=!1;for(let re=0;re<B.length;re++)this.#a.delete(`${S.key}:${K+re}`);const te=I&&typeof I.count=="number"?I.count:I&&typeof I.total=="number"?I.total:null,Q=I&&_(I.pendingTotal?.then)?I.pendingTotal:null;te!==null?(S.count=te,S.complete=!0):B.length<S.cache.pageSize?(S.count=K+B.length,S.complete=!0):Q&&(S.counting=!0,S.announced=null),I&&Array.isArray(I.pivotFields)&&this.#Re(I.pivotFields),I&&I.pivot&&typeof I.pivot=="object"&&this.#se(I.pivot),this.#_("model:changed",{reason:"page",groupPath:S.path,block:F}),this.#_("rows:changed",{companion:!0,reason:"page",groupPath:S.path,block:F}),this.#re(S),Q&&this.#Me(S,Q,W)}catch(I){if($.settle(),j(I))return;S.cache.failed(F,I),S.failed=!0;const{end:B}=S.cache.rangeOf(F);for(let J=K;J<B;J++)this.#a.delete(`${S.key}:${J}`);this.#_("model:changed",{reason:"page-error",groupPath:S.path,block:F}),this.#_("source:error",{error:I,groupPath:S.path,block:F})}}async#Me(S,F,$){let W;try{W=await F}catch(K){if($!==this.#f||this.#p)return;S.counting=!1,j(K)||(S.failed=!0),j(K)||this.#_("source:error",{error:K,groupPath:S.path});return}$!==this.#f||this.#p||(S.counting=!1,typeof W=="number"&&(S.count=W,S.complete=!0,this.#re(S),this.#_("model:changed",{reason:"total",count:W,groupPath:S.path})))}#re(S){typeof S.count!="number"||!S.complete||S.announced!==S.count&&(S.announced=S.count,this.#_("source:total",{total:S.count,groupPath:S.path}))}#he(S){if(this.#p)return null;this.#ee();const F=this.#m?null:new Promise(B=>{this.#g.push(B),setTimeout(B,M)}),$=S();if(!F&&!$)return null;const W=(async()=>{F&&await F;for(let B=S();B;B=S())await B})();let K;const I=new Promise(B=>{K=setTimeout(B,M)});return Promise.race([W,I]).then(()=>clearTimeout(K))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#N())return!1;this.#ee();const S=this.#r;return S.count===null&&!S.complete&&S.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#Re(S){S.length===this.#u.length&&S.every((F,$)=>F===this.#u[$])||(this.#u=S,this.#_("column:pivoted",{pivotFields:S,remote:!0}))}#_e(){const S=this.#t.config||{};return S.pivot&&S.pivot.separator||v}#Pe(S){const F=this.#_e(),$=this.#ye();if(!$.length)return S.slice();const W=[];for(const K of S)for(const I of $)W.push(`${K}${F}${I}`);return W}#se(S){const F=this.#_e();this.#d||(this.#d={keys:new Map,cells:new Map,result:null});const $=this.#d;let W=!1;const K=B=>{const J=Array.isArray(B)?B:[B],te=w(J,F);return $.keys.has(te)||($.keys.set(te,J),W=!0),te},I=this.#$("groupBy",[]).length>0;for(const B of Array.isArray(S.axis)?S.axis:[])K(B);for(const B of Array.isArray(S.cells)?S.cells:[]){if(!B||typeof B!="object")continue;const J=K(B.pivot);if(I&&!(Array.isArray(B.group)&&B.group.length))continue;const te=w(Array.isArray(B.group)?B.group:[],F);for(const[Q,re]of Object.entries(B.values||{}))$.cells.set(m(te,J,Q),re)}$.result=null,W&&this.#Re((this.pivot()||{fields:[]}).fields)}#xe(S){let F=this.#oe(S);for(const $ of S.children.values())this.#ke($.key,this.#Te($))&&(F+=this.#xe($));return F}#oe(S){if(S.count!==null)return S.count;const F=S.cache.loadedExtent();return S.complete?F:S.row&&S.row.leafCount>0?S.level>=this.#$("groupBy",[]).length?Math.max(F,S.row.leafCount):F===0?1:Math.min(F+S.cache.pageSize,Math.max(F,S.row.leafCount)):F+S.cache.pageSize}#Z(S,F){let $=F,W=0;const K=[...S.children.entries()].filter(([,B])=>this.#ke(B.key,this.#Te(B))).sort((B,J)=>B[0]-J[0]);for(const[B,J]of K){const te=B-W+1;if($<te)return{node:S,local:W+$};$-=te,W=B+1;const Q=this.#xe(J);if($<Q)return this.#Z(J,$);$-=Q}const I=this.#oe(S);return W+$<I?{node:S,local:W+$}:null}#z(S,F){const $=`${S.key}:${F}`,W=this.#a.get($);if(W)return W.group===!0?this.#J(W):W;const K=S.cache.rowAt(F);if(K===void 0)return null;const I=this.#$("groupBy",[]);let B;if(S.level<I.length&&!S.flat){const J=I[S.level],te=this.#d!==null&&S.level===I.length-1&&this.#$("pivotBy",[]).length>0,Q=this.#te(K,J),re=Q==null,ie=[...S.path,re?"":String(Q)],ue=[...S.keyPath,re?null:String(Q)];if(B=this.#l.group({path:ie,keyPath:ue,column:J,value:Q,level:S.level,parent:S.row,leafCount:Number(K.leafCount)||0,expanded:te?!1:this.#ke(o(ue),{key:o(ue),column:J,value:Q,level:S.level,path:ie}),...te?{hasChildren:!1}:{}}),B.totals=this.#U(K),B.data=K,!te){let ke=this.#s.get(B.key);ke?ke.row=B:(ke=new A(ie,S.level+1,this.#n,ue),ke.row=B,this.#s.set(ke.key,ke)),ke.values=[...S.values,Q],S.children.set(F,ke)}}else B=this.#l.leaf(K,F,S.level,S.row);return this.#a.set($,B),this.#c.set(B.key,$),B}#U(S){const F=S||{};if(F.totals&&typeof F.totals=="object")return F.totals;const $={};for(const W of this.#ye())Object.hasOwn(F,W)&&($[W]=F[W]);return $}#J(S){const F=this.#s.get(S.key);if(!F||F.row!==S||S.hasChildren===!1)return S;const $=this.#ke(S.key,this.#Te(F));return S.expanded!==$&&(S.expanded=$),S}#Ee(S,F){const{start:$,end:W}=S.cache.rangeOf(F);for(let K=$;K<W;K++){const I=`${S.key}:${K}`,B=this.#a.peek(I);B&&this.#c.delete(B.key),this.#a.delete(I)}}#ee(){const S=this.#ve();return S===this.#f?!1:(this.#f=S,this.#o.abortAll("query"),this.#pe(),this.#m=!1,this.#_("model:changed",{reason:"query"}),!0)}#pe(){for(const S of this.#s.values())S.cache.clear(),S.count=null,S.complete=!1,S.announced=null,S.counting=!1,S.failed=!1,S.children.clear(),S.flat=!1;this.#a.clear(),this.#c.clear(),this.#y++,this.#d=null}#ve(){const S=this.#$("where",null);return`${s({filters:this.#$("filters",null),sort:this.#$("sort",[]),quick:this.#$("quick",""),groupBy:this.#$("groupBy",[]),pivotBy:this.#$("pivotBy",[]),context:this.#$("context",null)})}|${S?S.version:0}`}#ke(S,F){const $=this.#$("expanded",null);return $?_($.has)?$.has(S,F):Array.prototype.includes.call($,S):this.#i.has(S)}#Te(S){if(S.row)return{key:S.key,column:S.row.column,value:S.row.value,level:S.level-1,path:S.path}}#ye(){const S=this.#$("totals",[]);if(S&&S.length)return[...S];const F=this.#t.columns;return!F||!_(F.all)?[]:F.all().filter($=>!!$.total).map($=>$.id)}#Ae(S){const F=this.#t.columns,$={};if(!F||!_(F.get))return $;for(const W of S){const K=F.get(W);if(!K)continue;const I=K.groupTotal!=null?K.groupTotal:K.total;typeof I=="string"?$[W]=I:I&&typeof I=="object"&&typeof I.fn=="string"&&($[W]={...I})}return $}#te(S,F){const $=this.#t.columns,W=$&&_($.get)?$.get(F):void 0;return W&&_(W.getValue)?W.getValue(S):S?.[F]}#me(){g(this.#t)}#fe(){const S=this.#t.config||{};return{tz:S.timeZone,weekStartsOn:S.weekStartsOn}}#$(S,F){const $=this.#t.state;if($&&_($[S])){const W=$[S]();return W??F}return F}#_(S,F){const $=this.#t.emit;_($)&&$(S,F)}}}),We("packages/core/src/source/gapbuffer.js",function(e,D){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return P}});const ne=64;class P{#e;#t=0;#n=0;constructor(_=ne){this.#e=new Uint32Array(Math.max(1,_)),this.#n=this.#e.length}static from(_,L=ne){const Z=new P(_.length+Math.max(1,L));return Z.#e.set(_,0),Z.#t=_.length,Z.#n=Z.#e.length,Z}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(_){return _<0||_>=this.length?0:_<this.#t?this.#e[_]:this.#e[_+(this.#n-this.#t)]}insert(_,L){const Z=_<0?0:_>this.length?this.length:_;this.#r(Z),this.#t===this.#n&&this.#s(),this.#e[this.#t++]=L}push(_){this.insert(this.length,_)}removeAt(_){return!Number.isInteger(_)||_<0||_>=this.length?!1:(this.#r(_),this.#n++,!0)}toArray(){const _=new Uint32Array(this.length);return _.set(this.#e.subarray(0,this.#t),0),_.set(this.#e.subarray(this.#n),this.#t),_}clear(){this.#t=0,this.#n=this.#e.length}#r(_){if(_!==this.#t)if(_<this.#t){const L=this.#t-_;this.#e.copyWithin(this.#n-L,_,this.#t),this.#t=_,this.#n-=L}else{const L=_-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+L),this.#t=_,this.#n+=L}}#s(){const _=this.#e.length-this.#n,L=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+ne));L.set(this.#e.subarray(0,this.#t),0),L.set(this.#e.subarray(this.#n),L.length-_),this.#e=L,this.#n=L.length-_}}}),We("packages/core/src/store/ingest.js",function(e,D){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return d}});const ne=D("packages/core/src/internal/schedule.js"),P=ne.now,Y=ne.nextFrame,_=D("packages/core/src/internal/warn.js"),L=_.infoOnce,Z=_.warnOnce,x=D("packages/core/src/internal/predicates.js").isFunction,U=D("packages/core/src/internal/paths.js").pathGetter,k=D("packages/core/src/store/columnstore.js").ColumnStore,b=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function a(s,g={}){if(g.multi)return"multi";if(s.length===0)return"object";let i=0,n=0,f=0,p=0,l=0;for(let c=0;c<s.length;c++){const m=s[c];typeof m=="number"?i++:typeof m=="boolean"?n++:typeof m=="string"?f++:m instanceof Date?p++:Array.isArray(m)&&l++}const y=s.length;return i===y?"float64":n===y?"bitset":p===y?"float64":f===y?"text":l===y?"multi":"object"}function h(s,g,i){return g<=0||s<i*g?"dictionary":"object"}function r(s,g,i){const n=new Map,f=new Map;for(const G of s){if(G.computed)continue;const q=x(G.read)?G.read:U(G.field||G.id);f.set(G.id,q),n.set(G.id,q)}const p=g?.order??[],l=g?.fns??{},y=g?.deps??{},c=g?.wrapDeps??null,m=p.filter(G=>x(l[G])),w=m.some(G=>y[G]==="*");let v=new WeakMap;const E=G=>{const q={};if(w)for(const[M,O]of f)q[M]=O(G);for(const M of m){const O=y[M];let T;if(O==="*")T=q;else{T={};const A=O||[];for(let N=0;N<A.length;N++){const C=A[N];T[C]=C in q?q[C]:f.get(C)?.(G)}}q[M]=l[M](c?c(T,M):T,{data:G,row:null,column:null,grid:null,context:i})}return q},V=G=>{if(G===null||typeof G!="object"&&typeof G!="function")return E(G);let q=v.get(G);return q===void 0&&(q=E(G),v.set(G,q)),q};for(const G of m)n.set(G,q=>V(q)[G]);return{readers:n,reset(){v=new WeakMap}}}class t{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(g,i){this.spec=g,this.read=i,this.kind="object",this.inferred=!1,this.nullable=g.nullable!==!1}}class o{#e;#t=[];#n=null;#r;#s=0;#i;#o=!1;#l=!1;#a=0;#c;constructor(g,i={},n={}){this.#e=Array.isArray(g)?g:Array.from(g||[]),this.#i={...b,...n};const f=i.columns??[];this.#r=r(f,i.computed??null,i.context),this.#c=this.#e.length>=this.#i.columnarBelow,this.#u(f,i.computed??null),this.#n=new k(this.#t.map(p=>({id:p.spec.id,kind:p.kind,nullable:p.nullable,read:p.read,dictionary:p.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#o||this.#l}get progress(){return this.#s}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const g=P(),{chunkMs:i,chunkRows:n}=this.#i,f=this.#e.length;do{const p=Math.min(this.#s+n,f);this.#n.append(this.#e.slice(this.#s,p)),this.#d(this.#s,p),this.#s=p,this.#r.reset(),this.#h(!1)}while(this.#s<f&&P()-g<i);return this.#a+=P()-g,this.#i.onProgress?.({loaded:this.#s,total:f}),this.#s>=f?(this.#h(!0),this.#o=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(g=>({id:g.spec.id,kind:g.kind,nullable:g.nullable,read:g.read,dictionary:g.spec.dictionary})),decisions:this.#t.map(g=>({id:g.spec.id,kind:g.kind,nullable:g.nullable,inferred:g.inferred,distinct:g.candidate||g.change?this.#f(g):null,change:g.change,reason:g.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#u(g,i){const n=this.#e,f=Math.min(this.#i.sampleSize,n.length),p=this.#i.dictionaryRatio,l=i?.pure instanceof Set?i.pure:new Set(i?.pure??i?.order??[]);for(const y of g){if(!y||!y.id)continue;if(y.computed&&(y.pure===!1||i&&!l.has(y.id))){Z(`ingest.impure.${y.id}`,`column "${y.id}" is an impure computed column and is not materialised into the store`);continue}const c=this.#r.readers.get(y.id)??(x(y.read)?y.read:U(y.field||y.id)),m=new t(y,c);if(y.kind)m.kind=y.kind,m.reason="declared by the caller";else if(y.dictionary)m.kind=y.multi?"multi":"dictionary",m.reason="value table supplied (lookup column)";else{const w=[];for(let E=0;E<f&&w.length<this.#i.sampleSize;E++){const V=c(n[E]);V!=null&&w.push(V)}m.inferred=!0;const v=a(w,{multi:y.multi});if(v==="text"){const E=new Set(w).size;m.kind=h(E,w.length,p),m.candidate=this.#c,m.reason=`sampled ${E} distinct in ${w.length}`}else m.kind=v,m.reason=`inferred from ${w.length} sampled values`,v==="object"&&w.length&&L(`ingest.mixed.${y.id}`,`column "${y.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);m.kind==="object"&&m.candidate&&(m.distinct=new Set(w))}this.#t.push(m)}}#d(g,i){const n=this.#e;for(const f of this.#t){if(!f.candidate||!f.distinct)continue;const p=f.distinct;for(let l=g;l<i;l++){const y=f.read(n[l]);y!=null&&p.add(y)}}}#f(g){if(g.distinct)return g.distinct.size;const i=this.#n.column(g.spec.id);return i?.dict?i.dict.size:0}#h(g){const i=this.#i.dictionaryRatio,n=this.#e.length;for(const f of this.#t){if(!f.candidate)continue;const p=this.#f(f);if(f.kind==="dictionary"&&p>=i*n){const l=this.#n.column(f.spec.id);f.distinct=new Set(l?.dict?l.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${p} distinct values is at or above ${i*100}% of ${n} rows`;continue}if(f.kind==="object"&&p>=i*n){f.candidate=!1,f.distinct=null,f.reason=`${p} distinct values is at or above ${i*100}% of ${n} rows`;continue}g&&f.kind==="object"&&p<i*n&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${p} distinct values is below ${i*100}% of ${n} rows`,f.distinct=null),g&&(f.candidate=!1)}}}async function u(s,g={},i={}){const n=new o(s,g,i),f=i.scheduler?.frame??Y;for(;n.slice();)await new Promise(p=>{f(p)});return n.result()}function d(s,g={},i={}){const n=new o(s,g,{...i,chunkMs:1/0});for(;n.slice(););return n.result()}}),We("packages/core/src/store/columnpack.js",function(e,D){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return h}});const P=D("packages/core/src/internal/paths.js").pathGetter,Y=D("packages/core/src/store/ingest.js"),_=Y.inferKind,L=Y.decideText,Z=Y.INGEST_DEFAULTS,x=D("packages/core/src/store/columnstore.js").toFloat,X=new Set(["float64","int32","bitset","dictionary","object","multi"]);function U(r){if(!Array.isArray(r)||r.length===0)return!1;for(const t of r)if(!t||typeof t.id!="string"||typeof t.field!="string"||t.field===""||t.kind&&!X.has(t.kind))return!1;return!0}function j(r){const t=x(r);return Number.isFinite(t)?t|0:0}function k(r){return r==null?[]:Array.isArray(r)?r:[r]}function b(r,t,o,u){if(r.kind)return r.kind;const d=[];for(let i=0;i<t.length&&d.length<Z.sampleSize;i++){const n=t[i];n!=null&&d.push(n)}const s=_(d,{multi:r.multi});if(s!=="text")return s;const g=new Set(d).size;return L(g,d.length,u)}function a(r,t,o={}){const u=t.length|0,d=o.dictionaryRatio??Z.dictionaryRatio,s=[];for(const g of r){const i=P(g.field||g.id),n=g.nullable!==!1,f=new Array(u);for(let m=0;m<u;m++){const w=i(t[m]);f[m]=w===void 0?null:w}const p=b(g,f,u,d),l=n?new Uint8Array(u+7>>3):null,y=m=>{l&&(l[m>>3]|=1<<(m&7))};let c;switch(p){case"float64":{const m=new Float64Array(u);for(let w=0;w<u;w++){const v=f[w],E=v===null;E||y(w),m[w]=E?NaN:x(v)}c={id:g.id,kind:p,nullable:n,values:m,presence:l,offsets:null,table:null};break}case"int32":{const m=new Int32Array(u);for(let w=0;w<u;w++){const v=f[w],E=v===null;E||y(w),m[w]=E?0:j(v)}c={id:g.id,kind:p,nullable:n,values:m,presence:l,offsets:null,table:null};break}case"bitset":{const m=new Uint8Array(u+7>>3);for(let w=0;w<u;w++){const v=f[w],E=v===null;E||y(w),!E&&v&&(m[w>>3]|=1<<(w&7))}c={id:g.id,kind:p,nullable:n,values:m,presence:l,offsets:null,table:null};break}case"dictionary":{const m=new Uint32Array(u),w=[],v=new Map;for(let E=0;E<u;E++){const V=f[E];if(V===null){m[E]=0;continue}y(E);let G=v.get(V);G===void 0&&(G=w.length,w.push(V),v.set(V,G)),m[E]=G}c={id:g.id,kind:p,nullable:n,values:m,presence:l,offsets:null,table:w};break}case"multi":{const m=[],w=new Map,v=new Uint32Array(u+1),E=[];for(let V=0;V<u;V++){const G=f[V];v[V]=E.length,G===null||y(V);const M=k(G);for(let O=0;O<M.length;O++){const T=M[O];let A=w.get(T);A===void 0&&(A=m.length,m.push(T),w.set(T,A)),E.push(A)}}v[u]=E.length,c={id:g.id,kind:p,nullable:n,values:Int32Array.from(E),presence:l,offsets:v,table:m};break}default:{const m=new Array(u);for(let w=0;w<u;w++){const v=f[w];v!==null&&y(w),m[w]=v}c={id:g.id,kind:"object",nullable:n,values:m,presence:l,offsets:null,table:null};break}}s.push(c)}return{count:u,columns:s}}function h(r){const t=[];if(!r||!Array.isArray(r.columns))return t;const o=u=>{ArrayBuffer.isView(u)&&u.buffer&&!t.includes(u.buffer)&&t.push(u.buffer)};for(const u of r.columns)o(u.values),o(u.presence),o(u.offsets);return t}}),We("packages/core/src/source/stream.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return A}});const P=D("packages/core/src/internal/lru.js").Lru,_=D("packages/core/src/internal/predicates.js").isFunction,L=D("packages/core/src/internal/schedule.js"),Z=L.now,H=L.nextFrame,x=L.cancelFrame,X=L.whenIdle,j=D("packages/core/src/internal/compare.js").defaultCompare,k=D("packages/core/src/internal/warn.js"),b=k.warnOnce,a=k.infoOnce,r=D("packages/core/src/internal/paths.js").getPath,t=D("packages/core/src/source/abort.js"),o=t.createAbortScope,u=t.isAbortError,d=D("packages/core/src/source/rows.js"),s=d.createRowFactory,g=d.lazyRowView,n=D("packages/core/src/source/gapbuffer.js").GapBuffer,p=D("packages/core/src/source/memory.js").createMemorySource,y=D("packages/core/src/source/filterwire.js").querySignature,m=D("packages/core/src/store/columnpack.js").isPortableSchema,w=25e4,v=Symbol("lattice.stream.storeBacked"),E=8,V=.1,G=1e3,q=50;function M(N){return Math.min(G,Math.max(q,Math.floor(N/4)))}function O(N){if(N instanceof Date)return N.getTime();if(typeof N=="number")return Number.isFinite(N)?N:NaN;if(typeof N=="string"){const C=N.trim();if(!C)return NaN;const S=Date.parse(C);return Number.isNaN(S)?Number(C):S}return NaN}function T(N,C){return new A(N,C)}class A{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#s=[];#i=null;#o;#l;#a=new Map;#c=o();#u={loaded:0,estimated:void 0};#d=null;#f=0;#h=0;#p=0;#m=0;#g=null;#b=null;#y=null;#O=!1;#w=!1;#A=!1;#v=!1;#P="";#S=0;#C=0;#E=0;#T=null;#M=1/0;#N=!1;#R=null;#D=null;#W=null;#V=null;#x=!1;#q=0;#B=0;#Y=!1;constructor(C,S){this.#e=C||{mode:"stream"},this.#t=S||{},this.#o=s(this.#t),this.#l=new P(4096),this.#P=this.#Xe();const F=(this.#t.config||{}).ingest;this.#x=!!F&&F.retainSource===!1,_(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 $=Number(this.#e.poll);Number.isFinite($)&&$>0&&(this.#V=setInterval(()=>{this.#v||this.reload()},$),this.#V&&_(this.#V.unref)&&this.#V.unref()),this.#I()}#G(){const C=Number(this.#e.maxAge);return Number.isFinite(C)&&C>0?C:0}#I(){const C=this.#G();if(!C)return;const S=this.#e.ageBy;_(S)?this.#D=S:typeof S=="string"&&S?this.#D=F=>r(F,S):this.#D=null,this.#T=[],this.#R=setInterval(()=>{this.#v||this.#H()&&(this.#Ee(),this.#_())},M(C)),this.#R&&_(this.#R.unref)&&this.#R.unref()}#H(){const C=this.#G();return!C||!this.#T?!1:this.#N?!0:this.#M<Date.now()-C*(1+V)}#be(C,S){if(!this.#T)return;const F=this.#D?O(this.#D(S)):Date.now();this.#T[C]=F,Number.isNaN(F)||(F<this.#M&&(this.#M=F),F<Date.now()-this.#G()&&(this.#N=!0))}#ce(){return this.#Oe("groupBy",[]).length>0?!0:!!this.#Oe("pivotMode",!1)&&this.#Oe("pivotBy",[]).length>0}#de(){if(this.#g||this.#v)return;const C=this.#ce();if(C&&!this.#b){this.#b=p({mode:"memory",rows:this.#n},this.#Me()),this.#O=!1;return}!C&&this.#b&&(this.#b.destroy(),this.#b=null)}#Me(){if(this.#y)return this.#y;const C=this,S={liveIndices:()=>C.#re(),live:F=>C.#n[F]!==void 0,source:F=>C.#ie(F),get physical(){return C.#n.length}};return this.#x&&(S.column=F=>{const $=C.#t.store;return $&&_($.column)?$.column(F):void 0}),this.#y=Object.create(this.#t,{store:{value:S,enumerable:!0,configurable:!0}}),this.#y}#re(){const C=new Uint32Array(this.#n.length);let S=0;for(let F=0;F<this.#n.length;F++)this.#n[F]!==void 0&&(C[S++]=F);return C.subarray(0,S)}#he(){return this.#g?this.#g:this.#b?(this.#O&&(this.#O=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(C="filter"){if(this.#g){this.#g.invalidate(C);return}this.#de(),this.#b&&this.#b.invalidate(C),(C==="filter"||C==="sort")&&this.#ke()}count(){const C=this.#he();return C?C.count():this.#r?this.#r.length:this.#S}matchCount(){const C=this.#he();return C&&_(C.matchCount)?C.matchCount():this.#r?this.#r.length:this.#S}totalCount(){const C=this.#he();return C&&_(C.totalCount)?C.totalCount():this.#S}unfilteredRows(){const C=this.#he();if(C&&_(C.unfilteredRows))return C.unfilteredRows();const S=[];for(let F=0;F<this.#n.length;F++){if(!this.#n[F])continue;const $=this.#je(F);$&&S.push($)}return S}at(C){const S=this.#he();if(S)return S.at(C);if(C<0||C>=this.count())return;const F=this.#r?this.#r.at(C):C,$=this.#je(F);return $.index=C,$}byKey(C){const S=this.#he();if(S)return S.byKey(C);const F=this.#a.get(C);return F===void 0?void 0:this.#je(F)}leavesOf(C){const S=this.#he();return S&&_(S.leavesOf)?S.leavesOf(C):[]}loaded(C){return C>=0&&C<this.count()}hint(C,S){if(this.#g){this.#g.hint(C,S);return}this.#Re(),this.#p=Math.max(0,Math.floor(C))}#Re(){this.#v||this.#Xe()===this.#P||this.reload()}display(){const C=this.#he();return C?C.display():g(()=>this.count(),S=>this.at(S))}apply(C){if(this.#g)return this.#g.apply(C);const S={added:[],updated:[],removed:[]};if(!C)return S;if(C.update){let F=!1;for(const $ of C.update){const W=this.#a.get(this.#o.keyOf($,-1));if(W===void 0)continue;const K=this.#Ae(W);this.#x?this.#We(W,$):this.#n[W]=$,this.#l.delete(W),this.#te(W,K),this.#T&&(this.#be(W,$),F=!0),this.#O=!0,S.updated.push(this.#je(W))}F&&this.#Ee()}if(C.add&&C.add.length){const F=this.#U(C.add);for(const $ of F)S.added.push(this.#je($))}return C.remove&&C.remove.length&&b("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#_(),S}reload(C){this.#c.abortAll("reload"),this.#Ve(),this.#b&&(this.#b.destroy(),this.#b=null),this.#O=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#S=0,this.#C=0,this.#E=0,this.#T&&(this.#T=[]),this.#M=1/0,this.#N=!1,this.#w=!1,this.#A=!1,this.#u={loaded:0,estimated:void 0},this.#P=this.#Xe(),this.#Se("model:changed",{reason:"reload"}),this.start()}destroy(){this.#v=!0,this.#V!==null&&(clearInterval(this.#V),this.#V=null),this.#R!==null&&(clearInterval(this.#R),this.#R=null),this.#T=null,this.#c.abortAll("destroyed"),this.#Ve(),this.#d!==null&&(this.#we(this.#d),this.#d=null),this.#b&&(this.#b.destroy(),this.#b=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#A||this.#v||!_(this.#e.open))return;this.#A=!0;const C=this.#c.begin("stream");this.#ke(),this.#de();let S;try{S=this.#e.open({sort:this.#Oe("sort",[]),filters:this.#Oe("filters",null),quick:this.#Oe("quick","")||void 0,context:this.#Oe("context",null),signal:C.signal})}catch($){this.#Se("source:error",{error:$});return}const F=_(S[Symbol.asyncIterator])?S[Symbol.asyncIterator]():S[Symbol.iterator]();this.#W=F;try{for(;;){const $=await F.next();if(!C.current||this.#v)return;if($.done){this.#$();return}if(await this.#_e($.value,C),!C.current||this.#v)return;if($.value&&$.value.done){this.#$();return}if(await this.#ue(),!C.current||this.#v)return}}catch($){if(u($))return;this.#Se("source:error",{error:$})}finally{C.settle()}}progress(){return{loaded:this.#u.loaded,estimated:this.#u.estimated,done:this.#w,live:this.#S,evicted:this.#C}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const C=this.#he();C&&(_(C.invalidateHandles)&&C.invalidateHandles(),_(C.invalidate)&&C.invalidate("sort"))}renderCount(){return this.#f}ingestStats(){return{worker:this.#q,inline:this.#B,storeBacked:this.#x}}#_e(C,S){if(!C)return;const F=C.rows;if(F&&F.length&&this.#se(F))return this.#oe(C,S);const $=Z();F&&F.length&&(this.#U(F),this.#B++),this.#Pe(C),this.#h+=Z()-$,this.#_()}#Pe(C){this.#u.loaded=C.progress&&typeof C.progress.loaded=="number"?C.progress.loaded:this.#n.length,C.progress&&typeof C.progress.estimated=="number"&&(this.#u.estimated=C.progress.estimated)}#se(C){if(this.#Y||this.#g)return!1;const S=this.#Z();if(!S)return!1;const F=this.#t.store;if(!F||!_(F.appendPacked))return!1;const $=this.#z();return!$||!m($)?(this.#Y=!0,a("source.stream.ingest-worker","stream ingest.useWorker is on but a column reads through a closure (a computed or date column); columnizing on the main thread instead."),!1):C.length<S.threshold?!1:!this.#xe(C)}#xe(C){if(!this.#o.keyed)return!1;const S=new Set;for(let F=0;F<C.length;F++){const $=this.#o.keyOf(C[F],this.#n.length+F);if($!=null){if(S.has($)||this.#a.has($))return!0;S.add($)}}return!1}async#oe(C,S){const F=C.rows,$=this.#Z(),W=this.#z();let K;try{K=await $.columnize(W,F,{key:"ingest:stream",signal:S&&S.signal})}catch(Q){if(u(Q)||(b("source.stream.columnize","worker columnization failed; columnizing on the main thread",Q),this.#Y=!0,S&&(!S.current||this.#v)))return;this.#U(F),this.#B++,this.#Pe(C),this.#_();return}if(S&&(!S.current||this.#v))return;const I=this.#t.store,B=this.#x?void 0:F,{from:J}=I.appendPacked(K,B),te=K.count|0;for(let Q=0;Q<te;Q++){const re=J+Q,ie=F[Q],ue=this.#o.keyed?this.#o.keyOf(ie,re):null;if(this.#n[re]=this.#x?v:ie,this.#S++,this.#be(re,ie),ue!==null&&this.#a.set(ue,re),!this.#r||!this.#Te(re))continue;const ke=this.#me(re);this.#r.insert(ke,re),ke<=this.#p&&this.#m++}this.#O=!0,this.#Ee(),this.#q++,this.#Pe(C),this.#_()}#Z(){const C=this.#t.ingestWorker;return _(C)?C():null}#z(){const C=this.#t.storeSchema;return _(C)?C():null}#U(C){const S=[],F=this.#t.store,$=new Array(C.length),W=[],K=new Set;for(let B=0;B<C.length;B++){const J=this.#o.keyed?this.#o.keyOf(C[B],this.#n.length+W.length):null;$[B]=J,!(J!==null&&(this.#a.has(J)||K.has(J)))&&(J!==null&&K.add(J),W.push(C[B]))}let I=W.length&&F&&_(F.append)?F.append(W).from:this.#n.length;for(let B=0;B<C.length;B++){const J=C[B],te=$[B];if(te!==null&&this.#a.has(te)){const ie=this.#a.get(te),ue=this.#Ae(ie);this.#x||(this.#n[ie]=J,F&&_(F.setSource)&&F.setSource(ie,J)),this.#We(ie,J),this.#l.delete(ie),this.#be(ie,J),this.#te(ie,ue);continue}const Q=I++;if(this.#n[Q]=this.#x?v:J,this.#S++,this.#be(Q,J),te!==null&&this.#a.set(te,Q),S.push(Q),!this.#r||!this.#Te(Q))continue;const re=this.#me(Q);this.#r.insert(re,Q),re<=this.#p&&this.#m++}return this.#O=!0,this.#Ee(),S}#J(C){const S=this.#n[C];let F=!1;if(this.#r){const I=this.#ve(C);I>=0&&I<=this.#p&&(F=!0)}else C<=this.#p&&(F=!0);const $=S===v?this.#ie(C):S,W=this.#o.keyed?this.#o.keyOf($,C):null;W!==null&&this.#a.get(W)===C&&this.#a.delete(W),this.#n[C]=void 0,this.#T&&(this.#T[C]=NaN),this.#l.delete(C);const K=this.#t.store;return K&&_(K.remove)&&K.remove(C),this.#S--,F}#Ee(){let C=0,S=0;const F=this.#pe();C+=F.dropped,S+=F.aboveAnchor;const $=this.#ee();C+=$.dropped,S+=$.aboveAnchor,C&&(this.#O=!0,this.#C+=C,this.#ke(),this.#m-=S,this.#Se("stream:evicted",{evicted:C,total:this.#C,live:this.#S}))}#ee(){const C=this.#e.maxRows;if(!Number.isFinite(C)||C<=0||this.#S<=C)return{dropped:0,aboveAnchor:0};const S=Math.max(1,Math.floor(C*(1-V)));let F=0,$=0;for(;this.#S>S&&this.#E<this.#n.length;){const W=this.#E++;this.#n[W]!==void 0&&(this.#J(W)&&$++,F++)}return{dropped:F,aboveAnchor:$}}#pe(){const C=this.#G();if(!C||!this.#T||!this.#H())return{dropped:0,aboveAnchor:0};const S=Date.now()-C;let F=0,$=0,W=1/0;for(let K=this.#E;K<this.#n.length;K++){if(this.#n[K]===void 0)continue;const I=this.#T[K];if(!(Number.isNaN(I)||I===void 0)){if(I>=S){I<W&&(W=I);continue}this.#J(K)&&$++,F++}}for(this.#M=W,this.#N=!1;this.#E<this.#n.length&&this.#n[this.#E]===void 0;)this.#E++;return{dropped:F,aboveAnchor:$}}#ve(C){if(!this.#r)return C;for(let S=0;S<this.#r.length;S++)if(this.#r.at(S)===C)return S;return-1}#ke(){this.#s=this.#Oe("sort",[]),this.#i=this.#Oe("filters",null);const C=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#G()>0,S=this.#Oe("where",null),F=(this.#t.config||{}).hostFilter,$=!!(S&&S.active)||!!(F&&_(F.active)&&F.active());if(!(C||this.#s.length>0||!!this.#i||!!this.#Oe("quick","")||$)){this.#r=null;return}this.#r=new n(Math.max(64,this.#n.length+64));for(let K=0;K<this.#n.length;K++)this.#n[K]!==void 0&&this.#Te(K)&&this.#r.insert(this.#me(K),K)}#Te(C){const S=this.#ie(C);if(this.#i&&!this.#ye(this.#i,S))return!1;const F=String(this.#Oe("quick","")||"").toLowerCase();if(F&&!this.#k(S).includes(F))return!1;const $=(this.#t.config||{}).hostFilter;if($&&_($.active)&&$.active()&&!$.passes(this.#je(C)))return!1;const W=this.#Oe("where",null);if(W&&W.active){const K=this.#je(C);if(!W.passes(K.data,K.key))return!1}return!0}#ye(C,S){if(!C)return!0;const F=C;if(Array.isArray(F.conditions))return F.op==="or"?F.conditions.some(K=>this.#ye(K,S)):F.op==="not"?!F.conditions.some(K=>this.#ye(K,S)):F.conditions.every(K=>this.#ye(K,S));const $=C,W=(this.#t.compute||{}).testValue;return _(W)?!!W(this.#Ue(S,$.col),$,(this.#t.config||{}).locale):(b("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#Ae(C){if(!this.#r)return-1;if(!this.#s.length)return this.#ve(C);let S=0,F=this.#r.length;for(;S<F;){const $=S+F>>>1;this.#fe(this.#r.at($),C)<0?S=$+1:F=$}for(let $=S;$<this.#r.length;$++){const W=this.#r.at($);if(W===C)return $;if(this.#fe(W,C)>0)break}return this.#ve(C)}#te(C,S){if(!this.#r||!this.#s.length)return;const F=this.#Te(C);if(S>=0&&this.#r.at(S)===C)this.#r.removeAt(S),S<=this.#p&&this.#m--;else if(S>=0)return;if(!F)return;const $=this.#me(C);this.#r.insert($,C),$<=this.#p&&this.#m++}#me(C){if(!this.#r||!this.#s.length)return this.#r?this.#r.length:0;let S=0,F=this.#r.length;for(;S<F;){const $=S+F>>>1;this.#fe(C,this.#r.at($))<0?F=$:S=$+1}return S}#fe(C,S){const F=this.#ie(C),$=this.#ie(S);for(const W of this.#s){const K=this.#Le(W.col),I=this.#Ue(F,W.col),B=this.#Ue($,W.col),te=(K&&K.value&&_(K.value.compare)?K.value.compare:j)(I,B);if(te!==0)return W.dir==="desc"?-te:te}return 0}#$(){this.#w=!0,this.#u.loaded=this.#u.loaded||this.#n.length;const C=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:w;!this.#x&&this.#n.length<C&&(this.#g=p({mode:"memory",rows:this.#n},this.#t),this.#R!==null&&(clearInterval(this.#R),this.#R=null),this.#b&&(this.#b.destroy(),this.#b=null)),this.#_(),this.#Se("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:C})}#_(){this.#d!==null||this.#v||(this.#d=this.#F(()=>{this.#d=null,this.#f++;const C=this.#m;this.#m=0,this.#h=0,this.#Se("stream:chunk",{loaded:this.#u.loaded,estimated:this.#u.estimated,count:this.count(),renders:this.#f}),this.#Se("model:changed",{reason:"stream",shiftAboveViewport:C,anchor:this.#p}),this.#Se("rows:changed",{companion:!0,reason:"stream"})}))}#ue(){return this.#f===0||this.#h<this.#ae()?Promise.resolve():(this.#h=0,new Promise(C=>{const S=(this.#t.scheduler||{}).idle;_(S)?S(()=>C()):X(()=>C())}))}#ae(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:E}#F(C){const S=this.#t.scheduler||{};return _(S.frame)?S.frame(C):H(C)}#we(C){const S=this.#t.scheduler||{};_(S.cancel)?S.cancel(C):x(C)}#ie(C){const S=this.#n[C];if(S!==void 0&&S!==v)return S;if(S===void 0)return;const F=this.#t.store;return F&&_(F.source)?F.source(C):void 0}#We(C,S){const F=this.#t.store;if(!F||!_(F.set))return;const $=this.#z();if(Array.isArray($))for(const W of $){if(!W||!W.id)continue;const K=_(W.read)?W.read:I=>r(I,W.field||W.id);F.set(W.id,C,K(S))}}#je(C){let S=this.#l.get(C);return S||(S=this.#o.leaf(this.#ie(C),C),this.#l.set(C,S)),S}#Ue(C,S){const F=this.#Le(S);return F&&_(F.getValue)?F.getValue(C):C?.[S]}#k(C){const S=this.#t.columns,F=S&&_(S.all)?S.all():[],$=[];for(const W of F){const K=_(W.getValue)?W.getValue(C):void 0;K!=null&&K!==""&&$.push(String(K))}return $.join(" ").toLowerCase()}#Le(C){const S=this.#t.columns;return S&&_(S.get)?S.get(C):void 0}#Ve(){const C=this.#W;if(this.#W=null,C&&_(C.return))try{C.return()}catch{}}#Xe(){return y({context:this.#Oe("context",null)})}#Oe(C,S){const F=this.#t.state;if(F&&_(F[C])){const $=F[C]();return $??S}return S}#Se(C,S){const F=this.#t.emit;_(F)&&F(C,S)}}}),We("packages/core/src/source/url.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return b}});const P=D("packages/core/src/internal/warn.js").warnOnce,Y=D("packages/core/src/internal/predicates.js"),_=Y.isObject,L=Y.isFunction,H=D("packages/core/src/internal/paths.js").getPath,X=D("packages/core/src/source/abort.js").isAbortError,U=500,j=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),k=Symbol("lattice.url.skip");function b(l,y={}){const c=_(y)?y:{},m=L(c.fetch)?c.fetch:typeof globalThis<"u"&&L(globalThis.fetch)?globalThis.fetch:null,w=c.format==="json"||c.format==="ndjson"?c.format:void 0,v=typeof c.rowsPath=="string"&&c.rowsPath?c.rowsPath:void 0,E=L(c.map)?c.map:void 0,V=_(c.headers)?c.headers:void 0,G=Number.isFinite(c.batchSize)&&c.batchSize>0?Math.floor(c.batchSize):U,q=c.lenient===!0,M=Number.isFinite(c.poll)&&c.poll>0?Math.floor(c.poll):void 0,O=typeof l=="string"&&l.length>0;O||P("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*T(N={}){if(!O)return;if(!m)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const C=N&&N.signal;let S;try{S=await m(l,V?{signal:C,headers:V}:{signal:C})}catch(W){throw X(W)?W:new Error(`[lattice] createUrlSource: request to ${l} failed — ${W&&W.message||W}`)}if(!S||!S.ok){const W=S?S.status:"no response";throw new Error(`[lattice] createUrlSource: ${W} for ${l}`)}const F=a(l,w,S),$=S.body&&L(S.body.getReader)?S.body.getReader():null;try{if(!$){const I=await S.text();(F||t(I,l))==="ndjson"?yield*i(null,null,I,0,S,l,G,q):yield*g(I,l,v,E);return}const W=new TextDecoder("utf-8");if(F==="json"){yield*g(await s($,W,""),l,v,E);return}if(F==="ndjson"){yield*i($,W,"",0,S,l,G,q);return}const K=await o($,W,l);K.format==="json"?yield*g(await s($,W,K.seed),l,v,E):yield*i($,W,K.seed,K.bytes,S,l,G,q)}finally{if($&&L($.cancel))try{await $.cancel()}catch{}}}const A={mode:"stream",open:T,autoStart:c.autoStart!==!1};return M!==void 0&&(A.poll=M),Number.isFinite(c.maxRows)&&(A.maxRows=c.maxRows),Number.isFinite(c.maxAge)&&(A.maxAge=c.maxAge),(typeof c.ageBy=="string"||L(c.ageBy))&&(A.ageBy=c.ageBy),Number.isFinite(c.coalesceMs)&&(A.coalesceMs=c.coalesceMs),Number.isFinite(c.promoteToMemoryBelow)&&(A.promoteToMemoryBelow=c.promoteToMemoryBelow),A}function a(l,y,c){if(y)return y;const m=h(l);if(m)return m;const w=c&&c.headers&&L(c.headers.get)?c.headers.get("content-type"):null;return r(w)}function h(l){const y=String(l).split(/[?#]/)[0].toLowerCase();if(y.endsWith(".ndjson")||y.endsWith(".jsonl"))return"ndjson";if(y.endsWith(".json"))return"json"}function r(l){if(!l)return;const y=l.split(";")[0].trim().toLowerCase();if(j.has(y))return"ndjson";if(y==="application/json"||y==="text/json"||y.endsWith("+json"))return"json"}function t(l,y){const c=l.replace(/^\s+/,""),m=u(c);if(m==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${y} — pass opts.format: 'json' | 'ndjson'.`);return m}async function o(l,y,c){let m="",w=0;for(;;){const{value:E,done:V}=await l.read();if(E&&(w+=E.byteLength,m+=y.decode(E,{stream:!0})),V){m+=y.decode();break}const G=m.replace(/^\s+/,"");if(G){if(G[0]==="[")return{format:"json",seed:m,bytes:w};if(G[0]!=="{"||m.indexOf(`
|
|
8
8
|
`)!==-1)break}}const v=u(m.replace(/^\s+/,""));if(v==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${c} — pass opts.format: 'json' | 'ndjson'.`);return{format:v,seed:m,bytes:w}}function u(l){if(!l||l[0]==="[")return"json";if(l[0]!=="{")return"error";const y=l.indexOf(`
|
|
9
9
|
`);if(y===-1)return"json";let c=l.slice(0,y);return c.endsWith("\r")&&(c=c.slice(0,-1)),d(c)?"ndjson":"json"}function d(l){try{return JSON.parse(l),!0}catch{return!1}}async function s(l,y,c){let m=c;for(;;){const{value:w,done:v}=await l.read();if(w&&(m+=y.decode(w,{stream:!0})),v)break}return m+=y.decode(),m}function*g(l,y,c,m){let w;try{w=JSON.parse(l)}catch(E){throw new Error(`[lattice] createUrlSource: ${y} is not valid JSON — ${E.message}`)}let v=c!==void 0?H(w,c):w;if(m&&(v=m(v)),!Array.isArray(v)){const E=c!==void 0||m?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${y} did not resolve to an array${E}.`)}yield{rows:v,progress:{loaded:v.length,estimated:v.length}}}async function*i(l,y,c,m,w,v,E,V){const G=p(w);let q=c||"",M=m||0,O=0,T=0,A=[];function*N(){let S;for(;(S=q.indexOf(`
|
|
10
10
|
`))!==-1;){const F=q.slice(0,S);q=q.slice(S+1),T++;const $=n(F,T,v,V);$!==k&&(A.push($),A.length>=E&&(O+=A.length,yield f(A,O,G,M),A=[]))}}if(l){for(;;){const{value:S,done:F}=await l.read();if(S&&(M+=S.byteLength,q+=y.decode(S,{stream:!0}),yield*N()),F)break}q+=y.decode()}yield*N(),T++;const C=n(q,T,v,V);C!==k&&A.push(C),A.length&&(O+=A.length,yield f(A,O,G,M))}function n(l,y,c,m){let w=l;if(w.endsWith("\r")&&(w=w.slice(0,-1)),!w.trim())return k;try{return JSON.parse(w)}catch(v){if(m)return P(`source.url.badline.${c}`,`skipping a malformed NDJSON line (line ${y}) from ${c} — ${v.message}`),k;throw new Error(`[lattice] createUrlSource: malformed NDJSON at line ${y} of ${c} — ${v.message}`)}}function f(l,y,c,m){const w=c&&m>0&&y>0?Math.max(y,Math.round(c/(m/y))):void 0;return{rows:l,progress:{loaded:y,estimated:w}}}function p(l){const y=l&&l.headers&&L(l.headers.get)?l.headers.get("content-length"):null,c=y!=null?Number(y):NaN;return Number.isFinite(c)&&c>0?c:void 0}}),We("packages/core/src/source/derive.js",function(e,D){"use strict";Object.defineProperty(e,"FOLLOW_MODES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"BUCKETS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DERIVED_ROW_KEY",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"DERIVED_SOURCE_KEY",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"UNION_KEY_SEP",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"readPath",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"unnest",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"reduceValues",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"applyLimit",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"applyCumulative",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"groupRows",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"finishGroups",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"derive",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"normalizeUnionSource",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"namespaceUnionKeys",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"joinRows",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"preGroup",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"buildJoinIndex",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"joinOne",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"joinKeyOf",{enumerable:!0,get:function(){return w}});const ne=D("packages/core/src/internal/predicates.js"),P=ne.isFunction,Y=ne.isObject,L=D("packages/core/src/compute/total.js").TOTAL_FNS,Z=Object.freeze(["filtered","all","selected","grouped"]),H=Object.freeze(["day","week","month","quarter","year"]),x="__key",X="__source",U="";function j(v,E){if(!Y(v)||typeof E!="string")return;if(!E.includes("."))return v[E];let V=v;for(const G of E.split(".")){if(!Y(V))return;V=V[G]}return V}function k(v,E){const V=[];for(const G of v){const q=j(G,E);if(!(!Array.isArray(q)||!q.length))for(const M of q)V.push({...G,[E]:M})}return V}function b(v,E){const V=v instanceof Date?v:new Date(v),G=V.getTime();if(!Number.isFinite(G))return null;const q=V.getUTCFullYear(),M=V.getUTCMonth(),O=V.getUTCDate(),T=A=>A.toISOString().slice(0,10);switch(E){case"year":return T(new Date(Date.UTC(q,0,1)));case"quarter":return T(new Date(Date.UTC(q,Math.floor(M/3)*3,1)));case"month":return T(new Date(Date.UTC(q,M,1)));case"week":{const A=(V.getUTCDay()+6)%7;return T(new Date(Date.UTC(q,M,O-A)))}default:return T(new Date(Date.UTC(q,M,O)))}}function a(v,E,V){const G=E.map(q=>V&&V.of===q?b(j(v,q),V.by):j(v,q));return{key:G.map(q=>q==null?"\0":String(q)).join(""),values:G}}function h(v,E){const V=L[E];return V?V({get:G=>v[G]},o(v.length)):null}function r(v,E){return!E||typeof E.of!="string"||E.of===""||v&&v.includes(E.of)?v:[E.of,...v||[]]}function t(v,E){const V={},G=o(v.length);for(const[q,M]of Object.entries(E)){const O=M.fn||"count",T=L[O];if(!T){V[q]=null;continue}const A=M.of?v.map(N=>j(N,M.of)):[];V[q]=T({get:N=>A[N]},G)}return V}const o=(()=>{const v=new Map;return E=>{let V=v.get(E);if(!V){V=new Uint32Array(E);for(let G=0;G<E;G++)V[G]=G;v.size<512&&v.set(E,V)}return V}})();function u(v,E,V){if(!Number.isFinite(E)||E<=0)return v;if(!V)return v.slice(0,E);const G=new Map,q=[];for(const M of v){const O=String(j(M,V)),T=G.get(O)||0;T>=E||(G.set(O,T+1),q.push(M))}return q}function d(v,E){const V=v.reduce((O,T)=>O+(Number(j(T,E.of))||0),0);if(!V)return v;const G=V*E.upTo;let q=0;const M=[];for(const O of v)if(M.push(O),q+=Number(j(O,E.of))||0,q>=G)break;return M}function s(v,E){return!Array.isArray(E)||!E.length?v:[...v].sort((V,G)=>{for(const q of E){const M=j(V,q.col),O=j(G,q.col);if(M===O)continue;return M==null?1:O==null?-1:((typeof M=="number"&&typeof O=="number"?M<O:String(M)<String(O))?-1:1)*(q.dir==="desc"?-1:1)}return 0})}function g(v,E,V){const G=E.groupBy?Array.isArray(E.groupBy)?E.groupBy:[E.groupBy]:null,q=Y(E.bucket)?E.bucket:null,M=r(G,q),O=new Map,T=new Map;if(!M)return{groups:O,rowGroup:T};for(const A of v){const{key:N,values:C}=a(A,M,q);let S=O.get(N);S||(S={values:C,rows:new Map},O.set(N,S));const F=V(A);S.rows.set(F,A),T.set(F,N)}return{groups:O,rowGroup:T}}function i(v,E,V=null,G=null){const q=E.groupBy?Array.isArray(E.groupBy)?E.groupBy:[E.groupBy]:null,M=Y(E.bucket)?E.bucket:null,O=r(q,M);let T=[...v.entries()].map(([A,N])=>{if(V&&G&&!G.has(A)){const S=V.get(A);if(S)return S}const C={[x]:A};return O.forEach((S,F)=>{C[S.includes(".")?S.split(".").pop():S]=N.values[F]}),Object.assign(C,t([...N.rows.values()],E.select||{})),V&&V.set(A,C),C});return T=s(T,E.sort),Y(E.cumulative)&&(T=d(T,E.cumulative)),u(T,E.limit,E.limitPer||null)}function n(v,E){const V=y(v,E),G=E.groupBy?Array.isArray(E.groupBy)?E.groupBy:[E.groupBy]:null,q=Y(E.bucket)?E.bucket:null,M=r(G,q);let O;if(!M)O=V.map((T,A)=>({...T,[x]:String(j(T,E.rowKey||"id")??A)}));else{const T=new Map;for(const A of V){const{key:N,values:C}=a(A,M,q);let S=T.get(N);S||(S={values:C,rows:[]},T.set(N,S)),S.rows.push(A)}O=[...T.entries()].map(([A,N])=>{const C={[x]:A};return M.forEach((S,F)=>{C[S.includes(".")?S.split(".").pop():S]=N.values[F]}),Object.assign(C,t(N.rows,E.select||{})),C})}return O=s(O,E.sort),Y(E.cumulative)&&(O=d(O,E.cumulative)),u(O,E.limit,E.limitPer||null)}function f(v,E){const G=Y(v)&&Y(v.grid)?v:{grid:v};return{grid:Y(G.grid)?G.grid:null,label:G.label!=null&&G.label!==""?String(G.label):String(E),follow:typeof G.follow=="string"?G.follow:void 0,map:P(G.map)?G.map:null}}function p(v){for(const E of v){const V=E[X];V!==void 0&&(E[x]=`${V}${U}${E[x]}`)}return v}function l(v,E){const V=E.on,G=Y(V)?String(V.left||V.right||""):String(V||""),q=Y(V)?String(V.right||V.left||""):String(V||"");if(!G||!q)return v;const M=E.index instanceof Map?E.index:c(Array.isArray(E.rows)?E.rows:[],q),O=Array.isArray(E.select)?E.select.map(String):null,T=E.prefix?String(E.prefix):"",A=String(E.type||"inner")==="left",N=[];for(const C of v){const S=j(C,G),F=S==null?void 0:M.get(String(S));if(!F){A&&N.push(C);continue}const $={...C},W=O||Object.keys(F);for(const K of W)!T&&K===G||($[T?T+K:K]=j(F,K));N.push($)}return N}function y(v,E){let V=Array.isArray(v)?v:[];return E.unnest&&(V=k(V,E.unnest)),Y(E.join)&&(Array.isArray(E.join.rows)||E.join.index instanceof Map)&&(V=l(V,E.join)),P(E.where)&&(V=V.filter(G=>!!E.where(G))),V}function c(v,E){const V=new Map;for(const G of v){const q=j(G,E);if(q==null)continue;const M=String(q);V.has(M)||V.set(M,G)}return V}function m(v,E){const V=E.on,G=Y(V)?String(V.left||V.right||""):String(V||""),q=Y(V)?String(V.right||V.left||""):String(V||"");if(!G||!q)return v;const M=E.index instanceof Map?E.index:new Map,O=j(v,G),T=O==null?void 0:M.get(String(O));if(!T)return String(E.type||"inner")==="left"?v:null;const A=Array.isArray(E.select)?E.select.map(String):null,N=E.prefix?String(E.prefix):"",C={...v};for(const S of A||Object.keys(T))!N&&S===G||(C[N?N+S:S]=j(T,S));return C}function w(v,E){const V=j(v,E);return V==null?null:String(V)}}),We("packages/core/src/source/derived.js",function(e,D){"use strict";Object.defineProperty(e,"IDLE_REFRESH_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PROFILE_FIELDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"ALERT_THRESHOLDS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"STATISTICS_FNS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SERIES_METRICS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"PRODUCER_IGNORED_KEYS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"profileAlerts",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"DerivedSource",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createDerivedSource",{enumerable:!0,get:function(){return q}});const ne=D("packages/core/src/internal/predicates.js"),P=ne.isFunction,Y=ne.isObject,L=D("packages/core/src/internal/warn.js").warnOnce,H=D("packages/core/src/source/memory.js").MemorySource,X=D("packages/core/src/source/settle.js").isPipelineSettle,U=D("packages/core/src/source/derive.js"),j=U.derive,k=U.preGroup,b=U.groupRows,a=U.finishGroups,h=U.readPath,r=U.buildJoinIndex,t=U.joinOne,o=U.joinKeyOf,u=U.FOLLOW_MODES,d=U.DERIVED_ROW_KEY,s=U.DERIVED_SOURCE_KEY,g=U.normalizeUnionSource,i=U.namespaceUnionKeys,n=16,f=Object.freeze(["column","rows","present","missing","numeric","distinct","min","max","mean","median","q1","q3","iqr","stddev","outliers","alerts","alertCount"]),p=Object.freeze({missing:.2,cardinality:.9,skew:1,outliers:.05}),l=Object.freeze(["correlation","series","datasetVsDataset"]),y=Object.freeze(["n","first","last","change","changePercent","volatility","annualisedVolatility","growth","maxDrawdown","maxDrawdownFrom","maxDrawdownTo","autocorrelation","upDays","downDays"]),c=Object.freeze(["unnest","join","where","bucket","groupBy","select","sort","limit","limitPer","cumulative"]);function m(M,O={}){const T={...p,...Y(O)?O:{}},A=te=>typeof te=="number"&&Number.isFinite(te)?te:null,N=A(M.rows)??0,C=A(M.numeric)??0,S=A(M.missing)??0,F=A(M.distinct),$=A(M.mean),W=A(M.median),K=A(M.stddev),I=A(Array.isArray(M.outliers)?M.outliers.length:M.outliers),B=C>0,J=[];return F===0?["empty"]:(F===1&&J.push("constant"),N>0&&S/N>=T.missing&&J.push("high-missing"),!B&&F!==null&&N>1&&F===N&&S===0?J.push("unique"):F!==null&&N>0&&F/N>=T.cardinality&&J.push("high-cardinality"),B&&$!==null&&W!==null&&K!==null&&K>0&&Math.abs(3*($-W)/K)>=T.skew&&J.push("skewed"),B&&I!==null&&I/C>=T.outliers&&J.push("outliers"),J)}class w extends H{#e=null;#t={};#n=[];#r=null;#s=!1;#i={};#o=!1;#l=null;#a=null;#c=!1;#u=null;#d=!1;#f=null;constructor(O,T){super({mode:"memory",rows:[]},T),this.#i=T||{},this.#t=Y(O)?O:{};const A=this.#t.from;if(Array.isArray(A)){if(this.#e=null,this.#f=this.#g(A),!this.#f.length){L("source.derived.from",'source.mode "derived" needs `from`: at least one grid to derive from.');return}this.#t.follow!==void 0&&L("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&&L("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&&(L("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.#d=!0),this.#m(),this.#b(),this.refresh();return}if(this.#e=A||null,!this.#e){L("source.derived.from",'source.mode "derived" needs `from`: the grid to derive from.');return}this.#t.follow&&!u.includes(String(this.#t.follow))&&L(`source.derived.follow.${this.#t.follow}`,`unknown follow "${this.#t.follow}"; using "filtered". Known: ${u.join(", ")}.`),this.#h()||(this.#d=!0),this.#m(),this.#b(),this.refresh()}#h(){const O=this.#t.statistics;if(O===void 0)return!0;if(this.#t.profile!==void 0)return L("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(!Y(O))return L("source.derived.statistics.shape",`source.mode "derived": \`statistics\` needs an object naming the statistic, e.g. \`{ fn: 'correlation', columns: ['a', 'b'] }\`. Known fn: ${l.join(", ")}.`),!1;const T=String(O.fn||"");return l.includes(T)?this.#p(T,O):(L(`source.derived.statistics.fn.${T}`,`source.mode "derived": unknown \`statistics.fn\` "${T}". Known: ${l.join(", ")}. Every *single-column* statistic is reached through \`select\` instead, e.g. \`select: { p95: { of: 'amount', fn: 'p95' } }\`.`),!1)}#p(O,T){if(O==="correlation"){if((Array.isArray(T.columns)?T.columns.filter(Boolean):[]).length<2)return L("source.derived.statistics.columns","source.mode \"derived\": `statistics: { fn: 'correlation' }` needs `columns`: at least two column ids to correlate pairwise."),!1;const N=T.orient===void 0?"pairs":String(T.orient);return N!=="pairs"&&N!=="matrix"&&L(`source.derived.statistics.orient.${N}`,`source.mode "derived": unknown \`statistics.orient\` "${N}" for \`fn: 'correlation'\`; using "pairs". Known: pairs, matrix.`),!0}return O==="series"?!T.of||!T.by?(L("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:Y(T.with)?!0:(L("source.derived.statistics.with","source.mode \"derived\": `statistics: { fn: 'datasetVsDataset' }` needs `with`: the second grid to compare this one against."),!1)}#m(){const O=this.#t.statistics!==void 0?"statistics":this.#t.profile!==void 0?"profile":null;if(!O)return;const T=c.filter(A=>this.#t[A]!==void 0);T.length&&L(`source.derived.producer.ignored.${O}`,`source.mode "derived": \`${O}\` is a terminal producer and replaces the pipeline, so ${T.map(A=>`\`${A}\``).join(", ")} ${T.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(O){const T=this.#i&&this.#i.grid,A=new Set,N=[];return O.forEach((C,S)=>{const F=g(C,S);if(A.has(F.label)&&L(`source.derived.union.label.${F.label}`,`source.mode "derived": two union sources share the label "${F.label}"; give each a distinct \`label\` or __source/__key will not distinguish them.`),A.add(F.label),!F.grid){L(`source.derived.union.missing.${F.label}`,`source.mode "derived": union source "${F.label}" has no grid and was skipped.`),N.push(F);return}if(T&&P(F.grid.on)){const $=E(T,F.grid,[F.label]);if($){L(`source.derived.union.cycle.${F.label}`,`source.mode "derived": union source "${F.label}" was refused — it derives from the grid being derived, directly or through a chain (${$.join(" → ")}). Remove it from \`from\`.`),N.push({...F,grid:null});return}}N.push(F)}),N}#b(){if(this.#f){this.#O(),this.#w();return}const O=this.#e;if(!O||!P(O.on))return;const T=String(this.#t.follow||"filtered"),A=["rows:changed"];(T==="filtered"||T==="grouped")&&A.push("filter:changed","model:changed"),T==="selected"&&A.push("selection:changed"),T==="grouped"&&A.push("column:grouped");for(const N of A){const C=S=>{N==="rows:changed"&&v(S)||N==="model:changed"&&!X(S)||this.schedule(N==="rows:changed"?S:null)};O.on(N,C),this.#n.push(()=>P(O.off)&&O.off(N,C))}this.#w(),this.#y()}#y(){const O=this.#t.statistics,T=Y(O)?O.with:null;if(!Y(T)||!P(T.on))return;const A=T;for(const N of["rows:changed","filter:changed","model:changed"]){const C=S=>{N==="rows:changed"&&v(S)||N==="model:changed"&&!X(S)||this.schedule(null)};A.on(N,C),this.#n.push(()=>P(A.off)&&A.off(N,C))}}#O(){for(const O of this.#f){const T=O.grid;if(!T||!P(T.on))continue;const A=u.includes(String(O.follow))?String(O.follow):"filtered",N=["rows:changed"];(A==="filtered"||A==="grouped")&&N.push("filter:changed","model:changed"),A==="selected"&&N.push("selection:changed"),A==="grouped"&&N.push("column:grouped");for(const C of N){const S=F=>{C==="rows:changed"&&v(F)||C==="model:changed"&&!X(F)||this.schedule(null)};T.on(C,S),this.#n.push(()=>P(T.off)&&T.off(C,S))}}}#w(){const O=this.#t.join,T=O&&O.with;if(!T||!P(T.on))return;const N=String(O.follow||"all")==="all"?["rows:changed"]:["rows:changed","filter:changed","model:changed"];for(const C of N){const S=F=>{C==="rows:changed"&&v(F)||C==="model:changed"&&!X(F)||this.schedule({partner:!0})};T.on(C,S),this.#n.push(()=>P(T.off)&&T.off(C,S))}}#A(){const O=this.#t.join;if(!O||!O.with)return null;const T=O.on,A=Y(T)?String(T.left||T.right||""):String(T||""),N=Y(T)?String(T.right||T.left||""):String(T||"");return A&&N?{left:A,right:N}:null}#v(){const O=this.#A();if(!O)return this.#u=null,null;const T=this.#u;if(this.#u=r(this.#C(),O.right),!T)return null;const A=this.#t.join||{},N=Array.isArray(A.select)?A.select.map(String):null,C=$=>$?(N||Object.keys($)).map(K=>String(h($,K))).join(""):null,S=new Set,F=new Set;for(const[$,W]of this.#u)C(W)!==C(T.get($))&&(S.add($),T.has($)||F.add($));for(const $ of T.keys())this.#u.has($)||S.add($);return{affected:S,gained:F}}#P(O,T){const A=this.#l;if(!A||!A.leftByJoinKey)return null;const N=[];for(const C of O){const S=A.leftByJoinKey.get(C);if(S)for(const F of S){const $=A.rowData.get(F);$!==void 0&&N.push({key:F,data:$})}}return this.#M({updated:N,added:[],removed:[]},T)}#S(O,T){if(!this.#l||!this.#l.leftByJoinKey||O.unnest||O.where||String(O.follow||"filtered")==="grouped")return!1;const A=O.join||{};return String(A.type||"inner")==="left"?!0:T.size===0}#C(){const O=this.#t.join,T=O&&O.with;if(!T||!T.rows)return[];const A=[],N=C=>{C.group||A.push(V(C))};return String(O.follow||"all")==="filtered"&&P(T.rows.forEach)?T.rows.forEach(N):P(T.rows.forEachAll)&&T.rows.forEachAll(N),A}schedule(O){const T=this.#t.refresh===void 0?"idle":this.#t.refresh;if(T==="manual")return;if(T==="live"){this.refresh(O);return}const A=typeof T=="number"&&Number.isFinite(T)?T:n;if(this.#r){this.#c=!0;return}this.#c=!1,this.#r=setTimeout(()=>{this.#r=null,this.refresh(this.#c?null:O)},A)}refresh(O){if(!(this.#s||!this.#e&&!this.#f)){if(this.#o){L("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 T=this.#d?[]:this.#f?this.#t.profile?this.#q():this.#x():this.#t.statistics!==void 0?this.#be():this.#t.profile?this.#re():this.#E(O);this.setRows(T),this.invalidate("filter"),P(this.#i.emit)&&this.#i.emit("rows:changed",{derived:!0},"derived")}finally{this.#o=!1}}}#E(O){const A=Y(O)&&O.partner===!0?this.#v():null,N=this.#D();if(A&&this.#l){if(!A.affected.size)return a(this.#l.groups,N,this.#l.reduced,new Set);if(this.#S(N,A.gained)){const Q=this.#P(A.affected,N);if(Q)return a(this.#l.groups,N,this.#l.reduced,Q)}}const C=this.#T(N,O);if(C&&this.#l){const Q=this.#M(C,N);return a(this.#l.groups,N,this.#l.reduced,Q)}const S=k(this.#B(),N);if(this.#a=this.#R(),!N.groupBy)return this.#l=null,j(S,N);const F=this.#N(),{groups:$,rowGroup:W}=b(S,N,F),K=new Map;for(const[Q,re]of W){const ie=$.get(re);ie&&K.set(Q,ie.rows.get(Q))}const I=new Map,B=this.#A(),J=new Map,te=new Map;if(B)for(const[Q,re]of K){const ie=o(re,B.left);if(ie===null)continue;J.set(Q,ie);let ue=te.get(ie);ue||(ue=new Set,te.set(ie,ue)),ue.add(Q)}return this.#l={groups:$,rowGroup:W,rowData:K,reduced:I,leftJoinKey:J,leftByJoinKey:te},a($,N,I,null)}#T(O,T){if(!this.#l||!O.groupBy||O.unnest||O.where||String(O.follow||"filtered")==="grouped"||Y(O.join)&&O.join.with&&!(O.join.index instanceof Map)||!Y(T))return null;const A=Array.isArray(T.updated)?T.updated:null,N=Array.isArray(T.added)?T.added:null,C=Array.isArray(T.removed)?T.removed:null;if(!A&&!N&&!C)return null;const S=this.#a;if(S&&S.size&&String(O.follow||"filtered")!=="all"){if(T.edit===!0&&Array.isArray(T.columns)){for(const F of T.columns)if(S.has(String(F)))return null}for(const F of A||[]){const $=F&&F.key,W=$===void 0?void 0:this.#l.rowData.get(String($)),K=V(F);for(const I of S)if(h(W,I)!==h(K,I))return null}}return{updated:A||[],added:N||[],removed:C||[]}}#M(O,T){const A=this.#l,N=this.#N(),C=new Set,S=Y(T.join)&&T.join.index instanceof Map?T.join:null,F=this.#A(),$=K=>{const I=A.rowGroup.get(K);if(I===void 0)return;C.add(I);const B=A.groups.get(I);if(B&&(B.rows.delete(K),B.rows.size||A.groups.delete(I)),A.rowGroup.delete(K),A.rowData.delete(K),A.leftJoinKey){const J=A.leftJoinKey.get(K);if(J!==void 0){const te=A.leftByJoinKey.get(J);te&&(te.delete(K),te.size||A.leftByJoinKey.delete(J)),A.leftJoinKey.delete(K)}}},W=K=>{const I=S?t(K,S):K;if(!I)return;const B=N(I),J=b([I],T,N);for(const[te,Q]of J.groups){let re=A.groups.get(te);re||(re={values:Q.values,rows:new Map},A.groups.set(te,re)),re.rows.set(B,I),A.rowGroup.set(B,te),C.add(te)}if(A.rowData.set(B,I),F&&A.leftByJoinKey){const te=o(I,F.left);if(te!==null){A.leftJoinKey.set(B,te);let Q=A.leftByJoinKey.get(te);Q||(Q=new Set,A.leftByJoinKey.set(te,Q)),Q.add(B)}}};for(const K of O.removed)$(String(K));for(const K of O.updated)$(String(K.key)),W(V(K));for(const K of O.added)W(V(K));return C}#N(){const O=this.#e,T=O&&O.config&&O.config.rowKey||"id";return A=>String(h(A,typeof T=="string"?T:"id")??"")}#R(){const O=this.#e,T=O&&O.state&&P(O.state.get)?O.state.get():null,A=new Set,N=C=>{if(C){if(Array.isArray(C.conditions)){C.conditions.forEach(N);return}C.col&&A.add(String(C.col))}};return T&&N(T.filters),A}#D(){let O=this.#t;if(O.join&&O.join.with&&(this.#u||this.#v(),O={...O,join:{...O.join,index:this.#u}}),this.#f||String(O.follow||"filtered")!=="grouped")return O;const T=this.#e,A=T&&T.state&&P(T.state.get)?T.state.get():null,N=A&&Array.isArray(A.group)?A.group:[];return N.length?{...O,groupBy:[...N]}:O}#W(){const O=[];for(const T of this.#f)if(T.grid)try{const A=u.includes(String(T.follow))?String(T.follow):"filtered",N=this.#V(T.grid,A);for(const C of N){const S=T.map?T.map(C):C;Y(S)&&O.push({...S,[s]:T.label})}}catch(A){L(`source.derived.union.failed.${T.label}`,`source.mode "derived": union source "${T.label}" failed to read (${A&&A.message?A.message:A}) and was skipped this pass.`)}return O}#V(O,T){if(!O||!O.rows)return[];if(T==="all"){const N=[];return P(O.rows.forEachAll)&&O.rows.forEachAll(C=>{C.group||N.push(V(C))}),N}if(T==="selected")return(O.selection&&P(O.selection.rows)?O.selection.rows():[]).filter(Boolean).map(V);const A=[];return P(O.rows.forEach)&&O.rows.forEach(N=>{N.group||A.push(V(N))}),A}#x(){const O=this.#D(),T=this.#W(),A=j(T,O);return O.groupBy?A:i(A)}#q(){return L("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.'),[]}#B(){const O=this.#e,T=String(this.#t.follow||"filtered");if(!O||!O.rows)return[];if(T==="all"){const C=[];return P(O.rows.forEachAll)&&O.rows.forEachAll(S=>{S.group||C.push(V(S))}),C}if(T==="selected")return(O.selection&&P(O.selection.rows)?O.selection.rows():[]).filter(Boolean).map(V);const A=this.#Y(),N=[];return A&&this.#G().length&&P(O.rows.forEachExcept)?(O.rows.forEachExcept(A,C=>{C.group||N.push(V(C))}),N):(P(O.rows.forEach)&&O.rows.forEach(C=>{C.group||N.push(V(C))}),N)}#Y(){const O=this.#t.crossFilter;if(!O||this.#f)return null;if(typeof O=="string")return O;if(O.col)return String(O.col);const T=this.#t.groupBy,A=Array.isArray(T)?T[0]:T;return A?String(A):null}#G(){const O=this.#Y(),T=this.#e;if(!O||!T||!T.filters||!P(T.filters.get))return[];const A=G(T.filters.get(),O);return A?A.op==="in"&&Array.isArray(A.value)?A.value.map(String):A.op==="eq"&&A.value!==void 0?[String(A.value)]:[]:[]}#I(O){const T=this.#Y(),A=this.#e;if(!T||!A||!A.filters||!P(A.filters.set))return;const N=this.#i.compute||{},C=P(A.filters.get)?A.filters.get():null,S=P(N.pruneColumn)?N.pruneColumn(C,T):null;if(!O.length){A.filters.set(S||null);return}const F=O.length===1?{col:T,op:"eq",value:O[0]}:{col:T,op:"in",value:O.slice()},$=S?S.conditions&&S.op?S.conditions:[S]:[];A.filters.set($.length?{op:"and",conditions:[...$,F]}:F)}crossFilter(){const O=this;return{enabled(){return!!O.#Y()},column(){return O.#Y()},get(){return O.#G()},set(T){const A=T==null?[]:(Array.isArray(T)?T:[T]).map(N=>String(N));O.#I(A)},toggle(T){const A=String(T),N=O.#G(),S=N.indexOf(A)>=0?N.filter(F=>F!==A):[...N,A];O.#I(S)},clear(){O.#I([])}}}#H(O){const T=O&&O.rows;if(T&&P(T.matchCount)){const A=T.matchCount(),N=Number(A);if(A!==null&&Number.isFinite(N))return N}if(T&&P(T.count)){const A=Number(T.count());if(Number.isFinite(A))return A}return 0}#be(){const O=this.#e,T=this.#t.statistics;if(!O||!O.statistics||!Y(T))return[];switch(String(T.fn)){case"correlation":return this.#ce(O,T);case"series":return this.#de(O,T);case"datasetVsDataset":return this.#Me(O,T);default:return[]}}#ce(O,T){const A=T.columns.filter(Boolean).map(String),N=this.#H(O),C=(S,F)=>{const $=O.statistics.correlation(S,F);return typeof $=="number"&&Number.isFinite($)?$:null};if(String(T.orient||"pairs")!=="matrix"){const S=[];for(let F=0;F<A.length;F++)for(let $=F+1;$<A.length;$++)S.push({[d]:`${A[F]}${A[$]}`,a:A[F],b:A[$],coefficient:C(A[F],A[$]),n:N});return S}return A.map(S=>{const F={[d]:S,column:S};for(const $ of A)F[$]=S===$?1:C(S,$);return F.n=N,F})}#de(O,T){const A=this.#H(O),N={by:String(T.by)};T.periodsPerYear!==void 0&&(N.periodsPerYear=Number(T.periodsPerYear));const C=O.statistics.series(String(T.of),N)||{};return y.map(S=>({[d]:S,metric:S,value:C[S]??null,n:A}))}#Me(O,T){const A=T.with,N=Array.isArray(T.columns)?{columns:T.columns.map(String)}:void 0,C=O.statistics.datasetVsDataset(A,N);if(!Y(C))return[];const F=(Array.isArray(C.ranked)?C.ranked:[]).map(K=>({[d]:String(K.column),column:K.column,measure:K.measure??null,magnitude:K.magnitude??null,distance:K.distance??null,direction:K.direction??null,nA:K.nA??null,nB:K.nB??null,meanA:K.meanA??null,meanB:K.meanB??null,reliable:K.reliable??null,unmatched:""})),$=C.unmatched,W=[["A",$&&$.onlyA],["B",$&&$.onlyB]];for(const[K,I]of W)for(const B of I||[])F.push({[d]:`${K}${B}`,column:B,measure:null,magnitude:null,distance:null,direction:null,nA:null,nB:null,meanA:null,meanB:null,reliable:!1,unmatched:K});return F}#re(){const O=this.#e;if(!O||!O.statistics||!P(O.statistics.profile))return[];const A=(Array.isArray(this.#t.profile)?this.#t.profile:[this.#t.profile]).filter(Boolean).map(C=>{const S=O.statistics.profile(String(C))||{},F={[d]:String(C)};for(const W of f)F[W]=W==="column"?String(C):S[W]??null;F.outliers=Array.isArray(S.outliers)?S.outliers.length:S.outliers??null;const $=m({...S,rows:F.rows,outliers:F.outliers,numeric:S.numeric},this.#t.alerts);return F.alerts=$.join(", "),F.alertCount=$.length,F});if(this.#t.orient!=="metrics")return A;const N=A[0];return N?f.filter(C=>C!=="column").map(C=>({[d]:C,metric:C,value:N[C]})):[]}apply(O){const T=["add","update","remove"],A=[];for(const N of T)for(const C of O&&O[N]||[])A.push({operation:N,id:C&&C.id,reason:"derived-read-only"});return A.length&&L("source.derived.readonly","a derived grid is read-only: its rows are computed from another grid. Write to the source grid instead, and the derived one follows."),{added:[],updated:[],removed:[],rejected:A}}destroy(){this.#s=!0,this.#r&&(clearTimeout(this.#r),this.#r=null),this.#Y()&&this.#G().length&&this.#I([]);for(const O of this.#n)try{O()}catch{}this.#n=[],this.#e=null,this.#f=null,super.destroy()}}function v(M){return Y(M)&&M.companion===!0}function E(M,O,T,A=new Set){if(O===M)return T;if(A.has(O))return null;A.add(O);let N=null;try{N=P(O.config)?O.config():null}catch{N=null}const C=N&&Y(N.source)?N.source:null;if(!C||C.mode!=="derived")return null;const S=C.from;if(Array.isArray(S)){for(let F=0;F<S.length;F++){const $=g(S[F],F);if(!$.grid||!P($.grid.on))continue;const W=E(M,$.grid,[...T,$.label],A);if(W)return W}return null}return Y(S)&&P(S.on)?E(M,S,[...T,"(from)"],A):null}function V(M){return Y(M)&&"data"in M?M.data:M}function G(M,O){if(!M||typeof M!="object")return null;if(Array.isArray(M.conditions)){for(const A of M.conditions){const N=G(A,O);if(N)return N}return null}return M.col===O?M:null}function q(M,O){return new w(M,O)}}),We("packages/core/src/source/adapters/odata.js",function(e,D){"use strict";Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return f}});const P=D("packages/core/src/internal/warn.js").warnOnce,_=D("packages/core/src/source/filterwire.js").isGroup,L=Object.freeze(["eq","ne","gt","gte","lt","lte","contains","startsWith","endsWith","blank","notBlank","between","notBetween"]),Z=/^\d{4}-\d{2}-\d{2}$/,H=/^\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 X(p){const l=p instanceof Date?p:typeof p=="number"&&Number.isFinite(p)?new Date(p):typeof p=="string"&&x.test(p)?new Date(p):null;return l&&!Number.isNaN(l.getTime())?l:null}const U=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function j(p,l){throw typeof l=="string"&&U.test(l)?new Error(`odataAdapter: "${l}" needs a zone designator to be used as a ${p} 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(l)}" is not a usable ${p} value`)}function k(p){const l=X(p);return l||j("DateTimeOffset",p),l.toISOString()}function b(p){if(typeof p=="string"&&Z.test(p))return p;const l=X(p);return l||j("Date",p),l.toISOString().slice(0,10)}function a(p){if(typeof p=="string"&&H.test(p))return p.length===5?`${p}:00`:p;if(typeof p=="number"&&Number.isFinite(p)&&p>=0&&p<864e5){const l=Math.floor(p),y=c=>String(c).padStart(2,"0");return`${y(Math.floor(l/36e5))}:${y(Math.floor(l%36e5/6e4))}:${y(Math.floor(l%6e4/1e3))}`}throw new Error(`odataAdapter: "${String(p)}" is not a usable TimeOfDay value`)}const h=Object.freeze({timestamp:k,datetime:k,date:b,dateString:b,time:a}),r=200,t=1e3,o=Object.freeze({eq:"eq",ne:"ne",gt:"gt",gte:"ge",lt:"lt",lte:"le"});function u(p,l){if(p==null)return"null";const y=l&&h[String(l)];return y?y(p):typeof p=="number"||typeof p=="boolean"?String(p):p instanceof Date?p.toISOString():`'${String(p).replace(/'/g,"''")}'`}function d(p){const l=String(p),y=/^[A-Za-z_][A-Za-z0-9_]*$/;if(!l||!l.split("/").every(c=>y.test(c)))throw new Error(`odataAdapter: "${l}" is not a usable column name`);return l}const s=Object.freeze({lo:{incl:"ge",excl:"gt"},hi:{incl:"le",excl:"lt"}});function g(p){const l=d(p.col),y=String(p.op),c=p.type;if(o[y])return`${l} ${o[y]} ${u(p.value,c)}`;if(y==="contains")return`contains(${l},${u(p.value,c)})`;if(y==="startsWith")return`startswith(${l},${u(p.value,c)})`;if(y==="endsWith")return`endswith(${l},${u(p.value,c)})`;if(y==="blank")return`(${l} eq null)`;if(y==="notBlank")return`(${l} ne null)`;if(y==="between"||y==="notBetween"){const m=Array.isArray(p.value)?p.value:[p.value,p.value],w=String(p.bounds||"[]"),v=w.charAt(0)==="("?s.lo.excl:s.lo.incl,E=w.charAt(1)===")"?s.hi.excl:s.hi.incl,V=`(${l} ${v} ${u(m[0],c)} and ${l} ${E} ${u(m[1],c)})`;return y==="between"?V:`(${l} eq null or not ${V})`}return null}function i(p){const l=String(p&&p.op);throw P(`source.odata.filter.refuse.${l}`,`a "${l}" 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 "${l}" filter condition cannot be expressed in OData and was refused`)}function n(p){if(!p)return"";if(!_(p)){const c=g(p);return c===null?i(p):c}const l=String(p.op)==="or"?" or ":" and ",y=(p.conditions||[]).map(c=>{if(_(c))return n(c);const m=g(c);return m===null?i(c):m}).filter(Boolean);return y.length?y.length===1?y[0]:`(${y.join(l)})`:""}function f(p={}){const l=String(p.url||""),y=p.fetch||(typeof fetch=="function"?fetch:null),c=p.count!==!1,m=d(p.key||"id"),w=p.edit===!0;return{name:"odata",capabilities:{filter:"tree",operators:L,sort:"multi",quick:p.search===!0,range:!0,total:c,mutate:w?{update:!0,delete:!0,append:!0,returning:"row"}:!1},urlFor(v){const E=[],V=(q,M)=>E.push(`${q}=${encodeURIComponent(M)}`),G=n(v.filters);return G&&V("$filter",G),v.sort&&v.sort.length&&V("$orderby",v.sort.map(q=>`${d(q.col)}${q.dir==="desc"?" desc":" asc"}`).join(",")),v.range&&(V("$skip",String(v.range.start)),V("$top",String(v.range.end-v.range.start))),v.quick&&V("$search",`"${String(v.quick).replace(/"/g,"")}"`),c&&V("$count","true"),E.length?`${l}?${E.join("&")}`:l},async execute(v,E){if(!y)throw new Error("odataAdapter needs a fetch implementation");const V={Accept:"application/json",...p.headers||{}},G=E&&E.signal,q=async A=>{const N=await y(A,{headers:V,signal:G});if(!N.ok)throw new Error(`OData request failed: ${N.status}`);return N.json()};let M=await q(this.urlFor(v)),O=M.value||M.rows||[];const T=M["@odata.count"]??M.count;if(!v.range){let A=M["@odata.nextLink"];for(;A&&O.length<r*t;)M=await q(A),O=O.concat(M.value||M.rows||[]),A=M["@odata.nextLink"]}return T==null?(c&&P("source.odata.nocount",`${l} 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:O}):{rows:O,total:Number(T)}},urlForKey(v){return`${l}(${u(v)})`},async mutate(v,E){if(!y)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 V={Accept:"application/json","Content-Type":"application/json",...p.headers||{}},G=E&&E.signal;if(v.kind==="delete"){const A=Array.isArray(v.keys)&&v.keys.length?v.keys[0]:v.key;if(A==null)throw new Error("odataAdapter: a delete needs a row key");const N=await y(this.urlForKey(A),{method:"DELETE",headers:V,signal:G});if(!N.ok)throw new Error(`OData delete failed: ${N.status}`);return{ok:!0}}if(v.kind==="append"){const A=Array.isArray(v.rows)?v.rows.filter($=>$&&typeof $=="object"):[];if(A.length!==1)throw new Error("odataAdapter: an append needs exactly one row object (OData creates one entity per POST)");const N=await y(l,{method:"POST",headers:V,signal:G,body:JSON.stringify(A[0])});if(!N.ok)throw new Error(`OData add-row failed: ${N.status}`);const C=N.status===204?null:await N.json().catch(()=>null),S=C&&typeof C=="object"&&"value"in C?C.value:C;if(!S||typeof S!="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 F=S[m];if(F==null)throw new Error(`odataAdapter: the created entity carried no ${m} to rekey the appended row by.`);return{ok:!0,keys:[String(F)],rows:[S]}}const q=this.urlForKey(v.key),M=await y(q,{method:"PATCH",headers:V,signal:G,body:JSON.stringify(v.patch||{})});if(!M.ok)throw new Error(`OData update failed: ${M.status}`);if(M.status===204)return{ok:!0};const O=await M.json(),T=O&&typeof O=="object"&&"value"in O?O.value:O;return T==null?{ok:!0}:{ok:!0,rows:[T]}}}}}),We("packages/core/src/source/adapters/rest.js",function(e,D){"use strict";Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"DEFAULT_VERBS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return Y}});const ne=Object.freeze({offset:"offset",limit:"limit",sort:"sort",order:"order",filter:"filter",search:"q"}),P=Object.freeze({update:"PATCH",delete:"DELETE",append:"POST"});function Y(_={}){const L=String(_.url||""),Z=_.fetch||(typeof fetch=="function"?fetch:null),H={...ne,..._.params||{}},x=_.encodeFilter||(t=>JSON.stringify(t)),X=_.rows||(t=>Array.isArray(t)?t:t.rows||t.data||[]),U=_.total||((t,o)=>Array.isArray(t)?o.length:t.total??t.count??o.length),j=_.edit===!0,k=_.returning==="row"?"row":_.returning==="key"?"key":"none",b=_.keyField||"id",a=_.writeUrlFor||(t=>`${L}/${encodeURIComponent(String(t.key??(t.keys&&t.keys[0])))}`),h=_.encodeMutation||(t=>{const o=P[t.kind];if(t.kind==="update")return{method:o,url:a(t),headers:{"Content-Type":"application/json"},body:JSON.stringify(t.patch||{})};if(t.kind==="append"){const u=Array.isArray(t.rows)?t.rows:t.rows?[t.rows]:[];return{method:o,url:L,headers:{"Content-Type":"application/json"},body:JSON.stringify(u.length===1?u[0]:u)}}return{method:o,url:a(t)}}),r=_.writeRow||(t=>{if(t===null||typeof t!="object")return null;if(Array.isArray(t))return t.length?t[0]:null;const o=t;return o.row??o.data??t});return{name:"rest",capabilities:{range:!0,total:!0,sort:"multi",filter:!1,quick:!1,mutate:j?{update:!0,delete:!0,append:!0,returning:k}:!1,..._.capabilities||{},..._.operators?{filter:"tree",operators:_.operators}:{}},urlFor(t){const o=new URLSearchParams;t.range&&(o.set(H.offset,String(t.range.start)),o.set(H.limit,String(t.range.end-t.range.start))),t.sort&&t.sort.length&&(o.set(H.sort,t.sort.map(d=>d.col).join(",")),o.set(H.order,t.sort.map(d=>d.dir||"asc").join(","))),t.filters&&o.set(H.filter,x(t.filters)),t.quick&&o.set(H.search,String(t.quick));const u=o.toString();return u?`${L}?${u}`:L},async execute(t,o){if(!Z)throw new Error("restAdapter needs a fetch implementation");const u=await Z(this.urlFor(t),{headers:{Accept:"application/json",..._.headers||{}},signal:o&&o.signal});if(!u.ok)throw new Error(`request failed: ${u.status}`);const d=await u.json(),s=X(d);return{rows:s,total:U(d,s)}},writeUrlFor(t){return a(t)},encodeMutation(t){return h(t)},async mutate(t,o){if(!Z)throw new Error("restAdapter needs a fetch implementation");if(!t||t.kind!=="update"&&t.kind!=="delete"&&t.kind!=="append")throw new Error(`restAdapter: mutation kind "${t&&t.kind}" is not supported (update, delete and append are wired)`);const u=h(t);if(!u||!u.url||!u.method)throw new Error("restAdapter: encodeMutation must return { method, url }");const d={Accept:"application/json",..._.headers||{},...u.headers||{}},s=await Z(u.url,{method:u.method,headers:d,signal:o&&o.signal,...u.body!==void 0?{body:u.body}:{}});if(!s.ok)throw new Error(`REST ${t.kind} failed: ${s.status}`);if(t.kind==="append"){if(k==="none")return{ok:!0};if(s.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 n=await s.json(),f=r(n),p=f&&typeof f=="object"?f[b]:void 0;if(p==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 k==="row"?{ok:!0,keys:[String(p)],rows:[f]}:{ok:!0,keys:[String(p)]}}if(k!=="row"||s.status===204)return{ok:!0};const g=await s.json(),i=r(g);return i==null?{ok:!0}:{ok:!0,rows:[i]}}}}}),We("packages/core/src/source/adapters/dfql.js",function(e,D){"use strict";Object.defineProperty(e,"DFQL_BASE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DFQL_WRITE_URL",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return j}});const P=D("packages/core/src/internal/predicates.js").isFunction,_=D("packages/core/src/internal/warn.js").warnOnce,L="https://rest.demandflow.com",Z="https://stream.demandflow.com/dfql",H=Object.freeze(["id","created","updated","ownerId","entity"]);function x(k){const b={},a=[];for(const[h,r]of Object.entries(k||{})){if(H.includes(h)){a.push(h);continue}b[h]=r}return a.length&&_("source.dfql.protected",`a DFQL update tried to write protected field(s) ${a.join(", ")}; they are server-assigned and immutable, so they were dropped from the PATCH.`),b}function X(k){if(!k||typeof k!="object"||Array.isArray(k))return["fields (must be an object)"];const b=k,a=[];return(typeof b.entity!="string"||!b.entity)&&a.push("entity (uppercase code)"),Number.isFinite(Number(b.level))||a.push("level (numeric)"),(typeof b.comboKey!="string"||!b.comboKey.endsWith("|ENT:"))&&a.push("comboKey (a string ending '|ENT:')"),a}async function U(k){const b=[],a=o=>{const u=o.trim();if(u)try{b.push(JSON.parse(u))}catch{}};if(!k.body||typeof k.body.getReader!="function")return(await k.text()).split(`
|